[Grok-dev] ModelTraverse on the application
Wichert Akkerman
wichert at wiggy.net
Thu Aug 16 05:07:34 EDT 2007
I'm working on an application which does not use the ZODB but keeps all
data in SQL. It seems that the best way to model that in grok is to use
model classes that map the SQL data and use the standard ModelTraverse
to go over them.
Unfortunately this does not seem to work for the application. I use
this simple test:
import grok
from saturn.status import Status
# Status is a simple grok.Model derived class
class saturn(grok.Application):
def __init__(self):
super(saturn, self).__init__(self)
self.status = Status()
class Index(grok.View):
grok.context(saturn)
For some reason I have to explicitly tell grok what the context for
Index is. That is no big deal though, but this is: as soon as I visit
/status in my application I get this traceback:
2007-08-16T11:04:56 ERROR ZODB.Connection Couldn't load state for 0x03
Traceback (most recent call last):
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Co
nnection.py", line 801, in setstate
self._setstate(obj)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Co
nnection.py", line 860, in _setstate
self._reader.setGhostState(obj, p)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 604, in setGhostState
state = self.getState(pickle)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 597, in getState
return unpickler.load()
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 469, in _persistent_load
return self.load_persistent(*reference)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 513, in load_persistent
self._cache[oid] = obj
TypeError: Cache values must be persistent objects.
------
2007-08-16T11:04:56 ERROR SiteError http://localhost:8080/test
Traceback (most recent call last):
File "/local/buildout/eggs/zope.publisher-3.5.0a1.dev_r78727-py2.4.egg/zope/pu
blisher/publish.py", line 130, in publish
obj = request.traverse(obj)
File "/local/buildout/eggs/zope.publisher-3.5.0a1.dev_r78727-py2.4.egg/zope/pu
blisher/browser.py", line 513, in traverse
ob = super(BrowserRequest, self).traverse(obj)
File "/local/buildout/eggs/zope.publisher-3.5.0a1.dev_r78727-py2.4.egg/zope/pu
blisher/http.py", line 453, in traverse
ob = super(HTTPRequest, self).traverse(obj)
File "/local/buildout/eggs/zope.publisher-3.5.0a1.dev_r78727-py2.4.egg/zope/pu
blisher/base.py", line 263, in traverse
obj = publication.traverseName(self, obj, entry_name)
File "/local/buildout/eggs/grok-0.9dev_r77767-py2.4.egg/grok/publication.py",
line 33, in traverseName
result = super(ZopePublicationSansProxy, self).traverseName(
File "/local/buildout/eggs/zope.app.publication-3.4.0a1_2-py2.4.egg/zope/app/p
ublication/publicationtraverse.py", line 61, in traverseName
ob2 = adapter.publishTraverse(request, nm)
File "/local/buildout/eggs/zope.app.container-3.5.0a1-py2.4-linux-i686.egg/zop
e/app/container/traversal.py", line 72, in publishTraverse
return self.context[name]
File "/local/buildout/eggs/zope.app.folder-3.4.0a1-py2.4.egg/zope/app/folder/f
older.py", line 62, in __getitem__
return self.data[name]
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Co
nnection.py", line 801, in setstate
self._setstate(obj)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/Co
nnection.py", line 860, in _setstate
self._reader.setGhostState(obj, p)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 604, in setGhostState
state = self.getState(pickle)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 597, in getState
return unpickler.load()
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 469, in _persistent_load
return self.load_persistent(*reference)
File "/local/buildout/eggs/ZODB3-3.9.0_dev_r77011-py2.4-linux-i686.egg/ZODB/se
rialize.py", line 513, in load_persistent
self._cache[oid] = obj
TypeError: Cache values must be persistent objects.
that is somewhat unexpected to me. Is my pattern wrong here?
Wichert.
--
Wichert Akkerman <wichert at wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
More information about the Grok-dev
mailing list