[ZODB-Dev] class persistence
Paolo Invernizzi
Paolo Invernizzi <paoloinvernizzi@dmsware.com>
Mon, 26 Aug 2002 10:06:41 +0200
Hello zodb-dev,
I was looking at the class persistence module, and there's a problem...
================================
testClassPrepare.py
--------------------------------
from ZODB.FileStorage import DB
from Persistence.Module import PersistentModuleImporter
from Transaction import get_transaction
db = DB("./prova.fs",create=1)
root = db.open().root()
importer = PersistentModuleImporter(root, verbose=1)
importer.module_from_source("foo", """\
from Persistence.Class import PersistentBaseClass
class Foo(PersistentBaseClass):
def __init__(self):
self.x = id(self)
def m(self):
self.x += 1
return self.x
""")
get_transaction().commit()
================================
testClassExecute.py
--------------------------------
Python 2.3a0 (#29, Aug 14 2002, 17:43:20) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import testClassPrepare
>>>
from ZODB.FileStorage import DB
from Persistence.Module import PersistentModuleImporter
from Transaction import get_transaction
db = DB("./prova.fs",create=0)
root = db.open().root()
importer = PersistentModuleImporter(root, verbose=1)
importer.install()
import foo
obj = foo.Foo()
obj.m()
Python 2.3a0 (#29, Aug 14 2002, 17:43:20) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import testClassExecute
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "testClassExecute.py", line 10, in ?
import foo
File "D:\cvs\python\dist\src\lib\ihooks.py", line 397, in import_module
q, tail = self.find_head_package(parent, name)
File "D:\cvs\python\dist\src\lib\ihooks.py", line 433, in find_head_package
q = self.import_it(head, qname, parent)
File "D:\cvs\python\dist\src\lib\ihooks.py", line 486, in import_it
m = self.loader.load_module(fqname, stuff)
File "D:\cvs\ZODB4\.\Persistence\Module.py", line 69, in load_module
assert stuff.__name__ == name, (stuff, stuff.__name__, name)
File "ZODB\Connection.py", line 247, in setstate
state = self._unpickle_state(p)
File "ZODB\Connection.py", line 191, in _unpickle_state
state = unpickler.load()
File "ZODB\Connection.py", line 144, in _persistent_load
object = klass.__new__(klass)
TypeError: __new__() takes exactly 4 arguments (1 given)
>>>
If I've understood all (I'm quite a zope4 newbie!) the problem is the way class are created from metaclasses...
The right direction is towards a Connection/Cache update or towards a
different approach for class persistence? Please point the to the
right path over walk on, as I'm pretty interested if
class-persistence.
I'll also post an help-for-an-advice cry to the persistence-sig ;)
Tnkz in advance!
--
Best regards,
Paolo mailto:paoloinvernizzi@dmsware.com