- 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
+ # using a simple incremental scheme to generate domids for now
+ # we just need this to be unique in a page
+ domid=0
+
+ @staticmethod
+ def newdomid():
+ Plugin.domid += 1
+ return "plugin-%d"%Plugin.domid
+
+ ##########
+ # Constructor
+ #### mandatory
+ # . title: is used visually for displaying the widget
+ #### optional
+ # . togglable: whether it can be turned on and off (like PleKitToggle)
+ # . toggled: if togglable, what's the initial status
+ # . visible: if not set the plugin does not show up at all
+ # (not quite sure what this was for)
+ #### internal data
+ # . domid: created internally, but can be set at creation time if needed
+ # useful for hand-made css, or for selecting an active plugin in a composite
+ # . rank: this is for plugins sons of a composite plugin
+ #### custom
+ # any other setting can also be set when creating the object, like
+ # p=Plugin(foo='bar')
+ # which will result in 'foo' being accessible to the template engine
+ #
+ def __init__ (self, title, domid=None,
+ visible=True, togglable=True, toggled=True, **settings):
+ # what is in this dictionary will get exposed to template and to javascript
+ self._settings=settings
+ self.title=title
+ if not domid: domid=Plugin.newdomid()
+ self.domid=domid
+ self.classname=self._classname()
+ self.add_to_settings ( ['title', 'domid', 'classname'] )