root/gaphor/tags/gaphor-0.13.0/gaphor/interfaces.py

Revision 2197, 1.9 kB (checked in by arj..@yirdis.nl, 1 year ago)

Added !IEventFilter interface. Filters can be registered (as subscription adapters) with this interface and can be used as filter on the event handler. Only events that pass all filters are actually emitted.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 """
2 Top level interface definitions for Gaphor.
3 """
4
5 from zope import interface
6
7
8 class IService(interface.Interface):
9     """
10     Base interface for all services in Gaphor.
11     """
12
13     def init(self, application):
14         """
15         Initialize the service, this method is called after all services
16         are instantiated.
17         """
18
19     def shutdown(self):
20         """
21         Shutdown the services, free resources.
22         """
23
24
25 class IServiceEvent(interface.Interface):
26     """
27     An event emitted by a service.
28     """
29     service = interface.Attribute("The service that emits the event")
30
31
32 class ITransaction(interface.Interface):
33     """
34     The methods each transaction should adhere.
35     """
36
37     def commit(self):
38         """
39         Commit the transaction.
40         """
41
42     def rollback(self):
43         """
44         Roll back the transaction.
45         """
46
47
48 class ITransactionEvent(interface.Interface):
49     """
50     Events related to transaction workflow (begin/commit/rollback) implements
51     this interface.
52     """
53
54
55 class IActionProvider(interface.Interface):
56     """
57     An action provider is a special service that provides actions
58     (see gaphor/action.py) and the accompanying XML for the UI manager.
59     """
60
61     menu_xml = interface.Attribute("The menu XML")
62
63     action_group = interface.Attribute("The accompanying ActionGroup")
64
65
66 class IActionExecutedEvent(interface.Interface):
67     """
68     An event emited when an action has been performed.
69     """
70     name = interface.Attribute("Name of the action performed, if any")
71     action = interface.Attribute("The performed action")
72
73
74 class IEventFilter(interface.Interface):
75     """
76     Filter events when they're about to be handled. Events can be changed or
77     blocked.
78     """
79
80     def filter(self):
81         """
82         Return a value (e.g. message/reason) why the event is filtered.
83         Returning `None` or `False` will propagate event emission.
84         """
85
86
87 # vim:sw=4:et
Note: See TracBrowser for help on using the browser.