A PyLucid plugin is very similar to a Django App, with views.py, models.py, template-dirs etc.
The Plugins stored in special directories:
| ../pylucid_project/pylucid_plugins/ | all shipped with PyLucid |
| ../pylucid_project/external_plugins/ | for external plugins, installed by users |
All Plugins in theses special directories would be automatic insert in settings.INSTALLED_APPS and settings.TEMPLATE_DIRS
There are a few API/callbacks in PyLucid for theses plugins. Read below...
| view type | HttpResponse | inline | urls.py |
|---|---|---|---|
| lucidTag | - | X | - |
| http_get_views() | X | X | - |
| PluginPage | X | X | X |
| context middleware | X | X | - |
explanation:
Probably the most used API. Used by many plugins e.g.: auth (insert login/logout link), RSS to insert a feed into the page.
A lucidTag is the simples plugin API. It's nice to insert dynamic stuff into a page. You can insert lucidTag into PageContent or into the global page template.
The plugin must only defined a lucidTag function in the views.py file and return a string/unicode content.
The lucidTag is a django template tag, witch called the view function. It's allways available.
Defined in pylucid_project/apps/pylucid/defaulttags/lucidTag.py
tag syntax looks like this:
examples:
The followed tag calls the view lucidTag(request, id=123) from pylucid_plugins/poll/views.py:
This tag calls all_polls() from pylucid_plugins/poll/views.py:
for surounding the plugin output with a DIV or SPAN tag the plugin template can extends from css_anchor_div or css_anchor_span, e.g:
used by e.g.: auth login/logout views
Requested via http GET Parameter, e.g.:
http_get_views() can return:
used by e.g.: blog plugin
A PluginPage is one type of plugin PageTree. The plugin has his own urls.py file. These urls would be "inserted" at the PageTree point.
The admin must create a PageTree entry from type plugin and select the plugin.
It's for "big" plugins witch has more than one view.
The template/output must extends from template, e.g.:
To 'insert' a page into the django admin panel, extends from admin/base_site.html, e.g.:
used by e.g.: breadcrumb
see also:
plugin has a context_middleware.py with a ContextMiddleware class witch has a render method.
context middleware plugin are inserted via a special tag:
The Plugin ContextMiddleware.render() method should return None or a HttpResponse object. The content from the response would be replace the tag.
django-processinfo: 9.7 ms of 587.3 ms (1.7%)