Menu:

page message
  • PageMeta v0-9-plugin-api existiert nicht in der bevorzugten Sprache deutsch, benutzte english.

new v0.9 plugin api

↑ view types  #

view type HttpResponse inline urls.py
lucidTag - X -
http_get_views() X X -
PluginPage X X X
context middleware X X -

explanation:

  • HttpResponse:
    • Plugin can build a complete page via return HttpResponse object
    • Plugin can return other response type, e.g.: HttpRedirect
  • inline:
    • Plugin can replace the normal page content with this own content
  • urls.py:
    • Plugin can have more than one view

↑ plugin hooks  #

↑ lucidTag  #

used by e.g.: auth (insert login/logout link)

A lucidTag is the simples plugin API. It's nice to insert dynamic stuff into a page. The Admin 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:

HTML+Django/Jinja
1
2
3
{% lucidTag PluginName %}
{% lucidTag PluginName kwarg1="value1" %}
{% lucidTag PluginName kwarg1="value1" kwarg2="value2" %}

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:

HTML+Django
1
2
3
4
5
{% extends "pylucid/css_anchor_div.html" %}

{% block plugin_content %}
...the plugin html template content...
{% endblock %}

↑ http_get_views()  #

used by e.g.: auth login/logout views

Requested via http GET Parameter.
e.g.: domain.tld/en/pageslug/?auth=login

view can return:

↑ PluginPage  #

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.:

HTML+Django/Jinja
1
2
3
4
5
{% extends template_name %}

{% block content %}
...the plugin html template content...
{% endblock content %}

To 'insert' a page into the django admin panel, extends from admin/base_site.html, e.g.:

HTML+Django/Jinja
1
2
3
4
5
{% extends "admin/base_site.html" %}

{% block content %}
...the plugin html template content...
{% endblock content %}

↑ context middleware  #

used by e.g.: breadcrumb

see also: http://forum.pylucid.org/viewtopic.php?t=276&highlight=context+middleware (de)

plugin has a context_middleware.py with a ContextMiddleware class witch has a render method.

context middleware plugin are inserted via a special tag:

HTML
1
<!-- ContextMiddleware PluginName -->

The Plugin ContextMiddleware.render() method should return None or a HttpResponse object. The content from the response would be replace the tag.

tag navi api | plugin | pylucid | pylucid v0.9
Fork me on GitHub