#7262 closed defect (fixed)
db.close() should not be used in trac 0.12
Reported by: | ejucovy | Owned by: | Jeff Hammel |
---|---|---|---|
Priority: | normal | Component: | TracSqlHelperScript |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description (last modified by )
Don't close the db connection after each SQL command is executed. In Trac 0.12 this causes subsequent db queries to have no connection, causing AttributeErrors.
Patch:
-
tracsqlhelper/__init__.py
29 29 Exception:%s""" %(sql, params, e)) 30 30 db.rollback() 31 31 raise 32 try:33 db.close()34 except:35 pass32 #try: 33 # db.close() 34 #except: 35 # pass 36 36 return self.return_values(**_data)
AFAICT this is a band-aid over a bigger issue. SQLHelperScript does not distinguish between commands that write to the db and commands that only read from it -- all commands will commit and roll-back the database. It also tries to manage its own database connections (get_db_cnx and the now-commented-out db.close()). And in fact it seems like as of Trac 0.12 it should not be trying to manage its own transactions either, or if it does it should be using the with_transaction decorator. But my hunch is that none of this should be managed at the level of the individual SQL command objects, rather by their callers.
Regardless this small change seems to fix the immediate issue, comment:4:ticket:7182-- though I don't know if it will cause additional problems.
Attachments (1)
Change History (8)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 Changed 11 years ago by
Description: | modified (diff) |
---|
I'm not sure that [12978] was a good idea, but on the other hand, I don't think it's a good idea to retain a directory named anyrelease, when it no longer works with any release. I've tested that the TracHoursPlugin installs correctly in Trac 0.11 from trachoursplugin/branches/0.11
, and I'll do the same for other plugins that utilize the TracSqlHelperScript, after changing their setup script to point to 0.11
rather than anyrelease
.
comment:5 Changed 11 years ago by
comment:6 Changed 11 years ago by
The setup.py
s for the following projects point to tracsqlhelperscript/anyrelease
, and will need to be modified to point to tracsqlhelperscript/0.11
:
comment:7 Changed 11 years ago by
(In [12984]) Refs #7262: Point setup,py
link to TracSqlHelperScript 0.11
directory rather than anyrelease
directory.
I can branch sqlhelperscript for 0.12-compat and commit this patch if you give me access -- I don't seem to have write access on this plugin at trac-hacks. Thanks!