How to use the lektor.datamodel.Field function in Lektor

To help you get started, we’ve selected a few Lektor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lektor / lektor / tests / test_types.py View on Github external
def make_field(env, type, **options):
    return Field(env, 'demo', type=env.types[type],
                 options=options)
github lektor / lektor-archive / lektor / datamodel.py View on Github external
def fields_from_data(env, data, parent_fields=None):
    fields = []
    known_fields = set()

    for name, options in data:
        ty = env.types[options.get('type', 'string')]
        fields.append(Field(env=env, name=name, type=ty, options=options))
        known_fields.add(name)

    if parent_fields is not None:
        prepended_fields = []
        for field in parent_fields:
            if field.name not in known_fields:
                prepended_fields.append(field)
        fields = prepended_fields + fields

    return fields
github lektor / lektor / lektor / datamodel.py View on Github external
def fields_from_data(env, data, parent_fields=None):
    fields = []
    known_fields = set()

    for name, options in data:
        ty = env.types[options.get('type', 'string')]
        fields.append(Field(env=env, name=name, type=ty, options=options))
        known_fields.add(name)

    if parent_fields is not None:
        prepended_fields = []
        for field in parent_fields:
            if field.name not in known_fields:
                prepended_fields.append(field)
        fields = prepended_fields + fields

    return fields
github lektor / lektor / lektor / datamodel.py View on Github external
pagination_config = PaginationConfig(env)
        self.pagination_config = pagination_config
        if fields is None:
            fields = []
        self.fields = fields
        if primary_field is None and fields:
            primary_field = fields[0].name
        self.primary_field = primary_field
        self.parent = parent

        # This is a mapping of the key names to the actual field which
        # also includes the system fields.  This is primarily used for
        # fast internal operations but also the admin.
        self.field_map = dict((x.name, x) for x in fields)
        for key, (ty, opts) in iteritems(system_fields):
            self.field_map[key] = Field(env, name=key, type=ty, options=opts)

        self._child_slug_tmpl = None
        self._child_replacements = None
        self._label_tmpls = {}
github lektor / lektor-archive / lektor / datamodel.py View on Github external
def __init__(self, env, id, name_i18n, filename=None, fields=None,
                 order=None, button_label=None):
        self.env = env
        self.id = id
        self.name_i18n = name_i18n
        self.filename = filename
        if fields is None:
            fields = []
        self.fields = fields
        if order is None:
            order = 100
        self.order = order
        self.button_label = button_label

        self.field_map = dict((x.name, x) for x in fields)
        self.field_map['_flowblock'] = Field(
            env, name='_flowblock', type=env.types['string'])