[Zope] Newbie Q:<dtml-with> and the PARENTS tag

List Subscriptions marc-lists@powersurfr.com
Wed, 11 Jul 2001 22:26:20 -0600


Thanks very much for the suggestion, but Method1 needs to be a 
method; if it's a document, some of the other methods it calls 
fail to function properly.

In addition, though what you say makes sense to me, it doesn't 
seem to work that way in practice.  I placed the code in DTML 
Doc and observed the same behavior:  PropertyX (actually, 
another DTML Doc) was picked up from higher up in the hierarchy, 
even with the 'only' parameter.  Also, as I noted, <dtml-var 
"PARENTS[0].id"> DOES pick up the proper container (perhaps b/c 
I already have other items in the folder, perhaps, but it does 
show that it's working with the right object).

If you (or anyone else on the list) has more suggestions, I'm 
all ears.  Again, I don't really care how it's done, I just want 
the basic logic to work.  Are there any other acquisition 
keywords I could use?

Marc

On Wednesday, July 11, 2001, at 10:03  PM, Ausum wrote:

> The reason is that  FolderC isn't a container, unless it has an
>  object within it. Methods doesn't count for that.
> If you want your code to work make Method1 a DTML document.
>
>
>
> Ausum
>
>
>
> List Subscriptions wrote:
>>
>> Although I've searched all the How-Tos and Tips, I'm probably
>> just missing something...
>>
>> I have a setup as follows:
>>
>> Root
>>       FolderA
>>            PropertyX
>>            FolderB
>>                   PropertyX
>>                   Method1
>>            FolderC
>>                    Method1
>>
>> What I want to do is: for Method1, check the enclosing item for
>> Property X.  PropertyX could be either a property or a DTML
>> Document (I realize these may be two separate cases).  If
>> PropertyX exists in/as a property of the Folderthat the Method
>> is in, I want to execute some code; if it doesn't, then I don't
>> want anything to happen.
>>
>> Here's what I started with:
>>
>> <dtml-with "PARENTS[0]" only>
>>      <dtml-if PropertyX>
>>       <dtml-var PropertyX>
>>       .....do some stuff...
>>     </dtml-if>
>> </dtml-with>
>>
>> This doesn't work.  Using the schema outlined above, both
>> FolderB/Method1 and FolderC/Method1 return a PropertyX, but in
>> the latter case it's the PropertyX from FolderA (of course....).
>>
>> So, does the 'only' option only restrict acquisition downward?
>> Or what?  This just doesn't jibe with how the docs describe the
>> only option -- maybe there's something up with my Zope?
>>
>> Most importantly, how can I do what I need to do?
>>
>> I've tried plugging all kinds of expressions into the with tag,
>> such as aq_explicit and aq_parent, but I'm not very familiar
>> with Python and am probably doing it wrong.  Really, I don't
>> care how I solve this, so long as I do!  I've tried about a ton
>> of things and I can't get around Zope continuing to acquire
>> upward irregardless of the 'only' modifier.
>>
>> When I tried it with <dtml-with PARENTS only> (no [0]), the if
>> test fails in all cases.  Yet in all of these cases, <dtml-var
>> "PARENTS[0].id"> returns the id of the proper folder (FolderB,
>> for example), so I know that PARENTS[0] is the place I want to
>> look.
>>
>> Help!!!!  (c.c. me via regular e-mail as well, if possible - I'm
>> on the Digest version and would love to get answer as soon as
>> someone gives me one!)
>>
>> Marc
>> marc@mail.su.ualberta.ca
>>
>> _______________________________________________
>> 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 )
>