[Zope] Using page templates to generate large XML files

Andreas Jung lists at zopyx.com
Sat Sep 6 04:49:59 EDT 2008



--On 6. September 2008 09:15:37 +0200 Marco Bizzarri 
<marco.bizzarri at gmail.com> wrote:

> On Sat, Sep 6, 2008 at 8:36 AM, Andreas Jung <lists at zopyx.com> wrote:
>>
>>
>> --On 6. September 2008 08:26:17 +0200 Marco Bizzarri
>> <marco.bizzarri at gmail.com> wrote:
>>
>>> Hi all.
>>>
>>> I need to generate a large XML file inside a Zope application; the
>>> file is for backup purposes, so it is stored on the server and can be
>>> downloaded later with whatever suitable tool.
>>>
>>> The data are taken from a database, and then they are used to create
>>> the XML. I assume there will be between 40.000 and 100.000 rows to be
>>> dumped.
>>>
>>> I thought i could use page template for this purpose, but I'm not sure
>>> if it is possible to send the output from a pt to a file, directly. Of
>>> course, this is a problem which can be easily solved.
>>
>> If you're using Zope 2.10 or higher, you can either use the "native"  ZPT
>> implementation from Zope 3 (see zope.pagetemplate module) or you use the
>> Zope 2 implementation (which is basically only a wrapper around the Z3
>> implementation). In this case you might look at the unittests in
>> testZopePageTemplates.py or otherwise you check the doctests of
>> zope.pagetemplate.
>>
>> -aj
>
> Thanks, Andreas. I'm using Zope 2.8, here (yes, I know it is old
> software; yes, I know, I should switch; yes, I will do soon, I promise
> :-) ))

In Zope 2.8 you could use the ZopePageTemplate class. Something like


pt = ZopePageTemplate()
pt.pt_edit(zpt_source_code)
xml = pt.pt_render(...)

should work. The unit tests (or the code) should show you how to specify 
text/xml as mime-type and how to pass the options/parameters to the 
template.

-aj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope/attachments/20080906/7e523715/attachment.bin 


More information about the Zope mailing list