Пример #1
0
class FeedSettingsForm(MappingSchema):

	days_back = SchemaNode(Integer(), validator=Range(1, 7))
	date_offset = SchemaNode(Integer(), validator=Range(0, 2))
	link_format = SchemaNode(String(), validator=Length(min=6))
Пример #2
0
class SimpleTextSchema(MappingSchema):
    text = SchemaNode(String(encoding='utf-8', allow_empty=False),
                      validator=Length(min=2, max=100000))
Пример #3
0
class SummarizeSchema(SimpleTextSchema):
    target_length = SchemaNode(Int(), missing=0)
Пример #4
0
class FilterPreferencesSchema(MappingSchema):
    activities = SchemaNode(Sequence(),
                            SchemaNode(String(), validator=OneOf(activities)),
                            missing=required)
    areas = SchemaNode(Sequence(), SchemaAssociationDoc(), missing=required)
    followed_only = SchemaNode(Boolean(), missing=required)
Пример #5
0
class ModifyNameSchema(MappingSchema):
    mac_address = SchemaNode(String())
    modified_name = SchemaNode(String(), validator=Length(min=1))
Пример #6
0
 class UpdateSchema(MappingSchema):
     message = SchemaNode(ColanderString(), missing='')
     document = document_schema.clone()
Пример #7
0
 class ModelField(MappingSchema):
     name = SchemaNode(String())
     description = SchemaNode(String())
Пример #8
0
class SearchForm(MappingSchema):

	search = SchemaNode(String(), validator=Length(min=2))
Пример #9
0
class PasswordResetForm(MappingSchema):

	email = SchemaNode(String(), validator=Email())
	password = SchemaNode(String(), validator=Length(min=6))
	verify = SchemaNode(String())
Пример #10
0
class LoginForm(MappingSchema):

	user = SchemaNode(String())
	password = SchemaNode(String())
Пример #11
0
class SignupForm(MappingSchema):

	name = SchemaNode(String(), validator=Length(max=30))
	email = SchemaNode(String(), validator=Email())
Пример #12
0
class SubscribeForm(MappingSchema):

	url = SchemaNode(String(), validator=Length(min=1))
Пример #13
0
class UnSubscribeForm(MappingSchema):

	show = SchemaNode(Integer(), validator=Range(min=1))
Пример #14
0
class PasswordForm(MappingSchema):

	current = SchemaNode(String())
	new = SchemaNode(String(), validator=Length(min=6))
	verify = SchemaNode(String())
Пример #15
0
class POSTLoginUsernameRequestSchema(colander.Schema):

    """Schema for login requests via username and password."""

    name = SchemaNode(colander.String(), missing=colander.required)
    password = Password(missing=colander.required)
Пример #16
0
class RequestPasswordResetForm(MappingSchema):

	email = SchemaNode(String(), validator=Email())
Пример #17
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
Пример #18
0
class ElasticSearchQuery(MappingSchema):
    start = SchemaNode(Date(), location='body', type='datetime.datetime')
    end = SchemaNode(Date(), location='body', type='datetime.datetime')
    names = SchemaNode(Seq(), location='body')
Пример #19
0
 class SchemaFromQuerystring(MappingSchema):
     yeah = SchemaNode(String(), location="querystring", type='str')
Пример #20
0
class PointSeries(SequenceSchema):
    point = SchemaNode(Float())
Пример #21
0
 class ModelDefinition(MappingSchema):
     title = SchemaNode(String(), location="body")
     fields = ModelFields(validator=Length(min=1), location="body")
Пример #22
0
class Labels(SequenceSchema):
    label = SchemaNode(String(), missing='')
Пример #23
0
class WorkflowMeta(MappingSchema):
    """Data structure to define a workflow (finite state machine)."""

    initial_state = SingleLine(missing=required)
    states = SchemaNode(Mapping(unknown='preserve'), missing=required)
    transitions = SchemaNode(Mapping(unknown='preserve'), missing=required)
Пример #24
0
class Formats(SequenceSchema):
    format = SchemaNode(String(), missing='')
Пример #25
0
class OilSchema(ObjTypeSchema):
    '''schema for Oil object'''
    name = SchemaNode(
        String(), missing=drop, save=True, update=True
    )
    api = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    adios_oil_id = SchemaNode(
        Int(), missing=drop, save=True, update=True
    )
    pour_point = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    flash_point = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    solubility = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    bullwinkle_fraction = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    bullwinkle_time = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    emulsion_water_fraction_max = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    densities = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    density_ref_temps = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    density_weathering = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    kvis = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    kvis_ref_temps = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    kvis_weathering = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    mass_fraction = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    boiling_point = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    molecular_weight = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    component_density = SchemaNode(
        Float(), missing=drop, save=True, update=True
    )
    sara_type = SchemaNode(
        Int(), missing=drop, save=True, update=True
    )
    num_pcs = SchemaNode(
        Int(), missing=drop, save=True, update=True
    )
    num_components = SchemaNode(
        Int(), missing=drop, save=True, update=True
    )
Пример #26
0
class GraphSchema(ObjTypeSchema):
    title = SchemaNode(String(), missing=drop, save=True, update=True)
    points = Points(save=True, update=True)
    labels = Labels(save=True, update=True)
    formats = Formats(save=True, update=True)
Пример #27
0
class Models(SequenceSchema):
    model = SchemaNode(String(encoding='utf-8', allow_empty=False),
                       validator=Length(min=2, max=100))
Пример #28
0
class POSTLocationMapping(colander.Schema):

    """Overview of POST request/response data structure."""

    request_body = SchemaNode(POSTResourceRequestSchemaList(), default=[])
    response_body = ResourceResponseSchema()
Пример #29
0
class SimpleModelSchema(SimpleTextSchema):
    model = SchemaNode(String(encoding='utf-8', allow_empty=False),
                       # TODO: write validator
                       )
Пример #30
0
class ProfileForm(MappingSchema):

	email = SchemaNode(String(), validator=Email())
	site_news = SchemaNode(Boolean())
	password = SchemaNode(String())