git://git.onelab.eu
/
unfold.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tabs don't get outlined
[unfold.git]
/
unfold
/
plugin.py
diff --git
a/unfold/plugin.py
b/unfold/plugin.py
index
17931b6
..
278c362
100644
(file)
--- a/
unfold/plugin.py
+++ b/
unfold/plugin.py
@@
-16,8
+16,8
@@
from unfold.prelude import Prelude
# . True : to debug all plugin
DEBUG= False
# . True : to debug all plugin
DEBUG= False
-#DEBUG= [ 'S
lic
eList' ]
-DEBUG=True
+#DEBUG= [ 'S
impl
eList' ]
+
#
DEBUG=True
# decorator to deflect calls on Plugin to its Prelude through self.page.prelude
def to_prelude (method):
# decorator to deflect calls on Plugin to its Prelude through self.page.prelude
def to_prelude (method):
@@
-80,6
+80,9
@@
class Plugin:
# do this only once the structure is fine
self.page.record_plugin(self)
# 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'
def _py_classname (self):
try: return self.__class__.__name__
except: return 'Plugin'
@@
-150,7
+153,7
@@
class Plugin:
if self.export_json_settings():
env ['settings_json' ] = self.settings_json()
# compute plugin-specific initialization
if self.export_json_settings():
env ['settings_json' ] = self.settings_json()
# compute plugin-specific initialization
- js_init = render_to_string ( 'plugin-
setenv
.js', env )
+ js_init = render_to_string ( 'plugin-
init
.js', env )
self.add_js_chunks (js_init)
# interpret the result of requirements ()
self.add_js_chunks (js_init)
# interpret the result of requirements ()
@@
-164,7
+167,12
@@
class Plugin:
def render_content (self, request):
"""Should return an HTML fragment"""
template = self.template_file()
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)
if not isinstance (env,dict):
raise Exception, "%s.template_env returns wrong type"%self.classname
result=render_to_string (template, env)