Modify

Opened 17 years ago

Closed 17 years ago

#2242 closed defect (fixed)

ProgrammingError triggered with 0.11dev-r5703

Reported by: martin@… Owned by: Dalius
Priority: normal Component: AuthOpenIdPlugin
Severity: major Keywords:
Cc: Trac Release: 0.11

Description

I get a

ProgrammingError: Cannot operate on a closed database

The action that triggered the error was:

GET: /openidverify

Attachments (1)

trac.diff (3.8 KB) - added by anonymous 17 years ago.
A special store implementation for Trac

Download all attachments as: .zip

Change History (23)

comment:1 Changed 17 years ago by anonymous

I would like to get more information

  • what database are you using?
  • is this error frequent?

comment:2 Changed 17 years ago by Dalius

Related ticket from old OpenId plugin: http://trac-hacks.org/ticket/1582

comment:3 Changed 17 years ago by martin@…

I will upgrade trac to the latest SVN and try again. I'm not using mod_python and using sqlite backend.

comment:4 Changed 17 years ago by martin@…

Severity: normalmajor

OK. I've upgraded to latest 0.11 SVN snapshot and the problem is still constant. Here is a stacktrace

Traceback (most recent call last):
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/web/main.py", line 386, in dispatch_request
    dispatcher.dispatch(req)
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/web/main.py", line 195, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/authopenid/authopenid.py", line 139, in process_request
    return self._do_verify(req)
  File "build/bdist.linux-i686/egg/authopenid/authopenid.py", line 197, in _do_verify
    request = oidconsumer.begin(openid_url)
  File "build/bdist.linux-i686/egg/openid/consumer/consumer.py", line 335, in begin
    return self.beginWithoutDiscovery(service, anonymous)
  File "build/bdist.linux-i686/egg/openid/consumer/consumer.py", line 358, in beginWithoutDiscovery
    auth_req = self.consumer.begin(service)
  File "build/bdist.linux-i686/egg/openid/consumer/consumer.py", line 560, in begin
    assoc = self._getAssociation(service_endpoint)
  File "build/bdist.linux-i686/egg/openid/consumer/consumer.py", line 1075, in _getAssociation
    assoc = self.store.getAssociation(endpoint.server_url)
  File "build/bdist.linux-i686/egg/openid/store/sqlstore.py", line 18, in wrapped
    return self._callInTransaction(func, self, *args, **kwargs)
  File "build/bdist.linux-i686/egg/openid/store/sqlstore.py", line 159, in _callInTransaction
    self.conn.rollback()
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/db/sqlite_backend.py", line 193, in rollback
    self.cnx.rollback()
ProgrammingError: Cannot operate on a closed database.

I'm using sqlite 3.3.13 with python 2.5

comment:5 Changed 17 years ago by anonymous

(and I'm also running it with twisted) This patch helps:

Index: authopenid/authopenid.py
===================================================================
--- authopenid/authopenid.py	(revision 2837)
+++ authopenid/authopenid.py	(working copy)
@@ -173,7 +173,8 @@
         s = self._get_session(req)
         if 'id' not in s:
             s['id'] = req.session.sid
-        return consumer.Consumer(s, self.store), s
+        db = self.env.get_db_cnx()
+        return consumer.Consumer(s, self._getStore(db)), s
 
     def _do_verify(self, req):
         """Process the form submission, initating OpenID verification.

but now I'm getting even more mystical traces:

2007-11-30 00:32:37,641 Trac[main] ERROR: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/web/main.py", line 386, in dispatch_request
    dispatcher.dispatch(req)
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/web/main.py", line 195, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/authopenid/authopenid.py", line 139, in process_request
    return self._do_verify(req)
  File "build/bdist.linux-i686/egg/authopenid/authopenid.py", line 198, in _do_verify
    request = oidconsumer.begin(openid_url)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/consumer/consumer.py", line 353, in begin
    return self.beginWithoutDiscovery(service, anonymous)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/consumer/consumer.py", line 376, in beginWithoutDiscovery
    auth_req = self.consumer.begin(service)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/consumer/consumer.py", line 598, in begin
    assoc = self._getAssociation(service_endpoint)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/consumer/consumer.py", line 1164, in _getAssociation
    assoc = self.store.getAssociation(endpoint.server_url)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/store/sqlstore.py", line 18, in wrapped
    return self._callInTransaction(func, self, *args, **kwargs)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/store/sqlstore.py", line 176, in _callInTransaction
    ret = func(*args, **kwargs)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/store/sqlstore.py", line 225, in txn_getAssociation
    self.db_get_assocs(server_url)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/store/sqlstore.py", line 160, in func
    return self._execSQL(sql_name, *args)
  File "/home/user/server/lib/python2.5/python_openid-2.1.0_rc1-py2.5.egg/openid/store/sqlstore.py", line 151, in _execSQL
    self.cur.execute(sql, args)
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/home/user/server/lib/python2.5/Trac-0.11dev_r6254-py2.5.egg/trac/db/sqlite_backend.py", line 56, in execute
    sql = sql % (('?',) * len(args))
TypeError: not all arguments converted during string formatting

comment:6 Changed 17 years ago by Dalius

OK. I will look deeper into this when I have time.

comment:7 Changed 17 years ago by martin@…

OK, I'm not a database expert at all, but it seems to me that there is a fundamental no-co-work between the openid library sqlite backend and trac sqlite backend. python-openid sqlitestore statements use ? as the placeholders for query parameters. Other engines (mysql and postgres) use %%s. the sqlite backend of trac at the same time tries to replace %s occurances in the intial sql statement with ?-s and fails because there is nothing to replace (no %s in the string, question marks already)

comment:8 Changed 17 years ago by anonymous

Solution: create a TracSQLiteStore. Patch attaches. After applying it works perfectly.

Changed 17 years ago by anonymous

Attachment: trac.diff added

A special store implementation for Trac

comment:9 Changed 17 years ago by Dalius

Thanks. I will review your patch.

comment:10 Changed 17 years ago by Dalius

Resolution: fixed
Status: newclosed

I have added your patch and registered ticket in trac itself: http://trac.edgewall.org/ticket/6429

While your patch is completely correct it will require review with each openid library release. While I'm lazy like any other programmer I have registered ticket in trac so we could use OpenID library sqlite backend without additional work.

Again, thanks for your input.

comment:11 Changed 17 years ago by dcapelis@…

Resolution: fixed
Status: closedreopened

Can this ticket be re-opened given the developments in the parent ticket?

comment:12 Changed 17 years ago by Dalius

Could you explain why you have reopen ticket 2242?

I have fixed this ticket before some time: http://hg.sandbox.lt/authopenid-plugin/rev/bfc6e0517c94

Recently I have reimplemented it: http://hg.sandbox.lt/authopenid-plugin/rev/ca4213a25081

The main reason for reimplementation is to minimize support time.

comment:13 Changed 17 years ago by anonymous

Apologies, I didn't realize this patch actually did happen...

I got the error above when I installed this plugin, I assumed it was because this bug hadn't been fixed.

comment:14 Changed 17 years ago by Dalius

Resolution: fixed
Status: reopenedclosed

It might be possible that pysqlite2 is required to get working with SQLite.

comment:15 in reply to:  14 Changed 17 years ago by anonymous

Resolution: fixed
Status: closedreopened

Replying to dalius:

It might be possible that pysqlite2 is required to get working with SQLite.

New Anon here, I'm getting this error using the WSGI handler and also the FastCGI handler. I've got the latest version of all the dependencies running, and adding pysqlite-2 made no difference in the error. Checked out the module source from mercurial this morning. Am I missing something?

comment:16 Changed 17 years ago by Dalius

OK. I have tested sqlite only on windows. I will test it on ubuntu in the weekend. Busy week. Please be patient.

comment:17 Changed 17 years ago by anonymous

No problem. I've averted the problem temporarily by using r9 for now. Thanks for looking into this.

comment:18 Changed 17 years ago by anonymous

I don't know what r9 is, but I was able to revert to the old (working) version with this command: <pre> hg co 670d7551958c </pre>

This assumes you've checked this out via Mercurial.

I took a look at the code, and I don't know why it doesn't work. Based on what was said and what I know about db connections, I think it should have worked. Probably something stupidly obvious.

Ciao!

comment:19 Changed 17 years ago by anonymous

I forgot this trac wasn't for the plugin alone, r9 was in reference to revision9, aka changeset bfc6e0517c94 . The one you just mentioned is revision22 (which I just test and also works here). Sorry for the confusion. To future anons until this is resolved, use changeset 670d7551958c as noted above.

comment:20 Changed 17 years ago by Dalius

I have reproduced this TR and I believe I have fixed it. All the details (and fix itself): http://hg.sandbox.lt/authopenid-plugin/rev/0618b6b80bee

Please, test it.

comment:21 Changed 17 years ago by anonymous

New version works fine for me, thanks!

comment:22 Changed 17 years ago by Dalius

Resolution: fixed
Status: reopenedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Dalius.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.