Example #1
0
class _RoomcatSchema(ResourceSchema):
    name = colander.SchemaNode(
        colander.String(),
        validator=name_validator
    )
Example #2
0
 class ArticleSchema(ResourceSchema):
     unread = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
     position = colander.SchemaNode(colander.Int(), missing=colander.drop)
Example #3
0
class OpenAPIResponseSchema(colander.MappingSchema):
    body = colander.SchemaNode(colander.Mapping(unknown='preserve'))
Example #4
0
File: schemas.py Project: rowhit/h
def password_node(**kwargs):
    """Return a Colander schema node for an existing user password."""
    kwargs.setdefault('widget', deform.widget.PasswordWidget())
    return colander.SchemaNode(
        colander.String(),
        **kwargs)
Example #5
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)]))
Example #6
0
class Schema(colander.MappingSchema):
    name = colander.SchemaNode(colander.String())
    age = colander.SchemaNode(colander.Integer(),
                              validator=colander.Range(1, 120))
Example #7
0
class MenuRatingSchema(colander.MappingSchema):
    user_id = colander.SchemaNode(colander.String())
    rating = colander.SchemaNode(colander.Float(),
                                 validator=colander.Range(min=0.0, max=5.0),
                                 missing=1)
Example #8
0
def scout_group_node():
    return colander.SchemaNode(
        colander.String(),
        title=_(u"Scout group"),
        validator=html_string_validator,
    )
Example #9
0
class SimpleModelSchema(c.MappingSchema):

    name = c.SchemaNode(c.String())
Example #10
0
class QuizSchema(ContentSchema):
    title = colander.SchemaNode(
        colander.String(),
        title=_(u'Quiz Title'),
        )
Example #11
0
class FileSchema(VisualisableElementSchema, SearchableEntitySchema):

    text = colander.SchemaNode(colander.String(),
                               widget=RichTextWidget(),
                               title=_("Text"))
Example #12
0
class Person(colander.Schema):
    name = colander.SchemaNode(colander.String())
    age = colander.SchemaNode(colander.Integer(),
                              validator=colander.Range(0, 200))
Example #13
0
 def test_mode_validator(self, dbsession):
     c = colander.SchemaNode(colander.String())
     validator = deferred_payment_mode_validator(
         "nutt", {'request': self.request()})
     with pytest.raises(colander.Invalid):
         validator(c, u'pièce en chocolat')
 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)
Example #15
0
class _NavigationCopySchema(colander.Schema):
    position_id = colander.SchemaNode(colander.Integer())
    from_position_id = colander.SchemaNode(colander.Integer(),
                                           validator=position_validator)
Example #16
0
class Url(colander.MappingSchema):
    id_account = colander.SchemaNode(
        name='id',
        typ=colander.Int(),
        missing=colander.required,
        description=u'Уникальный индентификатор интересующего нас аккайнта')
Example #17
0
         controls = request.POST.items()
         try:
             captured = form.validate(controls)
             response = webob.exc.HTTPFound(
                 location='/app?name=%(name)s&component=%(component)s' %
                 captured)
             return response(environ, start_response)
         except deform.ValidationFailure, e:
             rendering = e.render()
     else:
         rendering = form.render()
 elif request.path_info.startswith('/app'):
     component_name = request.GET['component']
     app_name = request.GET['name']
     component = loader.components[component_name]
     app_schema = colander.SchemaNode(colander.Mapping(), )
     app_schema.add(
         colander.SchemaNode(
             colander.String(),
             name='name',
             title='Name',
             default=app_name,
         ))
     app_schema.add(
         colander.SchemaNode(
             colander.String(),
             name='component',
             default=component_name,
         ))
     component_schema = component.schema.bind(loader=loader)
     component_schema.name = 'config'
Example #18
0
 class SelectDomain(colander.Schema):
     select_domain = colander.SchemaNode(colander.String(),
                                         widget=deform.widget.SelectWidget(values=domains_choices),
                                         title=_("i18n_select_domain", domain='i18n_helper'))
class TestQuerySchema(colander.MappingSchema):
    query = StringSchema()
    parameters = colander.SchemaNode(colander.Mapping(unknown='preserve'),
                                     validator=test_param_validator)
    results = TestResultsSchema()
Example #20
0
 class NewDomain(colander.Schema):
     new_domain = colander.SchemaNode(colander.String(),
                                      title=_("i18n_new_domain", domain='i18n_helper'))
Example #21
0
class AddFolderSchema(Schema):
    name = colander.SchemaNode(
        colander.String(),
        validator=name_validator,
    )
Example #22
0
class IntSchema(colander.Schema):
    int_field = colander.SchemaNode(
        colander.Int(),
        widget=deform.widget.RadioChoiceWidget(values=((0, "zero"), (1,
                                                                     "one"))),
    )
Example #23
0
class SearchParamsSchema(colander.Schema):
    _separate_replies = colander.SchemaNode(
        colander.Boolean(),
        missing=False,
        description="Return a separate set of annotations and their replies.",
    )
    sort = colander.SchemaNode(
        colander.String(),
        validator=colander.OneOf(["created", "updated", "group", "id",
                                  "user"]),
        missing="updated",
        description="The field by which annotations should be sorted.",
    )
    search_after = colander.SchemaNode(
        colander.String(),
        missing=colander.drop,
        description="""Returns results after the annotation who's sort field
                    has this value. If specifying a date use the format
                    yyyy-MM-dd'T'HH:mm:ss.SSX or time in miliseconds since the
                    epoch. This is used for iteration through large collections
                    of results.""",
    )
    limit = colander.SchemaNode(
        colander.Integer(),
        validator=colander.Range(min=0, max=LIMIT_MAX),
        missing=LIMIT_DEFAULT,
        description="The maximum number of annotations to return.",
    )
    order = colander.SchemaNode(
        colander.String(),
        validator=colander.OneOf(["asc", "desc"]),
        missing="desc",
        description="The direction of sort.",
    )
    offset = colander.SchemaNode(
        colander.Integer(),
        validator=colander.Range(min=0, max=OFFSET_MAX),
        missing=0,
        description="""The number of initial annotations to skip. This is
                       used for pagination. Not suitable for paging through
                       thousands of annotations-search_after should be used
                       instead.""",
    )
    group = colander.SchemaNode(
        colander.String(),
        missing=colander.drop,
        description="Limit the results to this group of annotations.",
    )
    quote = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description=
        """Limit the results to annotations that contain this text inside
                        the text that was annotated.""",
    )
    references = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description=
        """Returns annotations that are replies to this parent annotation id.""",
    )
    tag = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description=
        "Limit the results to annotations tagged with the specified value.",
    )
    tags = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description="Alias of tag.",
    )
    text = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description=
        "Limit the results to annotations that contain this text in their textual body.",
    )
    uri = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description="""Limit the results to annotations matching the specific URI
                       or equivalent URIs. URI can be a URL (a web page address) or
                       a URN representing another kind of resource such as DOI
                       (Digital Object Identifier) or a PDF fingerprint.""",
    )
    uri_parts = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        name="uri.parts",
        missing=colander.drop,
        description="""Limit the results to annotations with the given keyword
                       appearing in the URL.""",
    )
    url = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description="Alias of uri.",
    )
    wildcard_uri = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        validator=_validate_wildcard_uri,
        missing=colander.drop,
        description="""
            Limit the results to annotations matching the wildcard URI.
            URI can be a URL (a web page address) or a URN representing another
            kind of resource such as DOI (Digital Object Identifier) or a
            PDF fingerprint.

            `*` will match any character sequence (including an empty one),
            and a `_` will match any single character. Wildcards are only permitted
            within the path and query parts of the URI.

            Escaping wildcards is not supported.

            Examples of valid uris":" `http://foo.com/*` `urn:x-pdf:*` `file://localhost/_bc.pdf`
            Examples of invalid uris":" `*foo.com` `u_n:*` `file://*` `http://foo.com*`
            """,
    )
    any = colander.SchemaNode(
        colander.Sequence(),
        colander.SchemaNode(colander.String()),
        missing=colander.drop,
        description="""Limit the results to annotations whose quote, tags,
                       text or url fields contain this keyword.""",
    )
    user = colander.SchemaNode(
        colander.String(),
        missing=colander.drop,
        description=
        "Limit the results to annotations made by the specified user.",
    )

    def validator(self, node, cstruct):
        sort = cstruct["sort"]
        search_after = cstruct.get("search_after", None)

        if search_after:
            if sort in ["updated", "created"
                        ] and not self._date_is_parsable(search_after):
                raise colander.Invalid(
                    node,
                    """search_after must be a parsable date in the form
                    yyyy-MM-dd'T'HH:mm:ss.SSX
                    or time in miliseconds since the epoch.""",
                )

            # offset must be set to 0 if search_after is specified.
            cstruct["offset"] = 0

    def _date_is_parsable(self, value):
        """Return True if date is parsable and False otherwise."""

        # Dates like "2017" can also be cast as floats so if a number is less
        # than 9999 it is assumed to be a year and not ms since the epoch.
        try:
            if float(value) < 9999:
                raise ValueError("This is not in the form ms since the epoch.")
        except ValueError:
            try:
                parse(value)
            except ValueError:
                return False
        return True
Example #24
0
class RichTextSchema(colander.Schema):
    richtext = colander.SchemaNode(colander.String(),
                                   widget=deform.widget.RichTextWidget())
class UsersValidation(colander.MappingSchema):
    name = colander.SchemaNode(colander.String())
Example #26
0
class AutofocusDefaultSchema(colander.Schema):
    input1 = colander.SchemaNode(colander.String(), )
Example #27
0
class AccountSchema(resource.ResourceSchema):
    password = colander.SchemaNode(colander.String())
Example #28
0
class AutofocusSchema(colander.Schema):
    input1 = colander.SchemaNode(colander.String(), )
    input2 = colander.SchemaNode(colander.String(), autofocus="on")
Example #29
0
 def __new__(cls, *args, **kwargs):
     return colander.SchemaNode(colander.Mapping(unknown="preserve"), *args,
                                **kwargs)
Example #30
0
class _TransportSchema(ResourceSchema):
    name = colander.SchemaNode(
        colander.String(),
        validator=name_validator,
    )