Esempio n. 1
0
 def __call__(self, route, func, name=None, **kwargs):
     if not name:
         name = func.__name__
         if 'im_class' in dir(func):
             name = "%s.%s" % (func.im_class.__name__, func.__name__)
     if name in self.seen:
         raise NameError('Route name: ' + repr(name) + ' already used')
     self.seen.add(name)
     kwargs['action'] = 'f_%d' % len(self.funcs)
     aw = kwargs.pop('android_workaround', False)
     if route != '/':
         route = self.prefix + route
     if isinstance(route, unicode):
         # Apparently the routes package chokes on unicode routes, see
         # http://www.mobileread.com/forums/showthread.php?t=235366
         route = route.encode('utf-8')
     elif self.prefix:
         self.dispatcher.connect(name + 'prefix_extra', self.prefix, self,
                                 **kwargs)
         self.dispatcher.connect(name + 'prefix_extra_trailing',
                                 self.prefix + '/', self, **kwargs)
     self.dispatcher.connect(name, route, self, **kwargs)
     if self.auth_controller is not None:
         func = self.auth_controller(func, aw)
     self.funcs.append(expose(func))
Esempio n. 2
0
 def __call__(self, route, func, name=None, **kwargs):
     if not name:
         name = func.__name__
         if 'im_class' in dir(func):
             name = "%s.%s" % ( func.im_class.__name__, func.__name__)
     if name in self.seen:
         raise NameError('Route name: '+ repr(name) + ' already used')
     self.seen.add(name)
     kwargs['action'] = 'f_%d'%len(self.funcs)
     aw = kwargs.pop('android_workaround', False)
     if route != '/':
         route = self.prefix + route
     if isinstance(route, unicode):
         # Apparently the routes package chokes on unicode routes, see
         # http://www.mobileread.com/forums/showthread.php?t=235366
         route = route.encode('utf-8')
     elif self.prefix:
         self.dispatcher.connect(name+'prefix_extra', self.prefix, self,
                 **kwargs)
         self.dispatcher.connect(name+'prefix_extra_trailing',
                 self.prefix+'/', self, **kwargs)
     self.dispatcher.connect(name, route, self, **kwargs)
     if self.auth_controller is not None:
         func = self.auth_controller(func, aw)
     self.funcs.append(expose(func))
Esempio n. 3
0
 def __call__(self, name, route, func, **kwargs):
     if name in self.seen:
         raise NameError('Route name: '+ repr(name) + ' already used')
     self.seen.add(name)
     kwargs['action'] = 'f_%d'%len(self.funcs)
     aw = kwargs.pop('android_workaround', False)
     if route != '/':
         route = self.prefix + route
     elif self.prefix:
         self.dispatcher.connect(name+'prefix_extra', self.prefix, self,
                 **kwargs)
         self.dispatcher.connect(name+'prefix_extra_trailing',
                 self.prefix+'/', self, **kwargs)
     self.dispatcher.connect(name, route, self, **kwargs)
     if self.auth_controller is not None:
         func = self.auth_controller(func, aw)
     self.funcs.append(expose(func))
Esempio n. 4
0
 def __call__(self, name, route, func, **kwargs):
     if name in self.seen:
         raise NameError('Route name: ' + repr(name) + ' already used')
     self.seen.add(name)
     kwargs['action'] = 'f_%d' % len(self.funcs)
     aw = kwargs.pop('android_workaround', False)
     if route != '/':
         route = self.prefix + route
     elif self.prefix:
         self.dispatcher.connect(name + 'prefix_extra', self.prefix, self,
                                 **kwargs)
         self.dispatcher.connect(name + 'prefix_extra_trailing',
                                 self.prefix + '/', self, **kwargs)
     self.dispatcher.connect(name, route, self, **kwargs)
     if self.auth_controller is not None:
         func = self.auth_controller(func, aw)
     self.funcs.append(expose(func))