[view] sort using orm accessors not cache (closes #2897200)

Prevent crash if the cache is not filed. The orm accessors will access the cache if filled and query the DB otherwise.

authorPierre-Yves David <pierre-yves.david@logilab.fr>
changesetc83a2f1bd3d4
branchdefault
phasepublic
hiddenno
parent revision#61d56c47b31d Added tag cubicweb-forge-debian-version-1.9.2-1 for changeset 253fe22ccd09
child revision#d92b93d7bc3c [pkg] prepare release 1.9.3
files modified by this revision
views/project.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1369305246 -7200
# Thu May 23 12:34:06 2013 +0200
# Node ID c83a2f1bd3d45713df00dc38138e819604bf5d74
# Parent 61d56c47b31dec40fde934692a8d71b83cb56b36
[view] sort using orm accessors not cache (closes #2897200)

Prevent crash if the cache is not filed. The orm accessors will access the cache
if filled and query the DB otherwise.

diff --git a/views/project.py b/views/project.py
@@ -110,11 +110,11 @@
1  class ProjectListView(baseviews.SameETypeListView):
2      __select__ = (baseviews.SameETypeListView.__select__ &
3                    is_instance("Project"))
4      def call(self, **kwargs):
5          # sort by modification date
6 -        self.cw_rset = self.cw_rset.sorted_rset(lambda e: e.cw_attr_cache['modification_date'],
7 +        self.cw_rset = self.cw_rset.sorted_rset(lambda e: e.modification_date,
8                                                  reverse=True)
9          super(ProjectListView, self).call(**kwargs)
10 
11  class ProjetListItemView(baseviews.SameETypeListItemView):
12      __select__ = (baseviews.SameETypeListItemView.__select__ &