Plone/Zope time based event mechanism
Project description
Overview
This is a developer level product. This product is indended to replace Products.TickingMachine with more robust Zope 3 codebase.
Usage
Install collective.timedevents
Add the following to your buildout.cfg:
eggs = ... collective.timedeventsAdd 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>
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>
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for collective.timedevents-0.2.1.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | a880566b04392758d547b98a9084f95265002693bd19e5e4e43ea87feec5cf3a |
|
MD5 | df5d2e58f9d29569b44abe92cd64d741 |
|
BLAKE2b-256 | f1419254d460ba6ca07cd8fc66d89fd3b7b08d30536dc2b212a75adbdd84a4f6 |