From f4c581158d489aba88f3cbb2c61dd44949ea0038 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 15 Jul 2005 17:09:01 +0000 Subject: [PATCH] Renamed CMSRequest to DjangoRequest, and CMSContext to DjangoContext. Old code will still work. git-svn-id: http://code.djangoproject.com/svn/django/trunk@57 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/comments/views/comments.py | 2 +- django/contrib/comments/views/karma.py | 2 +- django/contrib/comments/views/userflags.py | 2 +- django/core/extensions.py | 20 +++++++++++------ django/core/handler.py | 4 ++-- django/middleware/admin.py | 2 +- django/views/admin/doc.py | 26 +++++++++++----------- django/views/admin/main.py | 2 +- django/views/admin/template.py | 2 +- django/views/auth/login.py | 2 +- django/views/core/flatfiles.py | 2 +- django/views/defaults.py | 2 +- django/views/generic/date_based.py | 2 +- django/views/generic/list_detail.py | 2 +- django/views/registration/passwords.py | 2 +- 15 files changed, 40 insertions(+), 34 deletions(-) diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py index ffad921ad32..1a28676a887 100644 --- a/django/contrib/comments/views/comments.py +++ b/django/contrib/comments/views/comments.py @@ -1,7 +1,7 @@ from django.core import formfields, template_loader, validators from django.core.mail import mail_admins, mail_managers from django.core.exceptions import Http404, ObjectDoesNotExist -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.auth import sessions from django.models.comments import comments, freecomments from django.models.core import contenttypes diff --git a/django/contrib/comments/views/karma.py b/django/contrib/comments/views/karma.py index 84f0ca852d3..afc115c0ef9 100644 --- a/django/contrib/comments/views/karma.py +++ b/django/contrib/comments/views/karma.py @@ -1,5 +1,5 @@ from django.core import template_loader -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.core.exceptions import Http404 from django.models.comments import comments, karma from django.utils.httpwrappers import HttpResponse diff --git a/django/contrib/comments/views/userflags.py b/django/contrib/comments/views/userflags.py index 051ecb19fed..f0d0715cdd2 100644 --- a/django/contrib/comments/views/userflags.py +++ b/django/contrib/comments/views/userflags.py @@ -1,5 +1,5 @@ from django.core import template_loader -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.core.exceptions import Http404 from django.models.comments import comments, moderatordeletions, userflags from django.views.decorators.auth import login_required diff --git a/django/core/extensions.py b/django/core/extensions.py index f37fac680e9..e68f8a934d2 100644 --- a/django/core/extensions.py +++ b/django/core/extensions.py @@ -1,13 +1,15 @@ -"Specialized Context and ModPythonRequest classes for our CMS. Use these!" +"Specialized Context and ModPythonRequest classes for Django. Use these!" from django.core.template import Context from django.utils.httpwrappers import ModPythonRequest from django.conf.settings import DEBUG, INTERNAL_IPS from pprint import pformat -class CMSContext(Context): - """This subclass of template.Context automatically populates 'user' and - 'messages' in the context. Use this.""" +class DjangoContext(Context): + """ + This subclass of template.Context automatically populates 'user' and + 'messages' in the context. + """ def __init__(self, request, dict={}): Context.__init__(self, dict) self['user'] = request.user @@ -37,13 +39,13 @@ class PermWrapper: def __getitem__(self, module_name): return PermLookupDict(self.user, module_name) -class CMSRequest(ModPythonRequest): - "A special version of ModPythonRequest with support for CMS sessions" +class DjangoRequest(ModPythonRequest): + "A special version of ModPythonRequest with support for Django sessions." def __init__(self, req): ModPythonRequest.__init__(self, req) def __repr__(self): - return '' % \ + return '' % \ (self.path, pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), pformat(self.META), pformat(self.user)) @@ -77,3 +79,7 @@ class CMSRequest(ModPythonRequest): session = property(_get_session, _set_session) user = property(_get_user, _set_user) + +# For legacy purposes. +CMSContext = DjangoContext +CMSRequest = DjangoRequest diff --git a/django/core/handler.py b/django/core/handler.py index 1412ee6838f..42f4c69d4c6 100644 --- a/django/core/handler.py +++ b/django/core/handler.py @@ -77,8 +77,8 @@ class CoreHandler: def get_request(self, req): "Returns an HttpRequest object for the given mod_python req object" - from django.core.extensions import CMSRequest - return CMSRequest(req) + from django.core.extensions import DjangoRequest + return DjangoRequest(req) def get_response(self, path, request): "Returns an HttpResponse object for the given HttpRequest" diff --git a/django/middleware/admin.py b/django/middleware/admin.py index f91b856d3b8..0a0a76201a4 100644 --- a/django/middleware/admin.py +++ b/django/middleware/admin.py @@ -1,6 +1,6 @@ from django.utils import httpwrappers from django.core import template_loader -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.auth import sessions, users from django.views.registration import passwords import base64, md5 diff --git a/django/views/admin/doc.py b/django/views/admin/doc.py index 7f4e686a820..7f8fa3b0b80 100644 --- a/django/views/admin/doc.py +++ b/django/views/admin/doc.py @@ -6,7 +6,7 @@ from django import templatetags from django.conf import settings from django.models.core import sites from django.views.decorators.cache import cache_page -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.core.exceptions import Http404, ViewDoesNotExist from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect from django.core import template, template_loader, defaulttags, defaultfilters, urlresolvers @@ -14,18 +14,18 @@ try: from django.parts.admin import doc except ImportError: doc = None - + # Exclude methods starting with these strings from documentation MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_') def doc_index(request): if not doc: return missing_docutils_page(request) - + t = template_loader.get_template('doc/index') c = Context(request, {}) return HttpResponse(t.render(c)) - + def bookmarklets(request): t = template_loader.get_template('doc/bookmarklets') c = Context(request, { @@ -36,10 +36,10 @@ def bookmarklets(request): def template_tag_index(request): if not doc: return missing_docutils_page(request) - - # We have to jump through some hoops with registered_tags to make sure + + # We have to jump through some hoops with registered_tags to make sure # they don't get messed up by loading outside tagsets - saved_tagset = template.registered_tags.copy(), template.registered_filters.copy() + saved_tagset = template.registered_tags.copy(), template.registered_filters.copy() load_all_installed_template_libraries() # Gather docs @@ -76,8 +76,8 @@ template_tag_index = cache_page(template_tag_index, 15*60) def template_filter_index(request): if not doc: return missing_docutils_page(request) - - saved_tagset = template.registered_tags.copy(), template.registered_filters.copy() + + saved_tagset = template.registered_tags.copy(), template.registered_filters.copy() load_all_installed_template_libraries() filters = [] @@ -191,7 +191,7 @@ def model_detail(request, model): except ImportError: raise Http404 opts = model.Klass._meta - + # Gather fields/field descriptions fields = [] for field in opts.fields: @@ -251,7 +251,7 @@ def load_all_installed_template_libraries(): reload(mod) except ImportError: pass - + def get_return_data_type(func_name): """Return a somewhat-helpful data type given a function name""" if func_name.startswith('get_'): @@ -292,13 +292,13 @@ DATA_TYPE_MAPPING = { 'XMLField' : 'XML text', } -def get_readable_field_data_type(field): +def get_readable_field_data_type(field): return DATA_TYPE_MAPPING[field.__class__.__name__] % field.__dict__ def extract_views_from_urlpatterns(urlpatterns, base=''): """ Return a list of views from a list of urlpatterns. - + Each object in the returned list is a two-tuple: (view_func, regex) """ views = [] diff --git a/django/views/admin/main.py b/django/views/admin/main.py index 8caeb6218e6..2138f070660 100644 --- a/django/views/admin/main.py +++ b/django/views/admin/main.py @@ -2,7 +2,7 @@ from django.core import formfields, meta, template_loader from django.core.exceptions import Http404, ObjectDoesNotExist, PermissionDenied -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.auth import log from django.utils.html import strip_tags from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect diff --git a/django/views/admin/template.py b/django/views/admin/template.py index 7c5e41e2372..f2004a4d943 100644 --- a/django/views/admin/template.py +++ b/django/views/admin/template.py @@ -1,6 +1,6 @@ from django.core import formfields, template_loader, validators from django.core import template -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.utils.httpwrappers import HttpResponse from django.models.core import sites from django.conf import settings diff --git a/django/views/auth/login.py b/django/views/auth/login.py index 97988d04445..5b374c8f522 100644 --- a/django/views/auth/login.py +++ b/django/views/auth/login.py @@ -1,6 +1,6 @@ from django.parts.auth.formfields import AuthenticationForm from django.core import formfields, template_loader -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.auth import sessions from django.models.core import sites from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect diff --git a/django/views/core/flatfiles.py b/django/views/core/flatfiles.py index 68af68a355d..2edccbf9826 100644 --- a/django/views/core/flatfiles.py +++ b/django/views/core/flatfiles.py @@ -1,6 +1,6 @@ from django.core import template_loader from django.core.exceptions import Http404 -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.core import flatfiles from django.utils.httpwrappers import HttpResponse from django.conf.settings import SITE_ID diff --git a/django/views/defaults.py b/django/views/defaults.py index 7677ecd8cd7..69574b41bfc 100644 --- a/django/views/defaults.py +++ b/django/views/defaults.py @@ -1,6 +1,6 @@ from django.core import template_loader from django.core.exceptions import Http404, ObjectDoesNotExist -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.core import sites from django.utils import httpwrappers diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py index 7db02813aae..cd1842ed920 100644 --- a/django/views/generic/date_based.py +++ b/django/views/generic/date_based.py @@ -1,6 +1,6 @@ from django.core import template_loader from django.core.exceptions import Http404, ObjectDoesNotExist -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.core.xheaders import populate_xheaders from django.models import get_module from django.utils.httpwrappers import HttpResponse diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py index 8b3ae5b9e9f..c5b2b9bbb38 100644 --- a/django/views/generic/list_detail.py +++ b/django/views/generic/list_detail.py @@ -2,7 +2,7 @@ from django import models from django.core import template_loader from django.utils.httpwrappers import HttpResponse from django.core.xheaders import populate_xheaders -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.core.paginator import ObjectPaginator, InvalidPage from django.core.exceptions import Http404, ObjectDoesNotExist diff --git a/django/views/registration/passwords.py b/django/views/registration/passwords.py index 0c06341af29..1f147a987c6 100644 --- a/django/views/registration/passwords.py +++ b/django/views/registration/passwords.py @@ -1,5 +1,5 @@ from django.core import formfields, template_loader, validators -from django.core.extensions import CMSContext as Context +from django.core.extensions import DjangoContext as Context from django.models.auth import users from django.views.decorators.auth import login_required from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect