Commit 21b126b1 authored by Kevin Deldycke's avatar Kevin Deldycke

Third patch; See http://svn.erp5.org/?rev=8067&view=rev for details

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11929 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d935010
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
# -*- Mode: Python; py-indent-offset: 4 -*- # -*- Mode: Python; py-indent-offset: 4 -*-
# Authors: Nik Kim <fafhrd@legco.biz> # Authors: Nik Kim <fafhrd@legco.biz>
__version__ = '$Revision: 1.3 $'[11:-2] __version__ = '$Revision: 1.3 $'[11:-2]
import sys, time, threading import sys, time, threading
...@@ -30,7 +30,7 @@ class TimerService(SimpleItem): ...@@ -30,7 +30,7 @@ class TimerService(SimpleItem):
icon = 'misc_/TimerService/timer_icon.gif' icon = 'misc_/TimerService/timer_icon.gif'
max_size = 0 max_size = 0
manage_options = ( manage_options = (
({'label': 'Subscribers', 'action':'manage_viewSubscriptions'},)) ({'label': 'Subscribers', 'action':'manage_viewSubscriptions'},))
...@@ -41,9 +41,9 @@ class TimerService(SimpleItem): ...@@ -41,9 +41,9 @@ class TimerService(SimpleItem):
globals(), globals(),
__name__='manage_viewSubscriptions' __name__='manage_viewSubscriptions'
) )
_version = 0 _version = 0
def __init__(self, id='timer_service'): def __init__(self, id='timer_service'):
""" """ """ """
self._subscribers = [] self._subscribers = []
...@@ -57,15 +57,21 @@ class TimerService(SimpleItem): ...@@ -57,15 +57,21 @@ class TimerService(SimpleItem):
if not acquired: if not acquired:
return return
subscriptions = [self.unrestrictedTraverse(path) # Don't let TimerService crash when the ERP5Site is not yet existing.
for path in self._subscribers] # This case append when we create a new Portal: At that step Timer Service start
# to 'ping' the portal before the zope transaction in which the portal is
# created is commited.
subscriptions = []
try:
subscriptions = [self.unrestrictedTraverse(path)
for path in self._subscribers]
except KeyError:
pass
tick = time.time() tick = time.time()
prev_tick = tick - interval prev_tick = tick - interval
next_tick = tick + interval next_tick = tick + interval
# LOG('TimerService', INFO, 'Ttimer tick at %s\n'%time.ctime(tick))
for subscriber in subscriptions: for subscriber in subscriptions:
try: try:
subscriber.process_timer( subscriber.process_timer(
...@@ -80,9 +86,6 @@ class TimerService(SimpleItem): ...@@ -80,9 +86,6 @@ class TimerService(SimpleItem):
""" """ """ """
path = '/'.join(ob.getPhysicalPath()) path = '/'.join(ob.getPhysicalPath())
#if not ISMTPHandler.isImplementedBy(ob):
# raise ValueError, 'Object not support ISMTPHandler'
subscribers = self._subscribers subscribers = self._subscribers
if path not in subscribers: if path not in subscribers:
subscribers.append(path) subscribers.append(path)
...@@ -102,7 +105,7 @@ class TimerService(SimpleItem): ...@@ -102,7 +105,7 @@ class TimerService(SimpleItem):
if path in subscribers: if path in subscribers:
subscribers.remove(path) subscribers.remove(path)
self._subscribers = subscribers self._subscribers = subscribers
security.declareProtected( security.declareProtected(
Permissions.view_management_screens, 'lisSubscriptions') Permissions.view_management_screens, 'lisSubscriptions')
def lisSubscriptions(self): def lisSubscriptions(self):
......
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
# -*- Mode: Python; py-indent-offset: 4 -*- # -*- Mode: Python; py-indent-offset: 4 -*-
# Authors: Nik Kim <fafhrd@legco.biz> # Authors: Nik Kim <fafhrd@legco.biz>
__version__ = 'TimerServer for Zope 0.1' __version__ = 'TimerServer for Zope 0.1'
import traceback import traceback
...@@ -96,7 +96,7 @@ class TimerResponse(BaseResponse): ...@@ -96,7 +96,7 @@ class TimerResponse(BaseResponse):
def unauthorized(self): def unauthorized(self):
pass pass
class TimerRequest(HTTPRequest): class TimerRequest(HTTPRequest):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment