I am still having problems creating my first turbogears database web
app. (They have been computations until now)
Windows XP
Python 2.4.1
Turbogears SVN 230
Note: The database is created outside of turbogears
Note 2: I verified the SQLObject works
There seems to be a problem with the connection to SQLObject
----------------------------------- Browser
------------------------------------
500 Internal error
Server got itself in trouble
Traceback (most recent call last):
File
"c:\python24\lib\site-packages\cherrypy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py",
line 271, in run
main()
File
"c:\python24\lib\site-packages\cherrypy-2.1.0-py2.4.egg\cherrypy\_cphttptools.py",
line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File
"c:\python24\lib\site-packages\TurboGears-0.9a0dev_r240-py2.4.egg\turbogears\controllers.py",
line 205, in newfunc
output = func(self, *args, **kw)
File "C:\devTesting\devtesting\devtesting\controllers.py", line 21,
in data
testCase = TestCase.byTest_id(testcase_id)
File "<string>", line 1, in <lambda>
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py",
line 1252, in _SO_fetchAlternateID
result, obj = cls._findAlternateID(name, dbName, value, connection)
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py",
line 1243, in _findAlternateID
return (connection or cls._connection)._SO_selectOneAlt(
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 848, in __get__
return self.getConnection()
File
"c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 860, in getConnection
raise AttributeError(
AttributeError: No connection has been defined for this thread or
process
Powered by Cherrypy 2.1.0
------------------------------------------------------ dev.cfg changes
-------------
# for Windows users, sqlite URIs look like:
sqlobject.dburi="sqlite:/C|/devTesting/data/data.db"
--------------------------- controller.py
-------------------------------------------
import turbogears
from turbogears import controllers
import os,sys
from gridnode.testcasedb.testcase import TestCase
from sqlobject import *
from turbogears.database import PackageHub
hub = PackageHub("devtesting")
__connection__ = hub
class Root(controllers.Root):
@turbogears.expose(html="devtesting.templates.welcome")
def index(self):
import time
return dict(now=time.ctime())
@turbogears.expose()
def data(self):
testcase_id="10"
testCase = TestCase.byTest_id(testcase_id)
return testCase.test_name
@turbogears.expose()
def quit(self):
sys.exit(0)
#----------------------------- TestCase -------------------------------
from sqlobject import *
from gridnode.testcasedb.TestPart import TestPart
class TestCase(SQLObject):
class sqlmeta:
lazyUpdate = True
cacheValues = False
seq = StringCol()
area_version = StringCol()
test_id = StringCol(alternateID=True)
test_name = StringCol()
part_name = ForeignKey('TestPart')
pre_script = StringCol()
full_test_name = StringCol()
depends = StringCol()
Try that and report back what happens.
Here is a reference to an earlier thread that described the correct
connection string formats (there are a few):
http://groups.google.com/group/turbogears/browse_thread/thread/d1ffcb...
Thanks,
Sean