Permalink
Browse files

unicode: Merged changes from trunk up to [5460].

git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5462 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 0b4122d commit 748ea65a6180293c356faa3ff0e754cb1d678d14 @malcolmt malcolmt committed Jun 11, 2007
View
@@ -73,6 +73,7 @@ answer newbie questions, and generally made Django that much better:
Michal Chruszcz <troll@pld-linux.org>
Ian Clelland <clelland@gmail.com>
crankycoder@gmail.com
+ Pete Crosier <pete.crosier@gmail.com>
Matt Croydon <http://www.postneo.com/>
flavio.curella@gmail.com
Jure Cuhalev <gandalf@owca.info>
@@ -131,6 +132,7 @@ answer newbie questions, and generally made Django that much better:
junzhang.jn@gmail.com
Antti Kaihola <http://akaihola.blogspot.com/>
Ben Dean Kawamura <ben.dean.kawamura@gmail.com>
+ ian.g.kelly@gmail.com
Garth Kidd <http://www.deadlybloodyserious.com/>
kilian <kilian.cavalotti@lip6.fr>
Sune Kirkeby <http://ibofobi.dk/>
@@ -171,6 +173,7 @@ answer newbie questions, and generally made Django that much better:
mitakummaa@gmail.com
mmarshall
Eric Moritz <http://eric.themoritzfamily.com/>
+ mrmachine <real.human@mrmachine.net>
Robin Munn <http://www.geekforgod.com/>
Robert Myers <myer0052@gmail.com>
Nebojša Dorđević
@@ -236,6 +239,7 @@ answer newbie questions, and generally made Django that much better:
wangchun <yaohua2000@gmail.com>
Dan Watson <http://theidioteque.net/>
Chris Wesseling <Chris.Wesseling@cwi.nl>
+ James Wheare <django@sparemint.com>
charly.wilhelm@gmail.com
Rachel Willmer <http://www.willmer.com/kb/>
Gary Wilson <gary.wilson@gmail.com>
View
@@ -1 +1,8 @@
VERSION = (0, 97, 'pre')
+
+def get_version():
+ "Returns the version as a human-format string."
+ v = '.'.join([str(i) for i in VERSION[:-1]])
+ if VERSION[-1]:
+ v += '-' + VERSION[-1]
+ return v
@@ -244,7 +244,8 @@
# The User-Agent string to use when checking for URL validity through the
# isExistingURL validator.
-URL_VALIDATOR_USER_AGENT = "Django/0.96pre (http://www.djangoproject.com)"
+from django import get_version
+URL_VALIDATOR_USER_AGENT = "Django/%s (http://www.djangoproject.com)" % get_version()
##############
# MIDDLEWARE #
Binary file not shown.
@@ -2202,10 +2202,11 @@ msgstr[0] "dag"
msgstr[1] "dagen"
#: utils/timesince.py:16
+# In the timesince context it is stilistically wrong to use the plural for hour in Dutch.
msgid "hour"
msgid_plural "hours"
msgstr[0] "uur"
-msgstr[1] "uren"
+msgstr[1] "uur"
#: utils/timesince.py:17
msgid "minute"
View
@@ -3,14 +3,17 @@
import django
from django.core.exceptions import ImproperlyConfigured
-import os, re, shutil, sys, textwrap
from optparse import OptionParser
from django.utils import termcolors
+import os, re, shutil, sys, textwrap
# For Python 2.3
if not hasattr(__builtins__, 'set'):
from sets import Set as set
+# For backwards compatibility: get_version() used to be in this module.
+get_version = django.get_version
+
MODULE_TEMPLATE = ''' {%% if perms.%(app)s.%(addperm)s or perms.%(app)s.%(changeperm)s %%}
<tr>
<th>{%% if perms.%(app)s.%(changeperm)s %%}<a href="%(app)s/%(mod)s/">{%% endif %%}%(name)s{%% if perms.%(app)s.%(changeperm)s %%}</a>{%% endif %%}</th>
@@ -93,14 +96,6 @@ def _get_sequence_list():
# field as the field to which it points.
get_rel_data_type = lambda f: (f.get_internal_type() in ('AutoField', 'PositiveIntegerField', 'PositiveSmallIntegerField')) and 'IntegerField' or f.get_internal_type()
-def get_version():
- "Returns the version as a human-format string."
- from django import VERSION
- v = '.'.join([str(i) for i in VERSION[:-1]])
- if VERSION[-1]:
- v += '-' + VERSION[-1]
- return v
-
def get_sql_create(app):
"Returns a list of the CREATE TABLE SQL statements for the given app."
from django.db import get_creation_module, models
@@ -239,22 +239,27 @@ def get_sql_sequence_reset(style, model_list):
from django.db import models
output = []
for model in model_list:
+ # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
+ # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
+ # if there are records (as the max pk value is already in use), otherwise set it to false.
for f in model._meta.fields:
if isinstance(f, models.AutoField):
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(quote_name(model._meta.db_table))))
break # Only one AutoField is allowed per model, so don't bother continuing.
for f in model._meta.many_to_many:
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('id')),
+ style.SQL_FIELD(quote_name('id')),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(f.m2m_db_table())))
return output
@@ -180,22 +180,27 @@ def get_sql_sequence_reset(style, model_list):
from django.db import models
output = []
for model in model_list:
+ # Use `coalesce` to set the sequence for each model to the max pk value if there are records,
+ # or 1 if there are none. Set the `is_called` property (the third argument to `setval`) to true
+ # if there are records (as the max pk value is already in use), otherwise set it to false.
for f in model._meta.fields:
if isinstance(f, models.AutoField):
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_%s_seq' % (model._meta.db_table, f.column))),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_FIELD(quote_name(f.column)),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(quote_name(model._meta.db_table))))
break # Only one AutoField is allowed per model, so don't bother continuing.
for f in model._meta.many_to_many:
- output.append("%s setval('%s', (%s max(%s) %s %s));" % \
+ output.append("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
(style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('%s_id_seq' % f.m2m_db_table())),
- style.SQL_KEYWORD('SELECT'),
style.SQL_FIELD(quote_name('id')),
+ style.SQL_FIELD(quote_name('id')),
+ style.SQL_KEYWORD('IS NOT'),
style.SQL_KEYWORD('FROM'),
style.SQL_TABLE(f.m2m_db_table())))
return output
@@ -98,7 +98,7 @@ def typecast_boolean(s):
return str(s)[0].lower() == 't'
def typecast_decimal(s):
- if s is None:
+ if s is None or s == '':
return None
return decimal.Decimal(s)
@@ -8,6 +8,14 @@
import sys
import re
+if not hasattr(__builtins__, 'reversed'):
+ # For Python 2.3.
+ # From http://www.python.org/doc/current/tut/node11.html
+ def reversed(data):
+ for index in xrange(len(data)-1, -1, -1):
+ yield data[index]
+
+
register = Library()
class CommentNode(Node):
@@ -104,11 +112,7 @@ def render(self, context):
values = list(values)
len_values = len(values)
if self.reversed:
- # From http://www.python.org/doc/current/tut/node11.html
- def reverse(data):
- for index in range(len(data)-1, -1, -1):
- yield data[index]
- values = reverse(values)
+ values = reversed(values)
unpack = len(self.loopvars) > 1
for i, item in enumerate(values):
context['forloop'] = {
View
@@ -3,7 +3,7 @@
from django.utils.html import escape
from django.http import HttpResponseServerError, HttpResponseNotFound
from django.utils.encoding import smart_unicode
-import os, re
+import os, re, sys
HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST')
@@ -132,6 +132,8 @@ def technical_500_response(request, exc_type, exc_value, tb):
'request': request,
'request_protocol': request.is_secure() and "https" or "http",
'settings': get_safe_settings(),
+ 'sys_executable' : sys.executable,
+ 'sys_version_info' : '%d.%d.%d' % sys.version_info[0:3],
'template_info': template_info,
'template_does_not_exist': template_does_not_exist,
'loader_debug_info': loader_debug_info,
@@ -346,6 +348,14 @@ def _get_lines_from_file(filename, lineno, context_lines, loader=None, module_na
<th>Exception Location:</th>
<td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td>
</tr>
+ <tr>
+ <th>Python Executable:</th>
+ <td>{{ sys_executable|escape }}</td>
+ </tr>
+ <tr>
+ <th>Python Version:</th>
+ <td>{{ sys_version_info }}</td>
+ </tr>
</table>
</div>
{% if template_does_not_exist %}
View
@@ -730,7 +730,7 @@ Django developers are currently discussing.
Default permissions
-------------------
-Three basic permissions -- add, create and delete -- are automatically created
+Three basic permissions -- add, change and delete -- are automatically created
for each Django model that has a ``class Admin`` set. Behind the scenes, these
permissions are added to the ``auth_permission`` database table when you run
``manage.py syncdb``.
View
@@ -388,7 +388,7 @@ The lookup parameters (``**kwargs``) should be in the format described in
`Field lookups`_ below. Multiple parameters are joined via ``AND`` in the
underlying SQL statement, and the whole thing is enclosed in a ``NOT()``.
-This example excludes all entries whose ``pub_date`` is the current date/time
+This example excludes all entries whose ``pub_date`` is later than 2005-1-3
AND whose ``headline`` is "Hello"::
Entry.objects.exclude(pub_date__gt=datetime.date(2005, 1, 3), headline='Hello')
@@ -398,8 +398,8 @@ In SQL terms, that evaluates to::
SELECT ...
WHERE NOT (pub_date > '2005-1-3' AND headline = 'Hello')
-This example excludes all entries whose ``pub_date`` is the current date/time
-OR whose ``headline`` is "Hello"::
+This example excludes all entries whose ``pub_date`` is later than 2005-1-3
+AND whose headline is NOT "Hello"::
Entry.objects.exclude(pub_date__gt=datetime.date(2005, 1, 3)).exclude(headline='Hello')
Oops, something went wrong.

0 comments on commit 748ea65

Please sign in to comment.