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

Gilles Lenfant glenfant@bigfoot.com
Thu, 31 May 2001 22:23:56 +0200


I'm in process to make a multilingual site using Zope.
My design is based on setting a cookie "favoritelanguage" to "en"/"fr"/"es"
(...) depending on the user preference chosen in the home page.
The python script "intlobject(anobject)" is used in a main DTML
document/method as <dtml-var "intlobject('subobject')">.
This renders the object of en/subobject, fr/subobject (depending on the
"favoritelanguage" cookie) in the main document.
But the so included object uses the acquisition path of the FOLDER that
contains the "main" object rather than the acquisition path of the "main"
object itself.
I need it to act just as an "#include " in C.

Thanks !

--Gilles

----- Original Message -----
From: "Casey Duncan" <cduncan@kaivo.com>
To: "Gilles Lenfant" <glenfant@bigfoot.com>
Cc: <zope@zope.org>
Sent: Thursday, May 31, 2001 9:18 PM
Subject: Re: [Zope] How to give caller acquisition path to an object through
python script ?


> 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
> `------------------>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>