--- a/web/views/navigation.py Wed Sep 23 19:26:38 2009 +0200
+++ b/web/views/navigation.py Wed Sep 23 19:40:19 2009 +0200
@@ -26,8 +26,8 @@
def call(self):
"""displays a resultset by page"""
w = self.w
- req = self.req
- rset = self.rset
+ req = self._cw
+ rset = self.cw_rset
page_size = self.page_size
start = 0
blocklist = []
@@ -59,12 +59,12 @@
nb_chars = 5
def display_func(self, rset, col, attrname):
- req = self.req
+ req = self._cw
if attrname is not None:
def index_display(row):
entity = rset.get_entity(row, col)
return entity.printable_value(attrname, format='text/plain')
- elif self.schema.eschema(rset.description[0][col]).is_final():
+ elif self._cw.schema.eschema(rset.description[0][col]).is_final():
def index_display(row):
return unicode(rset[row][col])
else:
@@ -80,9 +80,9 @@
[ana - cro] | [cro - ghe] | ... | [tim - zou]
"""
w = self.w
- rset = self.rset
+ rset = self.cw_rset
page_size = self.page_size
- rschema = self.schema.rschema
+ rschema = self._cw.schema.rschema
# attrname = the name of attribute according to which the sort
# is done if any
for sorterm in rset.syntax_tree().children[0].orderby:
@@ -122,10 +122,10 @@
# nothing usable found, use the first column
index_display = self.display_func(rset, 0, None)
blocklist = []
- params = dict(self.req.form)
+ params = dict(self._cw.form)
self.clean_params(params)
start = 0
- basepath = self.req.relative_path(includeparams=False)
+ basepath = self._cw.relative_path(includeparams=False)
while start < rset.rowcount:
stop = min(start + page_size - 1, rset.rowcount - 1)
cell = self.format_link_content(index_display(start), index_display(stop))
@@ -149,7 +149,7 @@
def limit_rset_using_paged_nav(self, req, rset, w, forcedisplay=False,
show_all_option=True, page_size=None):
if not (forcedisplay or req.form.get('__force_display') is not None):
- nav = self.vreg['components'].select_or_none('navigation', req,
+ nav = self._cw.vreg['components'].select_or_none('navigation', req,
rset=rset, page_size=page_size)
if nav:
# get boundaries before component rendering
@@ -170,8 +170,9 @@
from cubicweb.view import View
View.pagination = deprecated('.pagination is deprecated, use paginate')(limit_rset_using_paged_nav)
-def paginate(view, show_all_option=True, w=None, page_size=None):
- limit_rset_using_paged_nav(view, view.req, view.rset, w or view.w,
+def paginate(view, show_all_option=True, w=None, page_size=None, rset=None):
+ rset = rset or view.cw_rset
+ limit_rset_using_paged_nav(view, view._cw, view.cw_rset, w or view.w,
not view.need_navigation, show_all_option,
page_size=page_size)
View.paginate = paginate
@@ -187,23 +188,23 @@
context = 'navbottom'
order = 10
def call(self, view=None):
- entity = self.rset.get_entity(0,0)
+ entity = self.cw_rset.get_entity(0,0)
previous = entity.previous_entity()
next = entity.next_entity()
if previous or next:
- textsize = self.req.property_value('navigation.short-line-size')
+ textsize = self._cw.property_value('navigation.short-line-size')
self.w(u'<div class="prevnext">')
if previous:
self.w(u'<div class="previousEntity left">')
self.w(self.previous_link(previous, textsize))
self.w(u'</div>')
- self.req.html_headers.add_raw('<link rel="prev" href="%s" />'
+ self._cw.html_headers.add_raw('<link rel="prev" href="%s" />'
% xml_escape(previous.absolute_url()))
if next:
self.w(u'<div class="nextEntity right">')
self.w(self.next_link(next, textsize))
self.w(u'</div>')
- self.req.html_headers.add_raw('<link rel="next" href="%s" />'
+ self._cw.html_headers.add_raw('<link rel="next" href="%s" />'
% xml_escape(next.absolute_url()))
self.w(u'</div>')
self.w(u'<div class="clear"></div>')
@@ -211,11 +212,11 @@
def previous_link(self, previous, textsize):
return u'<a href="%s" title="%s"><< %s</a>' % (
xml_escape(previous.absolute_url()),
- self.req._('i18nprevnext_previous'),
+ self._cw._('i18nprevnext_previous'),
xml_escape(cut(previous.dc_title(), textsize)))
def next_link(self, next, textsize):
return u'<a href="%s" title="%s">%s >></a>' % (
xml_escape(next.absolute_url()),
- self.req._('i18nprevnext_next'),
+ self._cw._('i18nprevnext_next'),
xml_escape(cut(next.dc_title(), textsize)))