Exemplo n.º 1
0
 def get_template_names(self):
     """
     Returns list of template names to be used for the request. Used by
     :meth:`render`.
     """
     for dirname in reversed(self.__module__.split('.')):
         if dirname != 'views':
             break
     fmt = dirname, uncamel(self.__class__.__name__)
     template_names = [ self.template_name, u'%s/%s.html' % fmt ]
     if self.request.is_ajax():
         template_names = [ self.ajax_template_name,
             u'%s/%s.ajax.html' % fmt ] + template_names
     return [ t for t in template_names if t ]
Exemplo n.º 2
0
def url(regex, view, kwargs=None, name=None, prefix=""):
    """
    sets up a regexp pattern for url processing
    """
    if isinstance(view, (list, tuple)):
        # For include(...) processing.
        urlconf_module, app_name, namespace = view
        return urlresolvers.RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace)
    else:
        if isinstance(view, str):
            if not view:
                raise ImproperlyConfigured("Empty URL pattern view name not " "permitted (for pattern %r)" % regex)
            if prefix:
                view = "%s.%s" % (prefix, view)
            if name is None:
                name = uncamel(view.split(".")[-1])
        return RegexURLPattern(regex, view, kwargs, name)
Exemplo n.º 3
0
def url(regex, view, kwargs=None, name=None, prefix=''):
    """
    sets up a regexp pattern for url processing
    """
    if isinstance(view, (list, tuple)):
        # For include(...) processing.
        urlconf_module, app_name, namespace = view
        return urlresolvers.RegexURLResolver(regex,
                                             urlconf_module,
                                             kwargs,
                                             app_name=app_name,
                                             namespace=namespace)
    else:
        if isinstance(view, str):
            if not view:
                raise ImproperlyConfigured('Empty URL pattern view name not '
                                           'permitted (for pattern %r)' %
                                           regex)
            if prefix:
                view = '%s.%s' % (prefix, view)
            if name is None:
                name = uncamel(view.split('.')[-1])
        return RegexURLPattern(regex, view, kwargs, name)