コード例 #1
0
def relation_schema(schema, context, ignore_entities=False):
    relation = mapping('relation', validator=chained(source_not_target))
    relation.add(
        key('type', validator=chained(nonempty_string, in_([schema.name]))))
    if not ignore_entities:
        relation.add(_node(EntitySchemaType(context), 'source'))
        relation.add(_node(EntitySchemaType(context), 'target'))
    return apply_schema(relation, schema)
コード例 #2
0
ファイル: entity.py プロジェクト: jmorenoamor/grano
def entity_schema(schema):
    entity = mapping('entity')
    entity.add(key('title', validator=chained(
            nonempty_string
        )))
    entity.add(key('type', validator=chained(
            nonempty_string,
            in_([schema.name])
        )))
    return apply_schema(entity, schema)
コード例 #3
0
ファイル: relation.py プロジェクト: jmorenoamor/grano
def relation_schema(schema, context, ignore_entities=False):
    relation = mapping('relation', validator=chained(
            source_not_target
        ))
    relation.add(key('type', validator=chained(
            nonempty_string,
            in_([schema.name])
        )))
    if not ignore_entities:
        relation.add(_node(EntitySchemaType(context), 'source'))
        relation.add(_node(EntitySchemaType(context), 'target'))
    return apply_schema(relation, schema)
コード例 #4
0
ファイル: schema.py プロジェクト: pudo-attic/grano-old
def attribute_schema(name, meta):
    """ Validate the representation of a schema attribute. """
    schema = mapping(name,
                     validator=chained(
                         name_wrap(nonempty_string, name),
                         name_wrap(reserved_name(INVALID_NAMES), name),
                         name_wrap(database_name, name)))
    schema.add(key('label', validator=nonempty_string))
    schema.add(key('missing', missing=None))
    schema.add(
        key('type',
            validator=chained(nonempty_string, in_(ATTRIBUTE_TYPES_DB))))
    return schema
コード例 #5
0
ファイル: schema.py プロジェクト: jmorenoamor/grano
def attribute_schema(name, meta):
    """ Validate the representation of a schema attribute. """
    schema = mapping(name, validator=chained(
        name_wrap(nonempty_string, name),
        name_wrap(reserved_name(INVALID_NAMES), name),
        name_wrap(database_name, name)
        ))
    schema.add(key('label', validator=nonempty_string))
    schema.add(key('missing', missing=None))
    schema.add(key('type', validator=chained(
            nonempty_string,
            in_(ATTRIBUTE_TYPES_DB)
        )))
    return schema
コード例 #6
0
def entity_schema(schema):
    entity = mapping('entity')
    entity.add(key('title', validator=chained(nonempty_string)))
    entity.add(
        key('type', validator=chained(nonempty_string, in_([schema.name]))))
    return apply_schema(entity, schema)