[ZPT] Creating a XML resultset using ZPT?
Casey Duncan
casey@zope.com
Mon, 25 Mar 2002 10:24:49 -0700
From what I gather, each slide might have a different number of
parameters? How is this working using only one table? Do you simply have
a non-normal table with many columns, many of which are usually null? Or
are there just multiple rows per slide?
I'm going to assume the latter. In this case you will need to group on
each distinct slide key value. dtml-in can do this, but AFIAK,
tal:repeat cannot. however, it would be pretty easy to write a python
script which does list grouping. Basically it would just nest lists
together, like so (untested):
rs = container.selectSlides(context.REQUEST)
key = None
result = []
group = []
for rec in rs:
if group and rec.slide_key_field != key:
result.append(group)
group = []
else:
group.append(rec)
key = rec.slide_key_field
if group:
result.append(group)
return result
Then use two nested tal:repeats to generate your xml.
hth,
Casey
Luis Lavena wrote:
> I need to create a XML resultset that will represent a ZSQL method.
> I will contain more than one record, to be used in Flash.
>
> The thing is that the final XML must be similar to this:
>
> <slide>
> <param1>value1</param1>
> <param2>value2</param2>
> </slide>
>
> The thing is that: param1,2 are fields of the ZSQL result, aren't statis
> tags, becasue each slide could change the count of parameters.
>
> Any idea? was looking at tal:replace but din't know who to implement in
> healthy way (without createing a PyScripts).
>
> Thanks
>
> Luis
>
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt
>
>