diff --git a/docs/generic/event_system.rst b/docs/generic/event_system.rst index 5b1ff2605..15c1d8edc 100644 --- a/docs/generic/event_system.rst +++ b/docs/generic/event_system.rst @@ -3,7 +3,7 @@ Event system Generic library provides ``generic.event`` module which helps you implement event systems in your application. By event system I mean an API for -*subscribing* for some types of events and to *fire* those events so previously +*subscribing* for some types of events and to *handle* those events so previously subscribed *handlers* are being executed. .. contents:: @@ -29,12 +29,12 @@ Now you want to register handler for your event type:: def print_comment(ev): print "Got new comment: %s" % ev.comment -Then you just call ``generic.event.fire`` function with ``CommentAdded`` +Then you just call ``generic.event.handle`` function with ``CommentAdded`` instance as its argument:: - from generic.event import fire + from generic.event import handle - fire(CommentAdded(167, "Hello!")) # prints `Got new comment: Hello!` + handle(CommentAdded(167, "Hello!")) # prints `Got new comment: Hello!` This is how it works. @@ -48,12 +48,12 @@ API reference ------------- .. autoclass:: generic.event.Manager - :members: subscribe, subscriber, fire, unsubscribe + :members: subscribe, subscriber, handle, unsubscribe Functions below are just aliases for methods of globally instantiated manager: .. autofunction:: generic.event.subscribe(handler, event_type) .. autofunction:: generic.event.subscriber(event_type) -.. autofunction:: generic.event.fire(event) +.. autofunction:: generic.event.handle(event) .. autofunction:: generic.event.unsubscribe(handler, event_type) diff --git a/docs/model.rst b/docs/model.rst index 601faf0cd..9a5b7d1a9 100644 --- a/docs/model.rst +++ b/docs/model.rst @@ -2,9 +2,9 @@ UML datamodel ============= Gaphor uses the UML metamodel specs as guidelines for its data storage. -In fact, the datamodel is generated for a model file. +In fact, the datamodel is generated for a model file. -The model is built using smart properties (descriptors). Those descriptors fire +The model is built using smart properties (descriptors). Those descriptors handle events when they're changed. This allows the rest of the application (visuals, undo system) to update their state accordingly. The events are send using Zope (3)'s signalling mechanism, called Handlers. diff --git a/gaphor/misc/generic/event.py b/gaphor/misc/generic/event.py index 0b968b12d..1bd09ef6a 100644 --- a/gaphor/misc/generic/event.py +++ b/gaphor/misc/generic/event.py @@ -2,7 +2,7 @@ This module provides API for event management. There are two APIs provided: -* Global event management API: subscribe, unsubscribe, fire. +* Global event management API: subscribe, unsubscribe, handle. * Local event management API: Manager If you run only one instance of your application per Python @@ -25,7 +25,7 @@ class Manager(object): Provides API for subscribing for and firing events. There's also global event manager instantiated at module level with functions - :func:`.subscribe`, :func:`.fire` and decorator :func:`.subscriber` aliased + :func:`.subscribe`, :func:`.handle` and decorator :func:`.subscriber` aliased to corresponding methods of class. """ @@ -46,7 +46,7 @@ class Manager(object): if handler_set and handler in handler_set: handler_set.remove(handler) - def fire(self, event): + def handle(self, event): """ Fire ``event`` All subscribers will be executed with no determined order. @@ -76,7 +76,7 @@ class Manager(object): ... # handle event ... return - >>> mymanager.fire(MyEvent()) + >>> mymanager.handle(MyEvent()) """ diff --git a/gaphor/misc/generic/tests/test_event.py b/gaphor/misc/generic/tests/test_event.py index f2ef4f91b..6034d83f0 100644 --- a/gaphor/misc/generic/tests/test_event.py +++ b/gaphor/misc/generic/tests/test_event.py @@ -19,7 +19,7 @@ class ManagerTests(unittest.TestCase): events = self.createManager() events.subscribe(self.makeHandler("handler1"), EventA) e = EventA() - events.fire(e) + events.handle(e) self.assertEqual(len(e.effects), 1) self.assertTrue("handler1" in e.effects) @@ -27,7 +27,7 @@ class ManagerTests(unittest.TestCase): events = self.createManager() events.subscriber(EventA)(self.makeHandler("handler1")) e = EventA() - events.fire(e) + events.handle(e) self.assertEqual(len(e.effects), 1) self.assertTrue("handler1" in e.effects) @@ -37,12 +37,12 @@ class ManagerTests(unittest.TestCase): events.subscribe(self.makeHandler("handler2"), EventB) ea = EventA() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 1) self.assertTrue("handler1" in ea.effects) eb = EventB() - events.fire(eb) + events.handle(eb) self.assertEqual(len(eb.effects), 2) self.assertTrue("handler1" in eb.effects) self.assertTrue("handler2" in eb.effects) @@ -54,17 +54,17 @@ class ManagerTests(unittest.TestCase): events.subscribe(self.makeHandler("handler3"), EventD) ea = EventA() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 1) self.assertTrue("handler1" in ea.effects) ec = EventC() - events.fire(ec) + events.handle(ec) self.assertEqual(len(ec.effects), 1) self.assertTrue("handler2" in ec.effects) ed = EventD() - events.fire(ed) + events.handle(ed) self.assertEqual(len(ed.effects), 3) self.assertTrue("handler1" in ed.effects) self.assertTrue("handler2" in ed.effects) @@ -74,7 +74,7 @@ class ManagerTests(unittest.TestCase): events = self.createManager() ea = EventA() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 0) def test_subscribe_base_event(self): @@ -82,7 +82,7 @@ class ManagerTests(unittest.TestCase): events.subscribe(self.makeHandler("handler1"), EventA) ea = EventB() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 1) self.assertTrue("handler1" in ea.effects) @@ -93,18 +93,18 @@ class ManagerTests(unittest.TestCase): events.subscribe(self.makeHandler("handler3"), EventE) ea = EventA() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 1) self.assertTrue("handler1" in ea.effects) ed = EventD() - events.fire(ed) + events.handle(ed) self.assertEqual(len(ed.effects), 2) self.assertTrue("handler1" in ed.effects) self.assertTrue("handler2" in ed.effects) ee = EventE() - events.fire(ee) + events.handle(ee) self.assertEqual(len(ee.effects), 3) self.assertTrue("handler1" in ee.effects) self.assertTrue("handler2" in ee.effects) @@ -116,7 +116,7 @@ class ManagerTests(unittest.TestCase): events.subscribe(self.makeHandler("handler2"), EventB) eb = EventB() - events.fire(eb) + events.handle(eb) self.assertEqual(len(eb.effects), 2) self.assertTrue("handler1" in eb.effects) self.assertTrue("handler2" in eb.effects) @@ -127,7 +127,7 @@ class ManagerTests(unittest.TestCase): events.subscribe(handler, EventA) events.unsubscribe(handler, EventA) e = EventA() - events.fire(e) + events.handle(e) self.assertEqual(len(e.effects), 0) def test_unsubscribe_event_inheritance(self): @@ -139,11 +139,11 @@ class ManagerTests(unittest.TestCase): events.unsubscribe(handler1, EventA) ea = EventA() - events.fire(ea) + events.handle(ea) self.assertEqual(len(ea.effects), 0) eb = EventB() - events.fire(eb) + events.handle(eb) self.assertEqual(len(eb.effects), 1) self.assertTrue("handler2" in eb.effects) diff --git a/gaphor/services/componentregistry.py b/gaphor/services/componentregistry.py index 83a93df31..75d894912 100644 --- a/gaphor/services/componentregistry.py +++ b/gaphor/services/componentregistry.py @@ -86,4 +86,4 @@ class ComponentRegistry(Service): Send event notifications to registered handlers. """ for e in events: - self._events.fire(e) + self._events.handle(e)