George Song kirjoitti: > On 5/23/2009 5:13 AM, Jani Tiainen wrote: >> I'm designing application (site) that is supposed to rely heavily on >> pluings. >> >> i didn't found much of references how I can create plugin that can >> provide something useful for my main template. something like: >> >> myplugin.py: >> >> provide_link = "<a href="{% url myplugin.views.linkaction %}">MyPlugin</a>" >> >> And then in my "core" application template: >> templates/mycore/mycore.html: >> >> {% for plugin in allplugins %}{{ plugin.provide_link }}{% endfor %} >> >> Any pointers to such apps or snippets that uses this (or similiar) >> tehcnique would be appreciated. > > Well, if you break down the problem, it really is just two things: > > 1. Registry > 2. Interface > > Registry > ======== > The registry takes care of the part that when you create a new plugin, > it should be registered somehow as a plugin. > > Django itself is full of this pattern: models, template tags, filters, > admin sites, databrowse, serialization, etc. You can look to those for > ideas and inspirations. The most sophisticated being the models which > relies on a metaclass to do its implicit registration magic.
This one I've solved by metaclass registration magic. And this was the easy part of whole plugin system. > Interface > ========= > This is really internal to the specific plugin domain, so depending on > your needs, you can enforce it a number of ways: simple documentation of > the superclass, putting in a stub of NotImplemented, etc. > I believe in duck typing (documentation of the superclass) rather than explicitly forcing something. I'm just searching for reference implementations how to make something visible in my template. -- Jani Tiainen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---