diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-01 06:19:01 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-01 06:19:01 +0000 |
| commit | 7a30b4e03ae8848792bd114741bc2fb175d280a4 (patch) | |
| tree | 530a7af8a35e1e94bb14ac5884df09ef8c94b690 /django | |
| parent | 797c1d2a858bce0ae728c7bb2274e5b9a5b2423e (diff) | |
unicode: Merged from trunk up to [5398].
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 20 | ||||
| -rw-r--r-- | django/oldforms/__init__.py | 2 | ||||
| -rw-r--r-- | django/template/defaulttags.py | 4 | ||||
| -rw-r--r-- | django/test/_doctest.py (renamed from django/test/doctest.py) | 5 | ||||
| -rw-r--r-- | django/test/simple.py | 3 | ||||
| -rw-r--r-- | django/test/testcases.py | 3 |
6 files changed, 29 insertions, 8 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 666924eb79..930552ad47 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -555,9 +555,8 @@ class QuerySet(object): class ValuesQuerySet(QuerySet): def __init__(self, *args, **kwargs): super(ValuesQuerySet, self).__init__(*args, **kwargs) - # select_related and select aren't supported in values(). + # select_related isn't supported in values(). self._select_related = False - self._select = {} def iterator(self): try: @@ -567,13 +566,28 @@ class ValuesQuerySet(QuerySet): # self._fields is a list of field names to fetch. if self._fields: - columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] + #columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] + if not self._select: + columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] + else: + columns = [] + for f in self._fields: + if f in [field.name for field in self.model._meta.fields]: + columns.append( self.model._meta.get_field(f, many_to_many=False).column ) + elif not self._select.has_key( f ): + raise FieldDoesNotExist, '%s has no field named %r' % ( self.model._meta.object_name, f ) + field_names = self._fields else: # Default to all fields. columns = [f.column for f in self.model._meta.fields] field_names = [f.attname for f in self.model._meta.fields] select = ['%s.%s' % (backend.quote_name(self.model._meta.db_table), backend.quote_name(c)) for c in columns] + + # Add any additional SELECTs. + if self._select: + select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), backend.quote_name(s[0])) for s in self._select.items()]) + cursor = connection.cursor() cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) while 1: diff --git a/django/oldforms/__init__.py b/django/oldforms/__init__.py index bc787f860c..f5407273c3 100644 --- a/django/oldforms/__init__.py +++ b/django/oldforms/__init__.py @@ -792,7 +792,7 @@ class DecimalField(TextField): try: import decimal except ImportError: - from django.utils import decimal + from django.utils import _decimal as decimal try: return decimal.Decimal(data) except decimal.InvalidOperation, e: diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index f2453dff4a..5d2d8a57e0 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -238,7 +238,7 @@ class RegroupNode(Node): return '' output = [] # list of dictionaries in the format {'grouper': 'key', 'list': [list of contents]} for obj in obj_list: - grouper = self.expression.resolve(Context({'var': obj}), True) + grouper = self.expression.resolve(obj, True) # TODO: Is this a sensible way to determine equality? if output and repr(output[-1]['grouper']) == repr(grouper): output[-1]['list'].append(obj) @@ -848,7 +848,7 @@ def regroup(parser, token): if lastbits_reversed[1][::-1] != 'as': raise TemplateSyntaxError, "next-to-last argument to 'regroup' tag must be 'as'" - expression = parser.compile_filter('var.%s' % lastbits_reversed[2][::-1]) + expression = parser.compile_filter(lastbits_reversed[2][::-1]) var_name = lastbits_reversed[0][::-1] return RegroupNode(target, expression, var_name) diff --git a/django/test/doctest.py b/django/test/_doctest.py index 3b364f0a75..8777a2cbba 100644 --- a/django/test/doctest.py +++ b/django/test/_doctest.py @@ -1,3 +1,8 @@ +# This is a slightly modified version of the doctest.py that shipped with Python 2.4 +# It incorporates changes that have been submitted the the Python ticket tracker +# as ticket #1521051. These changes allow for a DoctestRunner and Doctest base +# class to be specified when constructing a DoctestSuite. + # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). # Major enhancements and refactoring by: diff --git a/django/test/simple.py b/django/test/simple.py index cfaa09a0a4..5f7f86f220 100644 --- a/django/test/simple.py +++ b/django/test/simple.py @@ -1,5 +1,6 @@ -import unittest, doctest +import unittest from django.conf import settings +from django.test import _doctest as doctest from django.test.utils import setup_test_environment, teardown_test_environment from django.test.utils import create_test_db, destroy_test_db from django.test.testcases import OutputChecker, DocTestRunner diff --git a/django/test/testcases.py b/django/test/testcases.py index 439dc8ba9e..bc4cde226c 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1,8 +1,9 @@ -import re, doctest, unittest +import re, unittest from urlparse import urlparse from django.db import transaction from django.core import management, mail from django.db.models import get_apps +from django.test import _doctest as doctest from django.test.client import Client normalize_long_ints = lambda s: re.sub(r'(?<![\w])(\d+)L(?![\w])', '\\1', s) |
