[Freedombox-discuss] Dev: Cross Cutting Concerns in Plinth?
sunil at medhas.org
Tue Mar 25 18:57:18 UTC 2014
On Tuesday 25 March 2014 07:17 AM, Nick Daly wrote:
> Hi folks, Plinth doesn't currently handle cross-cutting concerns very
> well. For example, if I change the hostname, I need to individually
> notify every service that depends on that hostname. If Plinth had
> better support for callbacks or advice, each service could just register
> a function to be performed when the hostname changed.
Indeed. We need a mechanism by which any arbitrary events are published
and are received by listeners. Ideally, apart from the basic provision,
such a mechanism provides:
- Publish arbitrary events. This must happen without registering them,
classing them or declaring them.
- Subscriber can subscribe even if the publisher is not available.
Example: PageKite wants react when SSH server port is changed. However,
PageKite does not want to depend on SSH module.
- Subscribing to a wildcard bunch of topics is also a bonus. Example:
publisher publishes a message for particular form change. But the
receiver is interested in all form changes. Some implementations have
hierarchy of topics such as topic 'form.register' will fire 'form.*'
- Get return responses from listeners. To do this, perform the
dispatching of event in synchronous manner.
- Hold weak references to listener so that they can be garbage collected
without worrying about unsubscribing.
> Do you have any recommendations for tools or approaches (preferably with
> working examples) that we could learn from to apply to Plinth? I've
> found a few examples, but I don't see an obvious best way forward yet.
I have spent significant amount of time with Drupal CMS it has 'hook'
mechanism that is quite nice. I just checkout Django's signal
mechanism. PyPubSub module has more ideal properties from the
I shall dig more.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: OpenPGP digital signature
More information about the Freedombox-discuss