[ZODB-Dev] Accessing Plone through ZEO back door?

Kirby Urner kirby at 4dsolutions.net
Sat Aug 21 21:38:43 EDT 2004


Christian Robottom Reis wrote:

>
>This isn't all ZEO-specific. You need to have local access to the
>modules. Install them wherever you're opening the ZODB and you'll see
>that indeed it works quite well.
>
>  
>
>>PS:  I thought I might solve the whole issue by putting a path to my 
>>zope instance (/var/zope) in PYTHONPATH, but that didn't help.
>>    
>>
>
>That sounds odd. It *should* work -- 
>
>  
>
>>ImportError: No module named CMFPlone.Portal
>>    
>>
>
>was this module importable via the python interactive interpreter? If
>not, it should!
>  
>
Thanks for the encouragment.

I think the problem is modules like CMFPlone in /var/zope/Products
(the zope instance) are not included in a Products package. There's
no __init__.py, like there is in /opt/Zope2.7/lib/python/Products.

I can set the PYTHONPATH so that CMFPlone is directly importable,
but the code in CMFPlone.Portal is looking for Products.CMFPlone:

[urnerk at localhost urnerk]$ echo $PYTHONPATH
/var/zope:/opt/Zope-2.7/lib/python

Python 2.3.4 (#1, Aug 4 2004, 14:41:39)
[GCC 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import CMFPlone
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named CMFPlone
 >>> import ZODB # no problem, in /opt/Zope2.7/lib/python/Products
 >>> import sys
 >>> sys.path.append('/var/zope/Products') # location of CMFPlone
 >>> import CMFPlone
 >>> import CMFPlone.Portal # needs to see Products.CMFPlone
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/var/zope/Products/CMFPlone/Portal.py", line 5, in ?
from Products.CMFPlone import cmfplone_globals
ImportError: No module named CMFPlone

I am able to make some progress if I create a softlink in 
/opt/Zope2.7../Products
to the CMFPlone directory in /var/zope/Products:

 >>> import Products.CMFPlone.Portal # softlink already made, new error
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/var/zope/Products/CMFPlone/Portal.py", line 7, in ?
from Products.CMFPlone import PloneFolder
File "/var/zope/Products/CMFPlone/PloneFolder.py", line 3, in ?
from Products.CMFCore.utils import _verifyActionPermissions, \
ImportError: No module named CMFCore.utils

OK, so I need a softlink to CMFCore as well (another subdirectory in
/var/zope/Products).

 >>> import Products.CMFPlone.Portal # OK, now it works

So now I go ahead and open a ZEO connection, and I get a different error
message.

It could be that this error would be resolved if I made a softlink to 
*every*
subdirectory in the Zope instance (there are about 20 of them), but is this
really the way to go? Plone aside, it seems that this setup of having some
products in the instance subdirectory is typical.

Or perhaps the traceback below makes it clear to someone more expert than
I that I have a different problem.

Before struggling with all this further, I thought I'd lay it out, in 
case anyone
sees the wall I'm hitting my head against.

 >>> from ZODB import DB
 >>> from ZEO import ClientStorage
 >>> storage = ClientStorage.ClientStorage(('localhost',8100))
 >>> root = DB(storage).open().root()
 >>> app = root['Application']
 >>> app.reset()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/opt/Zope-2.7/lib/python/ZODB/Connection.py", line 562, in setstate
self._set_ghost_state(obj, p)
File "/opt/Zope-2.7/lib/python/ZODB/Connection.py", line 601, in 
_set_ghost_state
state = unpickler.load()
File "/opt/Zope-2.7/lib/python/ZODB/Connection.py", line 198, in 
_persistent_load
return self[oid]
File "/opt/Zope-2.7/lib/python/ZODB/Connection.py", line 160, in __getitem__
klass=self._db._classFactory(self, module, name)
File "/opt/Zope-2.7/lib/python/ZODB/DB.py", line 128, in _classFactory
name)
AttributeError: 'module' object has no attribute 'PloneSite'

Kirby




More information about the ZODB-Dev mailing list