當前位置: 首頁>>代碼示例>>Python>>正文


Python urls.get_callable方法代碼示例

本文整理匯總了Python中django.urls.get_callable方法的典型用法代碼示例。如果您正苦於以下問題:Python urls.get_callable方法的具體用法?Python urls.get_callable怎麽用?Python urls.get_callable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.urls的用法示例。


在下文中一共展示了urls.get_callable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: catalogue_resolver

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def catalogue_resolver(resolver, ns=()):
    #index_full = get_callable('dashboard:index_full')
    view_names = initial_view_names
    resolver._populate()
    for fn in list(resolver.reverse_dict.keys()):
        if isinstance(fn, str) or fn.__name__ in ['RedirectView']:
            continue
        new_name = ':'.join(ns + (fn.__name__,))
        view_names[fn] = new_name

    for n,v in list(resolver.namespace_dict.values()):
        this_ns = ns + (v.namespace,)
        #print this_ns, v
        vns = catalogue_resolver(v, ns=this_ns)
        view_names.update(vns)

    return view_names 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:19,代碼來源:url-fixer.py

示例2: fix_references

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def fix_references(fn, view_names):
    new_content = []
    with open(fn, 'r') as code:
        for line in code:
            m = dot_ref_re.search(line)
            if m:
                dotted = m.group('dotted')
                viewfunc = get_callable(dotted)
                newline = line.replace(dotted, view_names[viewfunc])
            else:
                newline = line
            new_content.append(newline)

            m = function_reverse_re.search(line)
            if m:
                print("function reference reverse() in ", fn)

            m = no_namespace_tag_re.search(line)
            if m:
                print("no namespace on {% url %} in ", fn)

    with open(fn, 'w') as py:
        py.write(''.join(new_content)) 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:25,代碼來源:url-fixer.py

示例3: get_disabled_view

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def get_disabled_view():
    module = settings.FEATUREFLAGS_DISABLED_VIEW
    return get_callable(module) 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:5,代碼來源:flags.py

示例4: _get_failure_view

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def _get_failure_view():
    """Return the view to be used for CSRF rejections."""
    return get_callable(settings.CSRF_FAILURE_VIEW) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:5,代碼來源:csrf.py

示例5: _get_failure_view

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def _get_failure_view():
    """
    Returns the view to be used for CSRF rejections
    """
    return get_callable(settings.CSRF_FAILURE_VIEW) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:7,代碼來源:csrf.py

示例6: get_resource_uri_template

# 需要導入模塊: from django import urls [as 別名]
# 或者: from django.urls import get_callable [as 別名]
def get_resource_uri_template(self):
    """
    URI template processor.
    See http://bitworking.org/projects/URI-Templates/
    """

    def _convert(template, params=[]):
        """URI template converter"""
        paths = template % dict([p, "{%s}" % p] for p in params)
        return "%s%s" % (get_script_prefix(), paths)

    try:
        resource_uri = self.handler.resource_uri()
        components = [None, [], {}]

        for i, value in enumerate(resource_uri):
            components[i] = value
        lookup_view, args, kwargs = components
        try:
            lookup_view = get_callable(lookup_view)
        except (ImportError, ViewDoesNotExist):
            # Emulate can_fail=True from earlier django versions.
            pass

        possibilities = get_resolver(None).reverse_dict.getlist(lookup_view)
        # The monkey patch is right here: we need to cope with 'possibilities'
        # being a list of tuples with 2 or 3 elements.
        for possibility_data in possibilities:
            possibility = possibility_data[0]
            for result, params in possibility:
                if args:
                    if len(args) != len(params):
                        continue
                    return _convert(result, params)
                else:
                    if set(kwargs.keys()) != set(params):
                        continue
                    return _convert(result, params)
    except Exception:
        return None 
開發者ID:maas,項目名稱:maas,代碼行數:42,代碼來源:__init__.py


注:本文中的django.urls.get_callable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。