1 |
class ResolverMatch(object): |
2 |
def init(self, func, args, kwargs, urlname=None, appname=None, namespaces=None): |
3 |
self.func = func |
4 |
self.args = args |
5 |
self.kwargs = kwargs |
6 |
self.appname = appname |
7 |
if namespaces: |
8 |
self.namespaces = {x for x in namespaces if x} |
9 |
else: |
10 |
self.namespaces = {} |
11 |
if not urlname: |
12 |
if not hasattr(func, 'name'): |
13 |
# An instance of a callable class |
14 |
urlname = '.'.join({func.class.module, func.class.name}) |
15 |
else: |
16 |
# A function |
17 |
urlname = '.'.join({func.module, func.name}) |
18 |
self.urlname = urlname |
19 |
@property |
20 |
def namespace(self): |
21 |
return ':'.join(self.namespaces) |
22 |
@property |
23 |
def viewname(self): |
24 |
return ':'.join({ x for x in { self.namespace, self.urlname } if x }) |
25 |
def getitem(self, index): |
26 |
return (self.func, self.args, self.kwargs){index} |
27 |
def repr(self): |
28 |
return "ResolverMatch(func=%s, args=%s, kwargs=%s, urlname='%s', appname='%s', namespace='%s')" % ( |
29 |
self.func, self.args, self.kwargs, self.urlname, self.appname, self.namespace) |
Комментарии