1) Is there a cron-like tool in Zope? Or a way to have cron run a process in Zope? 2) Under Linux/Sendmail, can I have the above Zope process "receive" mail sent to a particular address? (Note that my ignorance of how mail works could fill volumes). Thanks... Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
On Wed, 16 May 2001, Bruce Eckel wrote:
1) Is there a cron-like tool in Zope? Or a way to have cron run a process in Zope?
Xron. Or external process(es) that touch Zope by HTTP or XML-RPC. Example: http://www.zope.org/Members/phd/cron-zope/
2) Under Linux/Sendmail, can I have the above Zope process "receive" mail sent to a particular address? (Note that my ignorance of how mail works could fill volumes).
ZMailIn (+ perhaps sendmail config, procmail etc) Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
1) Is there a cron-like tool in Zope? Or a way to have cron run a process in Zope?
Zope is completely event-driven, so there's no scheduler built in to it. There's a product named Xron which provides cron-like functionality within Zope (I've not used it). You can also use a Python script (a real one, on disk, having nothing to do with Zope) that calls a Zope method via HTTP or XML-RPC. Attached is a module named XMLRPCBasicAuth.py, which you can use like this:
import XMLRPCBasicAuth s = XMLRPCBasicAuth.Server('http://www.zope.org','chrism', 'mypassword') s.Members.chrism.manage_addDocument('foo', 'bar', 'some text')
Note that the library named "xmlrpclib" needs to be somewhere in your PYTHONPATH (read the source of the XMLRPCBasicAuth.py file to see how to put it in). Also, you'll likely see things like "ProtocolErrors" and HTML being returned from XMLRPC method calls. You'll need to experiment with what you want to to (e.g. use the XMLRPCBasicAuth module to call methods from a Python prompt, and then take a look at the running Zope via the Zope web mgmt interface after you've made a call to see if the call has succeeded, and its results), but for the most part, you can just call methods on Zope objects like you would if you were at a Python prompt, the two notable exceptions being: 1. You can't pass keyword arguments. 2. XMLRPC can only marshal certain types, and object instances aren't one of them. Combining a Python program that uses XMLRPC with UNIX cron (or WinNT Scheduler service) allows you to kick off events at scheduled times.
2) Under Linux/Sendmail, can I have the above Zope process "receive" mail sent to a particular address? (Note that my ignorance of how mail works could fill volumes).
Not really. If you can expland on what you'd like to accomplish by doing this, maybe I can help a little better. - C
Not really. If you can expland on what you'd like to accomplish by doing this, maybe I can help a little better.
What I want to do is take the confirmation email that PayPal sends and automatically respond to it by emailing the product to the customer (trying to do "the simplest thing that could possibly work" here). Another alternative is of course to do it completely outside of Zope, and drive the script with cron. That might be easiest if (1) I knew how to "read" mail to a particular address inside of Python (it looks like the 'mailbox' module does this, but it only reads from one mailbox. Thus, to work, it would seem that address must be sent to a particular mailbox, which I would guess is possible but requires sendmail(?) configuration). (2) I could figure out how to send attachments with Python-generated mail. I know there are libraries, but any docs on this seem to go on and on, and have all kinds of options and alternatives -- it's so simple in Zope. But in python, it appears I would use MimeWriter. I've found two examples of this, both of which write to sys.stdout, which is confusing -- how do you actually email such a thing? Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
On Wed, May 16, 2001 at 07:48:46AM -0700, Bruce Eckel wrote:
Not really. If you can expland on what you'd like to accomplish by doing this, maybe I can help a little better.
What I want to do is take the confirmation email that PayPal sends and automatically respond to it by emailing the product to the customer (trying to do "the simplest thing that could possibly work" here).
Another alternative is of course to do it completely outside of Zope, and drive the script with cron. That might be easiest if
(1) I knew how to "read" mail to a particular address inside of Python (it looks like the 'mailbox' module does this, but it only reads from one mailbox. Thus, to work, it would seem that address must be sent to a particular mailbox, which I would guess is possible but requires sendmail(?) configuration).
Most MTAs (the software that handles the mail delivery, like sendmail) allow you to attach a script to an email address. If you control your own MTA, you can set up an alias in the /etc/aliases file that points not to a mailbox but to a script. This is how most mailinglists are configured. This (usually) doesn't require any reconfiguration of the MTA. The script will get fired up for each email that comes in. You could then use it to generate your reply email. If PayPal payments are almost instantanious (only an email delay), you could have the incoming-mail script handle the parsing of that email and have it send ZOpe an XML-RPC message to set the correct 'Paid' flag. The customer would be watching a 'Your payment is being processed' page that refreshes itself every 30 seconds or so, until the correct flag is set in the database. He or she can then download the file. This latter solution is more complex, but allows the selling of files greater than 100k, as mailboxes of recipients may be quota limited.
(2) I could figure out how to send attachments with Python-generated mail. I know there are libraries, but any docs on this seem to go on and on, and have all kinds of options and alternatives -- it's so simple in Zope. But in python, it appears I would use MimeWriter. I've found two examples of this, both of which write to sys.stdout, which is confusing -- how do you actually email such a thing?
Use MimeWriter and the sendmail library. And read up on some mime documentation. You'd need the latter for sending attachments using Zope as well, as you'll need to create the correct mime boundaries anyway. Hope this helps! I-wish-chapter-3-of-TIC++-wasn't-quite-so-long-so-I-can-get-to-the-meat-ly yours, -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
If you have access to a machine anywhere on the net that is running Linux or another Unix variant, here's an admittedly low-tech but very useful solution to this problem. (for some reason, my Zope wouldnt boot with Xron, so I was forced to look elsewhere and I found this..) I've found that either lynx or wget running on a cron job works *very* well for doing things like this.. (scheduling events in a Zope somewhere, really anywhere where the cron-triggered lynx can send it a request..the Zope can even be running on NT.. *laugh*) Its also a great way to grab (to mirror) pages created on a Zope server for use on other machines running conventional Apache, etc. Use 'lynx source' running from cron on the other machine to save the file to disk at regular intervals..This can also be a great way to deal with situations in which certain pages get very high traffic that it might make sense to divert away from Zope.. The only gotcha for newbies is that when running it from cron, you have to make sure that lynx has a "term" variable set.. (vt220 always works well for me) You can do this by adding this to your shell script at the beginning of the command line that invokes lynx.. There's a how-to about this somewhere if you look around. This combination is rock solid reliable. Chris
1) Is there a cron-like tool in Zope? Or a way to have cron run a process in Zope?
Zope product Xron http://www.zope.org/Members/lstaffor/Xron
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Bruce Eckel Sent: Wednesday, May 16, 2001 06:28 To: zope@zope.org Cc: chrism@digicool.com Subject: [Zope] Cron & Receiving email
1) Is there a cron-like tool in Zope? Or a way to have cron run a process in Zope?
2) Under Linux/Sendmail, can I have the above Zope process "receive" mail sent to a particular address? (Note that my ignorance of how mail works could fill volumes).
Thanks...
Most current information can be found at: http://www.mindview.net/Etc/notes.html =================== Bruce Eckel http://www.BruceEckel.com Contains free electronic books: "Thinking in Java 2e" & "Thinking in C++ 2e" Please subscribe to my free newsletter -- just send any email to: join-eckel-oo-programming@earth.lyris.net My schedule can be found at: http://www.mindview.net/Calendar ===================
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (6)
-
Bruce Eckel -
Chris Beaumont -
Chris McDonough -
Loren Stafford -
Martijn Pieters -
Oleg Broytmann