[Checkins] SVN: zc.zodbrecipes/trunk/ You can now specify an email address in a packing crontab file to

Jim Fulton jim at zope.com
Wed Jan 2 11:47:02 EST 2008


Log message for revision 82642:
  You can now specify an email address in a packing crontab file to
  control where errors are sent.
  

Changed:
  U   zc.zodbrecipes/trunk/README.txt
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
  U   zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt

-=-
Modified: zc.zodbrecipes/trunk/README.txt
===================================================================
--- zc.zodbrecipes/trunk/README.txt	2008-01-02 16:46:59 UTC (rev 82641)
+++ zc.zodbrecipes/trunk/README.txt	2008-01-02 16:47:02 UTC (rev 82642)
@@ -7,6 +7,14 @@
 Changes
 *******
 
+0.3 (2008-01-02)
+================
+
+New Features
+------------
+
+- You can now specify an email address in a packing crontab file.
+
 0.2.1 (2007-04-23)
 ================
 

Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2008-01-02 16:46:59 UTC (rev 82641)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/__init__.py	2008-01-02 16:47:02 UTC (rev 82642)
@@ -93,7 +93,7 @@
                 if len(pack) < 5:
                     raise zc.buildout.UserError(
                         'Too few crontab fields in pack specification')
-                if len(pack) > 6:
+                if len(pack) > 7:
                     raise zc.buildout.UserError(
                         'Too many values in pack option')
                 pack_path = os.path.join(
@@ -204,11 +204,15 @@
                     else:
                         address = '-p '+address
                 f = open(pack_path, 'w')
+                if len(pack) == 7:
+                    assert '@' in pack[6]
+                    f.write("MAILTO=%s\n" % pack.pop())
+                    
                 if len(pack) == 6:
-                    days = pack[5]
-                    pack = pack[:5]
+                    days = pack.pop()
                 else:
                     days = 1
+
                 for storage in storages:
                     f.write("%s %s %s %s -S %s -d %s\n" % (
                             ' '.join(pack), options['user'],

Modified: zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt
===================================================================
--- zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2008-01-02 16:46:59 UTC (rev 82641)
+++ zc.zodbrecipes/trunk/zc/zodbrecipes/zeo.txt	2008-01-02 16:47:02 UTC (rev 82642)
@@ -381,9 +381,9 @@
 zdaemon configuration.
 
 We can request definition of a cron job to pack the databases by
-specifying a pack option.  This option takes 5 or 6 values.  The
+specifying a pack option.  This option takes 5 to 7 values.  The
 first 5 values are the time and date fields defined by Unix crontab
-files. The last field is the number of days in the past to pack to and
+files. The sixth field is the number of days in the past to pack to and
 defaults to 1.
 
 Let's add a pack option:
@@ -435,3 +435,53 @@
 
 In this example, we'll pack the databases every Sunday at 1:01 to 3
 days.
+
+We can add an email address to the pack option.  If we do, then a
+MAILTO variable will be added to the cron file:
+
+    >>> write('buildout.cfg',
+    ... '''
+    ... [buildout]
+    ... parts = zodb server
+    ... 
+    ... [zodb]
+    ... recipe = zc.recipe.egg:script
+    ... eggs = ZODB3
+    ... 
+    ... [server]
+    ... recipe = zc.zodbrecipes:server
+    ... zeo.conf = 
+    ...    <zeo>
+    ...       address 8100
+    ...       monitor-address 8101
+    ...       transaction-timeout 300
+    ...    </zeo>
+    ...    %%import foo
+    ...    <foo main>
+    ...       path /databases/Data.fs
+    ...    </foo>
+    ... deployment = demo
+    ... pack = 1 1 * * 0 3 jim at zope.com
+    ...
+    ... [demo]
+    ... crontab-directory = %(cron)s
+    ... etc-directory = %(etc)s
+    ... log-directory = %(log)s
+    ... logrotate-directory = %(rotate)s
+    ... rc-directory = %(rc)s
+    ... run-directory = %(run)s
+    ... user = bob
+    ... ''' % globals())
+
+    >>> print system(buildout+' -D'),
+    Uninstalling server.
+    Updating zodb.
+    Installing server.
+    Generated script '/sample-buildout/rc/demo-server'.
+
+    >>> cat(cron, 'pack-demo-server')
+    MAILTO=jim at zope.com
+    1 1 * * 0 bob /sample-buildout/bin/zeopack -p 8100 -S main -d 3
+
+This causes email to be sent to the given address, rather than to the
+user specified in the crontab file.



More information about the Checkins mailing list