本文整理汇总了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
示例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))
示例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)
示例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)
示例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)
示例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