f5d778bb8665a151a2662feaf9ec50ecff7c143f
1 # -*- coding: utf-8 -*-
2 #######################################################################################
3 # Plinn - http://plinn.org #
4 # Copyright (C) 2005-2009 BenoƮt PIN <benoit.pin@ensmp.fr> #
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. #
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. #
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
27 from zope
.event
import notify
28 from zope
.component
import getSiteManager
29 from events
import ZopeShutdownEvent
30 from OFS
.interfaces
import IApplication
32 class ZopeShutdownDispatcher(asyncore
.dispatcher
):
35 def __init__(self
, app
, map=None):
36 asyncore
.dispatcher
.__init
__(self
, None, map)
37 self
.connected
= False
38 self
.app
= self
._fileno
= app
47 def handle_read(self
):
53 def handle_write (self
):
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
)