Documentation for Using Descriptors has following example:
====
class EmailAddress(object):
def _set_email(self, email):
self._email = email
def _get_email(self):
return self._email
email = property(_get_email, _set_email)
mapper(MyAddress, addresses_table, properties={
'_email': addresses_table.c.email
})
...
mapper(EmailAddress, addresses_table, properties={
'email': synonym('_email', map_column=True)
})
====
Firstly, should "MyAddress" be "EmailAddress"?
Secondly, can one not create a plain property without using synonym()?
I do not understand the need for 'copying' a column, only to change
it's behaviour using property(). I would expect something more like
this:
====
class MyStuff(object):
def _set_useful_property(self, value):
self.useful_property= value
def _get_useful_property(self):
return self.useful_property
useful_property = property(_get_useful_property,
_set_useful_property)
mapper(MyStuff, stuff_table, properties={
'useful_property': MyStuff.useful_property
})
====
Have I misunderstood the methods by which to add mapped properties?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---