'Constructor.
:param arg1: DocType name as string or document **dict**
:param arg2: Document name, if `arg1` is DocType name.
If DocType name and document name are passed, the object will load
all values (including child documents) from the database.'

def __init__(self, arg1, arg2=None):

    self.doctype = self.name = None
    self._default_new_docs = {}
    self.flags = frappe._dict()
    if (arg1 and isinstance(arg1, basestring)):
        if (not arg2):
            self.doctype = self.name = arg1
        else:
            self.doctype = arg1
            if isinstance(arg2, dict):
                self.name = frappe.db.get_value(arg1, arg2, u'name')
                if (self.name is None):
                    frappe.throw(_(u'{0}    {1}    not    found').format(_(arg1), arg2), frappe.DoesNotExistError)
            else:
                self.name = arg2
        self.load_from_db()
    elif isinstance(arg1, dict):
        super(Document, self).__init__(arg1)
        self.init_valid_columns()
    else:
        raise frappe.DataError(u'Document({0},    {1})'.format(arg1, arg2))
