Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Generate a dictionary of fields for a given database model.

See `model_form` docstring for description of parameters.

        def model_fields(model, only=None, exclude=None, field_args=None, converter=None):
    """
    Generate a dictionary of fields for a given database model.

    See `model_form` docstring for description of parameters.
    """
    from mongoengine.base import BaseDocument, DocumentMetaclass
    if not isinstance(model, (BaseDocument, DocumentMetaclass)):
        raise TypeError('model must be a mongoengine Document schema')

    converter = converter or ModelConverter()
    field_args = field_args or {}

    names = ((k, v.creation_counter) for k, v in model._fields.iteritems())
    field_names = map(itemgetter(0), sorted(names, key=itemgetter(1)))

    if only:
        field_names = set((x for x in only if x in set(field_names)))
    elif exclude:
        field_names = set((x for x in set(field_names) if x not in exclude))

    field_dict = OrderedDict()
    for name in field_names:
        model_field = model._fields[name]
        field = converter.convert(model, model_field, field_args.get(name))
        if field is not None:
            field_dict[name] = field

    return field_dict
        


src/f/l/flask-mongoengine-0.7.0/flask_mongoengine/wtf/__init__.py   flask-mongoengine(Download)
from flask.ext.mongoengine.wtf.orm import model_fields, model_form
 

src/f/l/flask-mongoengine-HEAD/flask_mongoengine/wtf/__init__.py   flask-mongoengine(Download)
from flask.ext.mongoengine.wtf.orm import model_fields, model_form