在使用 Plone 4 时,我成功创建了一个订阅者事件,以便在保存自定义内容类型时进行额外处理。这是我通过使用Products.Archetypes.interfaces.IObjectInitializedEvent
界面完成的。
配置.zcml
<subscriber
for="mycustom.product.interfaces.IRepositoryItem
Products.Archetypes.interfaces.IObjectInitializedEvent"
handler=".subscribers.notifyCreatedRepositoryItem"
/>
订阅者.py
def notifyCreatedRepositoryItem(repositoryitem, event):
"""
This gets called on IObjectInitializedEvent - which occurs when a new object is created.
"""
my custom processing goes here. Should be asynchronous
但是,额外的处理有时可能需要很长时间,我想知道是否有办法在后台运行它,即异步。
是否可以异步运行订阅者事件,例如在保存对象时?