[Zope] 'IN' Atribute within as a python script parameter

Tino Wildenhain tino@wildenhain.de
Mon, 13 Aug 2001 23:47:50 +0200


Hi Alexandre,

--On Montag, 13. August 2001 17:29 -0300 Alexandre Aguiar <ale@thecook.org> wrote:

> Im having some trouble trying to pass a atribute to a python script:
>
> <dtml-in objectValues>
> <dtml-var "pythonScript(sequence-length)"> -- I dont know how I can make it
> understand the 'sequence-item'  as a parameter
> </dtml-in>

Both sequence-item and sequence-length have hypenations in the name which
becomes in a python expression a subtraction.
You either have to use _['sequence-item'] ( I think your sequence-length is
a typo) or <dtml-let si=sequence-item> <dtml-var "pythonScript(si)"></dtml-with>

But I dont think this is a good idea anyway. If you use pythonscripts, you dont
need to do the loop in DTML. Just put it all in the pythonscript:

for item in context.objectValues():
    do something with the values


If you really want only the length, you would use

len(context.objectIds())

Not that objectIds is faster and saves memory if you only want to
count the objects.

Regards
Tino

> Thanks one more time for the help!
>
> Alexandre Aguiar
>
>
> _______________________________________________
> 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 )