How to create a file and send it by e-mail ?
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. * I think ZOPE doe's not allow python to create files for security reasons. Can I change this security policy or it will make my application unsafe? Is there another way to create a file using ZOPE API calls ? * 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.) thanks for your time.. * *
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 :-)
* 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 ;-) http://www.simplistix.co.uk/software/zope/mailtemplates cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Nicolas Georgakopoulos schrieb:
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.
While I wonder how do you create a file in python using file?
* I think ZOPE doe's not allow python to create files for security reasons. Can I change this security policy or it will make my application unsafe? Is there another way to create a file using ZOPE API calls ?
You dont need a real (filesystem-) file if all you want is sending it over the net. Usually you just build a string - for example in python scripts via print/return printed or as a list which you join.
* 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.)
This is a bit more difficult, there are examples to send mails with attachments per DTML, but if you want to avoid you either open the python email package for python scripts or use ChrisWs product (but I did not have the time to test it - so try it :-) Regards Tino
Tino Wildenhain wrote:
This is a bit more difficult,
Not anymore it's not!
there are examples to send mails with attachments per DTML,
yuckety yuk yuk...
but if you want to avoid you either open the python email package
...which MailTemplates lets you use in python scripts :-D
for python scripts or use ChrisWs product (but I did not have the time to test it - so try it :-)
Heh, well, it's been built to solve this exact problem, amoung others... ...if you're building email in Zope, you should be using MailTemplates! </cheesy-advert> cheers, Chris - it solves world hunger, doncha know ;-) -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
Nicolas Georgakopoulos -
Tino Wildenhain