[Zope] Acquisition, Not! How?

Dieter Maurer dieter@handshake.de
Thu, 24 Aug 2000 22:26:03 +0200 (CEST)


=?ISO-8859-1?Q?J=FAlio?= Dinis Silva writes:
 > I know this sound strange but is there a way to,
 > during execution of a dtml method, when a with tag is used one
 > force acquisition not to be used?
It is possible -- with an external method.

But probably, you should not do it. It may have strange
side effects. Zope uses acquisition for access validation.
If you cut the acquisition chain, Zope may no longer find
the acl_user necessary to determine the identity of the
current user and its roles. You may get unexplanable
Unauthorized exceptions.

Okay, you may try it yourself:

  the external method:

    def getBase(obj): return getattr(obj,'aq_base',obj)
   
  it returns "obj" with all acquisition context removed.


As indicated above, I would not use it, but instead use
a test function:

    def hasattr_base(obj,attribute):
      base= getBase(obj)
      return hasattr(base,attribute)

I would use this to test in DTML whether a object "O" has
itself at attribute "a" which is not acquired and
raise an exception, if not.



Dieter