plonehrm notifications
======================

With plonehrm we want to send notifications.  A notification can be an email
or it can be a new checklist item (if you have the checklist module) and maybe
more.

Reasons for sending notifications can be for example: the current contract of
an employee is nearing its end; his birthday is coming; or we should have a
new job performance interview soon.

These examples are all conditions that need to be checked once in a while,
probably daily.  You can run a cron job on your operating system or you can do
something with the Zope clock server (from Zope 2.10 upwards only).  In any
case we need to provide a page that can be called by a user that will trigger
these checks.

We should not be able to do this as a mere mortal:

  >>> checker = self.portal.restrictedTraverse('@@do_hrm_check')
  Traceback (most recent call last):
  ...
  Unauthorized: You are not allowed to access '@@do_hrm_check' in this context

As Manager it should work.

  >>> self.setRoles(['Manager'])
  >>> checker = self.portal.restrictedTraverse('@@do_hrm_check')
  >>> checker()
  u'HRMCheckEvent triggered'

We create an event handler and subscribe it.

  >>> def hrm_checker(object, event):
  ...     print event.__class__, "triggered"
  ...     print "Will perform checks on", object
  >>> from zope.app.testing import ztapi
  >>> from Products.CMFPlone.interfaces import IPloneSiteRoot
  >>> from Products.plonehrm.interfaces import IHRMCheckEvent
  >>> ztapi.subscribe([IPloneSiteRoot, IHRMCheckEvent], None, hrm_checker)

Now trigger the event.

  >>> checker = self.portal.restrictedTraverse('@@do_hrm_check')
  >>> checker()
  <class 'plonehrm.notifications.events.HRMCheckEvent'> triggered
  Will perform checks on <PloneSite at plone>
  u'HRMCheckEvent triggered'
