How to give caller acquisition path to an object through python script ?
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. Any clue ? TIA --Gilles
The short answer is that you want to use the <dtml-with expr="expression"> tag. The long explanation can be found in the two urls below. http://www.zope.org/Documentation/How-To/AdvancedDTML http://www.zope.org/Members/Hoekstra/ChangingZopeContexts Eric Balasbas Senior Developer eric@virtosi.com http://www.virtosi.com/ Virtosi Ltd. Design -- Branding -- Zope On Thu, 31 May 2001, 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.
Any clue ?
TIA
--Gilles
_______________________________________________ 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 )
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 `------------------>
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 )
Gilles Lenfant wrote:
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')">.
Which is it? A DTML Document won't do what you want.
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.
How does the Python script call the subobject? What arguments do you pass it?
Thanks !
--Gilles
-- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
On Thu, 31 May 2001, Casey Duncan wrote:
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.
And it may also open a security hole by giving DTML programers the ability to wrap an object in a more permissive context, but I'm not sure, that just came to my mind. I wouldn't recommend it either. ;) -Michel
participants (4)
-
Casey Duncan -
Eric Balasbas -
Gilles Lenfant -
Michel Pelletier