yah someone else asked about this recently, clearly the docs are missing
this little point:
you can say:
m = mapper(User, users, properties = {
'_user_name' = users.c.user_name
})
to override the property name it uses against the column.
we also have a guy working on something new, an enhanced "property" object
on the class, where you might be able to do something like this:
User.user_name.beforegetitem = lambda self: <etc>
User.user_name.beforeappend = etc
so maybe we we will get something like that going soon as well.
Wade Leftwich wrote:
> Is there a way to specify what happens when a column property is set?
>
> Take an ordinary class like this contrived example:
>
> class User(object):
>
> def __init__(self, user_name=None, email=None):
> self.email = email
> self._setuser(user_name)
>
> def _setuser(self, name):
> self._user_name = name
> if name == 'fred':
> self.email = '[EMAIL PROTECTED]'
>
> def _getuser(self):
> return self._user_name
>
> user_name = property(_getuser, _setuser)
>
>
> Now I want to map this User class (or a different class that acts the
> same) to a table whose columns are 'user_name' and 'email'. When
> user_name is set, I want the same logic to apply.
>
> Is this doable? Any help appreciated.
>
> I'm just getting started with SqlAlchemy, really diggin it so far.
>
> -- Wade Leftwich
> Ithaca, NY
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users