Question on Placement of SQLObject classes (It works now, why????)

0 views
Skip to first unread message

Michael Schneider

unread,
Nov 22, 2005, 6:05:00 PM11/22/05
to TurboGears
Hello All,

I seem to have discovered that the SQLObect derived class must appear
in the model.py file


------------------------- This works
------------------------------------------------

from sqlobject import *
from turbogears.database import PackageHub

hub = PackageHub("devtesting")
__connection__ = hub

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')
part_name = StringCol()
pre_script = StringCol()
full_test_name = StringCol()
depends = StringCol()
-----------------------------------------------------------------------------------------------


When I break out TestCase into TestCase.py, and import TestCase, I get
a connection
error.

I think this has to do with the fact that my SQLObjects use the default
connection, but I am not sure.

Any insight would be apprieciated.

Thanks
Mike

------ This fails -----------------------------------
from sqlobject import *
from turbogears.database import PackageHub

hub = PackageHub("devtesting")
__connection__ = hub

from gridnode.testcasedb.testcase import TestCase

------------------------------------- Error in
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_r241-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

Michael Schneider

unread,
Nov 25, 2005, 8:24:17 AM11/25/05
to TurboGears
I went throught the Tickets for 0.9 and found that Ticket #77 was the
root cause.

I like to seperate the class defintions from the connection
information.

I would like to use model.py to assemble the data objects

create connection + import classes that will be in the connection.

Thanks
Mike

Reply all
Reply to author
Forward
0 new messages