本文整理匯總了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