diff options
Diffstat (limited to 'djangorestframework/utils')
| -rw-r--r-- | djangorestframework/utils/breadcrumbs.py | 1 | ||||
| -rw-r--r-- | djangorestframework/utils/description.py | 3 | ||||
| -rw-r--r-- | djangorestframework/utils/mediatypes.py | 28 | ||||
| -rw-r--r-- | djangorestframework/utils/staticviews.py | 3 |
4 files changed, 6 insertions, 29 deletions
diff --git a/djangorestframework/utils/breadcrumbs.py b/djangorestframework/utils/breadcrumbs.py index fd966282..cfc63a47 100644 --- a/djangorestframework/utils/breadcrumbs.py +++ b/djangorestframework/utils/breadcrumbs.py @@ -1,6 +1,7 @@ from django.core.urlresolvers import resolve from djangorestframework.utils.description import get_name + def get_breadcrumbs(url): """Given a url returns a list of breadcrumbs, which are each a tuple of (name, url).""" diff --git a/djangorestframework/utils/description.py b/djangorestframework/utils/description.py index ce61e558..096cf57f 100644 --- a/djangorestframework/utils/description.py +++ b/djangorestframework/utils/description.py @@ -50,7 +50,6 @@ def get_name(view): return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', name).strip() - def get_description(view): """ Provide a description for the view. @@ -63,7 +62,6 @@ def get_description(view): if getattr(view, 'cls_instance', None): view = view.cls_instance - # If this view has a resource that's been overridden, then use the resource's doctring if getattr(view, 'resource', None) not in (None, Resource, FormResource, ModelResource): doc = view.resource.__doc__ @@ -88,4 +86,3 @@ def get_description(view): # otherwise return it as-is return doc - diff --git a/djangorestframework/utils/mediatypes.py b/djangorestframework/utils/mediatypes.py index c0071f01..48dca0f0 100644 --- a/djangorestframework/utils/mediatypes.py +++ b/djangorestframework/utils/mediatypes.py @@ -61,10 +61,10 @@ def order_by_precedence(media_type_lst): 1. 'type/*' 0. '*/*' """ - ret = [[],[],[],[]] + ret = [[], [], [], []] for media_type in media_type_lst: precedence = _MediaType(media_type).precedence - ret[3-precedence].append(media_type) + ret[3 - precedence].append(media_type) return ret @@ -103,29 +103,6 @@ class _MediaType(object): return 2 return 3 - #def quality(self): - # """ - # Return a quality level for the media type. - # """ - # try: - # return Decimal(self.params.get('q', '1.0')) - # except Exception: - # return Decimal(0) - - #def score(self): - # """ - # Return an overall score for a given media type given it's quality and precedence. - # """ - # # NB. quality values should only have up to 3 decimal points - # # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.9 - # return self.quality * 10000 + self.precedence - - #def as_tuple(self): - # return (self.main_type, self.sub_type, self.params) - - #def __repr__(self): - # return "<MediaType %s>" % (self.as_tuple(),) - def __str__(self): return unicode(self).encode('utf-8') @@ -134,4 +111,3 @@ class _MediaType(object): for key, val in self.params.items(): ret += "; %s=%s" % (key, val) return ret - diff --git a/djangorestframework/utils/staticviews.py b/djangorestframework/utils/staticviews.py index 825ea6b5..12a36f6c 100644 --- a/djangorestframework/utils/staticviews.py +++ b/djangorestframework/utils/staticviews.py @@ -5,13 +5,16 @@ from django.shortcuts import render_to_response from django.template import RequestContext import base64 + def deny_robots(request): return HttpResponse('User-agent: *\nDisallow: /', mimetype='text/plain') + def favicon(request): data = 'AAABAAEAEREAAAEAIADwBAAAFgAAACgAAAARAAAAIgAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADLy8tLy8vL3svLy1QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAy8vLBsvLywkAAAAATkZFS1xUVPqhn57/y8vL0gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJmVlQ/GxcXiy8vL88vLy4FdVlXzTkZF/2RdXP/Ly8vty8vLtMvLy5DLy8vty8vLxgAAAAAAAAAAAAAAAAAAAABORkUJTkZF4lNMS/+Lh4f/cWtq/05GRf9ORkX/Vk9O/3JtbP+Ef3//Vk9O/2ljY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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//+AAP9/gAD+P4AA4AOAAMADgADAA4AAwAOAAMMBgACCAIAAAAGAAIBDgADAA4AAwAOAAMADgADAB4AA/H+AAP7/gAA=' return HttpResponse(base64.b64decode(data), mimetype='image/vnd.microsoft.icon') + # BLERGH # Replicate django.contrib.auth.views.login simply so we don't have get users to update TEMPLATE_CONTEXT_PROCESSORS # to add ADMIN_MEDIA_PREFIX to the RequestContext. I don't like this but really really want users to not have to |
