diff options
| author | tom christie tom@tomchristie.com | 2011-02-04 21:52:21 +0000 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-02-04 21:52:21 +0000 |
| commit | fcd7f414c407c8dab7c0badbfa16476826dad3ae (patch) | |
| tree | 4d532d354e5f63b0ab31212d2dfc26d937c2720d /djangorestframework/utils.py | |
| parent | eebcdc4dc0e3b34fa76eca638c469b1e79240844 (diff) | |
| download | django-rest-framework-fcd7f414c407c8dab7c0badbfa16476826dad3ae.tar.bz2 | |
Huge stack of refactoring getting stuff into Mixin classes, and loads of tests. Kickass.
Diffstat (limited to 'djangorestframework/utils.py')
| -rw-r--r-- | djangorestframework/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/djangorestframework/utils.py b/djangorestframework/utils.py index f9bbc0fe..bc797d60 100644 --- a/djangorestframework/utils.py +++ b/djangorestframework/utils.py @@ -9,6 +9,17 @@ except ImportError: import StringIO +def as_tuple(obj): + """Given obj return a tuple""" + if obj is None: + return () + elif isinstance(obj, list): + return tuple(obj) + elif isinstance(obj, tuple): + return obj + return (obj,) + + def url_resolves(url): """Return True if the given URL is mapped to a view in the urlconf, False otherwise.""" try: |
