class Plugin:
- uid=0
+ # using a simple incremental scheme to generate uuids for now
+ uuid=0
+
+ @staticmethod
+ def newuuid():
+ Plugin.uuid += 1
+ return Plugin.uuid
def __init__ (self, visible=True, hidable=True, hidden_by_default=False, **settings):
# xxx should generate some random id
- self.uuid=Plugin.uid
- Plugin.uid += 1
+ self.uuid=Plugin.newuuid()
self.visible=visible
self.hidable=hidable
self.hidden_by_default=hidden_by_default
# expose _settings in json format to js
settings_json = json.dumps (self._settings, separators=(',',':'))
- result = render_to_string ('widget-plugin.html',
+ result = render_to_string ('plugin.html',
{'uuid':uuid,
'classname':classname,
'visible':self.is_visible(),
return result
# you may redefine this completely, but if you don't we'll just use methods
- # . template() to find out which template to use, and
- # . render_env() to compute a dictionary to pass along to the templating system
+ # . template_file() to find out which template to use, and
+ # . template_env() to compute a dictionary to pass along to the templating system
def render_content (self, request):
"""Should return an HTML fragment"""
- template = self.template()
- env=self.render_env(request)
+ template = self.template_file()
+ env=self.template_env(request)
if not isinstance (env,dict):
- raise Exception, "%s.render_env returns wrong type"%self.classname()
+ raise Exception, "%s.template_env returns wrong type"%self.classname()
# expose this class's settings to the template
# xxx we might need to check that this does not overwrite env..
env.update(self._settings)
#################### requirements/prelude management
def _init_request (self, request):
if not hasattr (request, 'plugin_prelude'):
- request.plugin_prelude=Prelude()
+ # include css/plugins.css
+ request.plugin_prelude=Prelude(css_files='css/plugin.css')
def inspect_request (self, request, message):
has=hasattr(request,'plugin_prelude')
# your plugin is expected to implement either
# (*) def render_content(self, request) -> html fragment
# -- or --
- # (*) def template(self) -> filename
+ # (*) def template_file(self) -> filename
# relative to STATIC
- # (*) def render_env (self, request) -> dict
+ # (*) def template_env (self, request) -> dict
# this is the variable->value association used to render the template
# in which case the html template will be used
- # if you see this string somewhere your template() code is not kicking in
- def template (self): return "undefined_template"
- def render_env (self, request): return {}
+ # if you see this string somewhere your template_file() code is not kicking in
+ def template_file (self): return "undefined_template"
+ def template_env (self, request): return {}
# # tell the framework about requirements (for the document <header>)
# # the notion of 'Media' in django provides for medium-dependant