req.py
changeset 9022 a1cee6915ea3
parent 8847 074f9f385f6b
child 9051 944d66870c6a
equal deleted inserted replaced
9021:d8806996ac01 9022:a1cee6915ea3
   219 
   219 
   220         raises :exc:`ValueError` if None is found in arguments
   220         raises :exc:`ValueError` if None is found in arguments
   221         """
   221         """
   222         # use *args since we don't want first argument to be "anonymous" to
   222         # use *args since we don't want first argument to be "anonymous" to
   223         # avoid potential clash with kwargs
   223         # avoid potential clash with kwargs
       
   224         method = None
   224         if args:
   225         if args:
   225             assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
   226             assert len(args) == 1, 'only 0 or 1 non-named-argument expected'
   226             method = args[0]
   227             method = args[0]
   227         else:
   228         if method is None:
   228             method = None
   229             method = 'view'
   229         # XXX I (adim) think that if method is passed explicitly, we should
   230         # XXX I (adim) think that if method is passed explicitly, we should
   230         #     not try to process it and directly call req.build_url()
   231         #     not try to process it and directly call req.build_url()
   231         if method is None:
       
   232             if self.from_controller() == 'view' and not '_restpath' in kwargs:
       
   233                 method = self.relative_path(includeparams=False) or 'view'
       
   234             else:
       
   235                 method = 'view'
       
   236         base_url = kwargs.pop('base_url', None)
   232         base_url = kwargs.pop('base_url', None)
   237         if base_url is None:
   233         if base_url is None:
   238             secure = kwargs.pop('__secure__', None)
   234             secure = kwargs.pop('__secure__', None)
   239             base_url = self.base_url(secure=secure)
   235             base_url = self.base_url(secure=secure)
   240         if '_restpath' in kwargs:
   236         if '_restpath' in kwargs:
   241             assert method == 'view', method
   237             assert method == 'view', repr(method)
   242             path = kwargs.pop('_restpath')
   238             path = kwargs.pop('_restpath')
   243         else:
   239         else:
   244             path = method
   240             path = method
   245         if not kwargs:
   241         if not kwargs:
   246             return u'%s%s' % (base_url, path)
   242             return u'%s%s' % (base_url, path)