Exemple #1
0
class Entity(JsonObject):
    """
    A base class for the object model
    """

    oid = Property("oid", type=str)
    created = Property("created", default=datetime.now)
Exemple #2
0
        class Parent(JsonObject):
            __add_type_identifier__ = False
            field1 = Property(type=str,
                              allow_none=False,
                              description="some field 1")
            field2 = Property(type=str,
                              allow_none=False,
                              description="some field 2")
            field3 = Property(type=str,
                              allow_none=False,
                              description="some field 3",
                              schema_ref="http://schemas.org/fieldtype#")

            keys = Property(default=dict, type=MapOf(Child))
Exemple #3
0
class Company(Entity):
    """
    This class represents a company.
    """

    company_name = Property("company-name", type=str)
    description = Property("description", type=str)

    def __init__(self, **kwargs):
        super(Company, self).__init__(**kwargs)
        # I use this field only for checking that the field "description"
        # is accessed from the getter instead of using default accessor.
        self._used_getter = False

    def get_description(self):
        # Set _used_getter to True if this getter has been called.
        self._used_getter = True
        return self._description
Exemple #4
0
class TestObject(JsonObject):

    date_time = Property("date-time",
                         handler=DateTimeHandler(),
                         default=datetime.now)

    def __init__(self, **kwargs):
        JsonObject.__init__(self, **kwargs)
        self._deserialized = False

    def _after_deserialize(self):
        self._deserialized = True
Exemple #5
0
class TestObject1(JsonObject):
    field1 = Property()

    def get_field2(self):
        return self._field2

    def set_field2(self, field2):
        self._field2 = field2

    field2 = property(get_field2, set_field2)

    def update_field2(self, val):
        self.field2 = val
Exemple #6
0
        class TestObject(JsonObject):
            prop1 = Property()

            def __init__(self, **kwargs):
                super().__init__(**kwargs)
                self._prop2 = None

            def set_prop2(self, prop2):
                self._prop2 = prop2

            def get_prop2(self):
                return self._prop2

            prop2 = property(get_prop2, set_prop2)
Exemple #7
0
 class TestObject2(JsonObject):
     some_boolean_1 = Property(handler=bool_handler)
     some_boolean_2 = Property(handler=bool_handler)
     some_boolean_3 = Property(handler=bool_handler)
class Customer(JsonObject):
    first_name = Property(json="first-name")
    last_name = Property(json="last-name")
    tax_id = Property(json="tax-id")
class ListOfInts(JsonObject):
    __jsonpickle_format__ = True
    values = Property()
class JsonPickleInvoice(JsonObject):
    __jsonpickle_format__ = True
    customer = Property(type=Customer)
    items = Property(type=ArrayOf(Item))
Exemple #11
0
class Child(JsonObject):
    property1 = Property()
Exemple #12
0
 class Child(JsonObject):
     __add_type_identifier__ = False
     field1 = Property(type=str)
Exemple #13
0
 class TestObject(JsonObject):
     val = Property(type=Enum1, enum_as_str=True)
Exemple #14
0
class Type2(JsonObject):
    field_1 = Property(type=int, title="Field 1 title")
    field_2 = Property(type=Values, enum_as_str=True)
    field_3 = Property(type=str, pattern=".*")
    field_4 = Property(type=str, format="email")
Exemple #15
0
class Type1(JsonObject):

    field_1 = Property(type=str)
    field_2 = Property(type=Type2)
Exemple #16
0
 class Item(JsonObject):
     field = Property(schema=field_schema)
 class TestObject(JsonObject):
     property1 = Property()
Exemple #18
0
class Parent(JsonObject):
    children = Property(type=ArrayOf(Child))
Exemple #19
0
class TestAliasedObject(JsonObject):
    field1 = Property()
Exemple #20
0
 class TestObject5(JsonObject):
     field1 = Property(group="group1")
     field2 = Property(group="group2")
     field3 = Property(group="group2")
Exemple #21
0
 class TestObject4(JsonObject):
     val1 = Property()
     val2 = Property()
Exemple #22
0
class ValidatorTest(JsonObject):
    __validate__ = True
    field_1 = Property(type=str, allow_none=False, validator="default")
Exemple #23
0
 class TestObject(JsonObject):
     val = Property(type=Enum1)
Exemple #24
0
class Sector(Entity):
    employees = Property("employees", default=[])
Exemple #25
0
        class TestObject(JsonObject):

            __jsonpickle_format__ = True

            prop1 = Property()
Exemple #26
0
class Employee(Entity):
    name = Property()
Exemple #27
0
class ValidatorTest2(JsonObject):
    __validate__ = True
    email = Property(validator=EmailValidator())
class Item(JsonObject):
    product_id = Property(json="product-id")
    quantity = Property()
    unit_price = Property("unit-price")
Exemple #29
0
class TestObject(JsonObject):
    field1 = Property(default=1)
    field2 = Property(default=True)
    field3 = Property(default=False)
    field4 = Property(default=dict)
    field5 = Property(default=lambda: [1, 2, 3])
class Invoice(JsonObject):
    number = Property()
    datetime = Property()
    customer = Property(type=Customer)
    items = Property(type=ArrayOf(Item))