[Zope] ZODB Couldn't load state - help please

Dr. Peer Griebel peer@knoll-is.de
Tue, 21 Mar 2000 09:18:24 +0100


Hello Zopers,

I just joined these mailing lists. I have a boring problem I can't
understand. I wrote this little program:

import Persistence
import ZODB
import ZODB.Transaction
import ZODB.FileStorage

class dbclass(Persistence.Persistent):
	def __init__(self):
		self.thedata = 'testdata'

def getdata( request=None ):
	name = 'somename'
	db = ZODB.DB(ZODB.FileStorage.FileStorage('myfile.fs'))
	connection = db.open()
	root = connection.root()
	if not root.has_key( name ):
		print "initialising"
		root[name] = dbclass()
		get_transaction().commit()
	r = root[name].thedata
	connection.close()
	return r


This program works very well if it is started directly using the python
interpreter. But if I call it from Zope using 'Try it' in the management
console it works only one time. The second call of the function results
in:

Zope Error

          Zope has encountered an error while publishing this resource. 

          Error Type: AttributeError
          Error Value: dbclass

Traceback (innermost last):
  File D:\PROGRA~1\uZope\lib\python\ZPublisher\Publish.py, line 214, in
publish_module
  File D:\PROGRA~1\uZope\lib\python\ZPublisher\Publish.py, line 179, in
publish
  File D:\PROGRA~1\uZope\lib\python\Zope\__init__.py, line 202, in
zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File D:\PROGRA~1\uZope\lib\python\ZPublisher\Publish.py, line 165, in
publish
  File D:\PROGRA~1\uZope\lib\python\ZPublisher\mapply.py, line 160, in
mapply
    (Object: korb)
  File D:\PROGRA~1\uZope\lib\python\ZPublisher\Publish.py, line 102, in
call_object
    (Object: korb)
  File
D:\PROGRA~1\uZope\lib\python\Products\ExternalMethod\ExternalMethod.py,
line 248, in __call__
    (Object: korb)
    (Info: ((None,), {}, (None,)))
  File D:\Programme\uZope\Extensions\korb.py, line 15, in getdata
  File D:\PROGRA~1\uZope\lib\python\ZODB\Connection.py, line 396, in
setstate
  File D:\PROGRA~1\uZope\lib\python\ZODB\Connection.py, line 193, in
_persistent_load
    (Info: ('\000\000\000\000\000\000\000\001', ('App.PersistentExtra',
'dbclass')))
  File D:\PROGRA~1\uZope\lib\python\ZODB\Connection.py, line 153, in
__getitem__
    (Info: 


In the debug output I get:

2000-03-21T08:09:14 ERROR(200) ZODB Couldn't load state for
'\000\000\000\000\000\000\000\000'


What am I doing wrong? 
Thank you for your help!

-- 
connection reset by
      Peer

_______________________________________________________________________
Dr. Peer Griebel                                  Tel. +49 7581 4831 23
Geschäftsführer                                   Fax. +49 7581 4831 11
Knoll Informationssysteme GmbH                   http://www.knoll-is.de
Dreiköniggasse 17                               mailto:peer@knoll-is.de
88348 Saulgau                        privat: mailto:peer.griebel@gmx.de