Exemple #1
0
class _Address(domain.DomainObject):
    street = domain.DomainProperty(property_type.StringType(), "", "Street",
                                   "This is the street name.")
    streetNumber = domain.DomainProperty(property_type.NumberType(), None,
                                         "Street Number",
                                         "This is the street number.")
    city = domain.DomainProperty(property_type.DomainObjectType(_City),
                                 _City(), "City", "This is the city.")
Exemple #2
0
class _City(domain.DomainObject):    
    name = domain.DomainProperty(property_type.StringType(5), "", "City Name", "Name of the city.")
    zip = domain.DomainProperty(property_type.StringType(), "", "ZIP", "The postal code of the city.")
    
    def __init__(self, name="", zip_=""):
        domain.DomainObject.__init__(self)
        self.name = name
        self.zip = zip_
class UnknownDomainObject(domain.DomainObject):
    """ Used to represent values of domain object types whose
    class could not be loaded. """
    
    # Used to have a nice representation of the dictionary
    representation = domain.DomainProperty(StringType())
    
    def __init__(self, theDict):
        domain.DomainObject.__init__(self)
        self.theDict = theDict # Used to allow access to the properties
        self.representation = str(theDict)
Exemple #4
0
class _Author(domain.DomainObject):
    name = domain.DomainProperty(property_type.StringType(), None, "Name",
                                 "This is the author name")
    mainAddress = domain.DomainProperty(
        property_type.DomainObjectType(_Address), _Address(), "Addresses",
        "The main address.")
    addresses = domain.DomainProperty(
        property_type.ListType([property_type.DomainObjectType(_Address)]),
        None, "Addresses", "These are additional addresses.")

    def __init__(self, name="", mainAddress=None, addresses=None):
        domain.DomainObject.__init__(self)
        self.name = name
        if not mainAddress is None:
            self.mainAddress = mainAddress
        if not addresses is None:
            self.addresses = addresses

    @name.setValidate
    def _validateName(self):
        if self.name is None or len(self.name) == 0:
            raise ValueError("Name should not be empty.")
Exemple #5
0
 def testDomainPropertyRepresentation(self):
     domainProperty = domain.DomainProperty(property_type.StringType())
     self.assertEquals(repr(domainProperty), ": String\n")
Exemple #6
0
class _City(domain.DomainObject):
    name = domain.DomainProperty(property_type.StringType(), "", "City Name",
                                 "Name of the city.")
    zip = domain.DomainProperty(property_type.StringType(), "", "ZIP",
                                "The postal code of the city.")
Exemple #7
0
class _Test(domain.DomainObject):
    a = domain.DomainProperty(property_type.DomainObjectType(_City), _City("mmmmmm"))
    b = domain.DomainProperty(property_type.DomainObjectType(_City), _City("mmmmmm"))
    c = domain.DomainProperty(property_type.DomainObjectType(_City), _City("mmmmmm"))