1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

unicode: Merged from trunk up to [5333].

git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5337 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-05-25 03:02:12 +00:00
parent 5a396c8b1d
commit 78b75b9065
4 changed files with 5 additions and 27 deletions

View File

@ -73,6 +73,7 @@ def result_headers(cl):
for i, field_name in enumerate(lookup_opts.admin.list_display): for i, field_name in enumerate(lookup_opts.admin.list_display):
try: try:
f = lookup_opts.get_field(field_name) f = lookup_opts.get_field(field_name)
admin_order_field = None
except models.FieldDoesNotExist: except models.FieldDoesNotExist:
# For non-field list_display values, check for the function # For non-field list_display values, check for the function
# attribute "short_description". If that doesn't exist, fall back # attribute "short_description". If that doesn't exist, fall back
@ -89,7 +90,8 @@ def result_headers(cl):
header = field_name.replace('_', ' ') header = field_name.replace('_', ' ')
# It is a non-field, but perhaps one that is sortable # It is a non-field, but perhaps one that is sortable
if not getattr(getattr(cl.model, field_name), "admin_order_field", None): admin_order_field = getattr(getattr(cl.model, field_name), "admin_order_field", None)
if not admin_order_field:
yield {"text": header} yield {"text": header}
continue continue
@ -104,7 +106,7 @@ def result_headers(cl):
th_classes = [] th_classes = []
new_order_type = 'asc' new_order_type = 'asc'
if field_name == cl.order_field: if field_name == cl.order_field or admin_order_field == cl.order_field:
th_classes.append('sorted %sending' % cl.order_type.lower()) th_classes.append('sorted %sending' % cl.order_type.lower())
new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()] new_order_type = {'asc': 'desc', 'desc': 'asc'}[cl.order_type.lower()]

View File

@ -35,7 +35,6 @@ def Deserializer(stream_or_string, **options):
stream = StringIO(stream_or_string) stream = StringIO(stream_or_string)
else: else:
stream = stream_or_string stream = stream_or_string
#for obj in PythonDeserializer(simplejson.load(stream, cls=DjangoJSONDecoder)):
for obj in PythonDeserializer(simplejson.load(stream)): for obj in PythonDeserializer(simplejson.load(stream)):
yield obj yield obj
@ -62,25 +61,3 @@ class DjangoJSONEncoder(simplejson.JSONEncoder):
# Older, deprecated class name (for backwards compatibility purposes). # Older, deprecated class name (for backwards compatibility purposes).
DateTimeAwareJSONEncoder = DjangoJSONEncoder DateTimeAwareJSONEncoder = DjangoJSONEncoder
## Our override for simplejson.JSONNumber, because we want to use decimals in
## preference to floats (we can convert decimal -> float when they stored, if
## needed, but cannot go the other way).
#def DjangoNumber(match, context):
# match = DjangoNumber.regex.match(match.string, *match.span())
# integer, frac, exp = match.groups()
# if exp:
# res = float(integer + (frac or '') + (exp or ''))
# elif frac:
# res = decimal.Decimal(integer + frac)
# else:
# res = int(integer)
# return res, None
#decoder.pattern(r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?')(DjangoNumber)
#
#converters = decoder.ANYTHING[:]
#converters[-1] = DjangoNumber
#decoder.JSONScanner = decoder.Scanner(converters)
#
#class DjangoJSONDecoder(simplejson.JSONDecoder):
# _scanner = decoder.Scanner(converters)
#

View File

@ -25,7 +25,6 @@ django_conversions.update({
FIELD_TYPE.DATE: util.typecast_date, FIELD_TYPE.DATE: util.typecast_date,
FIELD_TYPE.TIME: util.typecast_time, FIELD_TYPE.TIME: util.typecast_time,
FIELD_TYPE.DECIMAL: util.typecast_decimal, FIELD_TYPE.DECIMAL: util.typecast_decimal,
FIELD_TYPE.NEWDECIMAL: util.typecast_decimal,
}) })
# This should match the numerical portion of the version numbers (we can treat # This should match the numerical portion of the version numbers (we can treat

View File

@ -488,7 +488,7 @@ class TokenParser(object):
while i < len(subject) and subject[i] != c: while i < len(subject) and subject[i] != c:
i += 1 i += 1
if i >= len(subject): if i >= len(subject):
raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % subject raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject)
i += 1 i += 1
s = subject[p:i] s = subject[p:i]
while i < len(subject) and subject[i] in (' ', '\t'): while i < len(subject) and subject[i] in (' ', '\t'):