[Zope] Acquisition / proxying object

Joerg Baach lists at baach.de
Mon Feb 25 14:45:37 EST 2008


Hi *,

I am trying to have a folderish object that acquires from a user object
(ldapuserfolder). It should have its own properties and contents, but
fall back to the ones of the ldap user.

I have created an object, extending Folder, and it behaves nicely in
zopectl debug. When I try to access it through e.g. a python script  I
get an:

Error Type: Unauthorized
Error Value: Unable to find __roles__ in the container and the container
is not wrapped. Access to 'dn' of test, acquired through (LDAPProxy at
/testfolder/ldapproxy), denied.

I am sure its my lack of understanding of acquisition. I am trying to
bascially put ldap user object 'on top' of the aquisition line (with the
ldapproxy at the bottom), but obviously failing in doing so. Any ideas?

Cheers,

  Joerg



--------8< excerpt from code ---------------

class LDAPProxy(Folder):

    meta_type='LDAPProxy'

    def __init__(self, id, remoteid,title='',REQUEST=None):
        self.id = id
        self.title = title
        self.remoteid = remoteid

    def __of__(self, parent):
        if not hasattr(parent,'aq_base'):
            return self
        folder,id = self.remoteid.split(':')
        acl = parent.restrictedTraverse(folder)
        remote = acl.getUser(id)
        return Folder.__of__(self,parent.__of__(remote))

------- teststructure----------

/testfolder/
           ldapproxy (LDAPProxy)
           acl_users/
           testscript (.py)


--------8< testscript ---------------------
return context.ldapproxy.dn

--------traceback--------------------------
Traceback (most recent call last):
  File "/home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py",
line 113, in publish
    request, bind=1)
  File "/home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/mapply.py",
line 88, in mapply
    if debug is not None: return debug(object,args,context)
  File "/home/joerg/zope/Zope-2.8.5/lib/python/ZPublisher/Publish.py",
line 40, in call_object
    result=apply(object,args) # Type s<cr> to step into published object.
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py",
line 311, in __call__
    return self._bindAndExec(args, kw, None)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/Shared/DC/Scripts/Bindings.py",
line 348, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/Products/PythonScripts/PythonScript.py",
line 323, in _exec
    result = f(*args, **kw)
  File "Script (Python)", line 1, in testscript
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py",
line 727, in guarded_getattr
    aq_acquire(inst, name, aq_validate, validate)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py",
line 669, in aq_validate
    return validate(inst, object, name, v)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py",
line 563, in validate
    self._context)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py",
line 293, in validate
    accessed, container, name, value, context)
  File
"/home/joerg/zope/Zope-2.8.5/lib/python/AccessControl/ImplPython.py",
line 808, in raiseVerbose
    raise Unauthorized(text)
Unauthorized: Unable to find __roles__ in the container and the
container is not wrapped.  Access to 'dn' of test, acquired through
(LDAPProxy at /testfolder/ldapproxy), denied.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://mail.zope.org/pipermail/zope/attachments/20080225/27b959ec/signature.bin


More information about the Zope mailing list