Skip to main content

collective.timedevents

Overview

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 regularly or after a certain period has expired.

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

There are two different styles of using it:

  1. Using the ITickEvent and calculating if action needs to be done in the event subscriber. This will also take care of timing over zope restarts by keeping event timing persistent.

  2. Subscribing to any of the cron-style IIntervalTicks*-events, not worrying about the timing client side. For the longer ticks (weekly, monthly) a cron-job as trigger makes most sense, in case of zope restarts.

https://github.com/collective/collective.timedevents/actions/workflows/test-matrix.yml/badge.svg

Installation

  1. Add collective.timedevents to your buildout by adding the egg to your buildout.cfg:

    eggs =
       ...
       collective.timedevents
  2. Trigger

Can either be cron-jobs or zope clock-server.

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

[instance]
...
    zope-conf-additional =
    <clock-server>
        method /mysite/@@tick
        period 90
        user clockserver-user
        password password
        host localhost
    </clock-server>

Or for the cron-like interval-based events, here 900 seconds for the 15-minute event:

<clock-server>
  method /mysite/@@tick_fifteen
  period 900
  user clockserver-user
  password password
  host localhost
</clock-server>

Now you should start to see ticks in the zope event log.

Usage

Subscribe to the events/ticks you need.

  1. Using the ITickEvent method:

  1. Add collective.timedevents.interfaces.ITickEvent subscribers to your product ZCML declarations:

    <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.interfaces.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
  1. Using the IIntervalTicks*-events:

Add collective.timedevents.interfaces.IIntervalTicks* subscribers to your module ZCML declarations:

<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="mymodule">

     <subscriber
           handler="myproduct.tickers.on_tick_fifteen"
           for="collective.timedevents.interfaces.IIntervalTicks15Event"
         />

</configure>

Other

All ticking code is executed under admin privileges.

ITickEvent tick period is 300 seconds by default. This can be controlled in views.py.

Ticks for ITickEvent are logged by events.tick_logger defined in configure.zcml.

Development

Plone 6.1 on Python 3.10 to 3.13, and Plone 6.2 on Python 3.10 to 3.14. The development environment uses uv:

make install       # Plone 6.2.3 in .venv (PLONE_VERSION=... to override)
make create-site   # Create a Plone site
make start         # Start Plone on localhost:8080
make test          # Run the tests on Plone 6.2.3 (tox)
make test-all      # Lint and the whole Plone / Python test matrix
make lint          # pre-commit hooks

The QA configuration (tox, GitHub Actions, pre-commit) is generated by plone.meta: change .meta.toml, then run uvx --from plone.meta config-package --branch current ..

Quality assurance

This product fills the following quality criteria:

  • Unit tests provided

  • Good documentation provided

  • Commented code

  • PyPi eggs provided

Author

  • Mikko Ohtamaa <http://opensourcehacker.com>

  • Quintagroup

  • Sune Brøndum Wøller

  • The original concept and code was created by Tomasz J. Kotarba <tomasz@kotarba.net> of SYSTEM7.

  • Twinapex Research, Oulu, Finland <http://www.twinapex.com>_ - High quality Python hackers for hire

Changelog

2.0.0 (2026-11-18)

Breaking changes:

  • Native namespace package (PEP 420): collective/__init__.py is gone. Plone 6.1 on Python 3.10 to 3.13, and Plone 6.2 on Python 3.10 to 3.14, only. Applications on Python 2 or older Plone releases must stay on 1.1. [bsuttor]

New features:

  • Use importlib.metadata instead of pkg_resources, which setuptools 81+ deprecates and setuptools 84 (Plone 6.2.3) no longer ships. [bsuttor]

Internal:

  • Configure with plone.meta: tox test matrix (Plone 6.2.3 on Python 3.10 to 3.14, Plone 6.1 on Python 3.10 to 3.13), GitHub Actions, pre-commit. Package metadata moved to pyproject.toml, src/ layout, plone.autoinclude entry point. [bsuttor]

  • make install builds a uv development environment on Plone 6.2.3. Travis, buildout configuration and the hand-written GitHub workflow are gone. [bsuttor]

1.1 (2021-08-26)

  • Add Python 3 & Plone 5.2 compatibility [boulch]

  • Use github CI for automated testing [tomgross]

1.0.3 (2016-02-01)

  • One final attempt to include HISTORY.txt into egg [tomgross]

1.0.2 (2016-02-01)

  • Fix brown bag release part 2 [tomgross]

1.0.1 (2016-02-01)

  • Fix brown bag release [tomgross]

1.0 (2016-01-30)

  • Plone 5 compatibility [karalics, tomgross]

0.3 (2013-12-14)

  • Travis CI integration [hvelarde]

  • Added cron-style tick events, to be triggered by cron or clockserver, with no internal calculation of interval. Updated readme and tests. [sunew]

0.2.1 (2012-04-24)

  • Added logging level option for tick_logger [vmaksymiv]

  • Bugfix: data storage

0.2

  • Added Plone 4 compatibility [kroman0]

0.1.1 (2008-11-04)

  • PyPi egg fixes

0.1

  • Initial release

Metadata

Release files for collective.timedevents 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for collective.timedevents 2.0.0
File Size Uploaded Provenance Actions
collective_timedevents-2.0.0.tar.gz 13.9 kB Without provenance Details for collective_timedevents-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for collective.timedevents 2.0.0
File Interpreter ABI Platform Actions
collective_timedevents-2.0.0-py3-none-any.whl Python 3 none any Details for collective_timedevents-2.0.0-py3-none-any.whl

Total release size: 24.8 kB

Release files / collective_timedevents-2.0.0.tar.gz

Download URL collective_timedevents-2.0.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3cef2a0267faedc73967c5afada27ac51b2667c7a9cea2597449a9487c4706c3
BLAKE2b-256 checksum
How to use checksums
048c1f9895b208b81049262a679f0b766a9236f7e6b7e90ab03ea537932dae60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / collective_timedevents-2.0.0-py3-none-any.whl

Download URL collective_timedevents-2.0.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e38489659827c451424a5e45d8d6f6d98e370bcd95f23ffd3bf11ad68f9cb2c
BLAKE2b-256 checksum
How to use checksums
5d5db504a44dd8b139c0aaefdb09db6fae3572e8b96ec26bd4aab985e5264070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for collective.timedevents 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page