[ZPT] Repeat over dict with options
Chris Withers
chris at simplistix.co.uk
Wed Jun 2 04:11:16 EDT 2004
David Pratt wrote:
> from ZTUtils import make_query
>
> query = make_query(results = {'foo':'bar','foo2':'bar2'})
>
> return RESPONSE.redirect('test_results?%s' % query)
that should really be:
return RESPONSE.redirect('test_results?' + query)
> This produces a url http://blah.com/
> test_results?results.foo:record=bar&results.foo2:record=bar2
>
> If am not getting anything using a repeat with options/results.
That's 'cos stuff in the REQUEST doesn't magically get put into options. ZPT
doesn't try and do any magic, which is a very good thing...
> How
> should I construct the zpt to get the values of foo and foo2?
>
> I have been trying iterations of something like this:
>
> <span tal:repeat="value options/results">
<span tal:repeat="value request/form/results">
> I noticed that the request object contains the dictionary I am passing
No it doesn't, it contains a string, which happens to be the same as the string
representation of your dictionary.
> Help much appreciated since I can't seem to get any further with this
> in the meantime.
I'd suggest changing your original python script to be:
return context.test_results(results = {1:{'foo':'bar','foo2':'bar2'},
2:{'foo':'barnone','foo2':'barnone2'}})
...now 'results' will be in options, as you originally expected, AND it'll
contain python types as you're expecting...
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the ZPT
mailing list