1 # this is the abstract interface for Plugin instances
2 # so it should be specialized in real plugin classes
3 # like e.g. plugins.simplelist.SimpleList
5 from django.template.loader import render_to_string
11 def __init__ (self, **settings):
14 # we store as a dictionary the arguments passed to constructor
15 # e.g. SimpleList (visible=True) => _settings = {'visible':True}
16 self._settings=settings
18 def get_class (self): return type(self).__name__
20 # shorthands to inspect _settings
21 def get_setting (self, setting, default):
22 if setting not in self._settings: return default
23 else: return self._settings[setting]
25 def is_visible (self): return self.get_setting ('visible',True)
26 def is_hidable (self): return self.get_setting ('hidable',False)
27 def is_hidden_by_default (self): return self.get_setting ('hidden_by_default', False)
29 # returns the html code for that plugin
30 # in essence, wraps the results of self.render_content ()
33 title = self.get_class()
34 plugin_content = self.render_content ()
36 # xxx missing from the php version
37 # compute an 'optionstr' from the set of available settings/options as a json string
38 # that gets passed to jquery somehow
40 result = render_to_string ('plugin-wrap.html',
41 {'uuid':uuid, 'title':title,
42 'visible':self.is_visible(),
43 'hidable':self.is_hidable(),
44 'hidden':self.is_hidden_by_default(),
45 'plugin_content' : plugin_content,
46 'optionstr' : 'xxx-todo',