[Freedombox-discuss] Dev: Cross Cutting Concerns in Plinth?

Sunil Mohan 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.*'
listener.

- 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[1][2]. PyPubSub module[3] has more ideal properties from the
list above.

I shall dig more.

Links:

1) https://docs.djangoproject.com/en/1.6/topics/signals/
2) https://pypi.python.org/pypi/dispatcher/1.0
3) http://pubsub.sourceforge.net/index.html

Thank you,

-- 
Sunil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/freedombox-discuss/attachments/20140326/e7772a76/attachment.sig>


More information about the Freedombox-discuss mailing list