[Zope] Newbie question(s)

Rik Hoekstra rik.hoekstra@inghist.nl
Mon, 13 Nov 2000 10:01:32 +0100


"Bowyer, Alex" wrote:
> 
> Hi,
> 
> I have what I'm sure is a very simple question about Zope programming style:
> I want to count how many objects are contained in the current container
> object and then do something with that value, but I can't do the bit I need
> to do at the point of reading the count variable because I am in the wrong
> namespace.
> I can't begin a dtml-let because I would need to close dtml-if before
> dtml-let, which is not allowed.
> 
> <dtml-in objectValues>
> <dtml-if sequence-end>
> <dtml-var count-id>      <!-- this is the value I want to use -->
> </dtml-if>
> </dtml-in>
> <!-- this is the scope in which I want to do something with the value. -->
> 

try (untested):

<dtml-call expr="REQUEST.set('countids', _.len(objectValues())">
<dtml-in objectValues>
<dtml-if sequence-end>
<dtml-var countids>
</dtml-if>
</dtml-in>
<!-- do something with the value. -->



> What is the "accepted" way of passing a value into a different scope? Do I
> have do a REQUEST.set or is there a tidier way?

<dtml-let>

> Also I think I read somewhere that you can use the object.subobject or
> object.property syntax but I never got that to work, what's the catch?

<dtml-var expr="object.subobject">

note that this is a Python expression and the code between quotes has
Python behaviour.
 

> 
> One last thing, I sent a couple of mails to the list about problems I had
> with manage_delObjects. I still haven't got it to work. Since the best way
> to learn Zope is by example, I wonder if anyone could direct me to a sample
> piece of code where a container of some sort deletes one of its children
> subobjects?
> 
>

try (untested):
<dtml-call "<subobject>.manage_delObjects([id1, id2, ..])">


hth

Rik