[ZODB-Dev] Maybe stupid question...
Paolo Invernizzi
paoloinvernizzi@dmsware.com
Thu, 13 Mar 2003 18:41:41 +0100
I'm playing with ZODB4 persistent code...
I've 2 script in that paths...
/devel/app_server/create_storage.py
/devel/app_server/code/ui_wx/wxColoredChoice.py
----- wxColoredChoice.py
from wxPython.wx import wxChoice
class wxColoredChoice(wxChoice):
<code snip...>
-------------------------
----- vnc_new_storage.py - very pedantic from test suite... but I'm a little
disperate ;)
from transaction import get_transaction
import zodb.db
from zodb.storage.file import FileStorage
from zodb.code.module import ManagedRegistry, PersistentModuleImporter
class TestPersistentModuleImporter(PersistentModuleImporter):
def __init__(self, registry):
self._registry = registry
self._registry._p_activate()
def __import__(self, name, globals={}, locals={}, fromlist=[]):
mod = self._import(self._registry, name, self._get_parent(globals),
fromlist)
if mod is not None:
return mod
return self._saved_import(name, globals, locals, fromlist)
db = zodb.db.DB(FileStorage("./vnc_tester.fs",create=True))
root = db.open().root()
registry = ManagedRegistry()
importer = TestPersistentModuleImporter(registry)
importer.install()
root["registry"] = registry
get_transaction().commit()
registry.newModule("ui_wx.wxVncVisualModule",
open("./code/ui_wx/wxColoredChoice.py").read())
get_transaction().commit()
assert registry.findModule("ui_wx.wxColoredChoice")
import ui_wx.wxVncVisualModule
self.importer.uninstall()
db.close()
-----------------------------------------------------
C:\devel\app_server\python vnc_new_storage.py
Traceback (most recent call last):
File "C:\Projects\vnc\Versione
Ultima\Sorgenti\vnc_server\vnc_new_storage.py", line 37, in ?
registry.newModule("ui_wx.wxVncVisualModule",
open("./code/ui_wx/wxColoredChoice.py").read())
File "C:\program files\python23\Lib\site-packages\zodb\code\module.py",
line 330, in newModule
mgr.new(name, source)
File "C:\program files\python23\Lib\site-packages\zodb\code\module.py",
line 136, in new
self.update(source)
File "C:\program files\python23\Lib\site-packages\zodb\code\module.py",
line 156, in update
convert(self._module, replacements)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 435, in
convert
p.dump(moddict)
File "c:\progra~1\python23\lib\pickle.py", line 231, in dump
self.save(obj)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 353, in
save
f(self, obj)
File "c:\progra~1\python23\lib\pickle.py", line 663, in save_dict
self._batch_setitems(obj.iteritems())
File "c:\progra~1\python23\lib\pickle.py", line 695, in _batch_setitems
save(v)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 353, in
save
f(self, obj)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 226, in
save_type
(atype.__bases__, atype.__dict__))
File "c:\progra~1\python23\lib\pickle.py", line 415, in save_reduce
save(args)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 353, in
save
f(self, obj)
File "c:\progra~1\python23\lib\pickle.py", line 576, in save_tuple
save(element)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 353, in
save
f(self, obj)
File "c:\progra~1\python23\lib\pickle.py", line 576, in save_tuple
save(element)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 353, in
save
f(self, obj)
File "D:\libs\ZODB4\build\lib.win32-2.3\zodb\code\patch.py", line 234, in
save_type
self.save_global(atype)
File "c:\progra~1\python23\lib\pickle.py", line 760, in save_global
raise PicklingError(
pickle.PicklingError: Can't pickle <class ui_wx.wxPython.controls.wxChoice
at 0x014F4CF0>: it's not found as ui_wx.wxPython.controls.wxChoice
first) I've switched from cPickle to pickle for better trace in others
problems...
second) wxPython.wx is installed correctly... It's importable from a plain
interpreter...
Why is 'ui_wx' package appended to wxPython.controls.wxChoice? Perhaps I'm
too tired....
python 2.3a2, ZODB4 CVS.
Thanks in Advance!
Paolo Invernizzi
Post Scriptum...
I forgot to mention for the windows XP file-lock problem that ZODB4 was
compiled with VC7 and it's running against plain 2.3a2 (VC6!)
Probably file.handle is not transferable between the 2 C lib... must build a
VC7 python version and try! ;(