aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/utils/__init__.py
diff options
context:
space:
mode:
authorTom Christie2011-05-10 12:21:48 +0100
committerTom Christie2011-05-10 12:21:48 +0100
commit527e4ffdf7f7798dc17757a26d8fd6b155a49bf9 (patch)
tree8a7811d692c136e78dd3ad64a6219d30f501d194 /djangorestframework/utils/__init__.py
parent8f58ee489d34b200acfc2666816eb32e47c8cef5 (diff)
downloaddjango-rest-framework-527e4ffdf7f7798dc17757a26d8fd6b155a49bf9.tar.bz2
renderer API work
Diffstat (limited to 'djangorestframework/utils/__init__.py')
-rw-r--r--djangorestframework/utils/__init__.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/djangorestframework/utils/__init__.py b/djangorestframework/utils/__init__.py
index 9dc769be..67870001 100644
--- a/djangorestframework/utils/__init__.py
+++ b/djangorestframework/utils/__init__.py
@@ -16,7 +16,15 @@ import xml.etree.ElementTree as ET
MSIE_USER_AGENT_REGEX = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )')
def as_tuple(obj):
- """Given obj return a tuple"""
+ """
+ Given an object which may be a list/tuple, another object, or None,
+ return that object in list form.
+
+ IE:
+ If the object is already a list/tuple just return it.
+ If the object is not None, return it in a list with a single element.
+ If the object is None return an empty list.
+ """
if obj is None:
return ()
elif isinstance(obj, list):
@@ -27,7 +35,9 @@ def as_tuple(obj):
def url_resolves(url):
- """Return True if the given URL is mapped to a view in the urlconf, False otherwise."""
+ """
+ Return True if the given URL is mapped to a view in the urlconf, False otherwise.
+ """
try:
resolve(url)
except: