Ejemplo n.º 1
0
class NestedSchema(halogen.Schema):
    """A combination of a Person, an attribute is_friend, and a price."""

    self = halogen.Link("/events/activity-event{?uid}",
                        type='application/pdf',
                        templated=True)
    person = halogen.Attr(PersonSchema)
    is_friend = halogen.Attr()
    price = halogen.Attr(AmountType)
    events = halogen.Embedded(halogen.types.List(EventSchema),
                              attr=lambda collection: collection["events"],
                              curie=em)
Ejemplo n.º 2
0
class VNDError(halogen.Schema):
    """An exception that can be serialized to the hal+json format."""

    message = halogen.Attr(required=False, attr=get_error_message)
    logref = halogen.Attr(attr=lambda error: uuid.uuid4().hex)
    help = halogen.Link(required=False, attr=get_current_profile_link)

    # Extended fields
    type = halogen.Attr(required=False,
                        attr='error_type',
                        default='UNKNOWN_ERROR')
    """Error type identifier."""

    details = halogen.Attr(required=False, attr='data')
    """Optional additional error details."""
Ejemplo n.º 3
0
class NestedSchema(halogen.Schema):
    """An example nested schema, with a person, an is_friend attribute, and a price."""

    self = halogen.Link(attr='/some/link')
    person = halogen.Attr(Person)
    is_friend = halogen.Attr()
    price = halogen.Attr(Amount)
    products = halogen.Attr(
        halogen.types.List(
            Product,
            allow_scalar=True,
            validators=[
                halogen.validators.Length(min_length=0, ),
            ],
        ),
        default=[],
    )
Ejemplo n.º 4
0
class AccountSchema(halogen.Schema):
    self = halogen.Link(attr=lambda account: url_for(
        "get_account", account_key=account.key.urlsafe()))
    id = halogen.Attr(attr=lambda account: account.key.id())
    username = halogen.Attr()
Ejemplo n.º 5
0
    class Schema(halogen.Schema):
        """A test schema."""

        warehouse = halogen.Link("/test/123", deprecation="http://foo.bar")
Ejemplo n.º 6
0
    class Schema(halogen.Schema):
        """A test schema."""

        warehouse = halogen.Link(curie=ACME)
Ejemplo n.º 7
0
 class Schema(halogen.Schema):
     self = halogen.Link(attr="uid")
Ejemplo n.º 8
0
 class OrderedSchema2(halogen.Schema):
     self = halogen.Link('http://somewhere.com')
     hello = halogen.Attr()
     foo = halogen.Attr('bar')
     person = halogen.Embedded(PersonSchema)