On Aug 16, 2006, at 9:07 AM, Sanjay wrote:
>
> Thanks. The traceback and sample code is as below:
>
> TRACEBACK
> ---------------------
> 500 Internal error
>
> The server encountered an unexpected condition which prevented it from
> fulfilling the request.
>
> Page handler: <bound method Root.createsanjay of
> <ierr.controllers.Root
> object at 0xb763220c>>
> Traceback (most recent call last):
> File
> "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/
> _cphttptools.py",
> line 105, in _run
> self.main()
> File
> "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/
> _cphttptools.py",
> line 254, in main
> body = page_handler(*virtual_path, **self.params)
> File "<string>", line 3, in createsanjay
> File
> "/usr/lib/python2.4/site-packages/TurboGears-0.9a7-py2.4.egg/
> turbogears/controllers.py",
> line 331, in expose
> output = database.run_with_transaction(
> File "<string>", line 5, in run_with_transaction
> File
> "/usr/lib/python2.4/site-packages/TurboGears-0.9a7-py2.4.egg/
> turbogears/database.py",
> line 268, in sa_rwt
> transaction.commit()
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line
> 46,
> in commit
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line
> 234, in flush
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line
> 192, in flush
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line
> 363, in execute
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line
> 631, in execute
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line
> 585, in _save_objects
> File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line
> 824,
> in save_obj
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 244, in execute
> return Connection.executors[type(object).__mro__[-2]](self,
> object,
> *multiparams, **params)
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 268, in execute_clauseelement
> return self.execute_compiled(elem.compile(engine=self.__engine,
> parameters=param), *multiparams, **params)
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 284, in execute_compiled
> proxy(str(compiled), parameters)
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 280, in proxy
> self._execute_raw(statement, parameters, cursor=cursor,
> context=context)
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 319, in _execute_raw
> self._execute(cursor, statement, parameters, context=context)
> File
> "/usr/lib/python2.4/site-packages/SQLAlchemy-0.2.6-py2.4.egg/
> sqlalchemy/engine/base.py",
> line 338, in _execute
> raise exceptions.SQLError(statement, parameters, e)
> SQLError: (IntegrityError) ERROR: duplicate key violates unique
> constraint "ux_person_name"
>
> INSERT INTO person (id, name) VALUES (7, 'sanjay') 'INSERT INTO person
> (id, name) VALUES (%(id)s, %(name)s)' {'id': 7L, 'name': 'sanjay'}
>
>
The problem is that the exception is raised by SA's transaction.commit
() inside "run_with_transaction" which wraps your exposed controller
method to commit the DB transaction if no errors occurs.
There's currenty no way to trap exceptions raised inside
run_with_transaction :( but I'm sure someone will tackle this soon if
you open a ticket at the Trac. I'm sure something can be done pretty
easily with TG's errorhandling to handle this.
So don't feel like a zero, you've just discovered a bug ;)
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---