Exemple #1
0
class ITestSchema(Interface):

    text = schema.TextLine(required=False)
    integer = schema.Int(required=False)
    floating = schema.Float(required=False)
    list_of_text = schema.List(value_type=schema.TextLine(), required=False)
    tuple_of_text = schema.Tuple(value_type=schema.TextLine(), required=False)
    set_of_text = schema.Set(value_type=schema.TextLine(), required=False)
    frozenset_of_text = schema.FrozenSet(value_type=schema.TextLine(),
                                         required=False)
    dict_value = schema.Dict(key_type=schema.TextLine(),
                             value_type=schema.TextLine(),
                             required=False)
    datetime = schema.Datetime(required=False)
    date = schema.Date(required=False)
    time = schema.Time(required=False)

    patch_list = fields.PatchField(
        schema.List(value_type=schema.Dict(key_type=schema.Text(),
                                           value_type=schema.Text()),
                    required=False))
    patch_list_int = fields.PatchField(
        schema.List(value_type=schema.Int(), required=False))
    patch_dict = fields.PatchField(schema.Dict(key_type=schema.Text(),
                                               value_type=schema.Text()),
                                   required=False)

    patch_int = fields.PatchField(schema.Int(default=22), required=False)

    patch_int_no_default = fields.PatchField(schema.Int(), required=False)

    bucket_list = fields.BucketListField(
        bucket_len=10,
        required=False,
        value_type=schema.Dict(key_type=schema.Text(),
                               value_type=schema.Text()),
    )

    datetime_bucket_list = fields.BucketListField(bucket_len=10,
                                                  required=False,
                                                  value_type=schema.Datetime())

    union_field = schema.UnionField(schema.Datetime(),
                                    schema.Int(),
                                    required=False)
    union_field_obj = schema.UnionField(schema.Object(IObjectA),
                                        schema.Object(schema=IObjectB),
                                        required=False)

    nested_patch = fields.PatchField(
        schema.Dict(
            required=False,
            key_type=schema.Text(),
            value_type=fields.PatchField(
                schema.List(value_type=schema.Object(
                    schema=INestFieldSchema))),
        ))

    dict_of_obj = schema.Dict(
        required=False,
        key_type=schema.Text(),
        value_type=schema.Object(schema=INestFieldSchema))

    patch_dict_of_obj = fields.PatchField(
        schema.Dict(required=False,
                    key_type=schema.Text(),
                    value_type=schema.Object(schema=INestFieldSchema)))

    patch_tuple = fields.PatchField(
        schema.Tuple(required=False,
                     value_type=schema.Text(schema=INestFieldSchema)))

    bucket_dict = fields.BucketDictField(bucket_len=10,
                                         required=False,
                                         key_type=schema.Text(),
                                         value_type=schema.Text())
Exemple #2
0
class IActivity(IFolder):

    metadata("id_strava")
    index_field("id_strava", type="text")
    id_strava = schema.TextLine(title="Strava id")

    metadata("name")
    index_field("name", type="text")
    name = schema.TextLine(title="Name")

    metadata("distance")
    index_field("distance", type="float")
    distance = schema.Int(title="Distance")

    metadata("moving_time")
    index_field("moving_time", type="int")
    moving_time = schema.Int(title="Moving time")

    elapsed_time = schema.Int(title="Elapsed time")

    metadata("total_elevation_gain")
    index_field("total_elevation_gain", type="int")
    total_elevation_gain = schema.Int(title="Total elevation gain")

    metadata("type_activity")
    index_field("type_activity", type="text")
    type_activity = schema.TextLine(title="Type")  # Pass to vocabulary

    metadata("start_date")
    index_field("start_date", type="date")
    start_date = schema.Datetime(title="Start date")

    start_date_local = schema.Datetime(title="Start date local")
    timezone = schema.TextLine(title="Timezone")
    utc_offset = schema.Int(title="Utc offset")

    metadata("average_speed")
    index_field("average_speed", type="float")
    average_speed = schema.Float(title="Averge speed")

    metadata("max_speed")
    index_field("max_speed", type="float")
    max_speed = schema.Float(title="Max speed")

    metadata("average_cadence")
    index_field("average_cadence", type="float")
    average_cadence = schema.Float(title="Average cadence")

    metadata("average_watts")
    index_field("average_watts", type="float")
    average_watts = schema.Float(title="Average watts")

    metadata("weighted_average_watts")
    index_field("weighted_average_watts", type="float")
    weighted_average_watts = schema.Float(title="Weighted average watts")

    metadata("kilojoules")
    index_field("kilojoules", type="float")
    kilojoules = schema.Float(title="Kilojoules")

    metadata("device_watts")
    index_field("device_watts", type="boolean")
    device_watts = schema.Bool(title="Device watts")

    metadata("max_watts")
    index_field("max_watts", type="float")
    max_watts = schema.Float(title="Max watts")

    metadata("average_heartrate")
    index_field("average_heartrate", type="float")
    average_heartrate = schema.Float(title="Average heartrate")

    metadata("max_heartrate")
    index_field("max_heartrate", type="int")
    max_heartrate = schema.Int(title="Max heartrate")

    elev_high = schema.Float(title="Elev high")
    elev_low = schema.Float(title="Elev low")
    calories = schema.Float(title="Calories")
Exemple #3
0
class INestFieldSchema(Interface):
    foo = schema.Text(required=False)
    bar = schema.Int(required=False)
    foobar_list = schema.List(required=False, value_type=schema.Text())
    nested_int = fields.PatchField(schema.Int(required=False))
Exemple #4
0
class INestFieldSchema(Interface):
    foo = schema.Text(required=False)
    bar = schema.Int(required=False)
    foobar_list = schema.List(required=False, value_type=schema.Text())