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

Reply via email to