Пример #1
0
def patterns(prefix, *args):
    """ A substitute for django.conf.urls.defaults.patterns: cycles over the
    given url list looking for instances of UrlSugar, adding the generated
    urls and calling the original `patterns'.
    """
    pattern_list = []
    for an_url in args:
        if isinstance(an_url, UrlSugar):
            pattern_list += an_url.generate_urls()
        else:
            pattern_list.append(an_url)
    return django_patterns(prefix, *pattern_list)
Пример #2
0
def reroute_patterns(wrappers, prefix, *args):
    # TODO(dnerdy) Require that all patterns be instances of RerouteRegexURLPattern
    # TODO(dnerdy) Remove additional patterns with identical regexes, if present (occurs
    #   when using verb_url)
    
    patterns_id = object()
    pattern_list = django_patterns(prefix, *args)
    
    for pattern in pattern_list:
        if isinstance(pattern, RerouteRegexURLPattern):            
            pattern.reroute_config(wrappers, patterns_id)
        
    return pattern_list
Пример #3
0
 def patterns(self, without_include=False):
     """Get urlpatterns for this section"""
     tuples = list(PatternList(self, without_include=without_include))
     return django_patterns('', *tuples)
Пример #4
0
 def testURLWithDjangoPatternsShouldFail(self):
     urlconf = URLConf(django_patterns('tests',
         url('^test$', 'wrapper_view')
     ))
     
     self.assertRaises(ImproperlyConfigured, content, '/test', urlconf)
Пример #5
0
 def patterns(self, without_include=False):
     """Get urlpatterns for this section"""
     tuples = list(PatternList(self, without_include=without_include))
     return django_patterns('', *tuples)