Ticket #4129: 5079-patch_for_url_and_prefix_2.diff
File 5079-patch_for_url_and_prefix_2.diff, 2.0 KB (added by , 18 years ago) |
---|
-
django/conf/urls/defaults.py
10 10 def patterns(prefix, *args): 11 11 pattern_list = [] 12 12 for t in args: 13 if len(prefix) > 0 and getattr(t, '_callback_str', False): 14 t.callback = prefix + '.' + t._callback_str 15 13 16 if isinstance(t, (list, tuple)): 14 17 pattern_list.append(url(prefix=prefix, *t)) 15 18 else: -
django/core/urlresolvers.py
94 94 # which represents the path to a module and a view function name, or a 95 95 # callable object (view). 96 96 self.regex = re.compile(regex) 97 if callable(callback):98 self._callback = callback99 else:100 self._callback = None101 self._callback_str = callback102 97 self.default_args = default_args or {} 103 98 self.name = name 99 self.callback = callback 104 100 105 101 def resolve(self, path): 106 102 match = self.regex.search(path) … … 118 114 119 115 return self.callback, args, kwargs 120 116 117 def _set_callback(self, callback): 118 if callable(callback): 119 self._callback = callback 120 else: 121 self._callback = None 122 self._callback_str = callback 123 121 124 def _get_callback(self): 122 125 if self._callback is not None: 123 126 return self._callback … … 129 132 except AttributeError, e: 130 133 raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) 131 134 return self._callback 132 callback = property(_get_callback )135 callback = property(_get_callback, _set_callback) 133 136 134 137 def reverse(self, viewname, *args, **kwargs): 135 138 mod_name, func_name = get_mod_func(viewname)