plugin / intra process communication system
Florian Ludwig
dino at phidev.org
Mon Feb 15 17:12:23 EST 2010
On Sun, 2010-02-14 at 18:47 +0100, Diez B. Roggisch wrote:
> > Here there problem with the trac (and other plugin systems I've
> seen)
> > approach:
> >
> > You need to define something like:
> > |
> > | class IAuthPlugin(Interface): [...]
> > |
> > in your blog software.
>
> Why? Any reason you can't define it in a separate package the
> blog-software depends on, as well as your wiki?
That's actually my point - most plugin systems I've seen, like the one
trac uses, are not encouraging you to do so. Having a module that just
defines an Interface is kind of weird - and in the real world no one is
doing it.
> And then of course, this is not really needed. In Python, behavior
> counts, not type-information. So you can get away without any explicit
> declared interface. You might chose to not do that, for aestetic
> reasons, or better documentation. But you aren't forced.
Actually some plugin-systems in python do force you and they check if
your "implementation" comply with the "interface".
Here is one solution I came up with. Based on the earlier example:
> > Lets say you program a wiki and like to allow different kind of
> > authentications. So you create two plugins (for example one for
> > OpenID and one for Shibboleth).
> >
> > Some time later you feel like reinventing the wheel again and
> > you program a blog. Again you like to allow different ways of
> > authentication and you already wrote plugins for exactly the
> > same for your wiki, right?
auth_openid.py - providing the authentication service
http://dpaste.com/hold/159619/
wiki.py - providing the wiki
http://dpaste.com/hold/159634/
Now putting both together:
> import pbus
>
> import wiki
> import auth_openid
> # or: import auth_shibboleth
>
> pbus.get("wiki").run()
No interface definitions.
What do you think? Any obvious pitfalls (besides reinventing something)?
Please keep in mind that syntax/api is not "done" or anything its just
an concept presentation.
Thanks,
Florian
--
Florian Ludwig <dino at phidev.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20100215/203003f6/attachment-0001.sig>
More information about the Python-list
mailing list