[ZODB-Dev] ZODB.config and py2exe
Michael Bernstein
webmaven at cox.net
Mon Jun 21 19:55:20 EDT 2004
Hi Folks,
I realize that this is a bit off-topic for this list, but there doesn't
seem to be a more-appropriate list, and I figure you might be interested
in this rather strange bug.
To cut a long story short, I have a simple ZODB-based CLI app that I was
trying to package up with py2exe for distribution. The app itself is
hardly more than a vehicle for me to experiment with various things, so
I'll spare you the specifics.
Suffice it to say that use of ZODB.config causes the .exe to crash on
startup.
My environment is Python 2.3.4 on Windows 2000, ZODB 3.2, and py2exe 0.5.
Here is the relevant python code:
==============================
import ZODB.config
db = ZODB.config.databaseFromURL('bookdb.conf')
conn = db.open()
dbroot = conn.root()
==============================
And the traceback:
Traceback (most recent call last):
File "bookcap.py", line 20, in ?
File "ZODB\config.pyc", line 51, in databaseFromURL
File "ZODB\config.pyc", line 34, in getDbSchema
File "ZConfig\loader.pyc", line 36, in loadSchema
File "ZConfig\loader.pyc", line 68, in loadURL
File "ZConfig\loader.pyc", line 100, in openResource
ZConfig.ConfigurationError: error opening resource C:\Documents and
Settings\Michael
Bernstein\Desktop\BookCapCLI\dist\library.zip\ZODB\config.xml: <urlopen
error unknown url type: c>
Examining the created library.zip file finds that the config.xml file
from the ZODB package was not included.
I tried to find a py2exe option to force the inclusion of the file, but
AFAICT you can only specify modules or packages for inclusion in
library.zip, not arbitrary files within packages.
In the end, the fix for me was fairly simple, I just avoided using a
bookdb.conf config file, and hard coded the ZODB setup:
==============================
from ZODB import FileStorage, DB
storage = FileStorage.FileStorage('bookcap.fs')
db = DB(storage)
conn = db.open()
dbroot = conn.root()
==============================
...which works perfectly well in both the original and .exe versions of
the app.
This is hardly a major inconvenience for a small app such as mine, but
as I grow it, not having the ability to use declarative configuration
files could become annoying, and so I thought I would mention it here in
case this interaction between py2exe and ZODB is not a known issue.
Cheers,
--
- Michael R. Bernstein | Author of Zope Bible
michaelbernstein.com | & Zope.org Webmaster
panhedron.com | PythonPhotos.org
More information about the ZODB-Dev
mailing list