How to trigger Zope externally (mail)
I am working on a poll/survey type product and want to handle responses by email as well as the web. If you have any advice about the best architecture, I would appreciate it. I'm currently using Zope 2.5 on Linux, though it would be nice if the solution weren't too platform dependent. Here are some options I have thought of. 1. Incoming mail goes to a pipe, which is a program that processes the message. I think the main drawback of this approach is that I would need to run Zope on top of ZEO so that multiple processes could access the database safely. I'm also not sure how hard it would be to reestablish the context of my product outside of regular Zope. Aside from these concerns, this seems the most natural approach. 2. Incoming mail goes to mbox; via the regular zope web interface I periodically point to the mbox and request that it be processed. Ugly, but relatively simple. Some locking and concurrency issues. Likely to result in much slower response to mail. Also, there could be some problems distinguishing message boundaries; in practice, probably not a problem. 3. Incoming mail goes to temp file or temp named pipe*. The running zope is tickled via http: with the name of the file/pipe, and processes it from there. *By "temp named pipe" I mean each mail would need a unique pipe name. I think if I try to use a single named pipe I may have trouble if multiple emails go down it around the same time. 4. Deliver the email to the running zope via some other protocol, e.g., ftp. I'm not sure how to set this up. ------------------------------ I welcome comments on these approaches, or others that are even better! Also, I would like the approach to be reasonably secure. Thanks.
On February 26, Ross Boylan wrote:
1. Incoming mail goes to a pipe, which is a program that processes the message.
Use curl or another HTTP client to POST the message to a Zope script. This seems to be the "idiomatic" way, because authentication occurs at the request level in the publisher.
zope is tickled via http: with the name of the file/pipe, and processes it from there.
Don't bother with named pipes; just pass the data with a POST. HTH, a. -- Adrian van den Dries adriand@flow.com.au Development team www.dev.flow.com.au FLOW Communications Pty. Ltd. www.flow.com.au
On Wed, 2003-02-26 at 16:16, Ross Boylan wrote:
1. Incoming mail goes to a pipe, which is a program that processes the message.
I think the main drawback of this approach is that I would need to run Zope on top of ZEO so that multiple processes could access the database safely. I'm also not sure how hard it would be to reestablish the context of my product outside of regular Zope.
Aside from these concerns, this seems the most natural approach.
Instead of writing to the ZODB directly, I would post the message to a form hosted by your Zope server using the ZPublisher.Client. Jeff
On 02/26/2003 07:16 PM, Ross Boylan wrote:
I am working on a poll/survey type product and want to handle responses by email as well as the web. If you have any advice about the best architecture, I would appreciate it. I'm currently using Zope 2.5 on Linux, though it would be nice if the solution weren't too platform dependent.
My favorite solution is to run a short-lived ZEO client for each incoming email. You just set the PYTHONPATH environment variable to point to <zope>/lib/python (and INSTANCE_HOME if you need it), then in your Python script you "import Zope; app = Zope.app()". "app" now has unrestricted access to the whole database. When you're done, get_transaction().commit() and exit the process. From what I've seen, the ZEO connection setup overhead is usually less than one second. Shane
Or just write a simple HTTP post using Python. Have a look around for the MailIn Product, or CMFMailIn which does this very simply and works fine for low volume traffic (eg: fine listening to zope@zope.org). -- Andy McKay
Andy McKay wrote:
Or just write a simple HTTP post using Python. Have a look around for the MailIn Product, or CMFMailIn which does this very simply and works fine for low volume traffic (eg: fine listening to zope@zope.org).
Here's a very simple example that we're using to glue cron to Zope. It does a GET, but you could just as easily make it do a POST. I can't remember where I cribbed from ;] -- Jean Jordaan http://www.upfrontsystems.co.za #!/usr/bin/python username="user" password="secret" # this is only example, of course zope="http://localhost:17081" import sys, urllib class NoGUI_URLopener(urllib.FancyURLopener): def __init__(self, username, password, *args): apply(urllib.FancyURLopener.__init__, (self,) + args) self.username = username self.password = password self.asked = 0 def prompt_user_passwd(self, host, realm): if self.asked: raise "Unauthorised" else: self.asked = 1 return self.username, self.password urllib._urlopener = NoGUI_URLopener(username, password) urllib.urlretrieve("%s/cron_hook" % zope )
I can't remember where I cribbed from ;]
Remembered: http://www.zope.org/Members/phd/cron-zope/pack-db_fs/view -- Jean Jordaan http://www.upfrontsystems.co.za
On Wed, Feb 26, 2003 at 05:37:17PM -0800, Andy McKay wrote:
Or just write a simple HTTP post using Python. Have a look around for the MailIn Product, or CMFMailIn which does this very simply and works fine for low volume traffic (eg: fine listening to zope@zope.org).
Thanks. I borrowed from CMFMailIn; I couldn't find the MailIn product.
Ross Boylan wrote:
On Wed, Feb 26, 2003 at 05:37:17PM -0800, Andy McKay wrote:
Or just write a simple HTTP post using Python. Have a look around for the MailIn Product, or CMFMailIn which does this very simply and works fine for low volume traffic (eg: fine listening to zope@zope.org).
Thanks. I borrowed from CMFMailIn; I couldn't find the MailIn product.
http://www.zope.org/Members/NIP/ZMailIn/ cheers, Chris
participants (7)
-
Adrian van den Dries -
Andy McKay -
Chris Withers -
Jean Jordaan -
Jeff Youel -
Ross Boylan -
Shane Hathaway