plone/zope基于时间的事件机制

collective.timedevents的Python项目详细描述


collective.timedevents

Overview

collective.timedevents触发基于时钟的zope 3事件。他们可以 zope应用程序对计时器作出反应。这对于创建服务很有用 必须经常发生或在一定时期后发生的事情 期满。

这是一个开发人员级别的产品。这个产品是注定要替换的 产品。具有更强大的Zope3代码库的滴答机。

有两种不同的使用方式:

  1. 使用itickevent并计算是否需要在中执行操作 事件订阅服务器。这也会影响到Zope的时间安排 通过保持事件计时的持久性来重新启动。
  2. 订阅任何cron样式的iIntervalticks*-事件,而不是 担心客户端的时间安排。对于更长的节拍(每周, montly)对于zope来说,cron作业作为触发器最有意义。 重新启动。

由Travis测试:

https://secure.travis-ci.org/collective/collective.timedevents.png?branch=master

Installation

  1. 通过将egg添加到 buildout.cfg:

    eggs =
       ...
       collective.timedevents
    
  2. 触发器

可以是cron作业或zope时钟服务器。

添加时钟服务器到tick timedevents订阅服务器-使用plone 实例名称:

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

或者对于类似cron的基于时间间隔的事件,这里是 15分钟活动:

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

现在您应该开始在zope事件日志中看到ticks了。

Usage

订阅所需的事件/节拍。

  1. 使用itickevent方法:
  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.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
    
  1. 使用iIntervalticks*-事件:

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.intefaces.IIntervalTicks15Event"
         />

</configure>

Other

所有计时代码都是在管理员权限下执行的。

默认情况下,itickevent tick period为300秒。这是可以控制的 在views.py中。

itickevent的ticks由events记录。tick\u logger在 配置.zcml。

Quality assurance

本产品符合以下质量标准:

  • 提供单元测试
  • 提供了良好的文档
  • 注释代码
  • 提供Pypi鸡蛋

Author

  • Mikko Ohtamaa <http://opensourcehacker.com>\
  • Quintagroup
  • 苏恩·布伦多姆·沃勒
  • 原始概念和代码是由tomasz cobata tomasz j创建的。 科塔巴tomasz@kotarba.net
  • Twinapex Research, Oulu, Finland <http://www.twinapex.com>- 雇佣高质量的python黑客

Changelog

1.0.4 (2017-04-07)

  • 将缺少的configure.zcml添加到egg分发 [汤姆格罗斯]

1.0.3 (2016-02-01)

  • 最后一次尝试将history.txt包含到egg中 [汤姆格罗斯]

1.0.2 (2016-02-01)

  • 固定棕色袋释放部件2 [汤姆格罗斯]

1.0.1 (2016-02-01)

  • 固定棕色袋释放 [汤姆格罗斯]

1.0 (2016-01-30)

  • plone 5兼容性 [卡拉利斯,汤格罗斯]

0.3 (2013-12-14)

  • travis-ci集成 [hvelarde]
  • 添加了cron样式的tick事件,由cron或clockserver触发,不需要内部计算间隔。更新了自述文件和测试。 [阳光]

0.2.1 (2012-04-24)

  • 为tick_logger添加了日志级别选项 [vmaksymiv]
  • 错误修复:数据存储

0.2

  • 增加了plone 4兼容性 [Kroman0]

0.1.1 (2008-11-04)

  • pypi egg修复程序

0.1

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
HTTP标头的java InputStream未终止   java测试SpringWebListener   具有定义的替换编号Java的regex ReplaceAll   在java中使用contains()方法   java在选择查询中使用JoinColumn字段   具有用户的java Start-stop demon不是以给定用户启动   java glBufferData生成GL\u无效\u操作   java中循环代码的循环   Java位无符号移位(>>>>)会产生奇怪的结果   java HQL使用点分隔符从select获取结果   条纹、弹簧、玩耍(或?):使用哪种高性能Java框架?   广播接收机中的java停止服务   java回收器视图占据整个屏幕。不在上面显示我的UI元素   java使MySQL查询更快   java MappedByteBuffer查询   java递归算法问题