[Zope] Re: How to pass arbitrary objects to a ZPT from Script(Python)

Martin Diers martin at diers.us
Sun Nov 9 17:25:04 EST 2003


Ok. Time to eat crow here.

The problem was a de-referencing problem. Here is the proper way to de-reference the result-set so
that I have a single record in a variable:

<span tal:define="global result python:options['results'][0]" tal:omit-tag=""/>

In other words, by passing a result set with a single record via the options dictionary, I had to
unwrap a dictionary contained in a list contained in a dictionary.

Does anyone know why it is not possible to reference a list element by number, using a simple TAL
path statement? It would sure be nice to write a statement like this:

<span tal-define="result options/records/0 | nothing"/>

In this case, if there were no records value, the statement would default to nothing. Otherwise,
result would receive the first element of the list stored in records.


Martin Diers
Future zope guru.
Now if I can only figure out this browser thingy.

> That doesn't half complicate what is a really simple thing.
>
> # script python
>
> context.aaa(a=1,b=2)
>
> # zpt
>
> <span tal:replace="options/a"/>
> <span tal:replace="options/b"/>




More information about the Zope mailing list