#1077: trapping exceptions raised inside SA's run_with_transaction
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: new
Priority: high | Milestone: 1.0
Component: TurboGears | Version:
Severity: critical | Keywords: sqlalchemy exception trapping
-----------------------------------+----------------------------------------
Using sqlalchemy, it's not being possible to trap database errors while
commitng. Example code:
# model.py
from sqlalchemy import *
from sqlalchemy.ext.assignmapper import assign_mapper
from turbogears.database import metadata, session
person_table = Table('person', metadata,
Column('id', Integer, primary_key=True),
Column('name', String(30), unique=True, nullable=False)
)
class Person(object):
pass
assign_mapper(session.context, Person, person_table)
# added the following method to root controller
@expose()
def createsanjay(self):
try:
sanjay = Person(name='sanjay')
#sanjay.flush()
except:
return "Can not insert"
return "Inserted!"
The try-except block does not trap the "duplicate name" error. The
discussion thread below can be refered for more details.
http://groups.google.co.in/group/turbogears/browse_thread/thread/24b21834e9ccae3e/046cb9e9543954e6?lnk=raot&hl=en#046cb9e9543954e6
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1077>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---