Changeset 5399
- Timestamp:
- 06/01/07 01:19:01 (1 year ago)
- Files:
-
- django/branches/unicode (modified) (1 prop)
- django/branches/unicode/django/db/models/query.py (modified) (3 diffs)
- django/branches/unicode/django/oldforms/__init__.py (modified) (1 diff)
- django/branches/unicode/django/template/defaulttags.py (modified) (2 diffs)
- django/branches/unicode/django/test/_doctest.py (copied) (copied from django/trunk/django/test/_doctest.py)
- django/branches/unicode/django/test/doctest.py (deleted)
- django/branches/unicode/django/test/simple.py (modified) (1 diff)
- django/branches/unicode/django/test/testcases.py (modified) (1 diff)
- django/branches/unicode/docs/testing.txt (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/lookup/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode
- Property svnmerge-integrated changed from /django/trunk:1-5380 to /django/trunk:1-5398
django/branches/unicode/django/db/models/query.py
r5203 r5399 556 556 def __init__(self, *args, **kwargs): 557 557 super(ValuesQuerySet, self).__init__(*args, **kwargs) 558 # select_related and select aren't supported in values().558 # select_related isn't supported in values(). 559 559 self._select_related = False 560 self._select = {}561 560 562 561 def iterator(self): … … 568 567 # self._fields is a list of field names to fetch. 569 568 if self._fields: 570 columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] 569 #columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] 570 if not self._select: 571 columns = [self.model._meta.get_field(f, many_to_many=False).column for f in self._fields] 572 else: 573 columns = [] 574 for f in self._fields: 575 if f in [field.name for field in self.model._meta.fields]: 576 columns.append( self.model._meta.get_field(f, many_to_many=False).column ) 577 elif not self._select.has_key( f ): 578 raise FieldDoesNotExist, '%s has no field named %r' % ( self.model._meta.object_name, f ) 579 571 580 field_names = self._fields 572 581 else: # Default to all fields. … … 575 584 576 585 select = ['%s.%s' % (backend.quote_name(self.model._meta.db_table), backend.quote_name(c)) for c in columns] 586 587 # Add any additional SELECTs. 588 if self._select: 589 select.extend(['(%s) AS %s' % (quote_only_if_word(s[1]), backend.quote_name(s[0])) for s in self._select.items()]) 590 577 591 cursor = connection.cursor() 578 592 cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) django/branches/unicode/django/oldforms/__init__.py
r5310 r5399 793 793 import decimal 794 794 except ImportError: 795 from django.utils import decimal795 from django.utils import _decimal as decimal 796 796 try: 797 797 return decimal.Decimal(data) django/branches/unicode/django/template/defaulttags.py
r5126 r5399 239 239 output = [] # list of dictionaries in the format {'grouper': 'key', 'list': [list of contents]} 240 240 for obj in obj_list: 241 grouper = self.expression.resolve( Context({'var': obj}), True)241 grouper = self.expression.resolve(obj, True) 242 242 # TODO: Is this a sensible way to determine equality? 243 243 if output and repr(output[-1]['grouper']) == repr(grouper): … … 849 849 raise TemplateSyntaxError, "next-to-last argument to 'regroup' tag must be 'as'" 850 850 851 expression = parser.compile_filter( 'var.%s' %lastbits_reversed[2][::-1])851 expression = parser.compile_filter(lastbits_reversed[2][::-1]) 852 852 853 853 var_name = lastbits_reversed[0][::-1] django/branches/unicode/django/test/simple.py
r5185 r5399 1 import unittest , doctest1 import unittest 2 2 from django.conf import settings 3 from django.test import _doctest as doctest 3 4 from django.test.utils import setup_test_environment, teardown_test_environment 4 5 from django.test.utils import create_test_db, destroy_test_db django/branches/unicode/django/test/testcases.py
r5241 r5399 1 import re, doctest,unittest1 import re, unittest 2 2 from urlparse import urlparse 3 3 from django.db import transaction 4 4 from django.core import management, mail 5 5 from django.db.models import get_apps 6 from django.test import _doctest as doctest 6 7 from django.test.client import Client 7 8 django/branches/unicode/docs/testing.txt
r5381 r5399 148 148 "pythonic". It's designed to make writing tests as easy as possible, so 149 149 there's no overhead of writing classes or methods; you simply put tests in 150 docstrings. This gives the added advantage of giv enyour modules automatic150 docstrings. This gives the added advantage of giving your modules automatic 151 151 documentation -- well-written doctests can kill both the documentation and the 152 152 testing bird with a single stone. … … 580 580 details of these advanced settings. 581 581 582 .. _settings: ../settings .txt582 .. _settings: ../settings/ 583 583 584 584 The test database is created by the user in the ``DATABASE_USER`` setting. django/branches/unicode/tests/modeltests/lookup/models.py
r5386 r5399 132 132 [('headline', u'Article 1'), ('id', 1)] 133 133 134 135 # you can use values() even on extra fields 136 >>> for d in Article.objects.extra( select={'id_plus_one' : 'id + 1'} ).values('id', 'id_plus_one'): 137 ... i = d.items() 138 ... i.sort() 139 ... i 140 [('id', 5), ('id_plus_one', 6)] 141 [('id', 6), ('id_plus_one', 7)] 142 [('id', 4), ('id_plus_one', 5)] 143 [('id', 2), ('id_plus_one', 3)] 144 [('id', 3), ('id_plus_one', 4)] 145 [('id', 7), ('id_plus_one', 8)] 146 [('id', 1), ('id_plus_one', 2)] 147 148 # however, an exception FieldDoesNotExist will still be thrown 149 # if you try to access non-existent field (field that is neither on the model nor extra) 150 >>> Article.objects.extra( select={'id_plus_one' : 'id + 1'} ).values('id', 'id_plus_two') 151 Traceback (most recent call last): 152 ... 153 FieldDoesNotExist: Article has no field named 'id_plus_two' 154 134 155 # if you don't specify which fields, all are returned 135 156 >>> list(Article.objects.filter(id=5).values()) == [{'id': 5, 'headline': 'Article 5', 'pub_date': datetime(2005, 8, 1, 9, 0)}]
