cwvreg.py
changeset 1985 9c1db4e06095
parent 1977 606923dff11b
child 2025 010a4b0fe855
--- a/cwvreg.py	Thu May 28 18:28:29 2009 +0200
+++ b/cwvreg.py	Thu May 28 18:31:14 2009 +0200
@@ -249,6 +249,16 @@
                 self.exception('error while trying to list possible %s views for %s',
                                vid, rset)
 
+    def view(self, __vid, req, rset=None, __fallback_vid=None, **kwargs):
+        """shortcut to self.vreg.render method avoiding to pass self.req"""
+        try:
+            view = self.select_view(__vid, req, rset, **kwargs)
+        except NoSelectableObject:
+            if __fallback_vid is None:
+                raise
+            view = self.select_view(__fallback_vid, req, rset, **kwargs)
+        return view.render(**kwargs)
+
     def select_box(self, oid, *args, **kwargs):
         """return the most specific view according to the result set"""
         try:
@@ -270,12 +280,11 @@
         except (NoSelectableObject, ObjectNotFound):
             return
 
-    def select_view(self, __vid, req, rset, **kwargs):
+    def select_view(self, __vid, req, rset=None, **kwargs):
         """return the most specific view according to the result set"""
         views = self.registry_objects('views', __vid)
         return self.select(views, req, rset, **kwargs)
 
-
     # properties handling #####################################################
 
     def user_property_keys(self, withsitewide=False):