req.py
changeset 2798 9c650701cb17
parent 2796 14d2c69e12c4
child 2808 497424219fb0
--- a/req.py	Thu Aug 13 09:49:21 2009 +0200
+++ b/req.py	Thu Aug 13 09:59:35 2009 +0200
@@ -132,8 +132,18 @@
         """
         # use *args since we don't want first argument to be "anonymous" to
         # avoid potential clash with kwargs
-        assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
-        method = args[0]
+        if args:
+            assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
+            method = args[0]
+        else:
+            method = None
+        # XXX I (adim) think that if method is passed explicitly, we should
+        #     not try to process it and directly call req.build_url()
+        if method is None:
+            if self.from_controller() == 'view' and not '_restpath' in kwargs:
+                method = self.relative_path(includeparams=False) or 'view'
+            else:
+                method = 'view'
         base_url = kwargs.pop('base_url', None)
         if base_url is None:
             base_url = self.base_url()