[Zope] How to give caller acquisition path to an object through python script ?

Casey Duncan cduncan@kaivo.com
Thu, 31 May 2001 13:18:14 -0600


Gilles Lenfant wrote:
> 
> Hi,
> 
> Sorry for the previous post. It was obscure. So I'm rewording it.
> 
> I's not possible to expose my problem with a simple phrase. So I'll write
> down an example:
> 
> I got a "main" DTML method that contains:
> 
> -- DTML method "main" --
> ...
> <dtml-var "getobject(somearg)">
> ...
> ---------------------------
> 
> "getobject" is a python script that finds a Zope object (DTML method or
> document) depending on "somearg".
> 
> -- Python script "getobject" --
> # find someobject depending on "somearg"
> ...
> return someobject(context)
> -----------------------------
> 
> The problem is that "someobject" renders using the acquisition path of the
> FOLDER that contains "main"
> I want the "someobject" to use the acquisition path of the "main" DTML
> object rather than the one of it's folder.
> 

DTML methods do this, DTML documents do not. Think "Containment before
context" as a mantra. The only way to make a DTML Document act like it
is contained in a different container would be to use an external method
like so that rewrapped the document:

def rewrap(DTMLdoc, folder):
	"""Returns a document in the context of another folder"""
	return DTMLdoc.aq_base.__of__(folder)

I am not sure I would recommend this approach, however, as it goes
against the original DTML document design. What exactly are you trying
to do? I suspect an aspect of your design could be changed to alleviate
this.

> Any clue ?
> 
> TIA
> 
> --Gilles
> 

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>