--- a/web/box.py Wed Sep 23 19:26:38 2009 +0200
+++ b/web/box.py Wed Sep 23 19:40:19 2009 +0200
@@ -77,18 +77,18 @@
return self.box_action(self._action(title, path, **kwargs))
def _action(self, title, path, **kwargs):
- return UnregisteredAction(self.req, self.rset, title, path, **kwargs)
+ return UnregisteredAction(self._cw, self.cw_rset, title, path, **kwargs)
# formating callbacks
def boxitem_link_tooltip(self, action):
- if action.id:
- return u'keyword: %s' % action.id
+ if action.__regid__:
+ return u'keyword: %s' % action.__regid__
return u''
def box_action(self, action):
cls = getattr(action, 'html_class', lambda: None)() or self.htmlitemclass
- return BoxLink(action.url(), self.req._(action.title),
+ return BoxLink(action.url(), self._cw._(action.title),
cls, self.boxitem_link_tooltip(action))
@@ -105,18 +105,18 @@
rql = None
def to_display_rql(self):
- assert self.rql is not None, self.id
+ assert self.rql is not None, self.__regid__
return (self.rql,)
def call(self, **kwargs):
try:
- rset = self.req.execute(*self.to_display_rql())
+ rset = self._cw.execute(*self.to_display_rql())
except Unauthorized:
# can't access to something in the query, forget this box
return
if len(rset) == 0:
return
- box = BoxWidget(self.req._(self.title), self.id)
+ box = BoxWidget(self._cw._(self.title), self.__regid__)
for i, (teid, tname) in enumerate(rset):
entity = rset.get_entity(i, 0)
box.append(self.mk_action(tname, entity.absolute_url()))
@@ -129,8 +129,8 @@
"""
def to_display_rql(self):
- assert self.rql is not None, self.id
- return (self.rql, {'x': self.req.user.eid}, 'x')
+ assert self.rql is not None, self.__regid__
+ return (self.rql, {'x': self._cw.user.eid}, 'x')
class EntityBoxTemplate(BoxTemplate):
@@ -147,12 +147,12 @@
__select__ = EntityBoxTemplate.__select__ & partial_has_related_entities()
def cell_call(self, row, col, **kwargs):
- entity = self.rset.get_entity(row, col)
- limit = self.req.property_value('navigation.related-limit') + 1
+ entity = self.cw_rset.get_entity(row, col)
+ limit = self._cw.property_value('navigation.related-limit') + 1
role = get_role(self)
self.w(u'<div class="sideBox">')
self.wview('sidebox', entity.related(self.rtype, role, limit=limit),
- title=display_name(self.req, self.rtype, role))
+ title=display_name(self._cw, self.rtype, role))
self.w(u'</div>')
@@ -165,9 +165,9 @@
"""
def cell_call(self, row, col, view=None, **kwargs):
- self.req.add_js('cubicweb.ajax.js')
- entity = self.rset.get_entity(row, col)
- box = SideBoxWidget(display_name(self.req, self.rtype), self.id)
+ self._cw.add_js('cubicweb.ajax.js')
+ entity = self.cw_rset.get_entity(row, col)
+ box = SideBoxWidget(display_name(self._cw, self.rtype), self.__regid__)
related = self.related_boxitems(entity)
unrelated = self.unrelated_boxitems(entity)
box.extend(related)
@@ -177,7 +177,7 @@
box.render(self.w)
def div_id(self):
- return self.id
+ return self.__regid__
def box_item(self, entity, etarget, rql, label):
"""builds HTML link to edit relation between `entity` and `etarget`
@@ -218,12 +218,12 @@
return entity.unrelated(self.rtype, self.etype, get_role(self)).entities()
# in other cases, use vocabulary functions
entities = []
- form = self.vreg['forms'].select('edition', self.req, rset=self.rset,
- row=self.row or 0)
+ form = self.vreg['forms'].select('edition', self._cw, rset=self.cw_rset,
+ row=self.cw_row or 0)
field = form.field_by_name(self.rtype, get_role(self), entity.e_schema)
for _, eid in form.form_field_vocabulary(field):
if eid is not None:
- rset = self.req.eid_rset(eid)
+ rset = self._cw.eid_rset(eid)
entities.append(rset.get_entity(0, 0))
return entities