(please keep the list CC'ed in)

Nicolas Georgakopoulos wrote:
Chris Withers wrote:

Nicolas Georgakopoulos wrote:

Hello all, I'm developing using ZPT and I need to create a file (CSV format) but I'm having some problems:

* 1. *I only know how to create files with python but I get an
*    Error Type: NameError*
*    Error Value: global name 'file' is not defined.

Indeed, just build your csv as a string :-)

Yes I will build my csv as string but how can I save it as a file ?

Why do you think you need to?

Is the csv data dynamically generated?

If you need to store it, create a Zope File Object in the python script that processes submission from your ZPT.

* 2.*When I create my file how can I send it as an attachment by mail ? (I already have setup my mail host object and I can send mail's successfully.)

I just wrote a product specifically for this ;-)


Thanks, I'm looking to it rigth now.

You'll want to build your own MIMEBase object and attach it to the result of rendering your Mail Template if you build your csv in a string.

If you end up with a Zope File object or a ZPublisher FileUpload object, then you can just do:

msg = context.my_mail_template.as_message(
         # insert your params here


There's plenty of examples in the readme.txt file, or in the tests folder...



Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to