def fields_for_document(document, fields=None, exclude=None,
        formfield_callback=None):
    field_list = []
    structure = document.structure
    for field_name, field_type in structure.items():
        if fields and not field_name in fields:
            continue
        if exclude and field_name in exclude:
            continue

        form_field = None
        if formfield_callback:
            form_field = formfield_callback(document, field_name)
        if not form_field:
            form_field = formfield_for_document_field(document, field_name)
        if form_field:
            field_list.append((field_name, form_field))

    field_dict = SortedDict(field_list)
    if fields:
        field_dict = SortedDict([(f, field_dict.get(f))
                for f in fields
                if (not exclude) or (exclude and f not in exclude)])
    return field_dict
_do_document(self, node) -> None
dataset/ETHPy150Open peterbe/django-mongokit/django_mongokit/forms/forms.py/fields_for_document--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/SOAPpy/wstools/c14n.py/_implementation._do_document