Example #1
0
class RendererSchema(BaseOutputterSchema):
    # not sure if bounding box needs defintion separate from LongLatBounds
    viewport = base_schema.LongLatBounds(save=True, update=True)

    # following are only used when creating objects, not updating -
    # so missing=drop
    map_filename = FilenameSchema(save=True, update=True,
                                  isdatafile=True, test_equal=False,
                                  missing=drop,)

    projection = ProjectionSchema(save=True, update=True, missing=drop)
    image_size = base_schema.ImageSize(save=True, update=False, missing=drop)
    output_dir = SchemaNode(String(), save=True, update=True, test_equal=False)
    draw_ontop = SchemaNode(String(), save=True, update=True)
Example #2
0
 class MySchema(MappingSchema):
     name = SchemaNode(String())
     title = SchemaNode(String())
     cool = SchemaNode(Boolean(), default=True, missing=True)
     series = SeriesSchema()
     nickname = SchemaNode(
         String(),
         widget=deform.widget.TextInputWidget(
             attributes={
                 "maxlength": 10,
                 "placeholder": "Nickname",
                 "disabled": "disabled",
             }),
     )
Example #3
0
class WifiAccessPointSchema(MappingSchema):
    # mapped to 'key' for submit
    macAddress = SchemaNode(String())

    # mapped to 'signal' for submit
    signalStrength = SchemaNode(Integer(), missing=0)
    age = SchemaNode(Integer(), missing=0)
    channel = SchemaNode(Integer(), missing=0)
    signalToNoiseRatio = SchemaNode(Integer(), missing=0)

    # The fields below are extra fields which are not part of the
    # geolocate API, but assist with data submission
    frequency = SchemaNode(Integer(), missing=0)
    radioType = SchemaNode(String(), missing=None)
Example #4
0
File: file.py Project: Doik/Kotti
 class FileSchema(MappingSchema):
     title = SchemaNode(String(), title=_(u'Title'), missing=u'')
     description = SchemaNode(
         String(),
         title=_('Description'),
         missing=u"",
         widget=TextAreaWidget(cols=40, rows=5),
     )
     file = SchemaNode(
         FileData(),
         title=_(u'File'),
         widget=FileUploadWidget(tmpstore),
         validator=validate_file_size_limit,
     )
Example #5
0
class QueryStringSchema(MappingSchema):
    limit = SchemaNode(Integer(),
                       missing=drop,
                       validator=colander.Range(0, COLLECTION_MAX_LENGTH))
    offset = SchemaNode(Integer(), missing=drop)
    sort_by = SchemaNode(String(), missing=drop)
    sort_direction = SchemaNode(String(),
                                missing='asc',
                                validator=OneOf(['asc', 'desc']))
    provider_id = SchemaNode(String(),
                             missing=drop,
                             validator=Length(1, SAFE_MAX_LENGTH))
    start_time = SchemaNode(DateTime(default_tzinfo=None), missing=drop)
    end_time = SchemaNode(DateTime(default_tzinfo=None), missing=drop)
 class FooBarSchema(MappingSchema):
     # foo and bar are required, baz is optional
     foo = SchemaNode(String(), location="body", type='str')
     bar = SchemaNode(String(),
                      location="body",
                      type='str',
                      validator=validate_bar)
     baz = SchemaNode(String(), location="body", type='str', missing=None)
     yeah = SchemaNode(String(), location="querystring", type='str')
     ipsum = SchemaNode(Integer(),
                        location="body",
                        type='int',
                        missing=1,
                        validator=Range(0, 3))
Example #7
0
class EditAccount(Schema):
    login_name = SchemaNode(
        String(),
        validator=login_name_validator,
    )
    email = SchemaNode(String(), validator=Email())
    old_password = SchemaNode(
        String(),
        widget=old_password_widget,
        missing=old_password_missing,
        validator=old_password_validator,
    )
    password = SchemaNode(String(), widget=CheckedPasswordWidget())
    security = SecurityQuestion()
Example #8
0
class ShipDriftMoverSchema(ProcessSchema):
    wind_file = SchemaNode(String(),
                           save=True,
                           missing=drop,
                           isdatafile=True,
                           test_equal=False)
    topology_file = SchemaNode(String(),
                               missing=drop,
                               save=True,
                               isdatafile=True,
                               test_equal=False)
    wind_scale = SchemaNode(Float(), missing=drop, save=True, update=True)
    grid_type = SchemaNode(Float(), missing=drop, save=True, update=True)
    drift_angle = SchemaNode(Float(), missing=drop, save=True, update=True)
Example #9
0
class UserFormSchema(MappingSchema):
    name = SchemaNode(String(), descriprtion='Enter your name')
    email = SchemaNode(String(),
                       description='Enter your email address',
                       validator=Email())
    password = SchemaNode(String(),
                          description='Enter your password',
                          widget=PasswordWidget(),
                          missing=False)
    confirm_password = SchemaNode(String(),
                                  description='Confirm your password',
                                  widget=PasswordWidget(),
                                  missing=False)
    tzoffset = SchemaNode(Integer(), widget=HiddenWidget())
Example #10
0
class MySchema(MappingSchema):
    name = SchemaNode(String(), description='The name of this thing')
    title = SchemaNode(String(),
                       widget=widget.TextInputWidget(size=40),
                       validator=Length(max=20),
                       description='A very short title')
    password = SchemaNode(String(),
                          widget=widget.CheckedPasswordWidget(),
                          validator=Length(min=5))
    is_cool = SchemaNode(Boolean(), default=True)
    dates = DatesSchema()
    color = SchemaNode(String(),
                       widget=widget.RadioChoiceWidget(values=colors),
                       validator=OneOf(('red', 'blue')))
Example #11
0
class Address(MappingSchema):
    """
    **Source:** `Primair onderwijs - Adressen <http://data.duo.nl/organisatie/open_onderwijsdata/databestanden/po/adressen/default.asp>`_
    **Source:** `Voortgezet onderwijs - Adressen <http://data.duo.nl/organisatie/open_onderwijsdata/databestanden/vo/adressen/default.asp>`_
    **Source:** `BAG42 Geocoding service <http://calendar42.com/bag42/>`_
    """
    street = SchemaNode(
        String(),
        validator=Length(min=4, max=300),
        title="Street name and number of the address of this branch.")
    city = city(title="Name of the city or village this branch is located.")
    zip_code = SchemaNode(
        String(),
        validator=Length(min=6, max=6),
        title=
        "Zip code of the address of this branch. A Dutch zip code consists of four digits, a space and two letters (*1234 AB*) [#zipcodes]_. For normalisation purposes, the whitespace is removed."
    )
    geo_location = Coordinates(
        title="Latitude/longitude coordinates of this address.")
    geo_viewport = Viewport(
        title="Latitude/longitude coordinates of the viewport for this address"
    )
    formatted_address = SchemaNode(
        String(),
        validator=Length(min=3, max=300),
        title=
        "Normalised address as returned by the BAG42 geocoding API [#bag42geo]_."
    )

    @colander.instantiate()
    class address_components(SequenceSchema):
        @colander.instantiate()
        class address_component(MappingSchema):
            """**Source:** `BAG42 Geocoding service <http://calendar42.com/bag42/>`_"""
            long_name = SchemaNode(
                String(),
                validator=Length(min=4, max=300),
                title="Full name of this component. (*i.e. 'Nederland'*)")
            short_name = SchemaNode(
                String(),
                validator=Length(min=4, max=300),
                title=
                "Abbreviated form (if applicable) of the long_name. (*i.e. 'NL'*)"
            )

            @colander.instantiate()
            class types(SequenceSchema):
                address_type = SchemaNode(String(),
                                          validator=Length(min=4, max=100))
Example #12
0
class FormLogin(CSRFSchema):
    """ 
    Formulário para login
    """
    email = SchemaNode(
        String(),
        validator=Email('E-mail inválido'),
        description='Digite seu e-mail'
    )	
    senha = SchemaNode(
        String(),
        validator=Length(min=5, max=32),
        widget=widget.PasswordWidget(),
        description='Digite sua senha'
    )
Example #13
0
class BaseReportSchema(MappingSchema):
    # lat/lon being set to -255 indicates that this report should be
    # skipped.  Other fields can be filled in with defaults
    lat = SchemaNode(Float(), missing=-255)
    lon = SchemaNode(Float(), missing=-255)

    time = SchemaNode(String(), missing='')
    accuracy = SchemaNode(Integer(), missing=0)
    altitude = SchemaNode(Integer(), missing=0)
    altitude_accuracy = SchemaNode(Integer(), missing=0)
    radio = SchemaNode(String(),
                       validator=OneOf(RADIO_TYPE_KEYS), missing='')

    heading = SchemaNode(Float(), missing=-1.0)
    speed = SchemaNode(Float(), missing=-1.0)
Example #14
0
class LoginSchema(Schema):
    login = SchemaNode(
        String(),
        title='Логин',
        widget=TextInputPlaceholderWidget(
            placeholder='email, id вконтакте или ник'
        ),
    )

    password = SchemaNode(
        String(),
        title='Пароль',
        placeholder='*****',
        widget=PasswordPlaceholderWidget(placeholder='*****'),
    )
Example #15
0
class GridVectorPropSchema(VectorPropSchema):
    varnames = SequenceSchema(SchemaNode(String()))
    grid = PyGridSchema(missing=drop)
    data_file = SchemaNode(typ=Sequence(accept_scalar=True),
                           children=[SchemaNode(String())])
    grid_file = SchemaNode(typ=Sequence(accept_scalar=True),
                           children=[SchemaNode(String())])

    def __init__(self, json_='webapi', *args, **kwargs):
        if json_ == 'save':
            self.add(
                SchemaNode(typ=Sequence(),
                           children=[SchemaNode(EnvProp())],
                           name='variables'))
        super(GridVectorPropSchema, self).__init__(*args, **kwargs)
Example #16
0
class ActivitySchema(BaseModelSchema):
    """
    Schema definition for activity model.

    """
    description = SchemaNode(String())
    start = SchemaNode(DateTime(), missing=drop)
    end = SchemaNode(DateTime(), missing=drop)
    activity_type = SchemaNode(String(),
                               missing=drop,
                               validator=OneOf(ACTIVITY_TYPES.keys()),
                               default=ACTIVITY_UNASSIGNED)
    project_id = SchemaNode(Integer(), missing=drop)
    task_id = SchemaNode(Integer(), missing=drop)
    user_id = SchemaNode(Integer())
class ParameterLinkSchema(MappingSchema):
    parameter = SchemaNode(typ=Int(),
                           title='Parameter',
                           default=deferred_parameter_default,
                           widget=deferred_parameter_widget)
    target = SchemaNode(
        typ=String(),
        title='Target Log',
        default=deferred_target_default,
        widget=SelectWidget(values=[('value',
                                     'Values'), ('setpoint', 'Setpoints')]))
    color = SchemaNode(typ=String(),
                       title='Color',
                       default=deferred_color_default,
                       widget=TextInputWidget())
Example #18
0
class DatasetForm(Schema):
    label = SchemaNode(String(),
                       preparer=prepare_name,
                       validator=Length(min=2))
    name = SchemaNode(String(), preparer=prepare_name, validator=dataset_name)
    description = SchemaNode(String(), missing=drop)
    private = SchemaNode(Boolean(), missing=drop)
    currency = SchemaNode(String(),
                          missing=drop,
                          validator=OneOf(CURRENCIES.keys()))
    category = SchemaNode(String(),
                          missing=drop,
                          validator=OneOf(CATEGORIES.keys()))
    languages = DatasetLanguages(missing=drop)
    territories = DatasetTerritories(missing=drop)
Example #19
0
class NetCDFOutputSchema(BaseSchema):
    'colander schema for serialize/deserialize object'
    netcdf_filename = SchemaNode(String(), missing=drop)
    all_data = SchemaNode(Bool(), missing=drop)
    compress = SchemaNode(Bool(), missing=drop)
    _start_idx = SchemaNode(Int(), missing=drop)
    _middle_of_run = SchemaNode(Bool(), missing=drop)
Example #20
0
class EditArticleSchema(MappingSchema):
    display_name = SchemaNode(String(),
                              widget=TextInputWidget(size=40),
                              missing='',
                              location="body",
                              type='str')
    article = SchemaNode(String(),
                         widget=TextAreaWidget(cols=140, rows=20),
                         location="body",
                         type='str')
    summary = SchemaNode(String(),
                         widget=TextInputWidget(size=40),
                         missing='',
                         location="body",
                         type='str')
    tags = SchemaNode(String(), widget=TextInputWidget(size=40), missing='')
Example #21
0
    def definition(cls, **kwargs):
        schema = SchemaNode(Mapping(unknown="preserve"))

        if kwargs.get('named', True):
            schema.add(
                SchemaNode(String(),
                           name='name',
                           validator=Regex(r'^[a-zA-Z][a-zA-Z0-9_\-]*$')))

        schema.add(SchemaNode(String(), name='label', missing=u''))
        schema.add(SchemaNode(String(), name='hint', missing=cls.hint))
        schema.add(SchemaNode(Boolean(), name='required',
                              missing=cls.required))
        schema.add(
            SchemaNode(String(), name='type', validator=OneOf(registry.names)))
        return schema
Example #22
0
class DocumentDataSchema(BaseDocumentSchema):
    """Document data update schema"""
    data = SchemaNode(
        FileUploadType(),
        title=_("Document data; may be provided in Base64 when using JSON"),
        missing=drop)
    filename = SchemaNode(String(), title=_("File name"), missing=drop)
Example #23
0
class CreateSecret(CSRFSchema):
    domain = SchemaNode(
        String(),
        widget=HiddenWidget(),
        default='',
        title=u'domain',
    )
Example #24
0
class EmailAddresses(SequenceSchema):
      email = SchemaNode(
          String(),
          title=u'Email Address',
          description=u'Add an email address to be notified.',
          validator=Email(),
      )
Example #25
0
class TrajectoryGeoJsonSchema(BaseOutputterSchema):
    '''
    Nothing is required for initialization
    '''
    round_data = SchemaNode(Bool(), missing=drop, save=True, update=True)
    round_to = SchemaNode(Int(), missing=drop, save=True, update=True)
    output_dir = SchemaNode(String(), missing=drop, save=True, update=True)
Example #26
0
class Authorization(CSRFSchema):
    description = SchemaNode(
        String(),
        title=u'Add an authorization',
        description=u'Application Name or Description',
        # validator=Regex(r'\S', msg="Be nice!")
    )
Example #27
0
class ThreadSchema(MappingSchema):
    title = SchemaNode(String(),
                       default=deferred_default_title,
                       widget=TextInputWidget(),
                       location="body",
                       type='str')
    description = SchemaNode(String(),
                             default=deferred_default_description,
                             widget=TextInputWidget(),
                             location="body",
                             type='str')
    body = SchemaNode(String(),
                      default='',
                      location="body",
                      type='str',
                      widget=TextAreaWidget(rows=5, cols=80))
Example #28
0
class TimeseriesVectorSchema(base_schema.ObjTypeSchema):
    units = SchemaNode(String(), missing=drop, save=True, update=True)
    time = TimeSchema(save=True, update=True, save_reference=True)
    variables = SequenceSchema(TimeseriesDataSchema(),
                               save=True,
                               update=True,
                               save_reference=True)
Example #29
0
class CellTowerSchema(MappingSchema):
    # mapped to 'radio' for submit
    radioType = SchemaNode(String(),
                           validator=OneOf(RADIO_STRINGS),
                           missing=None)
    # mapped to 'cid' for submit
    cellId = SchemaNode(Integer(), missing=None)
    # mapped to 'lac' for submit
    locationAreaCode = SchemaNode(Integer(), missing=None)
    # mapped to 'mcc' for submit
    mobileCountryCode = SchemaNode(Integer())
    # mapped to 'mnc' for submit
    mobileNetworkCode = SchemaNode(Integer())

    # optional
    age = SchemaNode(Integer(), missing=0)
    # mapped to 'signal' for submit
    signalStrength = SchemaNode(Integer(), missing=0)
    # mapped to 'ta' for submit
    timingAdvance = SchemaNode(Integer(), missing=0)

    # The fields below are extra fields which are not part of the
    # geolocate API, but assist with data submission
    psc = SchemaNode(Integer(), missing=-1)
    asu = SchemaNode(Integer(), missing=-1)
Example #30
0
 def create(self):
     require.dataset.create()
     try:
         dataset = dict(request.params)
         dataset['territories'] = request.params.getall('territories')
         dataset['languages'] = request.params.getall('languages')
         model = {'dataset': dataset}
         schema = dataset_schema(ValidationState(model))
         data = schema.deserialize(dataset)
         if Dataset.by_name(data['name']) is not None:
             raise Invalid(
                 SchemaNode(String(), name='dataset.name'),
                 _("A dataset with this identifer already exists!"))
         dataset = Dataset({'dataset': data})
         dataset.private = True
         dataset.managers.append(c.account)
         db.session.add(dataset)
         db.session.commit()
         redirect(
             h.url_for(controller='editor',
                       action='index',
                       dataset=dataset.name))
     except Invalid, i:
         errors = i.asdict()
         return self.new(errors)