[ckan-dev] Alternatives to IGenshiStreamFilter?

Sean Hammond snhmnd at gmail.com
Sat Oct 22 14:38:51 UTC 2011


Hey,

I noticed that CKAN extensions that need to modify the HTML templates
tend to implement the filter() method of the IGenshiStreamFilter
interface and do something like this:

stream = stream | Transformer('body//div[@class="dataset"]').append(some_html)

i.e they use XPath to search for a particular HTML element in the genshi
stream and append to it.

The problem is that changes to the CKAN templates can break the
extensions.  The templates are effectively part of the interface that
CKAN presents to extensions. Also, I imagine that it a CKAN instance has
many extensions installed and they're all modifying the templates like
this, the results could get messy.

Would it be better to have a more controlled way for plugins to show
themselves to the user? For example when viewing a dataset the user sees
three tabs View, Edit and History. Perhaps there could be an interface
that lets plugins implement a method that returns a link icon, relative URL
and link text for the plugin's own tab bar item. There could be several
methods like this allowing plugins to add themselves to different parts
of the HTML.

The point is that the HTML templates could change without necessarily
breaking the plugins. It should also help to keep the HTML nice and tidy
and the user interface nice and regular when extensions are being used,
and stop extensions from stepping on each other's toes.




More information about the ckan-dev mailing list