Re: [Django] #11274: Doctests broken after r10929

2009-06-06 Thread Django
#11274: Doctests broken after r10929
+---
  Reporter:  Honza_Kral | Owner:  nobody
Status:  new| Milestone:  1.1   
 Component:  Uncategorized  |   Version:  SVN   
Resolution: |  Keywords:
 Stage:  Ready for checkin  | Has_patch:  1 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by Alex):

  * needs_better_patch:  => 0
  * stage:  Unreviewed => Ready for checkin
  * needs_tests:  => 0
  * needs_docs:  => 0

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10937 - django/branches/soc2009/multidb/docs/topics/db

2009-06-06 Thread noreply

Author: Alex
Date: 2009-06-06 22:26:12 -0500 (Sat, 06 Jun 2009)
New Revision: 10937

Modified:
   django/branches/soc2009/multidb/docs/topics/db/transactions.txt
Log:
[soc2009/multidb] Updated the transactions documentation for parts of the API 
that were extended to support multiple databases.

Modified: django/branches/soc2009/multidb/docs/topics/db/transactions.txt
===
--- django/branches/soc2009/multidb/docs/topics/db/transactions.txt 
2009-06-07 03:06:13 UTC (rev 10936)
+++ django/branches/soc2009/multidb/docs/topics/db/transactions.txt 
2009-06-07 03:26:12 UTC (rev 10937)
@@ -56,7 +56,10 @@
 For most people, implicit request-based transactions work wonderfully. However,
 if you need more fine-grained control over how transactions are managed, you
 can use Python decorators to change the way transactions are handled by a
-particular view function.
+particular view function.  All of the decorators take an option ``using``
+parameter which should be the alias for a database connection for which the
+behavior applies to.  If no alias is specified then the ``"default"`` database
+is used.
 
 .. note::
 
@@ -79,9 +82,14 @@
 def viewfunc(request):
 
 
+@transaction.autocommit(using="my_other_database")
+def viewfunc2(request):
+
+
 Within ``viewfunc()``, transactions will be committed as soon as you call
 ``model.save()``, ``model.delete()``, or any other function that writes to the
-database.
+database.  ``viewfunc2()`` will have this same behavior, but for the
+``"my_other_database"`` connection.
 
 ``django.db.transaction.commit_on_success``
 ---
@@ -95,6 +103,10 @@
 def viewfunc(request):
 
 
+@transaction.commit_on_success(using="my_other_database")
+def viewfunc2(request):
+
+
 If the function returns successfully, then Django will commit all work done
 within the function at that point. If the function raises an exception, though,
 Django will roll back the transaction.
@@ -127,6 +139,10 @@
 else:
 transaction.commit()
 
+@transaction.commit_manually(using="my_other_database")
+def viewfunc2(request):
+
+
 .. admonition:: An important note to users of earlier Django releases:
 
 The database ``connection.commit()`` and ``connection.rollback()`` methods
@@ -169,21 +185,25 @@
 the ability to perform a fine-grained rollback, rather than the full rollback
 that would be performed by ``transaction.rollback()``.
 
+Each of these functions takes a ``using`` argument which should be the name of
+a database for which the behavior applies.  If no ``using`` argument is
+provided then the ``"default"`` database is used.
+
 Savepoints are controlled by three methods on the transaction object:
 
-.. method:: transaction.savepoint()
+.. method:: transaction.savepoint(using=None)
 
 Creates a new savepoint. This marks a point in the transaction that
 is known to be in a "good" state.
 
 Returns the savepoint ID (sid).
 
-.. method:: transaction.savepoint_commit(sid)
+.. method:: transaction.savepoint_commit(sid, using=None)
 
 Updates the savepoint to include any operations that have been performed
 since the savepoint was created, or since the last commit.
 
-.. method:: transaction.savepoint_rollback(sid)
+.. method:: transaction.savepoint_rollback(sid, using=None)
 
 Rolls the transaction back to the last point at which the savepoint was
 committed.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10936 - in django/branches/soc2009/multidb: . docs/internals

2009-06-06 Thread noreply

Author: Alex
Date: 2009-06-06 22:06:13 -0500 (Sat, 06 Jun 2009)
New Revision: 10936

Modified:
   django/branches/soc2009/multidb/TODO.TXT
   django/branches/soc2009/multidb/docs/internals/contributing.txt
Log:
[soc2009/multidb] Updated the contributing documentation for the settings 
changes

Modified: django/branches/soc2009/multidb/TODO.TXT
===
--- django/branches/soc2009/multidb/TODO.TXT2009-06-07 00:30:56 UTC (rev 
10935)
+++ django/branches/soc2009/multidb/TODO.TXT2009-06-07 03:06:13 UTC (rev 
10936)
@@ -8,7 +8,6 @@
 2)  Update all old references to ``settings.DATABASE_*`` to reference
 ``settings.DATABASES``.  This includes the following locations
 
-* internals/contributing -- still needs an update on TEST_*
 * ref/settings -- needs to be upddated for TEST_*
 * topics/testing -- needs update for the TEST_* settings, plus test 
refactor
 

Modified: django/branches/soc2009/multidb/docs/internals/contributing.txt
===
--- django/branches/soc2009/multidb/docs/internals/contributing.txt 
2009-06-07 00:30:56 UTC (rev 10935)
+++ django/branches/soc2009/multidb/docs/internals/contributing.txt 
2009-06-07 03:06:13 UTC (rev 10936)
@@ -759,8 +759,8 @@
 
 If you're using another backend:
 
-* Your the ``DATABASE_USER`` option for the ``'default'`` datbase setting
-  needs to specify an existing user account for the database engine.
+* Your the ``DATABASE_USER`` option for each of your databases needs to
+  specify an existing user account for the database.
 
 * The ``DATABASE_NAME`` option must be the name of an existing database to
   which the given user has permission to connect. The unit tests will not
@@ -771,8 +771,8 @@
 
 You will also need to ensure that your database uses UTF-8 as the default
 character set. If your database server doesn't use UTF-8 as a default charset,
-you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings
-file.
+you will need to include a value for ``TEST_DATABASE_CHARSET`` in the settings
+dictionary for the applicable database.
 
 If you want to run the full suite of tests, you'll need to install a number of
 dependencies:


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11274: Doctests broken after r10929

2009-06-06 Thread Django
#11274: Doctests broken after r10929
---+
 Reporter:  Honza_Kral |   Owner:  nobody
   Status:  new|   Milestone:  1.1   
Component:  Uncategorized  | Version:  SVN   
 Keywords: |   Stage:  Unreviewed
Has_patch:  1  |  
---+
 just some formatting issues

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11273: Tutorial - Part 2 should note the first appearance of curly brackets

2009-06-06 Thread Django
#11273: Tutorial - Part 2 should note the first appearance of curly brackets
+---
 Reporter:  thiggins|   Owner:  nobody
   Status:  new |   Milestone:
Component:  Uncategorized   | Version:  1.0   
 Keywords:  curly brackets  |   Stage:  Unreviewed
Has_patch:  0   |  
+---
 Curly brackets are visually hard to distinguish from parentheses at
 ordinary screen resolutions. Their use may go unnoticed by the student,
 leading to frustration. I recommend noting their first appearance in Part
 2 of the documentation. Some remarks about the conventions governing their
 use might also be in order.

 Nice documentation generally -- thanks.

 Tom

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10934 - in django/branches/soc2009/multidb: . django/db/models/fields django/db/models/sql tests/regressiontests/multiple_database

2009-06-06 Thread noreply

Author: Alex
Date: 2009-06-06 14:38:29 -0500 (Sat, 06 Jun 2009)
New Revision: 10934

Modified:
   django/branches/soc2009/multidb/TODO.TXT
   django/branches/soc2009/multidb/django/db/models/fields/__init__.py
   django/branches/soc2009/multidb/django/db/models/sql/query.py
   
django/branches/soc2009/multidb/tests/regressiontests/multiple_database/tests.py
Log:
[soc2009/multidb] Fixed the usage of the connection during Query construction, 
and defer it until actual SQL construction.  In practice this means the GROUP 
BY optimization we do will be correctly applied based on the connection the 
Query is executed against, as oppossed to the on the QuerySet is targeting at 
the time the GROUP BY items are added

Modified: django/branches/soc2009/multidb/TODO.TXT
===
--- django/branches/soc2009/multidb/TODO.TXT2009-06-06 18:01:43 UTC (rev 
10933)
+++ django/branches/soc2009/multidb/TODO.TXT2009-06-06 19:38:29 UTC (rev 
10934)
@@ -49,7 +49,6 @@
   phase.  This involves changing the following methods:
 
 * ``Query.add_aggregate``
-* ``Query.set_group_by``
 * ``DateQuery.add_date_select``
 * ``Field.get_db_prep_lookup``
 * ``DateField.get_db_prep_value``

Modified: django/branches/soc2009/multidb/django/db/models/fields/__init__.py
===
--- django/branches/soc2009/multidb/django/db/models/fields/__init__.py 
2009-06-06 18:01:43 UTC (rev 10933)
+++ django/branches/soc2009/multidb/django/db/models/fields/__init__.py 
2009-06-06 19:38:29 UTC (rev 10934)
@@ -204,6 +204,7 @@
 sql, params = value._as_sql()
 return QueryWrapper(('(%s)' % sql), params)
 
+
 if lookup_type in ('regex', 'iregex', 'month', 'day', 'week_day', 
'search'):
 return [value]
 elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte'):

Modified: django/branches/soc2009/multidb/django/db/models/sql/query.py
===
--- django/branches/soc2009/multidb/django/db/models/sql/query.py   
2009-06-06 18:01:43 UTC (rev 10933)
+++ django/branches/soc2009/multidb/django/db/models/sql/query.py   
2009-06-06 19:38:29 UTC (rev 10934)
@@ -878,6 +878,9 @@
 qn = self.quote_name_unless_alias
 result, params = [], []
 if self.group_by is not None:
+if len(self.model._meta.fields) == len(self.group_by) and \
+self.connection.features.allows_group_by_pk:
+self.group_by = [(self.model._meta.db_table, 
self.model._meta.pk.column)]
 group_by = self.group_by or []
 
 extra_selects = []
@@ -2099,11 +2102,6 @@
 will be made automatically.
 """
 self.group_by = []
-if self.connection.features.allows_group_by_pk:
-if len(self.select) == len(self.model._meta.fields):
-self.group_by.append((self.model._meta.db_table,
-  self.model._meta.pk.column))
-return
 
 for sel in self.select:
 self.group_by.append(sel)

Modified: 
django/branches/soc2009/multidb/tests/regressiontests/multiple_database/tests.py
===
--- 
django/branches/soc2009/multidb/tests/regressiontests/multiple_database/tests.py
2009-06-06 18:01:43 UTC (rev 10933)
+++ 
django/branches/soc2009/multidb/tests/regressiontests/multiple_database/tests.py
2009-06-06 19:38:29 UTC (rev 10934)
@@ -49,3 +49,10 @@
 
 dive = Book.objects.using(db).get(title__icontains="dive")
 self.assertEqual(dive.title, "Dive into Python")
+
+dive = Book.objects.using(db).get(title__iexact="dive INTO python")
+self.assertEqual(dive.title, "Dive into Python")
+
+pro = Book.objects.using(db).get(published__year=2008)
+self.assertEqual(pro.title, "Pro Django")
+self.assertEqual(pro.published, datetime.date(2008, 12, 16))


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11272: Various minor errors in the tutorial

2009-06-06 Thread Django
#11272: Various minor errors in the tutorial
+---
  Reporter:  jjinux | Owner:  nobody
Status:  new| Milestone:
 Component:  Documentation  |   Version:  1.0   
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by jjinux):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 By the way, nice job on a great tutorial :-D

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11272: Various minor errors in the tutorial

2009-06-06 Thread Django
#11272: Various minor errors in the tutorial
---+
 Reporter:  jjinux |   Owner:  nobody
   Status:  new|   Milestone:
Component:  Documentation  | Version:  1.0   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 Here is a list of minor errors or improvements that I kept while I read
 the tutorial:

 In http://docs.djangoproject.com/en/dev/intro/overview/#intro-overview:

  * This example doesn't indent the HTML in a for loop, but elsewhere in
 the tutorial, they do.

 In http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-
 tutorial01:

  * The phrase django.contrib.sessions isn't hyperlinked like the others on
 this page.

 In http://docs.djangoproject.com/en/dev/intro/tutorial02/:

  * The grammar in the following is wrong:  "The first register Choice with
 the admin just as we did with Poll."

 In http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-
 tutorial03:

  * It says, "When you ran python django-admin.py startproject mysite at
 the beginning of Tutorial 1".  Actually, it didn't say to use "python",
 but rather to execute the script directly.

  * It says, "it loads the associated Python package/module:
 mysite.polls.views.detail."  "detail" isn't a module, it's a function.

  * It says, "Now that we've decoupled that, we need to decouple the
 'mysite.polls.urls' URLconf by removing the leading "polls/" from each
 line:".  It should be more explicit that you should get rid of all the
 stuff related to admin.  After all, the text did tell you to copy the file
 mysite/urls.py to mysite/polls/urls.py.

 In http://docs.djangoproject.com/en/dev/intro/tutorial04/#intro-
 tutorial04:

  * Since the tutorial aims to not couple the polls app to the mysite
 project, it makes sense to remove the polls package from the mysite
 package.  Otherwise, you end up with the following stuff in the URLconf:
 "(r'^(?P\d+)/vote/$', 'mysite.polls.views.vote')".  In general,
 'egrep -r "mysite.polls" mysite' should find no matches.

  * There's a problem in using a relative URL for the form.  If you go to
 http://localhost:8001/polls/1/ and just click "Vote", it'll bring you to
 http://localhost:8001/polls/1/vote/.  If you click "Vote" again, you'll
 get http://localhost:8001/polls/1/vote/vote/, which leads to a 404.  Even
 if you enter a valid value, clicking on "Vote" this second time around
 will lead to a 404.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #10733: Invalid results when deferring fields in more than one related model with only()

2009-06-06 Thread Django
#10733: Invalid results when deferring fields in more than one related model 
with
only()
---+
  Reporter:  mrts  | Owner:  nobody 

Status:  reopened  | Milestone:  1.1

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:|  Keywords:  
efficient-admin
 Stage:  Accepted  | Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Changes (by mrts):

  * status:  closed => reopened
  * resolution:  fixed =>

Comment:

 Alas, given the above models, the following happens:

 {{{
 >>> from only_breakage.models import C
 >>> from django.db import connection
 >>> import copy
 }}}

 == Expected ==

 All three tables joined:
 {{{
 >>> C.objects.all().only('name', 'a', 'b', 'a__name',
 'b__name').select_related().query.as_sql()
 ('SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_a"."id", "only_breakage_a"."name",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c"
 INNER JOIN "only_breakage_a" ON ("only_breakage_c"."a_id" =
 "only_breakage_a"."id")
 INNER JOIN "only_breakage_b" ON ("only_breakage_c"."b_id" =
 "only_breakage_b"."id")', ())
 }}}

 A single query fetches all what's needed:
 {{{
 >>> results = C.objects.all().only('name', 'a', 'b', 'a__name',
 'b__name').select_related()
 >>> connection.queries
 []
 >>> results[0].a.name
 u'a2'
 >>> connection.queries
 [{'sql': u'SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_a"."id", "only_breakage_a"."name",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c"
 INNER JOIN "only_breakage_a" ON ("only_breakage_c"."a_id" =
 "only_breakage_a"."id")
 INNER JOIN "only_breakage_b" ON ("only_breakage_c"."b_id" =
 "only_breakage_b"."id")
 LIMIT 1',
   'time': '0.002'},
 >>> queries = copy.deepcopy(connection.queries)
 >>> results[0].b.name
 u'b1'
 >>> assert connection.queries == queries
 }}}

 == Actually got ==

 Only two tables joined (the `A` table is discarded):
 {{{
 >>> C.objects.all().only('name', 'a', 'b', 'a__name',
 'b__name').select_related().query.as_sql()
 ('SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c"
 INNER JOIN "only_breakage_b" ON ("only_breakage_c"."b_id" =
 "only_breakage_b"."id")', ())
 }}}

 Three queries happen:
 {{{
 >>> results = C.objects.all().only('name', 'a', 'b', 'a__name',
 'b__name').select_related()
 >>> connection.queries
 []
 >>> results[0].a.name
 u'a2'
 >>> connection.queries
 [{'sql': u'SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c" INNER JOIN "only_breakage_b" ON
 ("only_breakage_c"."b_id" = "only_breakage_b"."id") LIMIT 1',
   'time': '0.002'},
  {'sql': u'SELECT "only_breakage_a"."id", "only_breakage_a"."name",
 "only_breakage_a"."lots_of_text", "only_breakage_a"."a_field" FROM
 "only_breakage_a" WHERE "only_breakage_a"."id" = 2 ',
   'time': '0.000'}]
 >>> results[0].b.name
 u'b1'
 >>> connection.queries
 [{'sql': u'SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c" INNER JOIN "only_breakage_b" ON
 ("only_breakage_c"."b_id" = "only_breakage_b"."id") LIMIT 1',
   'time': '0.002'},
  {'sql': u'SELECT "only_breakage_a"."id", "only_breakage_a"."name",
 "only_breakage_a"."lots_of_text", "only_breakage_a"."a_field" FROM
 "only_breakage_a" WHERE "only_breakage_a"."id" = 2 ',
   'time': '0.000'},
  {'sql': u'SELECT "only_breakage_c"."id", "only_breakage_c"."name",
 "only_breakage_c"."a_id", "only_breakage_c"."b_id",
 "only_breakage_b"."id", "only_breakage_b"."name"
 FROM "only_breakage_c" INNER JOIN "only_breakage_b" ON
 ("only_breakage_c"."b_id" = "only_breakage_b"."id") LIMIT 1',
   'time': '0.000'}]
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 

[Changeset] r10933 - in django/branches/soc2009/multidb: django/contrib/admin/templates/admin django/db/models django/db/models/sql tests/modeltests/defer tests/regressiontests/defer_regress tests/reg

2009-06-06 Thread noreply

Author: Alex
Date: 2009-06-06 13:01:43 -0500 (Sat, 06 Jun 2009)
New Revision: 10933

Modified:
   
django/branches/soc2009/multidb/django/contrib/admin/templates/admin/pagination.html
   django/branches/soc2009/multidb/django/db/models/query.py
   django/branches/soc2009/multidb/django/db/models/sql/query.py
   django/branches/soc2009/multidb/tests/modeltests/defer/models.py
   django/branches/soc2009/multidb/tests/regressiontests/defer_regress/models.py
   django/branches/soc2009/multidb/tests/regressiontests/queries/models.py
Log:
[soc2009/multidb] Merged up to trunk r10931.  Resolved the slight merge conflict

Modified: 
django/branches/soc2009/multidb/django/contrib/admin/templates/admin/pagination.html
===
--- 
django/branches/soc2009/multidb/django/contrib/admin/templates/admin/pagination.html
2009-06-06 13:48:00 UTC (rev 10932)
+++ 
django/branches/soc2009/multidb/django/contrib/admin/templates/admin/pagination.html
2009-06-06 18:01:43 UTC (rev 10933)
@@ -8,5 +8,5 @@
 {% endif %}
 {{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name 
}}{% else %}{{ cl.opts.verbose_name_plural }}{% endifequal %}
 {% if show_all_url %}{% trans 'Show all' %}{% endif %}
-{% if cl.formset and cl.result_count %}{% endif %}
+{% if cl.formset and cl.result_count %}{% endif %}
 

Modified: django/branches/soc2009/multidb/django/db/models/query.py
===
--- django/branches/soc2009/multidb/django/db/models/query.py   2009-06-06 
13:48:00 UTC (rev 10932)
+++ django/branches/soc2009/multidb/django/db/models/query.py   2009-06-06 
18:01:43 UTC (rev 10933)
@@ -7,6 +7,8 @@
 except NameError:
 from sets import Set as set # Python 2.3 fallback
 
+from copy import deepcopy
+
 from django.db import connections, transaction, IntegrityError, 
DEFAULT_DB_ALIAS
 from django.db.models.aggregates import Aggregate
 from django.db.models.fields import DateField
@@ -43,6 +45,17 @@
 # PYTHON MAGIC METHODS #
 
 
+def __deepcopy__(self, memo):
+"""
+Deep copy of a QuerySet doesn't populate the cache
+"""
+obj_dict = deepcopy(self.__dict__, memo)
+obj_dict['_iter'] = None
+
+obj = self.__class__()
+obj.__dict__.update(obj_dict)
+return obj
+
 def __getstate__(self):
 """
 Allows the QuerySet to be pickled.
@@ -193,7 +206,25 @@
 index_start = len(extra_select)
 aggregate_start = index_start + len(self.model._meta.fields)
 
-load_fields = only_load.get(self.model)
+load_fields = []
+# If only/defer clauses have been specified,
+# build the list of fields that are to be loaded.
+if only_load:
+for field, model in self.model._meta.get_fields_with_model():
+if model is None:
+model = self.model
+if field == self.model._meta.pk:
+# Record the index of the primary key when it is found
+pk_idx = len(load_fields)
+try:
+if field.name in only_load[model]:
+# Add a field that has been explicitly included
+load_fields.append(field.name)
+except KeyError:
+# Model wasn't explicitly listed in the only_load table
+# Therefore, we need to load all fields from this model
+load_fields.append(field.name)
+
 skip = None
 if load_fields and not fill_cache:
 # Some fields have been deferred, so we have to initialise

Modified: django/branches/soc2009/multidb/django/db/models/sql/query.py
===
--- django/branches/soc2009/multidb/django/db/models/sql/query.py   
2009-06-06 13:48:00 UTC (rev 10932)
+++ django/branches/soc2009/multidb/django/db/models/sql/query.py   
2009-06-06 18:01:43 UTC (rev 10933)
@@ -635,10 +635,10 @@
 # models.
 workset = {}
 for model, values in seen.iteritems():
-for field, f_model in model._meta.get_fields_with_model():
+for field in model._meta.local_fields:
 if field in values:
 continue
-add_to_dict(workset, f_model or model, field)
+add_to_dict(workset, model, field)
 for model, values in must_include.iteritems():
 # If we haven't included a model in workset, we don't add the
 # corresponding must_include fields for that model, since an
@@ -657,6 +657,12 @@
 # included any fields, we have to make sure it's mentioned
 # so that only the "must include" fields are pulled in.
 seen[model] = 

Re: [Django] #10733: Invalid results when deferring fields in more than one related model with only()

2009-06-06 Thread Django
#10733: Invalid results when deferring fields in more than one related model 
with
only()
---+
  Reporter:  mrts  | Owner:  nobody 

Status:  closed| Milestone:  1.1

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:  fixed |  Keywords:  
efficient-admin
 Stage:  Accepted  | Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by mrts):

 Indeed, this has been corrected by [10926]. Thanks!

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10932 - django/branches/releases/1.0.X

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 08:48:00 -0500 (Sat, 06 Jun 2009)
New Revision: 10932

Modified:
   django/branches/releases/1.0.X/
Log:
[1.0.X] Blocked recent trunk update from merge to branch


Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-blocked
   - 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830,10926,10928-10929
   + 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830,10926,10928-10929,10931


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10931 - django/trunk/django/contrib/admin/templates/admin

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 08:43:44 -0500 (Sat, 06 Jun 2009)
New Revision: 10931

Modified:
   django/trunk/django/contrib/admin/templates/admin/pagination.html
Log:
Fixed #11271 -- Added a translation marker for the list_editable save button. 
Thanks to dc for the report.

Modified: django/trunk/django/contrib/admin/templates/admin/pagination.html
===
--- django/trunk/django/contrib/admin/templates/admin/pagination.html   
2009-06-06 13:39:13 UTC (rev 10930)
+++ django/trunk/django/contrib/admin/templates/admin/pagination.html   
2009-06-06 13:43:44 UTC (rev 10931)
@@ -8,5 +8,5 @@
 {% endif %}
 {{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name 
}}{% else %}{{ cl.opts.verbose_name_plural }}{% endifequal %}
 {% if show_all_url %}{% trans 'Show all' %}{% endif %}
-{% if cl.formset and cl.result_count %}{% endif %}
+{% if cl.formset and cl.result_count %}{% endif %}
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10930 - django/branches/releases/1.0.X

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 08:39:13 -0500 (Sat, 06 Jun 2009)
New Revision: 10930

Modified:
   django/branches/releases/1.0.X/
Log:
[1.0.X] Blocked recent trunk updates from merge to branch


Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-blocked
   - 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830,10926
   + 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830,10926,10928-10929


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11082: exclude subquery executed twice

2009-06-06 Thread Django
#11082: exclude subquery executed twice
---+
  Reporter:  handrews  | Owner:  nobody
Status:  closed| Milestone:  1.1   
 Component:  Database layer (models, ORM)  |   Version:  SVN   
Resolution:  fixed |  Keywords:
 Stage:  Accepted  | Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 (In [10929]) Fixed #11082 -- Ensured that subqueries used in an
 exclude(Xin=) clause aren't pre-evaluated. Thanks to Henry Andrews for the
 report, and clement for the fix.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10929 - in django/trunk: django/db/models django/db/models/sql tests/regressiontests/queries

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 08:35:33 -0500 (Sat, 06 Jun 2009)
New Revision: 10929

Modified:
   django/trunk/django/db/models/query.py
   django/trunk/django/db/models/sql/query.py
   django/trunk/tests/regressiontests/queries/models.py
Log:
Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause 
aren't pre-evaluated. Thanks to Henry Andrews for the report, and clement for 
the fix.

Modified: django/trunk/django/db/models/query.py
===
--- django/trunk/django/db/models/query.py  2009-06-06 12:16:06 UTC (rev 
10928)
+++ django/trunk/django/db/models/query.py  2009-06-06 13:35:33 UTC (rev 
10929)
@@ -7,6 +7,8 @@
 except NameError:
 from sets import Set as set # Python 2.3 fallback
 
+from copy import deepcopy
+
 from django.db import connection, transaction, IntegrityError
 from django.db.models.aggregates import Aggregate
 from django.db.models.fields import DateField
@@ -40,6 +42,17 @@
 # PYTHON MAGIC METHODS #
 
 
+def __deepcopy__(self, memo):
+"""
+Deep copy of a QuerySet doesn't populate the cache
+"""
+obj_dict = deepcopy(self.__dict__, memo)
+obj_dict['_iter'] = None
+
+obj = self.__class__()
+obj.__dict__.update(obj_dict)
+return obj
+
 def __getstate__(self):
 """
 Allows the QuerySet to be pickled.

Modified: django/trunk/django/db/models/sql/query.py
===
--- django/trunk/django/db/models/sql/query.py  2009-06-06 12:16:06 UTC (rev 
10928)
+++ django/trunk/django/db/models/sql/query.py  2009-06-06 13:35:33 UTC (rev 
10929)
@@ -1625,10 +1625,14 @@
 entry.negate()
 self.where.add(entry, AND)
 break
-elif not (lookup_type == 'in' and not value) and field.null:
+elif not (lookup_type == 'in'
+and not hasattr(value, 'as_sql')
+and not hasattr(value, '_as_sql')
+and not value) and field.null:
 # Leaky abstraction artifact: We have to specifically
 # exclude the "foo__in=[]" case from this handling, because
 # it's short-circuited in the Where class.
+# We also need to handle the case where a subquery is 
provided
 entry = self.where_class()
 entry.add((Constraint(alias, col, None), 'isnull', True), 
AND)
 entry.negate()

Modified: django/trunk/tests/regressiontests/queries/models.py
===
--- django/trunk/tests/regressiontests/queries/models.py2009-06-06 
12:16:06 UTC (rev 10928)
+++ django/trunk/tests/regressiontests/queries/models.py2009-06-06 
13:35:33 UTC (rev 10929)
@@ -1143,6 +1143,33 @@
 >>> r.save()
 >>> Ranking.objects.all()
 [, , ]
+
+# Regression test for #10742:
+# Queries used in an __in clause don't execute subqueries
+
+>>> subq = Author.objects.filter(num__lt=3000)
+>>> qs = Author.objects.filter(pk__in=subq)
+>>> list(qs)
+[, ]
+# The subquery result cache should not be populated
+>>> subq._result_cache is None
+True
+
+>>> subq = Author.objects.filter(num__lt=3000)
+>>> qs = Author.objects.exclude(pk__in=subq)
+>>> list(qs)
+[, ]
+# The subquery result cache should not be populated
+>>> subq._result_cache is None
+True
+
+>>> subq = Author.objects.filter(num__lt=3000)
+>>> list(Author.objects.filter(Q(pk__in=subq) & Q(name='a1')))
+[]
+# The subquery result cache should not be populated
+>>> subq._result_cache is None
+True
+
 """}
 
 # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11271: Save button for list_editable is not marked for translation

2009-06-06 Thread Django
#11271: Save button for list_editable is not marked for translation
--+-
 Reporter:  dc|   Owner:  nobody
   Status:  new   |   Milestone:  1.1   
Component:  django.contrib.admin  | Version:  SVN   
 Keywords:  admin list_editable   |   Stage:  Unreviewed
Has_patch:  1 |  
--+-
 Save button for list_editable is not marked for translation in
 admin/pagination.html template.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #10733: Invalid results when deferring fields in more than one related model with only()

2009-06-06 Thread Django
#10733: Invalid results when deferring fields in more than one related model 
with
only()
---+
  Reporter:  mrts  | Owner:  nobody 

Status:  closed| Milestone:  1.1

 Component:  Database layer (models, ORM)  |   Version:  SVN

Resolution:  fixed |  Keywords:  
efficient-admin
 Stage:  Accepted  | Has_patch:  1  

Needs_docs:  0 |   Needs_tests:  0  

Needs_better_patch:  1 |  
---+
Comment (by russellm):

 I suspect this may have been corrected as a result of the fixes for #10572
 in [10926]. I've added a regression test case to make sure, but if I'm
 missing something here, please reopen.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10928 - django/trunk/tests/regressiontests/defer_regress

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 07:16:06 -0500 (Sat, 06 Jun 2009)
New Revision: 10928

Modified:
   django/trunk/tests/regressiontests/defer_regress/models.py
Log:
Fixed #10733 -- Added a regression test for queries with multiple references to 
multiple foreign keys in only() clauses. Thanks to mrts for the report.

Modified: django/trunk/tests/regressiontests/defer_regress/models.py
===
--- django/trunk/tests/regressiontests/defer_regress/models.py  2009-06-06 
08:36:13 UTC (rev 10927)
+++ django/trunk/tests/regressiontests/defer_regress/models.py  2009-06-06 
12:16:06 UTC (rev 10928)
@@ -84,7 +84,8 @@
 (regression for #10710).
 
 >>> c1 = Child.objects.create(name="c1", value=42)
->>> obj = Leaf.objects.create(name="l1", child=c1)
+>>> c2 = Child.objects.create(name="c2", value=37)
+>>> obj = Leaf.objects.create(name="l1", child=c1, second_child=c2)
 
 >>> obj = Leaf.objects.only("name", "child").select_related()[0]
 >>> obj.child.name
@@ -101,5 +102,24 @@
 >>> c1 is c2 is c3
 True
 
+# Regression for #10733 - only() can be used on a model with two foreign keys.
+>>> results = Leaf.objects.all().only('name', 'child', 
'second_child').select_related()
+>>> results[0].child.name
+u'c1'
+>>> results[0].second_child.name
+u'c2'
+
+>>> results = Leaf.objects.all().only('name', 'child', 'second_child', 
'child__name', 'second_child__name').select_related()
+>>> results[0].child.name
+u'c1'
+>>> results[0].second_child.name
+u'c2'
+
+# Finally, we need to flush the app cache for the defer module.
+# Using only/defer creates some artifical entries in the app cache
+# that messes up later tests. Purge all entries, just to be sure.
+>>> from django.db.models.loading import cache
+>>> cache.app_models['defer_regress'] = {}
+
 """
 }


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r10927 - django/branches/releases/1.0.X

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 03:36:13 -0500 (Sat, 06 Jun 2009)
New Revision: 10927

Modified:
   django/branches/releases/1.0.X/
Log:
[1.0.X] Blocked update from merge to branch


Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-blocked
   - 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830
   + 
/django/trunk:9098,9103,9110,9112,9145,9152,9157,9160,9188,9248,9263,9278,9299-9300,9303-9304,9332,9344,9346,9348-9349,9353-9354,9397-9398,9463-9465,9470,9489-9490,9527-9528,9530-9532,9537-9538,9551-9555,9558,9561,9569,9592-9594,9620,9625,9637,9643,9646,9690,9700-9702,9707-9708,9714-9715,9724,9727-9729,9739,9742-9749,9752-9756,9759-9760,9763-9766,9769,9781,9785-9788,9791-9792,9799-9800,9803-9805,9808,9814-9820,9838-9841,9844-9846,9860,9862,9876,9882,9888-9898,9904-9905,9910-9911,9913,9915,9918,9921,9928,9930,9938,9940-9941,9944,9951-9952,9955,9963-9965,9978,9985,9989,10002,10005-10006,10008,10011-10012,10018,10021,10026-10030,10032-10035,10042-10048,10053,10062-10065,10070,10077,10080-10084,10088-10103,10105,10107-10124,10128-10135,10137,10141-10142,10144,10148,10161-10162,10168-10169,10171-10172,10174,10177-10179,10181-10184,10186-10188,10190-10191,10197,10222,10229,10235,10248-10249,10258,10271-10272,10275,10281,10315,10317-10318,10323,10326-10327,10330-10332,10345-10347,10352,10357,10364,10369-10370,10381-10385,10408-10410,10412,10428,10438-10439,10443,10446,10451,10454-10456,10465,10468,10481,10486-10488,10493-10494,10498,10506-10507,10510,10515-10516,10521-10523,10526-10527,10529,10538,10549,10558-10560,10562,10565-10566,10572,10575,10579,10590,10593-10594,10597-10598,10602,10621,10623,10628,10633,10636-10638,10642,10648,10650-10651,10664-10665,10674,10677-10678,10680-10681,10692,10705-10706,10711-10712,10716-10717,10721,10728,10730-10731,10735,10737-10742,10751,10776,10780-10781,10784-10786,10803-10804,10807,10818,10824,10826,10830,10926


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #11270: Cache templatetag with memcached can't handle long tags

2009-06-06 Thread Django
#11270: Cache templatetag with memcached can't handle long tags
--+-
 Reporter:  235   |   Owner:  nobody
   Status:  new   |   Milestone:
Component:  Cache system  | Version:  SVN   
 Keywords:|   Stage:  Unreviewed
Has_patch:  1 |  
--+-
 similar to #10016
 Memcached has a hard limit of 250 characters for cache keys.

 So we have to use md5 hash instead of the whole cached tag name with all
 vary variables.

 {{{
 Traceback (most recent call last):

   File "/var/www/virtual/sumno.com/modules/django/core/handlers/base.py",
 line 86, in get_response
 response = callback(request, *callback_args, **callback_kwargs)

   File
 "/var/www/virtual/sumno.com/htdocs/sumnocom/apps/lib/decorators.py", line
 56, in wrapper
 return func(request, *args, **kwargs)

   File
 
"/var/www/virtual/sumno.com/htdocs/sumnocom/../sumnocom/apps/generic_content/views.py",
 line 370, in detail_view_content_entry
 context_instance=RequestContext(request))

   File "/var/www/virtual/sumno.com/modules/django/shortcuts/__init__.py",
 line 18, in render_to_response
 return HttpResponse(loader.render_to_string(*args, **kwargs),
 **httpresponse_kwargs)

   File "/var/www/virtual/sumno.com/modules/django/template/loader.py",
 line 107, in render_to_string
 return t.render(context_instance)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 176, in render
 return self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 "/var/www/virtual/sumno.com/modules/django/template/loader_tags.py", line
 97, in render
 return compiled_parent.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 176, in render
 return self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 "/var/www/virtual/sumno.com/modules/django/template/loader_tags.py", line
 97, in render
 return compiled_parent.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 176, in render
 return self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 "/var/www/virtual/sumno.com/modules/django/template/loader_tags.py", line
 24, in render
 result = self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 
"/var/www/virtual/sumno.com/htdocs/sumnocom/apps/lib/templatetags/smartspaceless.py",
 line 17, in render
 s = self.nodelist.render(context).strip()

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 "/var/www/virtual/sumno.com/modules/django/template/loader_tags.py", line
 24, in render
 result = self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File
 "/var/www/virtual/sumno.com/modules/django/template/loader_tags.py", line
 24, in render
 result = self.nodelist.render(context)

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 768, in render
 bits.append(self.render_node(node, context))

   File "/var/www/virtual/sumno.com/modules/django/template/__init__.py",
 line 781, in render_node
 return node.render(context)

   File "/var/www/virtual/sumno.com/modules/django/templatetags/cache.py",
 line 27, in render
 value = cache.get(cache_key)

   File
 "/var/www/virtual/sumno.com/modules/django/core/cache/backends/memcached.py",
 line 25, 

[Changeset] r10926 - in django/trunk: django/db/models django/db/models/sql tests/modeltests/defer

2009-06-06 Thread noreply

Author: russellm
Date: 2009-06-06 01:14:05 -0500 (Sat, 06 Jun 2009)
New Revision: 10926

Modified:
   django/trunk/django/db/models/query.py
   django/trunk/django/db/models/sql/query.py
   django/trunk/tests/modeltests/defer/models.py
Log:
Fixed #10572 -- Corrected the operation of the defer() and only() clauses when 
used on inherited models.

Modified: django/trunk/django/db/models/query.py
===
--- django/trunk/django/db/models/query.py  2009-06-05 20:58:34 UTC (rev 
10925)
+++ django/trunk/django/db/models/query.py  2009-06-06 06:14:05 UTC (rev 
10926)
@@ -190,7 +190,25 @@
 index_start = len(extra_select)
 aggregate_start = index_start + len(self.model._meta.fields)
 
-load_fields = only_load.get(self.model)
+load_fields = []
+# If only/defer clauses have been specified,
+# build the list of fields that are to be loaded.
+if only_load:
+for field, model in self.model._meta.get_fields_with_model():
+if model is None:
+model = self.model
+if field == self.model._meta.pk:
+# Record the index of the primary key when it is found
+pk_idx = len(load_fields)
+try:
+if field.name in only_load[model]:
+# Add a field that has been explicitly included
+load_fields.append(field.name)
+except KeyError:
+# Model wasn't explicitly listed in the only_load table
+# Therefore, we need to load all fields from this model
+load_fields.append(field.name)
+
 skip = None
 if load_fields and not fill_cache:
 # Some fields have been deferred, so we have to initialise

Modified: django/trunk/django/db/models/sql/query.py
===
--- django/trunk/django/db/models/sql/query.py  2009-06-05 20:58:34 UTC (rev 
10925)
+++ django/trunk/django/db/models/sql/query.py  2009-06-06 06:14:05 UTC (rev 
10926)
@@ -635,10 +635,10 @@
 # models.
 workset = {}
 for model, values in seen.iteritems():
-for field, f_model in model._meta.get_fields_with_model():
+for field in model._meta.local_fields:
 if field in values:
 continue
-add_to_dict(workset, f_model or model, field)
+add_to_dict(workset, model, field)
 for model, values in must_include.iteritems():
 # If we haven't included a model in workset, we don't add the
 # corresponding must_include fields for that model, since an
@@ -657,6 +657,12 @@
 # included any fields, we have to make sure it's mentioned
 # so that only the "must include" fields are pulled in.
 seen[model] = values
+# Now ensure that every model in the inheritance chain is mentioned
+# in the parent list. Again, it must be mentioned to ensure that
+# only "must include" fields are pulled in.
+for model in orig_opts.get_parent_list():
+if model not in seen:
+seen[model] = set()
 for model, values in seen.iteritems():
 callback(target, model, values)
 

Modified: django/trunk/tests/modeltests/defer/models.py
===
--- django/trunk/tests/modeltests/defer/models.py   2009-06-05 20:58:34 UTC 
(rev 10925)
+++ django/trunk/tests/modeltests/defer/models.py   2009-06-06 06:14:05 UTC 
(rev 10926)
@@ -17,6 +17,12 @@
 def __unicode__(self):
 return self.name
 
+class Child(Primary):
+pass
+
+class BigChild(Primary):
+other = models.CharField(max_length=50)
+
 def count_delayed_fields(obj, debug=False):
 """
 Returns the number of delayed attributes on the given model instance.
@@ -33,7 +39,7 @@
 
 __test__ = {"API_TEST": """
 To all outward appearances, instances with deferred fields look the same as
-normal instances when we examine attribut values. Therefore we test for the
+normal instances when we examine attribute values. Therefore we test for the
 number of deferred fields on returned instances (by poking at the internals),
 as a way to observe what is going on.
 
@@ -98,5 +104,89 @@
 >>> Primary.objects.all()
 []
 
+# Regression for #10572 - A subclass with no extra fields can defer fields 
from the base class
+>>> _ = Child.objects.create(name="c1", value="foo", related=s1)
 
+# You can defer a field on a baseclass when the subclass has no fields
+>>> obj = Child.objects.defer("value").get(name="c1")
+>>> count_delayed_fields(obj)
+1
+>>> obj.name
+u"c1"
+>>> obj.value
+u"foo"
+>>> obj.name = "c2"
+>>>