[Zope3-Users] How to best include Zope3-based code in Zope3
unrelated Python projects?
Hermann Himmelbauer
dusty at qwer.tk
Fri Sep 21 05:09:20 EDT 2007
Hi,
I have the problem that I cannot include parts of my Zope3 project in
external, Zope3-unrelated projects due to import errors.
For instance, I currently build a LaTeX converter that automatically converts
SQL-Alchemy table definitions into nicely formatted LaTeX that I can then
include in my project documentation.
This converter has to import my table definitions file, which however fails,
as on the top of the file there are Zope3-specific imports and directives,
e.g.:
from zope.interface import implements
import z3c.zalchemy
metadata = z3c.zalchemy.metadata()
My Python interpreter does not know anything about zope yet, as it's not in
the PYTHONPATH, therefore the import of zope.interface fails. I assume, I
should somehow put the Zope3 modules into the PYTHONPATH - but how would you
recommend that? Should I perhaps link it from python/lib/site-packages? Or
should I include the Zope3 top-level directory into PYTHONPATH?
Moreover, what's even more complicated is the import of z3c.zalchemy, how
should I solve that one? I thought about a construct like this:
if ???started via debugzope / zopectl???:
import z3c.zalchemy
metadata = MetaData()
else:
from sqlalchemy import MetaData
metadata = MetaData()
But I don't know how to fomulate the if-clause above. Perhaps there's a better
solution to this problem?
Best Regards,
Hermann
--
x1 at aon.at
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7
More information about the Zope3-users
mailing list