sure, define your mapper like this:

class User(object):
          def _set_email(self, email_address):
             if isValidEMail(email_address):
                 self._email = email

          email = property(lambda self: self._email, _set_email)

m = mapper(User, users, properties = {
        '_email' : users.c.email
   })

- mike

Lars Heuer wrote:
> Hi all,
>
> If I like to check some constraints before the property of an object
> is really set, I have to use properties, right?
>
> I.e. I want to check if I like to accept the folling assignment:
>
>      user.email = '[EMAIL PROTECTED]'
>
> I have to do something like this:
>
>    class User(object):
>
>          def _set_email(self, email_address):
>             if isValidEMail(email_address):
>                 self._email = email
>
>          email = property(lambda self: self._email, _set_email)
>
> Where the "User._email" property is controlled by a SQLAlchemy mapper.
>
> SQLAlchemy does not add some magic methods like SQLObject does with
> <http://sqlobject.org/SQLObject.html#overriding-column-attributes>
>
> To make it short: Is the above mentioned code the SQLAlchemy way to
> check constraints?
>
> Best regards,
> Lars
> --
> http://semagia.com
>
>
>
> -------------------------------------------------------
> 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

Reply via email to