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 #702 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

[PATCH] Prepending notrans_ causes tg-admin sql create to fail

Reported by: anonymous Owned by: anonymous
Priority: normal Milestone: 0.9a3
Component: SQLObject Version: 0.9a1
Severity: critical Keywords:
Cc: turbogears@…

Description

I've enabled notrans_ on an SQLite database, the system itself works fine but tg-admin sql create fails with the exception:

$ tg-admin sql create
Using database URI notrans_sqlite:///tmp/dev.db?debug=1
Traceback (most recent call last):
  File "/usr/local/bin/tg-admin", line 7, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a1-py2.4.egg/turbogears/command/base.py", line 270, in main
    command.run()
  File "/usr/lib/python2.4/site-packages/TurboGears-0.9a1-py2.4.egg/turbogears/command/base.py", line 129, in run
    command.the_runner.run(sys.argv)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/manager/command.py", line 102, in run
    runner.run()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/manager/command.py", line 233, in run
    self.command()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/manager/command.py", line 542, in command
    for soClass in self.classes(require_some=True):
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/manager/command.py", line 255, in classes
    conn = self.connection()
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/manager/command.py", line 316, in connection
    return sqlobject.connectionForURI(self.options.connection_uri)
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/dbconnection.py", line 918, in connectionForURI
    assert self.schemeBuilders.has_key(scheme), (
AssertionError: No SQLObject driver exists for notrans_sqlite (only sqlite, sapdb, postgresql, firebird, maxdb, sybase, interbase, psycopg, mysql, mssql, postgres)

Change History

comment:1 Changed 11 years ago by baruch

  • Milestone set to 0.9a3

comment:2 Changed 11 years ago by baruch

  • Status changed from new to assigned

Patch against turbogears/command/base.py

--- base.py.orig        2006-03-31 20:47:02.000000000 +0100
+++ base.py     2006-03-31 20:48:25.000000000 +0100
@@ -62,6 +62,8 @@
             self.config = get_project_config()
             load_project_config(self.config)
         self.dburi = cherrypy.config.get("sqlobject.dburi", None)
+        if self.dburi.startswith("notrans_"):
+            self.dburi = self.dburi[8:]
 
 class SQL(CommandWithDB):
     """Wrapper command for sqlobject-admin.

comment:3 Changed 11 years ago by baruch

A better patch, the former one died if self.dburi was None:

--- base.py.orig        2006-03-31 20:47:02.000000000 +0100
+++ base.py     2006-04-01 20:57:46.000000000 +0100
@@ -62,6 +62,8 @@
             self.config = get_project_config()
             load_project_config(self.config)
         self.dburi = cherrypy.config.get("sqlobject.dburi", None)
+        if self.dburi and self.dburi.startswith("notrans_"):
+            self.dburi = self.dburi[8:]
 
 class SQL(CommandWithDB):
     """Wrapper command for sqlobject-admin.

comment:4 Changed 11 years ago by Baruch <turbogears@…>

  • Severity changed from major to critical

Another version, this one fixes yet another bug where the config file wouldn't be loaded at all. Did anyone use tg-admin sql?

--- base.py.orig        2006-03-31 20:47:02.000000000 +0100
+++ base.py     2006-04-01 21:18:40.000000000 +0100
@@ -38,6 +38,7 @@
     if config is None:
         config = get_project_config()
     if not os.path.isfile(config):
+        print 'config file %s not found or is not a file.' % config
         return
     ext = os.path.splitext(config)[1]
     if ".py" == ext.lower():
@@ -58,10 +59,10 @@
         """Chooses the config file, trying to guess whether this is a
         development or installed project."""
         import cherrypy
-        if not self.config:
-            self.config = get_project_config()
-            load_project_config(self.config)
+        load_project_config(self.config)
         self.dburi = cherrypy.config.get("sqlobject.dburi", None)
+        if self.dburi and self.dburi.startswith("notrans_"):
+            self.dburi = self.dburi[8:]
 
 class SQL(CommandWithDB):
     """Wrapper command for sqlobject-admin.

comment:5 Changed 11 years ago by Baruch <turbogears@…>

  • Summary changed from Prepending notrans_ causes tg-admin sql create to fail to [PATCH] Prepending notrans_ causes tg-admin sql create to fail

comment:6 Changed 11 years ago by kevin

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

committed in [1054]. Thanks!

Note: See TracTickets for help on using tickets.