app/django/conf/urls/defaults.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 08 Feb 2009 23:55:44 +0000
changeset 1255 9fe8c6c54933
parent 54 03e267d67478
permissions -rw-r--r--
Redone the listing in group_app.py. There is now a list_self that only shows the group application of the current user in the given a scope. The redirects point to edit or applicant when necessary. Review_overview will show all the group applications that can be reviewed in the given scope, the redirect points to review for all statusses. And list will just show all the group applications and redirect you to edit. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed

from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
from django.core.exceptions import ImproperlyConfigured

__all__ = ['handler404', 'handler500', 'include', 'patterns', 'url']

handler404 = 'django.views.defaults.page_not_found'
handler500 = 'django.views.defaults.server_error'

include = lambda urlconf_module: [urlconf_module]

def patterns(prefix, *args):
    pattern_list = []
    for t in args:
        if isinstance(t, (list, tuple)):
            t = url(prefix=prefix, *t)
        elif isinstance(t, RegexURLPattern):
            t.add_prefix(prefix)
        pattern_list.append(t)
    return pattern_list

def url(regex, view, kwargs=None, name=None, prefix=''):
    if type(view) == list:
        # For include(...) processing.
        return RegexURLResolver(regex, view[0], kwargs)
    else:
        if isinstance(view, basestring):
            if not view:
                raise ImproperlyConfigured('Empty URL pattern view name not permitted (for pattern %r)' % regex)
            if prefix:
                view = prefix + '.' + view
        return RegexURLPattern(regex, view, kwargs, name)