web/facet.py
branchstable
changeset 3328 76888cd23d83
parent 2996 866a2c135c33
child 3329 8430f6c693a1
--- a/web/facet.py	Fri Sep 18 19:48:58 2009 +0200
+++ b/web/facet.py	Fri Sep 18 19:49:54 2009 +0200
@@ -346,6 +346,8 @@
     sortfunc = None
     # ascendant/descendant sorting
     sortasc = True
+    # if you want to call a view on the entity instead of using `target_attr`
+    label_vid = None
 
     @property
     def title(self):
@@ -384,8 +386,14 @@
             rqlst.recover()
 
     def rset_vocabulary(self, rset):
-        _ = self.req._
-        return [(_(label), eid) for eid, label in rset]
+        if self.label_vid is None:
+            _ = self.req._
+            return [(_(label), eid) for eid, label in rset]
+        if self.sortfunc is None:
+            return sorted((entity.view(self.label_vid), entity.eid)
+                          for entity in rset.entities())
+        return [(entity.view(self.label_vid), entity.eid)
+                for entity in rset.entities()]
 
     @cached
     def support_and(self):