Ejemplo n.º 1
0
class PersonPostSchema(PersonSchema):
    # similar to person schema, but id is optional
    id = colander.SchemaNode(colander.Int(), missing=colander.drop)
Ejemplo n.º 2
0
class CollectionSchema(resource.ResourceSchema):
    schema = JSONSchemaMapping(missing=colander.drop)
    cache_expires = colander.SchemaNode(colander.Int(), missing=colander.drop)
Ejemplo n.º 3
0
class SubRIDPathSchema(RIDPathSchema):
    subrid = colander.SchemaNode(colander.Int(), )
Ejemplo n.º 4
0
 class ArticleSchema(ResourceSchema):
     unread = colander.SchemaNode(colander.Boolean(),
                                  missing=colander.drop)
     position = colander.SchemaNode(colander.Int(),
                                    missing=colander.drop)
Ejemplo n.º 5
0
class Person(colander.MappingSchema):
    name = colander.SchemaNode(colander.String())
    age = colander.SchemaNode(colander.Int(), validator=colander.Range(0, 200))
    friends = Friends()
    phones = Phones()
Ejemplo n.º 6
0
def int_property(**kwargs):
    return colander.SchemaNode(colander.Int(), **kwargs)
Ejemplo n.º 7
0
            ("4", u"Trésorerie de référence"),
            ("8", u"Trésorerie future"),
            ("10", u"Résultat de l'entreprise"),
        ))
    },
    "invoice_number_template": {
        "title": u"Gabarit du numéro de facture",
        "description": u"Peut contenir des caractères (préfixes, \
séparateurs… etc), ainsi que des variables et séquences. Ex: {YYYY}-{SEQYEAR}.",
        "missing": colander.required,
        "validator": invoice_number_template_validator,
    },
    "global_sequence_init_value": {
        "title": u"Valeur à laquelle on initialise de la séquence globale",
        "section": u"Séquence globale (SEQGLOBAL)",
        "type": colander.Int(),
        "validator": colander.Range(min=0),
    },
    "year_sequence_init_value": {
        "title": u"Valeur à laquelle on initialise la séquence annuelle",
        "section": u"Séquence annuelle (SEQYEAR)",
        "type": colander.Int(),
        "validator": colander.Range(min=0),
    },
    "year_sequence_init_date": {
        "title": u"Date à laquelle on initialise la séquence annuelle",
        "section": u"Séquence annuelle (SEQYEAR)",
        "widget": deform.widget.DateInputWidget(),
    },
    "month_sequence_init_value": {
        "title": u"Valeur à laquelle on initialise la séquence annuelle",
Ejemplo n.º 8
0
 class SheetASchema(colander.MappingSchema):
     count = colander.SchemaNode(colander.Int(),
                                 missing=colander.drop,
                                 default=0)
Ejemplo n.º 9
0
 class SheetBSchema(sheet_meta.schema_class):
     count = colander.SchemaNode(colander.Int(),
                                 missing=colander.drop,
                                 default=0)
Ejemplo n.º 10
0
class IntSchema(colander.Schema):
    int_field = colander.SchemaNode(
        colander.Int(),
        widget=deform.widget.RadioChoiceWidget(values=((0, "zero"), (1,
                                                                     "one"))),
    )
Ejemplo n.º 11
0
class FlowSchema(colander.MappingSchema):
    dl_src = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9A-Fa-f]{1,2}[:]){5}([0-9A-Fa-f]{1,2})"))
    dl_dst = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9A-Fa-f]{1,2}[:]){5}([0-9A-Fa-f]{1,2})"))
    dl_type = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(r"0x([0-9A-Fa-f]){1,4}"))
    dl_vlan = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(4096)]))
    dl_vlan_pcp = colander.SchemaNode(colander.String(),
                                      missing=None,
                                      validator=colander.OneOf(
                                          ["%d" % i for i in range(8)]))
    mpls_label = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(1048576)]))
    mpls_tc = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(8)]))
    mpls_bos = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(['%d' %i for i in range(2)]))
    nw_dst = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9a-fA-F]{1,3}(\.)){3}[0-9a-fA-F]{1,3}(/[0-9]{1,2}){0,1}"))
    nw_src = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9a-fA-F]{1,3}(\.)){3}[0-9a-fA-F]{1,3}(/[0-9]{1,2}){0,1}"))
    nw_dst6 = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9a-fA-F]{1,4}(:)){5}[0-9a-fA-F]{1,4}(/[0-9]{1,3}){0,1}"))
    nw_src6 = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Regex(
            r"([0-9a-fA-F]{1,4}(:)){5}[0-9a-fA-F]{1,4}(/[0-9]{1,3}){0,1}"))
    nw_proto = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(256)]))
    nw_tos = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(64)]))
    tp_dst = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(65536)]))
    tp_src = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(65536)]))
    in_port = colander.SchemaNode(colander.String(), missing=None)  #,
    #validator=colander.OneOf(["%d" %i for i in range(65536)]))
    table_id = colander.SchemaNode(colander.String(), missing=0)  #,
    #validator=colander.OneOf(["%d" %i for i in range(255)]))

    barrier = colander.SchemaNode(colander.String(),
                                  missing='disable',
                                  validator=colander.OneOf(
                                      ['enable', 'disable']))

    stat = colander.SchemaNode(colander.String(),
                               missing='enable',
                               valicator=colander.OneOf(['enable', 'disable']))

    instructions = InstructionList()

    priority = colander.SchemaNode(
        colander.Int(), missing=mul.C_FL_PRIO_FWD
    )  #, #validator=colander.OneOf([i for i in range(65536)]))
Ejemplo n.º 12
0
class Url(colander.MappingSchema):
    id_account = colander.SchemaNode(
        name='id',
        typ=colander.Int(),
        missing=colander.required,
        description=u'Уникальный индентификатор интересующего нас аккайнта')
Ejemplo n.º 13
0
 class Friend(colander.MappingSchema):
     person_id = colander.SchemaNode(colander.Int())
     friend_of = colander.SchemaNode(colander.Int())
     rank = colander.SchemaNode(colander.Int(),
                                missing=0,
                                default=0)
Ejemplo n.º 14
0
class CollectionSchema(resource.ResourceSchema):
    schema = JSONSchemaMapping(missing=colander.drop)
    cache_expires = colander.SchemaNode(colander.Int(), missing=colander.drop)

    class Options:
        preserve_unknown = True
Ejemplo n.º 15
0
 def test_get_colander_keys_from_node_names(self):
     friend = colander.SchemaNode(colander.Tuple())
     friend.add(colander.SchemaNode(colander.Int(),
                validator=colander.Range(0, 9999), name='rank'))
     friend.add(colander.SchemaNode(colander.Int(), name='foo'))
     assert_equal(http.get_colander_keys(friend), ['rank', 'foo'])
Ejemplo n.º 16
0
 class SubFormSchema(BaseFormSchema):
     age = colander.SchemaNode(
         colander.Int(),
         selector=('id', 'id2'),
         pypom_widget=MyStringWidget(options={'test': 1}))
Ejemplo n.º 17
0
class ContributorPostSchema(ContributorSchema):
    # similar to contributor schema, but id is optional
    id = colander.SchemaNode(colander.Int(), missing=colander.drop)
Ejemplo n.º 18
0
class ChildSchema(ObjectSchema):
    w = colander.SchemaNode(colander.Int())
    y = colander.SchemaNode(colander.String())
    x = Differential(colander.Int(), 10)
    z = colander.SchemaNode(colander.Int())
Ejemplo n.º 19
0
class RelatedConcept(colander.MappingSchema):
    id = colander.SchemaNode(colander.Int())
Ejemplo n.º 20
0
class ParentSchema(ObjectSchema):
    foo = colander.SchemaNode(colander.String())
    bar = MethodSchema(colander.Int())
    sub = ChildSchema()
    subs = ChildListSchema()
Ejemplo n.º 21
0
class User(colander.MappingSchema):
    first_name = colander.SchemaNode(colander.String())
    last_name = colander.SchemaNode(colander.String())
    email = colander.SchemaNode(colander.Email(msg=None))
    tickets = colander.SchemaNode(colander.Int())
Ejemplo n.º 22
0
 class range(colander.TupleSchema):
     start_month = colander.SchemaNode(colander.Int(), missing=colander.drop)
     end_month = colander.SchemaNode(colander.Int(), missing=colander.drop)
Ejemplo n.º 23
0
class IntSchema(colander.Schema):
    int_field = colander.SchemaNode(colander.Int(),
        widget=deform.widget.RadioChoiceWidget(values=((0, 'zero'), (1, 'one')))
    )
Ejemplo n.º 24
0
class GETPoolRequestSchema(colander.Schema):

    """GET parameters accepted for pool queries."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Raise if unknown to tell client the query parameters are wrong.
        self.typ.unknown = 'raise'

    # TODO For now we don't have a way to specify GET parameters that can
    # be repeated, e.g. 'sheet=Blah&sheet=Blub'. The querystring is converted
    # by Cornice into a MultiDict (http://docs.pylonsproject.org/projects
    # /pyramid/en/master/api/interfaces.html#pyramid.interfaces.IMultiDict),
    # which by default will only return the LAST value if a key is specified
    # several times. One possible workaround is to allow specifying multiple
    # values as a comma-separated list instead of repeated key=value pairs,
    # e.g. 'sheet=Blah,Blub'. This would require a custom Multiple SchemaNode
    # that wraps a SchemaType, e.g.
    # sheet = Multiple(Interface(), missing=None, sep=',')
    # Elements in this schema were multiple values should be allowed:
    # sheet, aggregateby, tag.

    depth = PoolQueryDepth()
    elements = PoolElementsForm(missing=colander.drop)
    count = SchemaNode(colander.Boolean(), missing=colander.drop)
    sort = SchemaNode(colander.String(),
                      missing=colander.drop,
                      validator=deferred_validate_sort)
    reverse = SchemaNode(colander.Boolean(), missing=colander.drop)
    # TODO: validate limit, offset to be multiple of 10, 20, 50, 100, 200, 500
    limit = SchemaNode(colander.Int(), missing=colander.drop)
    offset = SchemaNode(colander.Int(), missing=colander.drop)
    aggregateby = SchemaNode(colander.String(),
                             missing=colander.drop,
                             validator=deferred_validate_aggregateby)

    def deserialize(self, cstruct=colander.null):  # noqa
        """ Deserialize the :term:`cstruct` into an :term:`appstruct`.

        Adapt key/values to :class:`adhocracy_core.interfaces.SearchQuery`. for
        BBB.
        TODO: CHANGE API according to internal SearchQuery api.
             refactor to follow coding guideline better.
        """
        depth_cstruct = cstruct.get('depth', None)
        if depth_cstruct == 'all':
            cstruct['depth'] = 100
        appstruct = super().deserialize(cstruct)
        search_query = {}
        if appstruct:
            search_query['root'] = self.bindings['context']
        if 'depth' in appstruct:
            depth = appstruct['depth']
            if depth == 100:
                depth = None
            search_query['depth'] = depth
        if 'elements' in appstruct:
            elements = appstruct.get('elements')
            search_query['serialization_form'] = elements
            if elements == 'omit':
                search_query['resolve'] = False
        interfaces = ()
        if 'sheet' in appstruct:
            interfaces = appstruct['sheet']
        if interfaces:
            search_query['interfaces'] = interfaces
        if 'aggregateby' in appstruct:
            search_query['frequency_of'] = appstruct['aggregateby']
            search_query['show_frequency'] = True
        if 'sort' in appstruct:
            search_query['sort_by'] = appstruct['sort']
        if 'limit' in appstruct:
            search_query['limit'] = appstruct['limit']
        if 'offset' in appstruct:
            search_query['offset'] = appstruct['offset']
        if 'reverse' in appstruct:
            search_query['reverse'] = appstruct['reverse']
        if 'count' in appstruct:
            search_query['show_count'] = appstruct['count']
        fields = tuple([x.name for x in GETPoolRequestSchema().children])
        fields += ('sheet',)
        for filter, query in appstruct.items():
            if filter in fields + SearchQuery._fields:
                continue
            if ':' in filter:
                if 'references' not in search_query:  # pragma: no branch
                    search_query['references'] = []
                isheet_name, isheet_field = filter.split(':')
                isheet = resolver.resolve(isheet_name)
                target = appstruct[filter]
                reference = ReferenceTuple(None, isheet, isheet_field, target)
                search_query['references'].append(reference)
            else:
                if 'indexes' not in search_query:
                    search_query['indexes'] = {}
                if filter == 'content_type':
                    search_query['indexes']['interfaces'] = appstruct['content_type']
                    continue
                search_query['indexes'][filter] = query
        return search_query
Ejemplo n.º 25
0
class Friend(colander.TupleSchema):
    rank = colander.SchemaNode(colander.Int(),
                               validator=colander.Range(0, 9999))
    name = colander.SchemaNode(colander.String())
Ejemplo n.º 26
0
class Information(colander.MappingSchema):
    id = colander.SchemaNode(colander.String())
    login = colander.SchemaNode(colander.Int(),
                                validator=colander.Range(0, 999))
    gps = GPS()
Ejemplo n.º 27
0
class RIDPathSchema(colander.Schema):
    rid = colander.SchemaNode(colander.Int(), )
Ejemplo n.º 28
0
class JournalIssuesSchema(colander.MappingSchema):
    """Representa o schema de dados de atualização de fascículos de periódico.
    """

    issue = JournalIssueItem()
    index = colander.SchemaNode(colander.Int(), missing=colander.drop)
Ejemplo n.º 29
0
class RelationIDPathSchema(RIDPathSchema):
    relation_id = colander.SchemaNode(colander.Int(), )
Ejemplo n.º 30
0
 class group(colander.MappingSchema):
     id = colander.SchemaNode(colander.Int())
     name = colander.SchemaNode(colander.String())