On May 8, 1:58 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On May 8, 2007, at 1:23 PM, noah.gift wrote:
>
>
>
>
>
> > I am trying to use the following code to handle an exception in
> > Turbogears, but it does not grab the SQLError:
>
> > please note I did a:
> > from sqlalchemy.exceptions import SQLError
>
> > def save(self, name=None, email=None, password=None,
> > password_confirm=None,
> > **kw):
> > try:
> > u = User(user_name=name, display_name=name, email=email,
> > password=password)
> > raise redirect("/registered")
>
> > except SQLError:
> > flash("That account already exists.")
>
> i think youre confusing a pattern from SQLObject here. creating a
> new object doesnt write any changes to the database in sqlalchemy.
Your right. I wasn't sure of how much magic was occuring with
Turbogears, but I really do like that I have to be explicit even
inside of Turbogears.
Forgive the dumb question, but what is the proper SQLAlchemy
recommended way to deal with a situation like this.
Should I see if the object already exists first, or be lazy and try to
write to the database and attempt to catch the exception.
I love to read, so if you can point me to some examples on situations
like this it would be very helpful.
Noah
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---