Trees | Indices | Help |
|
---|
|
1 #-*- coding: utf8 -* 2 # 3 # Max E. Kuznecov ~syhpoon <mek@mek.uz.ua> 2008 4 # 5 6 # This file is part of XYZCommander. 7 # XYZCommander is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU Lesser Public License as published by 9 # the Free Software Foundation, either version 3 of the License, or 10 # (at your option) any later version. 11 # XYZCommander 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 Lesser Public License for more details. 15 # You should have received a copy of the GNU Lesser Public License 16 # along with XYZCommander. If not, see <http://www.gnu.org/licenses/>. 17 18 import traceback 19 20 from libxyz.core.utils import ustring 2123 """ 24 Hooks dispatcher 25 """ 26 29 30 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 318133 """ 34 Register proc to be run upon event occured 35 """ 36 37 if event not in self._data: 38 self._data[event] = [] 39 40 if not callable(proc): 41 xyzlog.error(_(u"HookManager: Callable argument expected")) 42 return False 43 44 self._data[event].append(proc) 45 46 return True47 48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 49 56 57 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5860 """ 61 Sequentially run procedures registered with provided event 62 """ 63 64 # No callbacks registered 65 if event not in self._data or not self._data[event]: 66 return False 67 68 for proc in self._data[event]: 69 try: 70 proc(*args) 71 except Exception, e: 72 xyzlog.error( 73 _(u"Error running callback procedure for event %s") % 74 unicode(e)) 75 76 xyzlog.debug(ustring(traceback.format_exc())) 77 78 return False 79 80 return True
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Sep 16 01:52:01 2010 | http://epydoc.sourceforge.net |