Don't process the AttributeError exception but let calling code handle it.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -123,7 +123,6 @@ def resolve(path, urlconf=None):
|
|||||||
|
|
||||||
|
|
||||||
def return_attrib(obj, attrib, arguments=None):
|
def return_attrib(obj, attrib, arguments=None):
|
||||||
try:
|
|
||||||
if isinstance(attrib, types.FunctionType):
|
if isinstance(attrib, types.FunctionType):
|
||||||
return attrib(obj)
|
return attrib(obj)
|
||||||
elif isinstance(
|
elif isinstance(
|
||||||
@@ -139,20 +138,15 @@ def return_attrib(obj, attrib, arguments=None):
|
|||||||
return result()
|
return result()
|
||||||
else:
|
else:
|
||||||
return result
|
return result
|
||||||
except Exception as exception:
|
|
||||||
if settings.DEBUG:
|
|
||||||
return 'Attribute error: %s; %s' % (attrib, exception)
|
|
||||||
else:
|
|
||||||
return force_text(exception)
|
|
||||||
|
|
||||||
|
|
||||||
def return_related(instance, attribute):
|
def return_related(instance, related_field):
|
||||||
"""
|
"""
|
||||||
This functions works in a similar method to return_attrib but is
|
This functions works in a similar method to return_attrib but is
|
||||||
meant for related models. Support multiple levels of relationship
|
meant for related models. Support multiple levels of relationship
|
||||||
using double underscore.
|
using double underscore.
|
||||||
"""
|
"""
|
||||||
return reduce_function(getattr, attribute.split('__'), instance)
|
return reduce_function(getattr, related_field.split('__'), instance)
|
||||||
|
|
||||||
|
|
||||||
def urlquote(link=None, get=None):
|
def urlquote(link=None, get=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user