Changeset 786
- Timestamp:
- 10/05/05 21:27:08 (3 years ago)
- Files:
-
- django/trunk/django/conf/global_settings.py (modified) (1 diff)
- django/trunk/django/core/formfields.py (modified) (4 diffs)
- django/trunk/django/core/handlers/modpython.py (modified) (2 diffs)
- django/trunk/django/core/handlers/wsgi.py (modified) (1 diff)
- django/trunk/django/core/template.py (modified) (2 diffs)
- django/trunk/django/middleware/cache.py (modified) (1 diff)
- django/trunk/django/middleware/common.py (modified) (1 diff)
- django/trunk/django/utils/httpwrappers.py (modified) (2 diffs)
- django/trunk/django/views/decorators/cache.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/conf/global_settings.py
r782 r786 33 33 MANAGERS = ADMINS 34 34 35 # Default MIME type to use for all HttpResponse objects, if a MIME type 36 # isn't manually specified. This is directly used as the Content-Type header. 37 DEFAULT_MIME_TYPE = 'text/html; charset=utf-8' 35 # Default content type and charset to use for all HttpResponse objects, if a 36 # MIME type isn't manually specified. These are used to construct the 37 # Content-Type header. 38 DEFAULT_CONTENT_TYPE = 'text/html' 39 DEFAULT_CHARSET = 'utf-8' 38 40 39 41 # E-mail address that error messages come from. django/trunk/django/core/formfields.py
r702 r786 2 2 from django.core.exceptions import PermissionDenied 3 3 from django.utils.html import escape 4 from django.conf.settings import DEFAULT_CHARSET 4 5 5 6 FORM_FIELD_ID_PREFIX = 'id_' … … 222 223 223 224 def isValidLength(self, data, form): 224 if data and self.maxlength and len(data ) > self.maxlength:225 if data and self.maxlength and len(data.decode(DEFAULT_CHARSET)) > self.maxlength: 225 226 raise validators.ValidationError, "Ensure your text is less than %s characters." % self.maxlength 226 227 … … 236 237 maxlength = 'maxlength="%s" ' % self.maxlength 237 238 if isinstance(data, unicode): 238 data = data.encode( 'utf-8')239 data = data.encode(DEFAULT_CHARSET) 239 240 return '<input type="text" id="%s" class="v%s%s" name="%s" size="%s" value="%s" %s/>' % \ 240 241 (FORM_FIELD_ID_PREFIX + self.field_name, self.__class__.__name__, self.is_required and ' required' or '', … … 265 266 data = '' 266 267 if isinstance(data, unicode): 267 data = data.encode( 'utf-8')268 data = data.encode(DEFAULT_CHARSET) 268 269 return '<textarea id="%s" class="v%s%s" name="%s" rows="%s" cols="%s">%s</textarea>' % \ 269 270 (FORM_FIELD_ID_PREFIX + self.field_name, self.__class__.__name__, self.is_required and ' required' or '', django/trunk/django/core/handlers/modpython.py
r518 r786 151 151 def populate_apache_request(http_response, mod_python_req): 152 152 "Populates the mod_python request object with an HttpResponse" 153 mod_python_req.content_type = http_response['Content-Type'] or httpwrappers.DEFAULT_MIME_TYPE 153 from django.conf import settings 154 mod_python_req.content_type = http_response['Content-Type'] 154 155 for key, value in http_response.headers.items(): 155 156 if key != 'Content-Type': … … 158 159 mod_python_req.headers_out.add('Set-Cookie', c.output(header='')) 159 160 mod_python_req.status = http_response.status_code 160 mod_python_req.write(http_response.get_content_as_string( 'utf-8'))161 mod_python_req.write(http_response.get_content_as_string(settings.DEFAULT_CHARSET)) 161 162 162 163 def handler(req): django/trunk/django/core/handlers/wsgi.py
r636 r786 168 168 for c in response.cookies.values(): 169 169 response_headers.append(('Set-Cookie', c.output(header=''))) 170 output = [response.get_content_as_string( 'utf-8')]170 output = [response.get_content_as_string(settings.DEFAULT_CHARSET)] 171 171 start_response(status, response_headers) 172 172 return output django/trunk/django/core/template.py
r644 r786 56 56 """ 57 57 import re 58 from django.conf.settings import DEFAULT_CHARSET 58 59 59 60 __all__ = ('Template','Context','compile_string') … … 475 476 output = str(output) 476 477 elif isinstance(output, unicode): 477 output = output.encode( 'utf-8')478 output = output.encode(DEFAULT_CHARSET) 478 479 return output 479 480 django/trunk/django/middleware/cache.py
r178 r786 77 77 """ 78 78 if request._cache_middleware_set_cache: 79 content = response.get_content_as_string( 'utf-8')79 content = response.get_content_as_string(settings.DEFAULT_CHARSET) 80 80 if request._cache_middleware_accepts_gzip: 81 81 content = compress_string(content) django/trunk/django/middleware/common.py
r782 r786 77 77 # Use ETags, if requested. 78 78 if settings.USE_ETAGS: 79 etag = md5.new(response.get_content_as_string( 'utf-8')).hexdigest()79 etag = md5.new(response.get_content_as_string(settings.DEFAULT_CHARSET)).hexdigest() 80 80 if request.META.get('HTTP_IF_NONE_MATCH') == etag: 81 81 response = httpwrappers.HttpResponseNotModified() django/trunk/django/utils/httpwrappers.py
r711 r786 2 2 from pprint import pformat 3 3 from urllib import urlencode 4 import datastructures4 from django.utils import datastructures 5 5 6 6 class HttpRequest(object): # needs to be new-style class because subclasses define "property"s … … 140 140 def __init__(self, content='', mimetype=None): 141 141 if not mimetype: 142 from django.conf.settings import DEFAULT_ MIME_TYPE143 mimetype = DEFAULT_MIME_TYPE142 from django.conf.settings import DEFAULT_CONTENT_TYPE, DEFAULT_CHARSET 143 mimetype = "%s; charset=%s" % (DEFAULT_CONTENT_TYPE, DEFAULT_CHARSET) 144 144 self.content = content 145 145 self.headers = {'Content-Type':mimetype} django/trunk/django/views/decorators/cache.py
r175 r786 2 2 from django.utils.httpwrappers import HttpResponseNotModified 3 3 from django.utils.text import compress_string 4 from django.conf.settings import DEFAULT_CHARSET 4 5 import datetime, md5 5 6 … … 26 27 if response is None: 27 28 response = view_func(request, *args, **kwargs) 28 content = response.get_content_as_string( 'utf-8')29 content = response.get_content_as_string(DEFAULT_CHARSET) 29 30 if accepts_gzip: 30 31 content = compress_string(content)
