_finishConstruction a disparue sans prévenir. _contructInstance fait son boulot maint...
[Plinn.git] / shutdown_dispatcher.py
1 # -*- coding: utf-8 -*-
2 #######################################################################################
3 # Plinn - http://plinn.org #
4 # Copyright (C) 2005-2009 Benoît PIN <benoit.pin@ensmp.fr> #
5 # #
6 # This program is free software; you can redistribute it and/or #
7 # modify it under the terms of the GNU General Public License #
8 # as published by the Free Software Foundation; either version 2 #
9 # of the License, or (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program; if not, write to the Free Software #
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
19 #######################################################################################
20 """ provides utilities to raise / handle zope server shutdown events
21
22 $Id: shutdown_dispatcher.py 1480 2009-03-19 19:15:52Z pin $
23 $URL: http://svn.cri.ensmp.fr/svn/Plinn/branches/CMF-2.1/shutdown_dispatcher.py $
24 """
25
26 import asyncore
27 from zope.event import notify
28 from zope.component import getSiteManager
29 from events import ZopeShutdownEvent
30 from OFS.interfaces import IApplication
31
32 class ZopeShutdownDispatcher(asyncore.dispatcher):
33
34
35 def __init__(self, app, map=None):
36 asyncore.dispatcher.__init__(self, None, map)
37 self.connected = False
38 self.app = self._fileno = app
39 self.add_channel()
40
41 def close(self) :
42 self.del_channel()
43
44 def readable(self):
45 return False
46
47 def handle_read(self):
48 return True
49
50 def writable(self):
51 return False
52
53 def handle_write (self):
54 return True
55
56 def clean_shutdown_control(self, phase, time):
57 asyncore.dispatcher.log_info(self, 'zope shutdown event raised at phase: %s' % phase, 'info')
58 e = ZopeShutdownEvent(self.app, phase, time)
59 notify(e)
60 return e.veto