# . True : to debug all plugin
DEBUG= False
-DEBUG= [ 'SimpleList' ]
-DEBUG=True
+#DEBUG= [ 'SimpleList' ]
+#DEBUG=True
# decorator to deflect calls on Plugin to its Prelude through self.page.prelude
def to_prelude (method):
# . page: the context of the request being served
# . 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)
+ # . togglable: whether it can be turned on and off by clicking on the title (like PleKitToggle)
+ # . toggled: whether the plugin should startup open/shown or closed/hidden
+ #### xxx NOTE : pending move towards a more elaborate mode for 'toggled'
+ # . toggled: if togglable, what's the initial status; possible values are
+ # .. True : start up open/hidden
+ # .. False : start up closed/shown
+ # .. 'last' : start up as it was the last time that browser showed it (based on 'domid')
+ # .. None : if not passed to __init__ at all, then the DefaultTaggled() method is called
+ # .. : anything else, defaults to True
+ #### xxx NOTE : pending move towards a more elaborate mode for 'toggled'
+ #
#### 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
# do this only once the structure is fine
self.page.record_plugin(self)
+ def __repr__ (self):
+ return "[%s]:%s"%(self.classname,self.domid)
+
def _py_classname (self):
try: return self.__class__.__name__
except: return 'Plugin'
except: return '%s:"undefined"'%setting
else:
value=getattr(self,setting,None)
- if not value: value = "unknown-setting-%s"%setting
+ if value is None: value = "unknown-setting-%s"%setting
# first try to use to_json method (json.dumps not working on class instances)
try: value_json=value.to_json()
except: value_json=json.dumps(value,separators=(',',':'))
def render_content (self, request):
"""Should return an HTML fragment"""
template = self.template_file()
- env=self.template_env(request)
+ # start with a fresh one
+ env={}
+ # add our own settings as defaults
+ env.update(self.__dict__)
+ # then the things explicitly defined in template_env()
+ env.update(self.template_env(request))
if not isinstance (env,dict):
raise Exception, "%s.template_env returns wrong type"%self.classname
result=render_to_string (template, env)