collective.timedevents

Warning
This product has not had a release in over 1 year and may no longer be maintained.
by Mikko Ohtamaa last modified Feb 16, 2011 02:04 AM

collective.timedevents fires clock based Zope 3 events. They can make Zope application react to timers. This is useful for creating services where something must happen regurlarly or after a certain period has expired.

Project Description

Overview

This is a developer level product. This product is indended to replace Products.TickingMachine with more robust Zope 3 codebase.

Usage

  1. Install collective.timedevents

Add the following to your buildout.cfg:

eggs =
        ...
        collective.timedevents

zcml =
    ...
        collective.timedevents

Add clock server to tick timedevents subscribers - use your Plone instance name:

[instance]
...
        zope-conf-additional =
        <clock-server>
            method /mysite/@@tick
            period 90
        user admin
            password adminpassword
            host localhost
        </clock-server>
  1. Add collective.timedevents.interfaces.ITickEvent subscribers to your product ZCML declarations.

    Example:

    <configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="harvinaiset.app">
    
                 <subscriber
                       handler="myproduct.tickers.on_tick"
                       for="collective.timedevents.intefaces.ITickEvent"
                     />
    
    </configure>
    
  2. Configure your event handler to react after certain period has expired:

    from zope.app.component.hooks import getSite
    
    def on_tick(event):
        """ Do something after one hour has elapsed """
        interval_in_days = 1.0 / 24.0 # One hour, floating point
        context = site.my_magic_context # Persistent object which stores our timing data
        if event.last_tick > context.last_action + interval_in_days: # Check whether enough time has elaped
            do_stuff()
            context.last_action = event.last_tick # Store when we last time did something
    

Other

All ticking code is executed under admin privileges. Tick period is 300 seconds by default. This can be controlled in views.py. Ticks are logged by events.tick_logger defined in configure.zcml.

The product is loosely connected to Plone, but can be used standalone with little modifications.

Quality assurance

This product fills the following quality criteria:

  • Unit tests provided
  • Good documentation provided
  • Commented code
  • PyPi eggs provided

Future

Cron like "on day/hour/minute X" like subscribers could be added.

Author

Mikko Ohtamaa <mikko.ohtamaa@twinapex.com>

The orignal concept and code was created by Tomasz J. Kotarba <tomasz@kotarba.net>.

Twinapex Research, Oulu, Finland - High quality Python hackers for hire

Current Release
collective.timedevents 0.1.1

Released Nov 04, 2008 — tested with Plone 3

Fixed PyPi egg
More about this release…

Download file Get collective.timedevents for all platforms
If you are using Plone 3.2 or higher, you probably want to install this product with buildout. See our tutorial on installing add-on products with buildout for more information.

All Releases

Version Released Description Compatibility Status
0.1.1 Nov 04, 2008 Fixed PyPi egg More about this release…
Plone 3
final
0.1 Nov 04, 2008 Initial release More about this release…
Plone 3
final

Comments (0)