'Load document `doc` and `layout` properties for template'

def load_document(self, context):

    if (frappe.form_dict.name or frappe.form_dict.new):
        context.layout = self.get_layout()
        context.parents = [{u'route': self.route, u'label': _(self.title)}]
    if frappe.form_dict.name:
        context.doc = frappe.get_doc(self.doc_type, frappe.form_dict.name)
        context.title = context.doc.get(context.doc.meta.get_title_field())
        context.doc.add_seen()
        context.reference_doctype = context.doc.doctype
        context.reference_name = context.doc.name
        if self.allow_comments:
            context.comment_list = get_comment_list(context.doc.doctype, context.doc.name)
