--- a/web/views/basecontrollers.py Mon May 18 14:36:09 2009 +0200
+++ b/web/views/basecontrollers.py Mon May 18 14:36:26 2009 +0200
@@ -487,6 +487,24 @@
rql = 'DELETE B bookmarked_by U WHERE B eid %(b)s, U eid %(u)s'
self.req.execute(rql, {'b': typed_eid(beid), 'u' : self.req.user.eid})
+ def js_node_clicked(self, treeid, nodeeid):
+ """add/remove eid in treestate cookie"""
+ from cubicweb.web.views.treeview import treecookiename
+ cookies = self.req.get_cookie()
+ statename = treecookiename(treeid)
+ treestate = cookies.get(statename)
+ if treestate is None:
+ cookies[statename] = nodeeid
+ self.req.set_cookie(cookies, statename)
+ else:
+ marked = set(filter(None, treestate.value.split(';')))
+ if nodeeid in marked:
+ marked.remove(nodeeid)
+ else:
+ marked.add(nodeeid)
+ cookies[statename] = ';'.join(marked)
+ self.req.set_cookie(cookies, statename)
+
def js_set_cookie(self, cookiename, cookievalue):
# XXX we should consider jQuery.Cookie
cookiename, cookievalue = str(cookiename), str(cookievalue)
--- a/web/views/treeview.py Mon May 18 14:36:09 2009 +0200
+++ b/web/views/treeview.py Mon May 18 14:36:26 2009 +0200
@@ -13,7 +13,6 @@
from cubicweb.interfaces import ITree
from cubicweb.selectors import implements
from cubicweb.view import EntityView
-from cubicweb.web.views.basecontrollers import jsonize, JSonController
def treecookiename(treeid):
return str('treestate-%s' % treeid)
@@ -149,21 +148,3 @@
self.wview(parentvid, self.req.execute(rql), treeid=treeid, initial_load=False)
w(u'</li>')
-@monkeypatch(JSonController)
-@jsonize
-def js_node_clicked(self, treeid, nodeeid):
- """add/remove eid in treestate cookie"""
- cookies = self.req.get_cookie()
- statename = treecookiename(treeid)
- treestate = cookies.get(statename)
- if treestate is None:
- cookies[statename] = nodeeid
- self.req.set_cookie(cookies, statename)
- else:
- marked = set(filter(None, treestate.value.split(';')))
- if nodeeid in marked:
- marked.remove(nodeeid)
- else:
- marked.add(nodeeid)
- cookies[statename] = ';'.join(marked)
- self.req.set_cookie(cookies, statename)