Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #199 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

turbogears.identity broken inside tg-admin shell

Reported by: Jorge Godoy <jgodoy@…> Owned by: kevin
Priority: high Milestone: 0.9
Component: TurboGears Version:
Severity: major Keywords:
Cc:

Description

When using "tg-admin shell" to create new users / groups, nothing is recorded in the database. This started happening after the implicit transactions were added. One can try starting a new transaction and commiting it manually, but it doesn't work.

On the other hand, everything works fine inside a method.

Other operations involving the database are commited and work inside "tg-admin shell" without any problem.

Demonstration of the problem:

In [1]: from turbogears.identity.model.somodel import *

In [2]: u = TG_User(userId='test', password='test', displayName='test user', emailAddress='test_user@…')

In [3]: u Out[3]: <TG_User 7L userId=u'test' emailAddress="u'test_user@g2cte...'" displayName=u'test user' password=u'test' created='datetime.datetime...)'>

In [4]: hub.commit()

In [5]: hub.end()

From the database itself:

test_db=# select * from tg_user where id=7;

id | user_id | email_address | display_name | password | created


(0 registros)

test_db=#

Change History

comment:1 Changed 13 years ago by kevin

  • Milestone set to 0.9

comment:2 Changed 13 years ago by Ryan Forsythe <flamingweasel@…>

I'm getting the same error with a sqlite db. When I use tg-admin shell it fails silently; when I use Catwalk to browse or Add TG_User I get the following traceback:

2005/12/08 15:49:43  INFO Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 271, in run
    main()
  File "/usr/lib/python2.4/site-packages/CherryPy-2.1.0-py2.4.egg/cherrypy/_cphttptools.py", line 502, in main
    body = page_handler(*args, **cherrypy.request.paramMap)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r298-py2.4.egg/turbogears/controllers.py", line 196, in newfunc
    html, *args, **kw)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r298-py2.4.egg/turbogears/database.py", line 174, in run_with_transaction
    retval = func(*args, **kw)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r298-py2.4.egg/turbogears/controllers.py", line 222, in _execute_func
    output = func(self, *args, **kw)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r298-py2.4.egg/turbogears/catwalk/catwalk.py", line 753, in instances
    return self.object_instances(objectName)
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a0dev_r298-py2.4.egg/turbogears/catwalk/catwalk.py", line 307, in object_instances
    headers, rows = self.headers_and_rows(object_name,list(obj.select()))
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/sresults.py", line 149, in __iter__
    return iter(list(self.lazyIter()))
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/sresults.py", line 157, in lazyIter
    return conn.iterSelect(self)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/dbconnection.py", line 755, in iterSelect
    select, keepConnection=True)))
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/dbconnection.py", line 687, in __init__
    self.dbconn._executeRetry(self.rawconn, self.cursor, self.query)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/dbconnection.py", line 295, in _executeRetry
    return cursor.execute(query)
  File "/usr/lib/python2.4/site-packages/sqlite/main.py", line 244, in execute
    self.rs = self.con.db.execute(SQL)
OperationalError: database is locked

comment:3 Changed 13 years ago by jchu@…

Just a thought, try:

from turbogears import database
database.commit_all()

instead of hub.commit().

It's not the answer, but it'll explain a little bit more about the situation with the identity stuff.

comment:4 Changed 13 years ago by kevin

  • Owner changed from anonymous to kevin
  • Status changed from new to assigned

Actually, that is basically the answer. identity is using its own hub, so hub.commit() won't do the trick but database.commit_all() will.

the fix is either to make commit_all readily available in the shell *or* to make hub.commit effectively do a commit_all.

comment:5 Changed 13 years ago by kevin

  • Status changed from assigned to closed
  • Resolution set to fixed

OK, looking again at the database code the solution was trivial: change identity to use a PackageHub?. The PackageHub? already ensures that there's *only one* connection for a given dburi! That means that commits will work, etc.

This gets trickier if the user is legitimately pointing to different databases, but I'm not going to worry about that use case yet.

Done in [415].

Note: See TracTickets for help on using tickets.