On Mon, Jul 7, 2008 at 10:24 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
>
> On Jul 7, 2008, at 3:29 PM, Eric Lemoine wrote:
>
>>
>> Hello
>>
>> To override attribute behavior the 0.5 doc gives this example:
>>
>> class MyAddress(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':synonym('_email', map_column=True)
>> })
>>
>> What won't work if I just set the python property and don't use the
>> synonym func:
>>
>> mapper(MyAddress, addresses_table)
>>
>> What difference does it make? I couldn't find an explanation in the
>> doc.
>>
>> Sorry if that's a dumb question!
>
>
> without synonym(), just add "_email:addresses_table.c.email" to your
> mapper properties dict so that the "email" name is made available.

In that case, on DB read, SA will set _email directly and won't go
through _set_email(). Is that correct?

And with "email:synonym('_email', map_column=True)", will SA set
_email directly or will it go through _set_email()? My feeling is that
it will set it directly, so it is exactly the same as doing
"_email:addresses_table.c.email".

And if one uses neither "email:synonym('_email', map_column=True)" nor
"_email:addresses_table.c.email" then SA will go through _set_email().

Is my understanding correct?

--
Eric

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to