mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
newforms-admin: Merged from trunk up to [6782].
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6783 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fcb30a11d8
commit
d0c49bfc60
@ -10,7 +10,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{{ field.label_tag }}{{ field.field }}
|
{{ field.label_tag }}{{ field.field }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text }}</p>{% endif %}
|
{% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -8,7 +8,6 @@ been reviewed for security issues. Don't use it for production use.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||||
from types import ListType, StringType
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -72,7 +71,7 @@ def _formatparam(param, value=None, quote=1):
|
|||||||
class Headers(object):
|
class Headers(object):
|
||||||
"""Manage a collection of HTTP response headers"""
|
"""Manage a collection of HTTP response headers"""
|
||||||
def __init__(self,headers):
|
def __init__(self,headers):
|
||||||
if type(headers) is not ListType:
|
if not isinstance(headers, list):
|
||||||
raise TypeError("Headers must be a list of name/value tuples")
|
raise TypeError("Headers must be a list of name/value tuples")
|
||||||
self._headers = headers
|
self._headers = headers
|
||||||
|
|
||||||
@ -327,7 +326,7 @@ class ServerHandler(object):
|
|||||||
"""Compute Content-Length or switch to chunked encoding if possible"""
|
"""Compute Content-Length or switch to chunked encoding if possible"""
|
||||||
try:
|
try:
|
||||||
blocks = len(self.result)
|
blocks = len(self.result)
|
||||||
except (TypeError,AttributeError,NotImplementedError):
|
except (TypeError, AttributeError, NotImplementedError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if blocks==1:
|
if blocks==1:
|
||||||
@ -356,14 +355,14 @@ class ServerHandler(object):
|
|||||||
elif self.headers is not None:
|
elif self.headers is not None:
|
||||||
raise AssertionError("Headers already set!")
|
raise AssertionError("Headers already set!")
|
||||||
|
|
||||||
assert type(status) is StringType,"Status must be a string"
|
assert isinstance(status, str),"Status must be a string"
|
||||||
assert len(status)>=4,"Status must be at least 4 characters"
|
assert len(status)>=4,"Status must be at least 4 characters"
|
||||||
assert int(status[:3]),"Status message must begin w/3-digit code"
|
assert int(status[:3]),"Status message must begin w/3-digit code"
|
||||||
assert status[3]==" ", "Status message must have a space after code"
|
assert status[3]==" ", "Status message must have a space after code"
|
||||||
if __debug__:
|
if __debug__:
|
||||||
for name,val in headers:
|
for name,val in headers:
|
||||||
assert type(name) is StringType,"Header names must be strings"
|
assert isinstance(name, str),"Header names must be strings"
|
||||||
assert type(val) is StringType,"Header values must be strings"
|
assert isinstance(val, str),"Header values must be strings"
|
||||||
assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
|
assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
|
||||||
self.status = status
|
self.status = status
|
||||||
self.headers = self.headers_class(headers)
|
self.headers = self.headers_class(headers)
|
||||||
@ -386,7 +385,7 @@ class ServerHandler(object):
|
|||||||
def write(self, data):
|
def write(self, data):
|
||||||
"""'write()' callable as specified by PEP 333"""
|
"""'write()' callable as specified by PEP 333"""
|
||||||
|
|
||||||
assert type(data) is StringType,"write() argument must be string"
|
assert isinstance(data, str), "write() argument must be string"
|
||||||
|
|
||||||
if not self.status:
|
if not self.status:
|
||||||
raise AssertionError("write() before start_response()")
|
raise AssertionError("write() before start_response()")
|
||||||
|
@ -804,7 +804,7 @@ class NodeList(list):
|
|||||||
bits.append(self.render_node(node, context))
|
bits.append(self.render_node(node, context))
|
||||||
else:
|
else:
|
||||||
bits.append(node)
|
bits.append(node)
|
||||||
return ''.join([force_unicode(b) for b in bits])
|
return mark_safe(''.join([force_unicode(b) for b in bits]))
|
||||||
|
|
||||||
def get_nodes_by_type(self, nodetype):
|
def get_nodes_by_type(self, nodetype):
|
||||||
"Return a list of all nodes of the given type"
|
"Return a list of all nodes of the given type"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
unicode_tests = ur"""
|
unicode_tests = ur"""
|
||||||
Templates can be created from unicode strings.
|
Templates can be created from unicode strings.
|
||||||
>>> from django.template import *
|
>>> from django.template import *
|
||||||
|
>>> from django.utils.safestring import SafeData
|
||||||
>>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}')
|
>>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}')
|
||||||
|
|
||||||
Templates can also be created from bytestrings. These are assumed by encoded
|
Templates can also be created from bytestrings. These are assumed by encoded
|
||||||
@ -24,10 +25,13 @@ Contexts can be constructed from unicode or UTF-8 bytestrings.
|
|||||||
>>> c4 = Context({u'var': '\xc4\x90\xc4\x91'})
|
>>> c4 = Context({u'var': '\xc4\x90\xc4\x91'})
|
||||||
|
|
||||||
Since both templates and all four contexts represent the same thing, they all
|
Since both templates and all four contexts represent the same thing, they all
|
||||||
render the same (and are returned as unicode objects).
|
render the same (and are returned as unicode objects and "safe" objects as
|
||||||
|
well, for auto-escaping purposes).
|
||||||
|
|
||||||
>>> t1.render(c3) == t2.render(c3)
|
>>> t1.render(c3) == t2.render(c3)
|
||||||
True
|
True
|
||||||
>>> type(t1.render(c3))
|
>>> isinstance(t1.render(c3), unicode)
|
||||||
<type 'unicode'>
|
True
|
||||||
|
>>> isinstance(t1.render(c3), SafeData)
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user