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
This commit is contained in:
Adrian Holovaty 2005-07-15 17:09:01 +00:00
parent 960644ab08
commit f4c581158d
15 changed files with 40 additions and 34 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 '<CMSRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s,\nuser:%s>' % \
return '<DjangoRequest\npath:%s,\nGET:%s,\nPOST:%s,\nCOOKIES:%s,\nMETA:%s,\nuser:%s>' % \
(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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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