X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=unfold%2Fplugin.py;h=f0b6128e9ebf59966388028bf8cf3b0f51bed967;hb=544e6ac78d490061f848f98adb0e08574b474371;hp=f9e1ea41b07f380fbc5b3645c2f514fb316af2d8;hpb=c8ac1863026e5736065065e931e20de310cb3b06;p=myslice.git diff --git a/unfold/plugin.py b/unfold/plugin.py index f9e1ea41..f0b6128e 100644 --- a/unfold/plugin.py +++ b/unfold/plugin.py @@ -32,10 +32,14 @@ class Plugin: # we just need this to be unique in a page domid=0 - @staticmethod - def newdomid(): + # when a domid is not set by the caller, we name plugins after their respective class as well, + # so as to limit name clashes between different views + # this has to see with the UI storing the last-seen status of plugins based on their id + # put it more bluntly it is recommended that a domid should be set + # and maybe xxx we should just enforce that... + def newdomid(self): Plugin.domid += 1 - return "plugin-%d"%Plugin.domid + return "plugin-%s-%d"%(self.__class__.__name__.lower(),Plugin.domid) ########## # Constructor @@ -65,13 +69,15 @@ class Plugin: # p=Plugin(foo='bar') # which will result in 'foo' being accessible to the template engine # - def __init__ (self, page, title, domid=None, + def __init__ (self, page, title=None, domid=None, visible=True, togglable=None, toggled=None, **settings): self.page = page - self.title=title # callers can provide their domid for css'ing - if not domid: domid=Plugin.newdomid() + if not domid: domid=self.newdomid() self.domid=domid + # title is shown when togglable + if not title: title="Plugin title for %s"%domid + self.title=title self.classname=self._py_classname() self.plugin_classname=self._js_classname() self.visible=visible