mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user