mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
boulder-oracle-sprint: Merged to [5061]
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5062 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
172d4ba33b
commit
62ba18d750
3
AUTHORS
3
AUTHORS
@ -78,6 +78,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Jason Davies (Esaj) <http://www.jasondavies.com/>
|
Jason Davies (Esaj) <http://www.jasondavies.com/>
|
||||||
Alex Dedul
|
Alex Dedul
|
||||||
deric@monowerks.com
|
deric@monowerks.com
|
||||||
|
Max Derkachev <mderk@yandex.ru>
|
||||||
dne@mayonnaise.net
|
dne@mayonnaise.net
|
||||||
Maximillian Dornseif <md@hudora.de>
|
Maximillian Dornseif <md@hudora.de>
|
||||||
Jeremy Dunck <http://dunck.us/>
|
Jeremy Dunck <http://dunck.us/>
|
||||||
@ -113,6 +114,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Tom Insam
|
Tom Insam
|
||||||
Baurzhan Ismagulov <ibr@radix50.net>
|
Baurzhan Ismagulov <ibr@radix50.net>
|
||||||
jcrasta@gmail.com
|
jcrasta@gmail.com
|
||||||
|
Zak Johnson <zakj@nox.cx>
|
||||||
Michael Josephson <http://www.sdjournal.com/>
|
Michael Josephson <http://www.sdjournal.com/>
|
||||||
jpellerin@gmail.com
|
jpellerin@gmail.com
|
||||||
junzhang.jn@gmail.com
|
junzhang.jn@gmail.com
|
||||||
@ -180,6 +182,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Brian Ray <http://brianray.chipy.org/>
|
Brian Ray <http://brianray.chipy.org/>
|
||||||
remco@diji.biz
|
remco@diji.biz
|
||||||
rhettg@gmail.com
|
rhettg@gmail.com
|
||||||
|
Armin Ronacher
|
||||||
Oliver Rutherfurd <http://rutherfurd.net/>
|
Oliver Rutherfurd <http://rutherfurd.net/>
|
||||||
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
|
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
|
||||||
David Schein
|
David Schein
|
||||||
|
@ -273,7 +273,7 @@ class AnonymousUser(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'AnonymousUser'
|
return _('AnonymousUser')
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return isinstance(other, self.__class__)
|
return isinstance(other, self.__class__)
|
||||||
|
@ -332,7 +332,9 @@ class NullBooleanField(BooleanField):
|
|||||||
return {True: True, False: False}.get(value, None)
|
return {True: True, False: False}.get(value, None)
|
||||||
|
|
||||||
class ChoiceField(Field):
|
class ChoiceField(Field):
|
||||||
def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None, help_text=None):
|
widget = Select
|
||||||
|
|
||||||
|
def __init__(self, choices=(), required=True, widget=None, label=None, initial=None, help_text=None):
|
||||||
super(ChoiceField, self).__init__(required, widget, label, initial, help_text)
|
super(ChoiceField, self).__init__(required, widget, label, initial, help_text)
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
|
|
||||||
@ -364,9 +366,7 @@ class ChoiceField(Field):
|
|||||||
|
|
||||||
class MultipleChoiceField(ChoiceField):
|
class MultipleChoiceField(ChoiceField):
|
||||||
hidden_widget = MultipleHiddenInput
|
hidden_widget = MultipleHiddenInput
|
||||||
|
widget = SelectMultiple
|
||||||
def __init__(self, choices=(), required=True, widget=SelectMultiple, label=None, initial=None, help_text=None):
|
|
||||||
super(MultipleChoiceField, self).__init__(choices, required, widget, label, initial, help_text)
|
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
"""
|
"""
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from django.template import resolve_variable, Library
|
from django.template import resolve_variable, Library
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext
|
from django.utils.translation import gettext, ngettext
|
||||||
import re
|
import re
|
||||||
import random as random_module
|
import random as random_module
|
||||||
|
|
||||||
@ -517,12 +517,12 @@ def filesizeformat(bytes):
|
|||||||
return "0 bytes"
|
return "0 bytes"
|
||||||
|
|
||||||
if bytes < 1024:
|
if bytes < 1024:
|
||||||
return "%d byte%s" % (bytes, bytes != 1 and 's' or '')
|
return ngettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes}
|
||||||
if bytes < 1024 * 1024:
|
if bytes < 1024 * 1024:
|
||||||
return "%.1f KB" % (bytes / 1024)
|
return gettext("%.1f KB") % (bytes / 1024)
|
||||||
if bytes < 1024 * 1024 * 1024:
|
if bytes < 1024 * 1024 * 1024:
|
||||||
return "%.1f MB" % (bytes / (1024 * 1024))
|
return gettext("%.1f MB") % (bytes / (1024 * 1024))
|
||||||
return "%.1f GB" % (bytes / (1024 * 1024 * 1024))
|
return gettext("%.1f GB") % (bytes / (1024 * 1024 * 1024))
|
||||||
|
|
||||||
def pluralize(value, arg='s'):
|
def pluralize(value, arg='s'):
|
||||||
"""
|
"""
|
||||||
|
@ -41,7 +41,10 @@ class FilterNode(Node):
|
|||||||
def render(self, context):
|
def render(self, context):
|
||||||
output = self.nodelist.render(context)
|
output = self.nodelist.render(context)
|
||||||
# apply filters
|
# apply filters
|
||||||
return self.filter_expr.resolve(Context({'var': output}))
|
context.update({'var': output})
|
||||||
|
filtered = self.filter_expr.resolve(context)
|
||||||
|
context.pop()
|
||||||
|
return filtered
|
||||||
|
|
||||||
class FirstOfNode(Node):
|
class FirstOfNode(Node):
|
||||||
def __init__(self, vars):
|
def __init__(self, vars):
|
||||||
@ -999,7 +1002,7 @@ def do_with(parser, token):
|
|||||||
"""
|
"""
|
||||||
bits = list(token.split_contents())
|
bits = list(token.split_contents())
|
||||||
if len(bits) != 4 or bits[2] != "as":
|
if len(bits) != 4 or bits[2] != "as":
|
||||||
raise TemplateSyntaxError, "%r expected format is 'value as name'" % tagname
|
raise TemplateSyntaxError, "%r expected format is 'value as name'" % bits[0]
|
||||||
var = parser.compile_filter(bits[1])
|
var = parser.compile_filter(bits[1])
|
||||||
name = bits[3]
|
name = bits[3]
|
||||||
nodelist = parser.parse(('endwith',))
|
nodelist = parser.parse(('endwith',))
|
||||||
|
@ -211,7 +211,7 @@ class MultiValueDict(dict):
|
|||||||
def update(self, *args, **kwargs):
|
def update(self, *args, **kwargs):
|
||||||
"update() extends rather than replaces existing key lists. Also accepts keyword args."
|
"update() extends rather than replaces existing key lists. Also accepts keyword args."
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
raise TypeError, "update expected at most 1 arguments, got %d", len(args)
|
raise TypeError, "update expected at most 1 arguments, got %d" % len(args)
|
||||||
if args:
|
if args:
|
||||||
other_dict = args[0]
|
other_dict = args[0]
|
||||||
if isinstance(other_dict, MultiValueDict):
|
if isinstance(other_dict, MultiValueDict):
|
||||||
|
@ -90,11 +90,18 @@ def technical_500_response(request, exc_type, exc_value, tb):
|
|||||||
exc_type, exc_value, tb, template_info = get_template_exception_info(exc_type, exc_value, tb)
|
exc_type, exc_value, tb, template_info = get_template_exception_info(exc_type, exc_value, tb)
|
||||||
frames = []
|
frames = []
|
||||||
while tb is not None:
|
while tb is not None:
|
||||||
|
# support for __traceback_hide__ which is used by a few libraries
|
||||||
|
# to hide internal frames.
|
||||||
|
if tb.tb_frame.f_locals.get('__traceback_hide__'):
|
||||||
|
tb = tb.tb_next
|
||||||
|
continue
|
||||||
filename = tb.tb_frame.f_code.co_filename
|
filename = tb.tb_frame.f_code.co_filename
|
||||||
function = tb.tb_frame.f_code.co_name
|
function = tb.tb_frame.f_code.co_name
|
||||||
lineno = tb.tb_lineno - 1
|
lineno = tb.tb_lineno - 1
|
||||||
pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7)
|
loader = tb.tb_frame.f_globals.get('__loader__')
|
||||||
if pre_context_lineno:
|
module_name = tb.tb_frame.f_globals.get('__name__')
|
||||||
|
pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7, loader, module_name)
|
||||||
|
if pre_context_lineno is not None:
|
||||||
frames.append({
|
frames.append({
|
||||||
'tb': tb,
|
'tb': tb,
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
@ -161,13 +168,26 @@ def empty_urlconf(request):
|
|||||||
})
|
})
|
||||||
return HttpResponseNotFound(t.render(c), mimetype='text/html')
|
return HttpResponseNotFound(t.render(c), mimetype='text/html')
|
||||||
|
|
||||||
def _get_lines_from_file(filename, lineno, context_lines):
|
def _get_lines_from_file(filename, lineno, context_lines, loader=None, module_name=None):
|
||||||
"""
|
"""
|
||||||
Returns context_lines before and after lineno from file.
|
Returns context_lines before and after lineno from file.
|
||||||
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
||||||
"""
|
"""
|
||||||
|
source = None
|
||||||
|
if loader is not None:
|
||||||
|
source = loader.get_source(module_name).splitlines()
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
source = open(filename).readlines()
|
f = open(filename)
|
||||||
|
try:
|
||||||
|
source = f.readlines()
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
|
except (OSError, IOError):
|
||||||
|
pass
|
||||||
|
if source is None:
|
||||||
|
return None, [], None, []
|
||||||
|
|
||||||
lower_bound = max(0, lineno - context_lines)
|
lower_bound = max(0, lineno - context_lines)
|
||||||
upper_bound = lineno + context_lines
|
upper_bound = lineno + context_lines
|
||||||
|
|
||||||
@ -176,8 +196,6 @@ def _get_lines_from_file(filename, lineno, context_lines):
|
|||||||
post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]]
|
post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]]
|
||||||
|
|
||||||
return lower_bound, pre_context, context_line, post_context
|
return lower_bound, pre_context, context_line, post_context
|
||||||
except (OSError, IOError):
|
|
||||||
return None, [], None, []
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Templates are embedded in the file so that we know the error handler will
|
# Templates are embedded in the file so that we know the error handler will
|
||||||
@ -314,7 +332,7 @@ TECHNICAL_500_TEMPLATE = """
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Exception Location:</th>
|
<th>Exception Location:</th>
|
||||||
<td>{{ lastframe.filename }} in {{ lastframe.function }}, line {{ lastframe.lineno }}</td>
|
<td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -361,7 +379,7 @@ TECHNICAL_500_TEMPLATE = """
|
|||||||
<ul class="traceback">
|
<ul class="traceback">
|
||||||
{% for frame in frames %}
|
{% for frame in frames %}
|
||||||
<li class="frame">
|
<li class="frame">
|
||||||
<code>{{ frame.filename }}</code> in <code>{{ frame.function }}</code>
|
<code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code>
|
||||||
|
|
||||||
{% if frame.context_line %}
|
{% if frame.context_line %}
|
||||||
<div class="context" id="c{{ frame.id }}">
|
<div class="context" id="c{{ frame.id }}">
|
||||||
|
@ -47,16 +47,18 @@ Fedora
|
|||||||
------
|
------
|
||||||
|
|
||||||
A Django package is available for `Fedora Linux`_, in the "Fedora Extras"
|
A Django package is available for `Fedora Linux`_, in the "Fedora Extras"
|
||||||
repository. The `current Fedora package`_ is based on Django 0.95.1, and can be
|
repository. The `current Fedora package`_ is based on Django 0.96, and can be
|
||||||
installed by typing ``yum install Django``.
|
installed by typing ``yum install Django``. The previous link is for the i386
|
||||||
|
binary. Users of other architectures should be able to use that as a starting
|
||||||
|
point to find their preferred version.
|
||||||
|
|
||||||
.. _Fedora Linux: http://fedora.redhat.com/
|
.. _Fedora Linux: http://fedora.redhat.com/
|
||||||
.. _current Fedora package: http://fedoraproject.org/extras/6/i386/repodata/repoview/Django-0-0.95.1-1.fc6.html
|
.. _current Fedora package: http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386/repoview/Django.html
|
||||||
|
|
||||||
Gentoo
|
Gentoo
|
||||||
------
|
------
|
||||||
|
|
||||||
A Django build is available for `Gentoo Linux`_, and is based on Django 0.95.1.
|
A Django build is available for `Gentoo Linux`_, and is based on Django 0.96.
|
||||||
The `current Gentoo build`_ can be installed by typing ``emerge django``.
|
The `current Gentoo build`_ can be installed by typing ``emerge django``.
|
||||||
|
|
||||||
.. _Gentoo Linux: http://www.gentoo.org/
|
.. _Gentoo Linux: http://www.gentoo.org/
|
||||||
|
@ -44,7 +44,7 @@ simple weblog app that drives the blog on djangoproject.com::
|
|||||||
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict),
|
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\w{1,2})/$', 'archive_day', info_dict),
|
||||||
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict),
|
(r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict),
|
||||||
(r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
|
(r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
|
||||||
(r'^/?$', 'archive_index', info_dict),
|
(r'^$', 'archive_index', info_dict),
|
||||||
)
|
)
|
||||||
|
|
||||||
As you can see, this URLconf defines a few options in ``info_dict``.
|
As you can see, this URLconf defines a few options in ``info_dict``.
|
||||||
|
@ -259,6 +259,7 @@ class Templates(unittest.TestCase):
|
|||||||
'filter01': ('{% filter upper %}{% endfilter %}', {}, ''),
|
'filter01': ('{% filter upper %}{% endfilter %}', {}, ''),
|
||||||
'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'),
|
'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'),
|
||||||
'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'),
|
'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'),
|
||||||
|
'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'),
|
||||||
|
|
||||||
### FIRSTOF TAG ###########################################################
|
### FIRSTOF TAG ###########################################################
|
||||||
'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''),
|
'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''),
|
||||||
@ -654,6 +655,9 @@ class Templates(unittest.TestCase):
|
|||||||
'with01': ('{% with dict.key as key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, '50'),
|
'with01': ('{% with dict.key as key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, '50'),
|
||||||
'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')),
|
'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')),
|
||||||
|
|
||||||
|
'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
|
||||||
|
'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError),
|
||||||
|
|
||||||
### NOW TAG ########################################################
|
### NOW TAG ########################################################
|
||||||
# Simple case
|
# Simple case
|
||||||
'now01' : ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),
|
'now01' : ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user