self.title=title
if not domid: domid=Plugin.newdomid()
self.domid=domid
- self.classname=self._classname()
+ self.classname=self._py_classname()
+ self.plugin_classname=self._js_classname()
self.visible=visible
self.togglable=togglable
self.toggled=toggled
# do this only once the structure is fine
self.pluginset.record_plugin(self)
- def _classname (self):
+ def _py_classname (self):
try: return self.__class__.__name__
except: return 'Plugin'
+ def _js_classname (self):
+ try: return self.plugin_classname ()
+ except: return self._py_classname()
+
##########
def need_debug (self):
if not DEBUG: return False
# also 'query_uuid' gets replaced with query.uuid
def json_settings_list (self): return ['json_settings_list-must-be-redefined']
+ # might also define this one; see e.g. slicelist.py that piggybacks simplelist js code
+ # def plugin_classname (self):
-$(document).ready(function() { jQuery('#{{ domid }}').{{ classname }}({{ settings_json|safe }}); });
+$(document).ready(function() { jQuery('#{{ domid }}').{{ plugin_classname }}({{ settings_json|safe }}); });
class SimpleList (Plugin) :
# only deal with our own stuff here and let Plugin handle the rest
- def __init__ (self, list=[], with_datatables=False, **settings):
+ def __init__ (self, key, value, with_datatables=False, **settings):
Plugin.__init__ (self, **settings)
- self.list=list
+ self.key=key
+ self.value=value
self.with_datatables = with_datatables
# SimpleList is useless per se anyways
from plugins.simplelist import SimpleList
+# the SimpleList plugin requires 'key' and 'value' that are used
+# on the results of the query for rendering
class SliceList (SimpleList):
- def __init__ (self, list=[], **settings):
- SimpleList.__init__(self, **settings)
- self.list = [ "<a href='/slice/%s/' class='slicelist'>%s</a>"%(x,x) for x in list ]
+ def __init__ (self, **settings):
+ SimpleList.__init__(self, key='slice_hrn', value='slice_hrn', **settings)
-# def requirements (self):
-# reqs=SimpleList.requirements(self)
-# reqs['js_files'].append('slice.js')
-# reqs['js_files'].append('slice2.js')
-# reqs['css_files'].append('slice.css')
-# reqs['css_files'].append('slice2.css')
-# reqs['js_chunks']=['js chunk1','js chunk2']
-# reqs['css_chunks']=['css chunk1','css chunk2']
-# return reqs
+ # writing a js plugin for that would be overkill, just use SimpleList
+ def plugin_classname (self):
+ return 'SimpleList'
}
var options = e.data.data().SimpleList.options;
var is_cached = options.query.timestamp != 'now' ? true : false;
+ // here is where we use 'key' and 'value' from the SimpleList (python) constructor
html_code=myslice_html_ul(rows, options.key, options.value, is_cached)+"<br/>";
e.data.html(html_code);
var $elt = e.data;
from engine.pluginset import PluginSet
from engine.manifoldquery import ManifoldQuery
-from plugins.simplelist import SimpleList
+from plugins.slicelist import SliceList
#
from myslice.viewutils import topmenu_items, the_user
# xxx filter : should filter on the slices the logged user can see
# we don't have the user's hrn yet
# in addition this currently returns all slices anyways
+ # filter = ...
sort='slice_hrn',)
pluginset.enqueue_query (slices_query)
- main_plugin = SimpleList ( # setting visible attributes first
+ main_plugin = SliceList ( # setting visible attributes first
pluginset=pluginset,
- title='Asynchroneous SimpleList',
+ title='Asynchroneous SliceList',
header='slices list',
with_datatables=True,
toggled=True,
# this is required for the javascript code
query=slices_query,
- key='slice_hrn',
- value='slice_hrn',
+# key='slice_hrn',
+# value='slice_hrn',
)
# variables that will get passed to the view-plugin.html template