the two main options are using TypeDecorator, or to filter at the  
object level using the technique described at 
http://www.sqlalchemy.org/docs/05/mappers.html#using-descriptors 
  .


On Apr 23, 2009, at 12:51 PM, Brendan Zerr wrote:

>
> I'm just starting out using SQLAlchemy and Pylons. I'm trying to  
> create
> a model that will hash the 'password' field before insert/update into
> the database.
>
> Basically I'm looking for a way to filter data before it goes in and
> before it comes out of the database.
>
> Here's some snippets:
>
> class User(object):
>    def setPassword(self):
>        m = hashlib.md5(self.password)
>        self.password = m.hexdigest()
>        return self.password
>
> t_users = sa.Table('users', meta.metadata,
>                   sa.Column('id', sa.types.Integer, primary_key=True),
>                   sa.Column('username', sa.types.String(128)),
>                   sa.Column('password', sa.types.String(64)),
>                   sa.Column('email', sa.types.String(256)),
>                   sa.Column('displayName', sa.types.String(256)))
>
> orm.mapper(User, t_users)
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to