Commits

Lynn Rees committed b378784

[svn]

  • Participants
  • Parent commits a063039
  • Branches urlrelay

Comments (0)

Files changed (1)

branches/0.6/trunk/urlrelay.py

         try:
             path, method = environ['PATH_INFO'], environ['REQUEST_METHOD']
             callback, args, kws = self.resolve(path, method)
-            environ[self.key] = (args, kws)
-            environ[self.akey], environ[self.kkey] = args, kws
+            curargs, curkws = environ.get(self.key, ((), {}))            
+            newargs = list(curargs).extend(list(args))
+            newkws = curkws.copy().update(kws)
+            environ[self.key] = (newargs, newkws)
+            environ[self.akey], environ[self.kkey] = newargs, newkws
             return callback(environ, start_response)
         except ImportError:
             return self.handler(environ, start_response)        
                 search = pattern.search(uri)
                 if not search: continue
                 # Extract any keywords or arguments in the URL
-                kw, args = self._getargs(search)
+                kw, args = search.groupdict(), search.groups()
                 # If callable object, return callable
                 if hasattr(callbacks, '__call__'):
                     callback = callbacks
             if self.default is not None:
                 return self.default, self.args, self.kwargs
             else:
-                raise ImportError()        
+                raise ImportError()
 
     def getcallback(self, callback):
         '''Loads a callable based on its name
         except ImportError, error:
             print 'Could not import %s. Error was: %s' % (modname, str(error))
         except AttributeError, error:
-            print 'Tried %s in module %s. Error was: %s' % (funcname, modname, str(error))     
-
-    def _getargs(self, search):
-        '''Extracts arguments from URLs.'''
-        # If there are any named groups, use those as kwargs, ignoring
-        # non-named groups. Otherwise, pass all non-named arguments as
-        # positional arguments.
-        kw = search.groupdict()
-        if kw:
-            args = ()
-        else:
-            args = search.groups()
-        return kw, args
+            print 'Tried %s in module %s. Error was: %s' % (funcname, modname, str(error))