Run update-copyright.py.
[hooke.git] / hooke / ui / gui / handler / __init__.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 from ....util.pluggable import IsSubclass, construct_odict
19
20
21 HANDLER_MODULES = [
22     'boolean',
23     'float',
24 #    'int'
25 #    'point',
26     'selection',
27     'string'
28     ]
29 """List of handler modules.  TODO: autodiscovery
30 """
31
32 class Handler (object):
33     """Base class for :class:`~hooke.interaction.Request` handlers.
34     
35     :attr:`name` identifies the request type and should match the
36     module name.
37     """
38     def __init__(self, name):
39         self.name = name
40
41     def run(self, hooke_frame, msg):
42         raise NotImplemented
43
44     def _cancel(self, *args, **kwargs):
45         # TODO: somehow abort the running command
46         pass
47
48
49 HANDLERS = construct_odict(
50     this_modname=__name__,
51     submodnames=HANDLER_MODULES,
52     class_selector=IsSubclass(Handler, blacklist=[Handler]))
53 """:class:`hooke.compat.odict.odict` of :class:`Handler`
54 instances keyed by `.name`.
55 """