===============================
Subscriptions Scheduling How-to
===============================

:Revision: $Id: HOWTO.subscriptions_scheduling.txt 30652 2005-12-14 22:16:00Z dkuhlman $

.. sectnum::    :depth: 4
.. contents::   :depth: 4


What Is Subscription Scheduling
===============================

Subscription scheduling is the ability to request the CPS Portal
to send mails according to the daily / weekly / monthly
subscriptions.


How is Subscription Scheduling Done
===================================

Since Zope (CPS neither) doesn't provide Scheduler (And I think
this is better like that...), you need to use crond to perform
subscription scheduling.


Configurations
==============

Use the ``cps_housekeeping.py`` script that comes with CPS in
folder ``CPSUtil/bin``; adjust the default values in the header;
and run it as follows::

  $ python /path/to/cps_housekeeping.py --send-notifications daily

A crontab example is provided in the header of the script.

To get the list of all available options, type::

  $ python /path/to/cps_housekeeping.py --help

Otherwise, if you have ``wget`` installed on your \*NIX to request
the portal you can directly call the corresponding method as
described below.


Daily notifications
===================

Create a script in your ``/etc/cron.daily/`` by issuing the
following command::

  cd /etc/cron.daily/
  cat <<'EOF' >portal_XXX_daily_subscriptions
  #!/bin/sh
  wget -q http://manager:password_manager@localhost:8080/cps/cps_subscriptions_schedule_notifications?subscription_mode=daily
  EOF

Replace, if necessary, "manager" by the login name of a Zope user
with manager role on the CPS instance, "password_manager" by its
password, and "8080" by the actual port of your Zope instance, "cps"
by the ID of your CPS site, and "XXX" by the name of your portal.

And, make sure that the script has execution rights.  For example::

  chmod +x /etc/portal_XXX_daily_subscriptions


Weekly notifications
====================

Add within your ``/etc/cron.weekly/`` the following script::

  cat <<'EOF' >portal_XXX_weekly_subscriptions
  #!/bin/sh
  wget -q http://root:pwd_root@localhost:9080/cps/cps_subscriptions_schedule_notifications?subscription_mode=weekly
  EOF

(Same remark as above).


Monthly notifications
=====================

Add within your ``/etc/cron.monthly/`` the following script::

  cat <<'EOF' >portal_XXX_monthly_subscriptions
  #!/bin/sh
  wget -q http://root:pwd_root@localhost:9080/cps/cps_subscriptions_schedule_notifications?subscription_mode=monthly
  EOF

(Same remark as above).


.. Emacs
.. Local Variables:
.. mode: rst
.. End:
.. Vim
.. vim: set filetype=rst:

