--- a/web/views/baseviews.py Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/baseviews.py Wed Sep 23 19:40:19 2009 +0200
@@ -44,7 +44,7 @@
def call(self, **kwargs):
self.w(u'<div class="searchMessage"><strong>%s</strong></div>\n'
- % self.req._('No result matching query'))
+ % self._cw._('No result matching query'))
class FinalView(AnyRsetView):
@@ -69,11 +69,11 @@
_('%d seconds')
def cell_call(self, row, col, props=None, format='text/html'):
- etype = self.rset.description[row][col]
- value = self.rset.rows[row][col]
+ etype = self.cw_rset.description[row][col]
+ value = self.cw_rset.rows[row][col]
if etype == 'String':
- entity, rtype = self.rset.related_entity(row, col)
+ entity, rtype = self.cw_rset.related_entity(row, col)
if entity is not None:
# yes !
self.w(entity.printable_value(rtype, value, format=format))
@@ -93,21 +93,21 @@
else:
space = ' '
if value.days > 730: # 2 years
- self.w(self.req.__('%%d%syears' % space) % (value.days // 365))
+ self.w(self._cw.__('%%d%syears' % space) % (value.days // 365))
elif value.days > 60: # 2 months
- self.w(self.req.__('%%d%smonths' % space) % (value.days // 30))
+ self.w(self._cw.__('%%d%smonths' % space) % (value.days // 30))
elif value.days > 14: # 2 weeks
- self.w(self.req.__('%%d%sweeks' % space) % (value.days // 7))
+ self.w(self._cw.__('%%d%sweeks' % space) % (value.days // 7))
elif value.days > 2:
- self.w(self.req.__('%%d%sdays' % space) % int(value.days))
+ self.w(self._cw.__('%%d%sdays' % space) % int(value.days))
elif value.seconds > 3600:
- self.w(self.req.__('%%d%shours' % space) % int(value.seconds // 3600))
+ self.w(self._cw.__('%%d%shours' % space) % int(value.seconds // 3600))
elif value.seconds >= 120:
- self.w(self.req.__('%%d%sminutes' % space) % int(value.seconds // 60))
+ self.w(self._cw.__('%%d%sminutes' % space) % int(value.seconds // 60))
else:
- self.w(self.req.__('%%d%sseconds' % space) % int(value.seconds))
+ self.w(self._cw.__('%%d%sseconds' % space) % int(value.seconds))
return
- self.wdata(printable_value(self.req, etype, value, props))
+ self.wdata(printable_value(self._cw, etype, value, props))
# XXX deprecated
@@ -119,9 +119,9 @@
"""the secondary view for an entity
secondary = icon + view(oneline)
"""
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
self.w(u' ')
- self.wview('oneline', self.rset, row=row, col=col)
+ self.wview('oneline', self.cw_rset, row=row, col=col)
class OneLineView(EntityView):
@@ -131,9 +131,9 @@
def cell_call(self, row, col):
"""the one line view for an entity: linked text view
"""
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
self.w(u'<a href="%s">' % xml_escape(entity.absolute_url()))
- self.w(xml_escape(self.view('text', self.rset, row=row, col=col)))
+ self.w(xml_escape(self._cw.view('text', self.cw_rset, row=row, col=col)))
self.w(u'</a>')
@@ -150,11 +150,11 @@
Views applicable on None result sets have to override this method
"""
- rset = self.rset
+ rset = self.cw_rset
if rset is None:
raise NotImplementedError, self
for i in xrange(len(rset)):
- self.wview(self.id, rset, row=i, **kwargs)
+ self.wview(self.__regid__, rset, row=i, **kwargs)
if len(rset) > 1:
self.w(u"\n")
@@ -170,20 +170,20 @@
show_eid = True
def cell_call(self, row, col):
- _ = self.req._
- entity = self.rset.get_entity(row, col)
+ _ = self._cw._
+ entity = self.cw_rset.get_entity(row, col)
self.w(u'<div class="metadata">')
if self.show_eid:
self.w(u'#%s - ' % entity.eid)
if entity.modification_date != entity.creation_date:
self.w(u'<span>%s</span> ' % _('latest update on'))
self.w(u'<span class="value">%s</span>, '
- % self.format_date(entity.modification_date))
+ % self._cw.format_date(entity.modification_date))
# entities from external source may not have a creation date (eg ldap)
if entity.creation_date:
self.w(u'<span>%s</span> ' % _('created on'))
self.w(u'<span class="value">%s</span>'
- % self.format_date(entity.creation_date))
+ % self._cw.format_date(entity.creation_date))
if entity.creator:
self.w(u' <span>%s</span> ' % _('by'))
self.w(u'<span class="value">%s</span>' % entity.creator.name())
@@ -194,7 +194,7 @@
__regid__ = 'textincontext'
title = None # not listed as a possible view
def cell_call(self, row, col):
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
self.w(entity.dc_title())
@@ -202,7 +202,7 @@
__regid__ = 'textoutofcontext'
def cell_call(self, row, col):
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
self.w(entity.dc_long_title())
@@ -210,12 +210,12 @@
__regid__ = 'incontext'
def cell_call(self, row, col):
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
desc = cut(entity.dc_description(), 50)
self.w(u'<a href="%s" title="%s">' % (
xml_escape(entity.absolute_url()), xml_escape(desc)))
- self.w(xml_escape(self.view('textincontext', self.rset,
- row=row, col=col)))
+ self.w(xml_escape(self._cw.view('textincontext', self.cw_rset,
+ row=row, col=col)))
self.w(u'</a>')
@@ -223,12 +223,12 @@
__regid__ = 'outofcontext'
def cell_call(self, row, col):
- entity = self.rset.get_entity(row, col)
+ entity = self.cw_rset.get_entity(row, col)
desc = cut(entity.dc_description(), 50)
self.w(u'<a href="%s" title="%s">' % (
xml_escape(entity.absolute_url()), xml_escape(desc)))
- self.w(xml_escape(self.view('textoutofcontext', self.rset,
- row=row, col=col)))
+ self.w(xml_escape(self._cw.view('textoutofcontext', self.cw_rset,
+ row=row, col=col)))
self.w(u'</a>')
@@ -245,8 +245,8 @@
:param listid: the DOM id to use for the root element
"""
# XXX much of the behaviour here should probably be outside this view
- if subvid is None and 'subvid' in self.req.form:
- subvid = self.req.form.pop('subvid') # consume it
+ if subvid is None and 'subvid' in self._cw.form:
+ subvid = self._cw.form.pop('subvid') # consume it
if listid:
listid = u' id="%s"' % listid
else:
@@ -256,7 +256,7 @@
self.w(u'<ul>\n')
else:
self.w(u'<ul%s class="%s">\n' % (listid, klass or 'section'))
- for i in xrange(self.rset.rowcount):
+ for i in xrange(self.cw_rset.rowcount):
self.cell_call(row=i, col=0, vid=subvid, **kwargs)
self.w(u'</ul>\n')
if title:
@@ -264,7 +264,7 @@
def cell_call(self, row, col=0, vid=None, **kwargs):
self.w(u'<li>')
- self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs)
+ self.wview(self.item_vid, self.cw_rset, row=row, col=col, vid=vid, **kwargs)
self.w(u'</li>\n')
@@ -273,7 +273,7 @@
@property
def redirect_vid(self):
- if self.req.search_state[0] == 'normal':
+ if self._cw.search_state[0] == 'normal':
return 'outofcontext'
return 'outofcontext-search'
@@ -281,11 +281,11 @@
if not vid:
vid = self.redirect_vid
try:
- self.wview(vid, self.rset, row=row, col=col, **kwargs)
+ self.wview(vid, self.cw_rset, row=row, col=col, **kwargs)
except NoSelectableObject:
if vid == self.redirect_vid:
raise
- self.wview(self.redirect_vid, self.rset, row=row, col=col, **kwargs)
+ self.wview(self.redirect_vid, self.cw_rset, row=row, col=col, **kwargs)
class SimpleListView(ListItemView):
@@ -302,17 +302,17 @@
@property
def title(self):
- etype = iter(self.rset.column_types(0)).next()
- return display_name(self.req, etype, form='plural')
+ etype = iter(self.cw_rset.column_types(0)).next()
+ return display_name(self._cw, etype, form='plural')
def call(self, **kwargs):
"""display a list of entities by calling their <item_vid> view"""
- if not 'vtitle' in self.req.form:
+ if not 'vtitle' in self._cw.form:
self.w(u'<h1>%s</h1>' % self.title)
super(AdaptedListView, self).call(**kwargs)
def cell_call(self, row, col=0, vid=None, **kwargs):
- self.wview(self.item_vid, self.rset, row=row, col=col, vid=vid, **kwargs)
+ self.wview(self.item_vid, self.cw_rset, row=row, col=col, vid=vid, **kwargs)
class AdaptedListItemView(ListItemView):
@@ -324,7 +324,7 @@
redirect_vid = 'incontext'
def call(self, **kwargs):
- rset = self.rset
+ rset = self.cw_rset
for i in xrange(len(rset)):
self.cell_call(i, 0, vid=kwargs.get('vid'))
if i < rset.rowcount-1:
@@ -335,7 +335,7 @@
__regid__ = 'treeitem'
def cell_call(self, row, col):
- self.wview('incontext', self.rset, row=row, col=col)
+ self.wview('incontext', self.cw_rset, row=row, col=col)
class TextSearchResultView(EntityView):
"""this view is used to display full-text search
@@ -347,9 +347,9 @@
__regid__ = 'tsearch'
def cell_call(self, row, col, **kwargs):
- entity = self.complete_entity(row, col)
+ entity = self.cw_rset.complete_entity(row, col)
self.w(entity.view('incontext'))
- searched = self.rset.searched_text()
+ searched = self.cw_rset.searched_text()
if searched is None:
return
searched = searched.lower()
@@ -376,7 +376,7 @@
"""A entity view used in a tooltip"""
__regid__ = 'tooltip'
def cell_call(self, row, col):
- self.wview('oneline', self.rset, row=row, col=col)
+ self.wview('oneline', self.cw_rset, row=row, col=col)
# XXX bw compat