- # expose _settings in json format to js
- settings_json = json.dumps (self._settings, separators=(',',':'))
-
- result = render_to_string ('plugin.html',
- {'uuid':uuid,
- 'classname':classname,
- 'visible':self.is_visible(),
- 'hidable':self.is_hidable(),
- 'hidden':self.is_hidden_by_default(),
- 'plugin_content' : plugin_content,
- 'settings_json' : settings_json,
- })
-
- # handle requirements() if defined on this class
- try:
- self.handle_requirements (request, self.requirements())
- except AttributeError:
- # most likely the object does not have that method defined, which is fine
- pass
- except:
- import traceback
- traceback.print_exc()
- pass
+ # shove this into plugin.html
+ env = {}
+ env ['plugin_content']= plugin_content
+ env.update(self._settings)
+ result = render_to_string ('plugin.html',env)
+
+ # expose _settings in json format to js, and add plugin_uuid: domid in the mix
+ # NOTE this plugin_uuid thing might occur in js files, ** do not rename **
+ js_env = { 'plugin_uuid' : self.domid }
+ js_env.update (self._settings)
+ for k in self.exclude_from_json():
+ if k in js_env: del js_env[k]
+ settings_json = json.dumps (js_env, separators=(',',':'))
+ env ['settings_json' ] = settings_json
+ # compute plugin-specific initialization
+ js_init = render_to_string ( 'plugin-setenv.js', env )
+ self.add_js_chunks (request, js_init)
+
+ # interpret the result of requirements ()
+ self.handle_requirements (request)