[Django] #9744: admin base template does not validate against xhtml 1.0 w3c.org validator

2008-12-02 Thread Django
#9744: admin base template does not validate against xhtml 1.0 w3c.org validator
--+-
 Reporter:  terrex|   Owner:  nobody
   Status:  new   |   Milestone:
Component:  django.contrib.admin  | Version:  1.0   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 There are some problems in admin's base template:

  - Warning No Character Encoding Found! Falling back to UTF-8
(this turns fixed with  as first
 line of generated xhtml)

  - conditional-css tags:
 # Error Line 5, Column 6: character data is not allowed here.
 
 # Error Line 10, Column 3: "endif" is not a reserved name.
 
 # Error Line 5, Column 1: XML Parsing Error: StartTag: invalid element
 name.
 
 # Error Line 10, Column 1: XML Parsing Error: StartTag: invalid
 element name.
 
 (I don't know how to solve this)

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9560 - django/branches/releases/1.0.X/docs/howto

2008-12-02 Thread noreply

Author: mtredinnick
Date: 2008-12-02 23:53:57 -0600 (Tue, 02 Dec 2008)
New Revision: 9560

Modified:
   django/branches/releases/1.0.X/docs/howto/custom-model-fields.txt
Log:
[1.0.X] Fixed #9734 -- Typo fix in the custom fields documentation, pointed out 
by
col16.

Backport of r9557 from trunk.


Modified: django/branches/releases/1.0.X/docs/howto/custom-model-fields.txt
===
--- django/branches/releases/1.0.X/docs/howto/custom-model-fields.txt   
2008-12-03 05:53:26 UTC (rev 9559)
+++ django/branches/releases/1.0.X/docs/howto/custom-model-fields.txt   
2008-12-03 05:53:57 UTC (rev 9560)
@@ -31,12 +31,12 @@
 --
 
 Creating custom fields requires a bit of attention to detail. To make things
-easier to follow, we'll use a consistent example throughout this document.
-Suppose you have a Python object representing the deal of cards in a hand of
-Bridge_. (Don't worry, you don't know how to play Bridge to follow this
-example. You only need to know that 52 cards are dealt out equally to four
-players, who are traditionally called *north*, *east*, *south* and *west*.)
-Our class looks something like this::
+easier to follow, we'll use a consistent example throughout this document:
+wrapping a Python object representing the deal of cards in a hand of Bridge_.
+Don't worry, you don't have know how to play Bridge to follow this example.
+You only need to know that 52 cards are dealt out equally to four players, who
+are traditionally called *north*, *east*, *south* and *west*.  Our class looks
+something like this::
 
 class Hand(object):
 def __init__(self, north, east, south, west):


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9559 - django/branches/releases/1.0.X/docs/topics

2008-12-02 Thread noreply

Author: mtredinnick
Date: 2008-12-02 23:53:26 -0600 (Tue, 02 Dec 2008)
New Revision: 9559

Modified:
   django/branches/releases/1.0.X/docs/topics/cache.txt
Log:
[1.0.X] Fixed #9740 -- Updated and correct usage of max_entries in cache 
documentation.

Backport of r9556 from trunk.


Modified: django/branches/releases/1.0.X/docs/topics/cache.txt
===
--- django/branches/releases/1.0.X/docs/topics/cache.txt2008-12-03 
05:50:46 UTC (rev 9558)
+++ django/branches/releases/1.0.X/docs/topics/cache.txt2008-12-03 
05:53:26 UTC (rev 9559)
@@ -213,8 +213,9 @@
 minutes (300 seconds).
 
 max_entries
-For the simple and database backends, the maximum number of entries
-allowed in the cache before it is cleaned. Defaults to 300.
+For the ``locmem``, ``filesystem`` and ``database`` backends, the
+maximum number of entries allowed in the cache before it is cleaned.
+Defaults to 300.
 
 cull_percentage
 The percentage of entries that are culled when max_entries is reached.
@@ -231,7 +232,7 @@
 
 In this example, ``timeout`` is ``30`` and ``max_entries`` is ``400``::
 
-CACHE_BACKEND = "memcached://127.0.0.1:11211/?timeout=30&max_entries=400"
+CACHE_BACKEND = "locmem:///?timeout=30&max_entries=400"
 
 Invalid arguments are silently ignored, as are invalid values of known
 arguments.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9558 - django/trunk/docs/ref/templates

2008-12-02 Thread noreply

Author: mtredinnick
Date: 2008-12-02 23:50:46 -0600 (Tue, 02 Dec 2008)
New Revision: 9558

Modified:
   django/trunk/docs/ref/templates/builtins.txt
Log:
Fixed #9735 -- Documentation typo fix.


Modified: django/trunk/docs/ref/templates/builtins.txt
===
--- django/trunk/docs/ref/templates/builtins.txt2008-12-03 05:50:11 UTC 
(rev 9557)
+++ django/trunk/docs/ref/templates/builtins.txt2008-12-03 05:50:46 UTC 
(rev 9558)
@@ -254,7 +254,7 @@
 than -- the following::
 
 
-  {% if althete_list %}
+  {% if athlete_list %}
 {% for athlete in athlete_list %}
   {{ athlete.name }}
 {% endfor %}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9557 - django/trunk/docs/howto

2008-12-02 Thread noreply

Author: mtredinnick
Date: 2008-12-02 23:50:11 -0600 (Tue, 02 Dec 2008)
New Revision: 9557

Modified:
   django/trunk/docs/howto/custom-model-fields.txt
Log:
Fixed #9734 -- Typo fix in the custom fields documentation, pointed out by
col16.


Modified: django/trunk/docs/howto/custom-model-fields.txt
===
--- django/trunk/docs/howto/custom-model-fields.txt 2008-12-03 05:49:37 UTC 
(rev 9556)
+++ django/trunk/docs/howto/custom-model-fields.txt 2008-12-03 05:50:11 UTC 
(rev 9557)
@@ -31,12 +31,12 @@
 --
 
 Creating custom fields requires a bit of attention to detail. To make things
-easier to follow, we'll use a consistent example throughout this document.
-Suppose you have a Python object representing the deal of cards in a hand of
-Bridge_. (Don't worry, you don't know how to play Bridge to follow this
-example. You only need to know that 52 cards are dealt out equally to four
-players, who are traditionally called *north*, *east*, *south* and *west*.)
-Our class looks something like this::
+easier to follow, we'll use a consistent example throughout this document:
+wrapping a Python object representing the deal of cards in a hand of Bridge_.
+Don't worry, you don't have know how to play Bridge to follow this example.
+You only need to know that 52 cards are dealt out equally to four players, who
+are traditionally called *north*, *east*, *south* and *west*.  Our class looks
+something like this::
 
 class Hand(object):
 def __init__(self, north, east, south, west):


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9556 - django/trunk/docs/topics

2008-12-02 Thread noreply

Author: mtredinnick
Date: 2008-12-02 23:49:37 -0600 (Tue, 02 Dec 2008)
New Revision: 9556

Modified:
   django/trunk/docs/topics/cache.txt
Log:
Fixed #9740 -- Updated and correct usage of max_entries in cache documentation.


Modified: django/trunk/docs/topics/cache.txt
===
--- django/trunk/docs/topics/cache.txt  2008-12-03 00:44:12 UTC (rev 9555)
+++ django/trunk/docs/topics/cache.txt  2008-12-03 05:49:37 UTC (rev 9556)
@@ -213,8 +213,9 @@
 minutes (300 seconds).
 
 max_entries
-For the simple and database backends, the maximum number of entries
-allowed in the cache before it is cleaned. Defaults to 300.
+For the ``locmem``, ``filesystem`` and ``database`` backends, the
+maximum number of entries allowed in the cache before it is cleaned.
+Defaults to 300.
 
 cull_percentage
 The percentage of entries that are culled when max_entries is reached.
@@ -231,7 +232,7 @@
 
 In this example, ``timeout`` is ``30`` and ``max_entries`` is ``400``::
 
-CACHE_BACKEND = "memcached://127.0.0.1:11211/?timeout=30&max_entries=400"
+CACHE_BACKEND = "locmem:///?timeout=30&max_entries=400"
 
 Invalid arguments are silently ignored, as are invalid values of known
 arguments.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9678: Flatpage with URL of "/" ends up in a redirect loop.

2008-12-02 Thread Django
#9678: Flatpage with URL of "/" ends up in a redirect loop.
+---
  Reporter:  watusee| Owner:  nobody  
Status:  reopened   | Milestone:  post-1.0
 Component:  Uncategorized  |   Version:  1.0 
Resolution: |  Keywords:  flatpage
 Stage:  Unreviewed | Has_patch:  0   
Needs_docs:  0  |   Needs_tests:  0   
Needs_better_patch:  0  |  
+---
Changes (by watusee):

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

Comment:

 Should have mentioned earlier using Python 2.5 with Django 1.02. It
 happens with both the built-in server and on Web Faction using mod_python.
 I've attached the setting.py and urls.py to see if I'm doing something
 unusual or wrong.

 Replying to [comment:1 dih0658]:
 > I've been using a site with a flatpage as it's root for quite some time.
 I went back to double check that I wasn't losing my mind and tried both
 APPEND_SLASH options. All works just fine for me.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9739: Admin does not correctly prefill DataTimeField from URL

2008-12-02 Thread Django
#9739: Admin does not correctly prefill DataTimeField from URL
---+
  Reporter:  gilhad| Owner:  nobody
Status:  new   | Milestone:
 Component:  django.contrib.admin  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by mtredinnick):

  * has_patch:  1 => 0
  * summary:  Admin does correctly prefill DataTimeField from URL (GET) +
  patch => Admin does not correctly prefill
  DataTimeField from URL

Comment:

 Edited description for clarity.

 Please attach a proper patch to the ticket, rather than mixing the
 proposed changes into the description of the problem. It makes things a
 lot easier for reviewing and further improvements (if subsequent patches
 are made).

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9738: unit test examples in docs use old "failUnless" methods instead of new "assert" methods

2008-12-02 Thread Django
#9738: unit test examples in docs use old "failUnless" methods instead of new
"assert" methods
+---
  Reporter:  brandon| Owner:  nobody
Status:  closed | Milestone:
 Component:  Documentation  |   Version:  1.0   
Resolution:  wontfix|  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by mtredinnick):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => wontfix
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 Those methods still exist, so using them is fine. Django supports Python
 2.3 - 2.6, all of which have those methods. If we changed to use the new
 methods, we'd end up having to add a note to mention the alternative names
 for Python 2.3, which makes things seem more complicated than they really
 are.

 This isn't worth changing at the moment, since it works fine with all the
 Python we support. There'll be lots of changes for Python 3 and we don't
 run on that at the moment.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #7167: Add a SafeForm / SecureForm to django.contrib.csrf

2008-12-02 Thread Django
#7167: Add a SafeForm / SecureForm to django.contrib.csrf
-+--
  Reporter:  mrts| Owner:  nobody  
Status:  new | Milestone:  post-1.0
 Component:  Contrib apps|   Version:  SVN 
Resolution:  |  Keywords:  
 Stage:  Design decision needed  | Has_patch:  1   
Needs_docs:  1   |   Needs_tests:  0   
Needs_better_patch:  0   |  
-+--
Comment (by lukeplant):

 I have just beefed up the !CsrfMiddleware a bit, in particular:

  * split it into two components, which allows for only using the
 'incoming' bit, and the not the response processing.
  * added a 'csrf_exempt' decorator for views so that they are not checked
 in the incoming bit.

 This allows for a combined approach:

  * We have !CsrfMiddleware turned on by default
  * Use @csrf_exempt on the views that don't need it (e.g ones that use
 !SafeForm)
  * Eventually replace !CsrfMiddleware (which combines !CsrfViewMiddleware
 and !CsrfResponseMiddleware) with just !CsrfViewMiddleware.  Users are
 then responsible for added the token themselves, but the middleware will
 catch them if they ever forget it.

 This assumes the middleware and !SafeForm can cooperate e.g. use the same
 name/contents for the CSRF token.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9555 - django/trunk/docs/ref/contrib

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 18:44:12 -0600 (Tue, 02 Dec 2008)
New Revision: 9555

Modified:
   django/trunk/docs/ref/contrib/csrf.txt
Log:
Updated csrf docs with 'versionadded' info


Modified: django/trunk/docs/ref/contrib/csrf.txt
===
--- django/trunk/docs/ref/contrib/csrf.txt  2008-12-03 00:34:18 UTC (rev 
9554)
+++ django/trunk/docs/ref/contrib/csrf.txt  2008-12-03 00:44:12 UTC (rev 
9555)
@@ -32,6 +32,8 @@
 Exceptions
 --
 
+.. versionadded:: 1.1
+
 To manually exclude a view function from being handled by the
 CsrfMiddleware, you can use the ``csrf_exempt`` decorator (found in
 the ``django.contrib.csrf.middleware`` module).
@@ -82,6 +84,10 @@
 respectively.  This allows the individual components to be used and/or
 replaced instead of using ``CsrfMiddleware``.
 
+.. versionchanged:: 1.1
+(previous versions of Django did not provide these two components
+of ``CsrfMiddleware`` as described above)
+
 .. _9.1.1 Safe Methods, HTTP 1.1, RFC 2616: 
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
 
 Limitations


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9554 - in django/trunk: django/contrib/csrf docs/ref/contrib

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 18:34:18 -0600 (Tue, 02 Dec 2008)
New Revision: 9554

Modified:
   django/trunk/django/contrib/csrf/middleware.py
   django/trunk/django/contrib/csrf/tests.py
   django/trunk/docs/ref/contrib/csrf.txt
Log:
New CsrfMiddleware features: automatic exceptions for known AJAX and decorator 
for manual exceptions


Modified: django/trunk/django/contrib/csrf/middleware.py
===
--- django/trunk/django/contrib/csrf/middleware.py  2008-12-03 00:31:31 UTC 
(rev 9553)
+++ django/trunk/django/contrib/csrf/middleware.py  2008-12-03 00:34:18 UTC 
(rev 9554)
@@ -7,6 +7,10 @@
 
 import re
 import itertools
+try:
+from functools import wraps
+except ImportError:
+from django.utils.functional import wraps  # Python 2.3, 2.4 fallback.
 
 from django.conf import settings
 from django.http import HttpResponseForbidden
@@ -30,6 +34,12 @@
 """
 def process_view(self, request, callback, callback_args, callback_kwargs):
 if request.method == 'POST':
+if getattr(callback, 'csrf_exempt', False):
+return None
+
+if request.is_ajax():
+return None
+
 try:
 session_id = request.COOKIES[settings.SESSION_COOKIE_NAME]
 except KeyError:
@@ -107,3 +117,14 @@
 and CsrfResponseMiddleware which can be used independently.
 """
 pass
+
+def csrf_exempt(view_func):
+"""
+Marks a view function as being exempt from the CSRF checks
+"""
+def wrapped_view(*args, **kwargs):
+return view_func(*args, **kwargs)
+# We could just do view.csrf_exempt = True, but decorators are
+# nicer if they don't have side-effects.
+wrapped_view.csrf_exempt = True
+return wraps(view_func)(wrapped_view)

Modified: django/trunk/django/contrib/csrf/tests.py
===
--- django/trunk/django/contrib/csrf/tests.py   2008-12-03 00:31:31 UTC (rev 
9553)
+++ django/trunk/django/contrib/csrf/tests.py   2008-12-03 00:34:18 UTC (rev 
9554)
@@ -2,10 +2,19 @@
 
 from django.test import TestCase
 from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
-from django.contrib.csrf.middleware import CsrfMiddleware, _make_token
+from django.contrib.csrf.middleware import CsrfMiddleware, _make_token, 
csrf_exempt
 from django.conf import settings
 
 
+def post_form_response():
+resp = HttpResponse(content="""
+
+""", mimetype="text/html")
+return resp
+
+def test_view(request):
+return post_form_response()
+
 class CsrfMiddlewareTest(TestCase):
 
 _session_id = "1"
@@ -34,10 +43,7 @@
 return req
 
 def _get_post_form_response(self):
-resp = HttpResponse(content="""
-
-""", mimetype="text/html")
-return resp
+return post_form_response()
 
 def _get_new_session_response(self):
 resp = self._get_post_form_response()
@@ -48,8 +54,7 @@
 self.assertContains(response, "name='csrfmiddlewaretoken' value='%s'" 
% _make_token(self._session_id))
 
 def get_view(self):
-def dummyview(request):
-return self._get_post_form_response()
+return test_view
 
 # Check the post processing
 def test_process_response_no_session(self):
@@ -109,3 +114,21 @@
 req = self._get_POST_session_request_with_token()
 req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
 self.assertEquals(None, req2)
+
+def test_process_request_session_no_token_exempt_view(self):
+"""
+Check that if a session is present and no token, but the csrf_exempt
+decorator has been applied to the view, the middleware lets it through
+"""
+req = self._get_POST_session_request()
+req2 = CsrfMiddleware().process_view(req, 
csrf_exempt(self.get_view()), (), {})
+self.assertEquals(None, req2)
+
+def test_ajax_exemption(self):
+"""
+Check the AJAX requests are automatically exempted.
+"""
+req = self._get_POST_session_request()
+req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
+req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
+self.assertEquals(None, req2)

Modified: django/trunk/docs/ref/contrib/csrf.txt
===
--- django/trunk/docs/ref/contrib/csrf.txt  2008-12-03 00:31:31 UTC (rev 
9553)
+++ django/trunk/docs/ref/contrib/csrf.txt  2008-12-03 00:34:18 UTC (rev 
9554)
@@ -26,8 +26,19 @@
 your list of middleware classes, :setting:`MIDDLEWARE_CLASSES`. It needs to 
process
 the response after the SessionMiddleware, so must come before it in the
 list. It also must process the response before things like compression
-happen to the response, so it must come after GZipMiddleware in the list.
+happen to the response, so it must come after GZipMiddleware in the
+li

[Changeset] r9553 - django/trunk/django/contrib/csrf

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 18:31:31 -0600 (Tue, 02 Dec 2008)
New Revision: 9553

Modified:
   django/trunk/django/contrib/csrf/middleware.py
   django/trunk/django/contrib/csrf/tests.py
Log:
Split CsrfMiddleware into two to make it more reusable.

Also converted it to be a view middleware instead of request,
as this allows more options.


Modified: django/trunk/django/contrib/csrf/middleware.py
===
--- django/trunk/django/contrib/csrf/middleware.py  2008-12-02 23:00:06 UTC 
(rev 9552)
+++ django/trunk/django/contrib/csrf/middleware.py  2008-12-03 00:31:31 UTC 
(rev 9553)
@@ -23,25 +23,12 @@
 def _make_token(session_id):
 return md5_constructor(settings.SECRET_KEY + session_id).hexdigest()
 
-class CsrfMiddleware(object):
-"""Django middleware that adds protection against Cross Site
-Request Forgeries by adding hidden form fields to POST forms and
-checking requests for the correct value.
-
-In the list of middlewares, SessionMiddleware is required, and must come
-after this middleware.  CsrfMiddleWare must come after compression
-middleware.
-
-If a session ID cookie is present, it is hashed with the SECRET_KEY
-setting to create an authentication token.  This token is added to all
-outgoing POST forms and is expected on all incoming POST requests that
-have a session ID cookie.
-
-If you are setting cookies directly, instead of using Django's session
-framework, this middleware will not work.
+class CsrfViewMiddleware(object):
 """
-
-def process_request(self, request):
+Middleware that requires a present and correct csrfmiddlewaretoken
+for POST requests that have an active session.
+"""
+def process_view(self, request, callback, callback_args, callback_kwargs):
 if request.method == 'POST':
 try:
 session_id = request.COOKIES[settings.SESSION_COOKIE_NAME]
@@ -61,6 +48,12 @@
 
 return None
 
+class CsrfResponseMiddleware(object):
+"""
+Middleware that post-processes a response to add a
+csrfmiddlewaretoken if the response/request have an active
+session.
+"""
 def process_response(self, request, response):
 csrf_token = None
 try:
@@ -92,3 +85,25 @@
 # Modify any POST forms
 response.content = _POST_FORM_RE.sub(add_csrf_field, 
response.content)
 return response
+
+class CsrfMiddleware(CsrfViewMiddleware, CsrfResponseMiddleware):
+"""Django middleware that adds protection against Cross Site
+Request Forgeries by adding hidden form fields to POST forms and
+checking requests for the correct value.
+
+In the list of middlewares, SessionMiddleware is required, and
+must come after this middleware.  CsrfMiddleWare must come after
+compression middleware.
+
+If a session ID cookie is present, it is hashed with the
+SECRET_KEY setting to create an authentication token.  This token
+is added to all outgoing POST forms and is expected on all
+incoming POST requests that have a session ID cookie.
+
+If you are setting cookies directly, instead of using Django's
+session framework, this middleware will not work.
+
+CsrfMiddleWare is composed of two middleware, CsrfViewMiddleware
+and CsrfResponseMiddleware which can be used independently.
+"""
+pass

Modified: django/trunk/django/contrib/csrf/tests.py
===
--- django/trunk/django/contrib/csrf/tests.py   2008-12-02 23:00:06 UTC (rev 
9552)
+++ django/trunk/django/contrib/csrf/tests.py   2008-12-03 00:31:31 UTC (rev 
9553)
@@ -5,6 +5,7 @@
 from django.contrib.csrf.middleware import CsrfMiddleware, _make_token
 from django.conf import settings
 
+
 class CsrfMiddlewareTest(TestCase):
 
 _session_id = "1"
@@ -46,6 +47,10 @@
 def _check_token_present(self, response):
 self.assertContains(response, "name='csrfmiddlewaretoken' value='%s'" 
% _make_token(self._session_id))
 
+def get_view(self):
+def dummyview(request):
+return self._get_post_form_response()
+
 # Check the post processing
 def test_process_response_no_session(self):
 """
@@ -86,7 +91,7 @@
 to the incoming request.
 """
 req = self._get_POST_no_session_request()
-req2 = CsrfMiddleware().process_request(req)
+req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
 self.assertEquals(None, req2)
 
 def test_process_request_session_no_token(self):
@@ -94,7 +99,7 @@
 Check that if a session is present but no token, we get a 'forbidden'
 """
 req = self._get_POST_session_request()
-req2 = CsrfMiddleware().process_request(req)
+req2 = CsrfMiddleware().process_view(req, self.get_view(), (), {})
 self.assertEquals(HttpResponseForbidden, req2.__class__)
 
   

[Django] #9743: Problem in admin when displaying foreignkey of a model that reference himself

2008-12-02 Thread Django
#9743: Problem in admin when displaying foreignkey of a model that reference
himself
+---
   Reporter:  daniels   |Owner:  nobody
 Status:  new   |Milestone:
  Component:  Database layer (models, ORM)  |  Version:  1.0   
   Keywords:|Stage:  Unreviewed
  Has_patch:  1 |   Needs_docs:  0 
Needs_tests:  0 |   Needs_better_patch:  0 
+---
 {{{
 class Client(models.Model):
   name = models.CharField()

 class Module(models.Model):
   client = models.ForeignKey(Client)

 class SuperModule(Module):
   sample = models.ForeignKey(Module)
 }}}

 If in the django.admin.contrib, we want to display SuperModule with a
 list_display = ('name', 'client')
 it will not work unless we remove the foreign key to Module.
 It was not tested with the simple code above, but in our complete code.

 After some investigation, I found a way where an error occured when doing
 'as_sql()' on a
 query_set.  The error was about an extra parameter to avoid.update().  And
 some lines below,
 the same function call but with a small difference in parenthesis and
 works OK.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9552 - django/trunk/django/contrib/csrf

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 17:00:06 -0600 (Tue, 02 Dec 2008)
New Revision: 9552

Modified:
   django/trunk/django/contrib/csrf/tests.py
Log:
More tests for the other half of CsrfMiddleware


Modified: django/trunk/django/contrib/csrf/tests.py
===
--- django/trunk/django/contrib/csrf/tests.py   2008-12-02 22:40:00 UTC (rev 
9551)
+++ django/trunk/django/contrib/csrf/tests.py   2008-12-02 23:00:06 UTC (rev 
9552)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 from django.test import TestCase
-from django.http import HttpRequest, HttpResponse
+from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
 from django.contrib.csrf.middleware import CsrfMiddleware, _make_token
 from django.conf import settings
 
@@ -9,14 +9,29 @@
 
 _session_id = "1"
 
-def _get_no_session_request(self):
+def _get_GET_no_session_request(self):
 return HttpRequest()
 
-def _get_session_request(self):
-req = self._get_no_session_request()
+def _get_GET_session_request(self):
+req = self._get_GET_no_session_request()
 req.COOKIES[settings.SESSION_COOKIE_NAME] = self._session_id
 return req
 
+def _get_POST_session_request(self):
+req = self._get_GET_session_request()
+req.method = "POST"
+return req
+
+def _get_POST_no_session_request(self):
+req = self._get_GET_no_session_request()
+req.method = "POST"
+return req
+
+def _get_POST_session_request_with_token(self):
+req = self._get_POST_session_request()
+req.POST['csrfmiddlewaretoken'] = _make_token(self._session_id)
+return req
+
 def _get_post_form_response(self):
 resp = HttpResponse(content="""
 
@@ -31,11 +46,12 @@
 def _check_token_present(self, response):
 self.assertContains(response, "name='csrfmiddlewaretoken' value='%s'" 
% _make_token(self._session_id))
 
+# Check the post processing
 def test_process_response_no_session(self):
 """
 Check the the post-processor does nothing if no session active
 """
-req = self._get_no_session_request()
+req = self._get_GET_no_session_request()
 resp = self._get_post_form_response()
 resp_content = resp.content
 resp2 = CsrfMiddleware().process_response(req, resp)
@@ -45,7 +61,7 @@
 """
 Check that the token is inserted if there is an existing session
 """
-req = self._get_session_request()
+req = self._get_GET_session_request()
 resp = self._get_post_form_response()
 resp_content = resp.content
 resp2 = CsrfMiddleware().process_response(req, resp)
@@ -56,9 +72,35 @@
 """
 Check that the token is inserted if there is a new session being 
started
 """
-req = self._get_no_session_request() # no session in request
+req = self._get_GET_no_session_request() # no session in request
 resp = self._get_new_session_response() # but new session started
 resp_content = resp.content
 resp2 = CsrfMiddleware().process_response(req, resp)
 self.assertNotEqual(resp_content, resp2.content)
 self._check_token_present(resp2)
+
+# Check the request processing
+def test_process_request_no_session(self):
+"""
+Check that if no session is present, the middleware does nothing.
+to the incoming request.
+"""
+req = self._get_POST_no_session_request()
+req2 = CsrfMiddleware().process_request(req)
+self.assertEquals(None, req2)
+
+def test_process_request_session_no_token(self):
+"""
+Check that if a session is present but no token, we get a 'forbidden'
+"""
+req = self._get_POST_session_request()
+req2 = CsrfMiddleware().process_request(req)
+self.assertEquals(HttpResponseForbidden, req2.__class__)
+
+def test_process_request_session_and_token(self):
+"""
+Check that if a session is present and a token, the middleware lets it 
through
+"""
+req = self._get_POST_session_request_with_token()
+req2 = CsrfMiddleware().process_request(req)
+self.assertEquals(None, req2)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #8375: It's better to allow using tables parameter with custom alias in extra query

2008-12-02 Thread Django
#8375: It's better to allow using tables parameter with custom alias in extra
query
---+
  Reporter:  Wonlay| Owner:  nobody 
   
Status:  new   | Milestone:  post-1.0   
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  query, 
extra, tables, custom alias
 Stage:  Someday/Maybe | Has_patch:  1  
   
Needs_docs:  1 |   Needs_tests:  1  
   
Needs_better_patch:  1 |  
---+
Changes (by russellm):

  * stage:  Design decision needed => Someday/Maybe

Comment:

 A design decision has already been made. That decision was "Someday,
 maybe". Reverting ticket state.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9551 - django/trunk/django/contrib/csrf

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 16:40:00 -0600 (Tue, 02 Dec 2008)
New Revision: 9551

Added:
   django/trunk/django/contrib/csrf/models.py
   django/trunk/django/contrib/csrf/tests.py
Log:
Added tests for CsrfMiddleware.


Added: django/trunk/django/contrib/csrf/models.py
===
--- django/trunk/django/contrib/csrf/models.py  (rev 0)
+++ django/trunk/django/contrib/csrf/models.py  2008-12-02 22:40:00 UTC (rev 
9551)
@@ -0,0 +1 @@
+# models.py file for tests to run.


Property changes on: django/trunk/django/contrib/csrf/models.py
___
Name: svn:eol-style
   + native

Added: django/trunk/django/contrib/csrf/tests.py
===
--- django/trunk/django/contrib/csrf/tests.py   (rev 0)
+++ django/trunk/django/contrib/csrf/tests.py   2008-12-02 22:40:00 UTC (rev 
9551)
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+
+from django.test import TestCase
+from django.http import HttpRequest, HttpResponse
+from django.contrib.csrf.middleware import CsrfMiddleware, _make_token
+from django.conf import settings
+
+class CsrfMiddlewareTest(TestCase):
+
+_session_id = "1"
+
+def _get_no_session_request(self):
+return HttpRequest()
+
+def _get_session_request(self):
+req = self._get_no_session_request()
+req.COOKIES[settings.SESSION_COOKIE_NAME] = self._session_id
+return req
+
+def _get_post_form_response(self):
+resp = HttpResponse(content="""
+
+""", mimetype="text/html")
+return resp
+
+def _get_new_session_response(self):
+resp = self._get_post_form_response()
+resp.cookies[settings.SESSION_COOKIE_NAME] = self._session_id
+return resp
+
+def _check_token_present(self, response):
+self.assertContains(response, "name='csrfmiddlewaretoken' value='%s'" 
% _make_token(self._session_id))
+
+def test_process_response_no_session(self):
+"""
+Check the the post-processor does nothing if no session active
+"""
+req = self._get_no_session_request()
+resp = self._get_post_form_response()
+resp_content = resp.content
+resp2 = CsrfMiddleware().process_response(req, resp)
+self.assertEquals(resp_content, resp2.content)
+
+def test_process_response_existing_session(self):
+"""
+Check that the token is inserted if there is an existing session
+"""
+req = self._get_session_request()
+resp = self._get_post_form_response()
+resp_content = resp.content
+resp2 = CsrfMiddleware().process_response(req, resp)
+self.assertNotEqual(resp_content, resp2.content)
+self._check_token_present(resp2)
+
+def test_process_response_new_session(self):
+"""
+Check that the token is inserted if there is a new session being 
started
+"""
+req = self._get_no_session_request() # no session in request
+resp = self._get_new_session_response() # but new session started
+resp_content = resp.content
+resp2 = CsrfMiddleware().process_response(req, resp)
+self.assertNotEqual(resp_content, resp2.content)
+self._check_token_present(resp2)


Property changes on: django/trunk/django/contrib/csrf/tests.py
___
Name: svn:eol-style
   + native


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9550 - django/trunk/django/db/models/fields

2008-12-02 Thread noreply

Author: lukeplant
Date: 2008-12-02 16:09:51 -0600 (Tue, 02 Dec 2008)
New Revision: 9550

Modified:
   django/trunk/django/db/models/fields/related.py
Log:
Fixed #8248: made help() work on models and improved introspection support.

Descriptors now return themselves when accessed via the class, as per standard
Python descriptors like property().



Modified: django/trunk/django/db/models/fields/related.py
===
--- django/trunk/django/db/models/fields/related.py 2008-12-02 18:42:30 UTC 
(rev 9549)
+++ django/trunk/django/db/models/fields/related.py 2008-12-02 22:09:51 UTC 
(rev 9550)
@@ -175,7 +175,7 @@
 
 def __get__(self, instance, instance_type=None):
 if instance is None:
-raise AttributeError, "%s must be accessed via instance" % 
self.related.opts.object_name
+return self
 
 try:
 return getattr(instance, self.cache_name)
@@ -223,7 +223,7 @@
 
 def __get__(self, instance, instance_type=None):
 if instance is None:
-raise AttributeError, "%s must be accessed via instance" % 
self.field.name
+return self
 cache_name = self.field.get_cache_name()
 try:
 return getattr(instance, cache_name)
@@ -287,7 +287,7 @@
 
 def __get__(self, instance, instance_type=None):
 if instance is None:
-raise AttributeError, "Manager must be accessed via instance"
+return self
 
 rel_field = self.related.field
 rel_model = self.related.model
@@ -500,7 +500,7 @@
 
 def __get__(self, instance, instance_type=None):
 if instance is None:
-raise AttributeError, "Manager must be accessed via instance"
+return self
 
 # Dynamically create a class that subclasses the related
 # model's default manager.
@@ -545,7 +545,7 @@
 
 def __get__(self, instance, instance_type=None):
 if instance is None:
-raise AttributeError, "Manager must be accessed via instance"
+return self
 
 # Dynamically create a class that subclasses the related
 # model's default manager.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #3553: urlpatterns uses urllib.quote/unquote should use urllib.quote/unquote_plus

2008-12-02 Thread Django
#3553: urlpatterns uses urllib.quote/unquote should use 
urllib.quote/unquote_plus
-+--
  Reporter:  [EMAIL PROTECTED]  | Owner:  graham_king 
Status:  closed  | Milestone:  post-1.0
 Component:  Core framework  |   Version:  0.95
Resolution:  wontfix |  Keywords:  sprintsept14
 Stage:  Design decision needed  | Has_patch:  0   
Needs_docs:  0   |   Needs_tests:  1   
Needs_better_patch:  0   |  
-+--
Changes (by graham_king):

  * status:  assigned => closed
  * resolution:  => wontfix

Comment:

 Attached a patch that will allow you to do this, but I don't recommend you
 do. It will probably break mod_rewrite. The answer is don't put the query
 in the path. Change your URL structure to be /search?q=foo%2B+bar.

 + encodes a space in a _query_ (coming from a form), not in a _path_. In a
 path %20 should be used. Create a document called 'my test.html' on a
 local Apache install and try browsing to http://localhost/my+test.html ->
 404, replace the + with %20 and it works.

 When Apache hands Django the PATH_INFO, the %2B has been correctly
 converted to a +, and the other plus is left as it because, in the path,
 it doesn't mean anything special. So foo%2B+bar correctly becomes foo++bar

 Look at last.fm, where there is both a band called '44' and one called
 '+44':
 http://www.last.fm/music/44 --> 44
 http://www.last.fm/music/+44 --> 44
 http://www.last.fm/music/%2B44 --> 44
 http://www.last.fm/music/%252B44 --> +44

 They had to double encode it, replacing the % with %25. That's what you'll
 have to do to use + as a character and a space in the path. Otherwise
 shift the query to the query component or the URL.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9742: GIS render_to_kml has incorrect mime type

2008-12-02 Thread Django
#9742: GIS render_to_kml has incorrect mime type
---+
 Reporter:  anonymous  |   Owner:  nobody
   Status:  new|   Milestone:
Component:  GIS| Version:  1.0   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 The render_to_kml shortcut has an incorrect mime type of 'application/vnd
 .google-earth.kml+xml kml', which should be 'application/vnd.google-
 earth.kml+xml'.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9741: generic relations: reverse chain of references not followed fully yon delete

2008-12-02 Thread Django
#9741: generic relations: reverse chain of references not followed fully yon
delete
---+
  Reporter:  wiswaud   | Owner:  nobody 
  
Status:  new   | Milestone: 
  
 Component:  Contrib apps  |   Version:  1.0
  
Resolution:|  Keywords:  genericrelation 
genericforeignkey
 Stage:  Unreviewed| Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Comment (by wiswaud):

 python + django version tested with:

 {{{
 Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
 [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import django
 >>> django.VERSION
 (1, 1, 0, 'alpha', 0)

 }}}

 which is rev 9549.

 also tried with (1, 0, 'final') with the exact same result.

 MySQL is 5.0.51a-3ubuntu5.4

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9741: generic relations: reverse chain of references not followed fully yon delete

2008-12-02 Thread Django
#9741: generic relations: reverse chain of references not followed fully yon
delete
---+
  Reporter:  wiswaud   | Owner:  nobody 
  
Status:  new   | Milestone: 
  
 Component:  Contrib apps  |   Version:  1.0
  
Resolution:|  Keywords:  genericrelation 
genericforeignkey
 Stage:  Unreviewed| Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Comment (by wiswaud):

 test output:

 {{{
 [EMAIL PROTECTED]:~/akoha/sandbox/gr_test$ ./manage.py test gr_test_app
 Creating test database...
 Creating table auth_permission
 Creating table auth_group
 Creating table auth_user
 Creating table auth_message
 Creating table django_content_type
 Creating table django_session
 Creating table django_site
 Creating table gr_test_app_a
 Creating table gr_test_app_fk_b
 Creating table gr_test_app_fk_c
 Creating table gr_test_app_gr_b
 Creating table gr_test_app_gr_c
 Installing index for auth.Permission model
 Installing index for auth.Message model
 Installing index for gr_test_app.FK_B model
 Installing index for gr_test_app.FK_C model
 Installing index for gr_test_app.GR_B model
 Installing index for gr_test_app.GR_C model
 F
 ==
 FAIL: Doctest: gr_test_app.models.GR_C
 --
 Traceback (most recent call last):
   File "/home/eric/django/django_src/django/test/_doctest.py", line 2180,
 in runTest
 raise self.failureException(self.format_failure(new.getvalue()))
 AssertionError: Failed doctest test for gr_test_app.models.GR_C
   File "/home/eric/akoha/sandbox/gr_test/gr_test_app/models.py", line 25,
 in GR_C

 --
 File "/home/eric/akoha/sandbox/gr_test/gr_test_app/models.py", line 54, in
 gr_test_app.models.GR_C
 Failed example:
 print A.objects.all(), GR_B.objects.all(), GR_C.objects.all(),
 FK_B.objects.all(), FK_C.objects.all()
 Expected:
 [] [] [] [] []
 Got:
 [] [] [] [] []


 --
 Ran 1 test in 0.041s

 FAILED (failures=1)
 Destroying test database...

 }}}

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9741: generic relations: reverse chain of references not followed fully yon delete

2008-12-02 Thread Django
#9741: generic relations: reverse chain of references not followed fully yon
delete
---+
  Reporter:  wiswaud   | Owner:  nobody 
  
Status:  new   | Milestone: 
  
 Component:  Contrib apps  |   Version:  1.0
  
Resolution:|  Keywords:  genericrelation 
genericforeignkey
 Stage:  Unreviewed| Has_patch:  0  
  
Needs_docs:  0 |   Needs_tests:  0  
  
Needs_better_patch:  0 |  
---+
Changes (by wiswaud):

 * cc: [EMAIL PROTECTED] (removed)
 * cc: [EMAIL PROTECTED] (added)
  * needs_better_patch:  => 0
  * 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9741: generic relations: reverse chain of references not followed fully yon delete

2008-12-02 Thread Django
#9741: generic relations: reverse chain of references not followed fully yon
delete
---+
 Reporter:  wiswaud|   Owner:  nobody
   Status:  new|   Milestone:
Component:  Contrib apps   | Version:  1.0   
 Keywords:  genericrelation genericforeignkey  |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 If i have an object c, which has a genericforeignkey relation to b, which
 in turn has a genericforeignkey relation to a, and i delete a, b does get
 deleted, but not c. If i were to delete b, c does get deleted.

 If these were foreign keys, the chain of reverse relations would get
 properly deleted, but for genericrelations, it only goes back 1 link.

 {{{
 from django.db import models
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic

 class A(models.Model):
 t = models.CharField(max_length=50)
 gr_b_reverse = generic.GenericRelation('GR_B')

 class FK_B(models.Model):
 """An object with a foreign key, that we'll point to an A"""
 fk = models.ForeignKey('A')

 class FK_C(models.Model):
 """An object with a foreign key, that we'll point to a FK_B"""
 fk = models.ForeignKey('FK_B')

 class GR_B(models.Model):
 """An object with a generic key, that we'll point to an A"""
 content_type = models.ForeignKey(ContentType)
 object_id = models.PositiveIntegerField()
 content_obj = generic.GenericForeignKey(ct_field="content_type",
 fk_field="object_id")
 gr_c_reverse = generic.GenericRelation('GR_C')

 class GR_C(models.Model):
 """An object with a generic key, that we'll point to a GR_B

 # test proper deletion of gr_c pointing to gr_b if we delete gr_b
 >>> a=A.objects.create(t='foo')
 >>> gr_b=GR_B.objects.create(content_obj=a)
 >>> gr_c=GR_C.objects.create(content_obj=gr_b)
 >>> gr_b.delete()
 >>> print A.objects.all(), GR_B.objects.all(), GR_C.objects.all()
 [] [] []
 >>> a.delete()

 # test proper deletion of gr_b pointing to a if we delete a
 >>> a=A.objects.create(t='foo')
 >>> gr_b=GR_B.objects.create(content_obj=a)
 >>> a.delete()
 >>> print A.objects.all(), GR_B.objects.all()
 [] []

 # test proper deletion of fk_b pointing to a, fk_c pointing to b, gr_b
 pointing
 # to a, and gr_c pointing to gr_b if we delete a
 >>> a=A.objects.create(t='foo')
 >>> gr_b=GR_B.objects.create(content_obj=a)
 >>> gr_c=GR_C.objects.create(content_obj=gr_b)
 >>> fk_b=FK_B.objects.create(fk=a)
 >>> fk_c=FK_C.objects.create(fk=fk_b)
 >>> print A.objects.all(), GR_B.objects.all(), GR_C.objects.all(),
 FK_B.objects.all(), FK_C.objects.all()
 [] [] [] [] []
 >>> a.delete()
 >>> print A.objects.all(), GR_B.objects.all(), GR_C.objects.all(),
 FK_B.objects.all(), FK_C.objects.all()
 [] [] [] [] []

 # FAIL! we instead get:
 # [] [] [] [] []
 """

 content_type = models.ForeignKey(ContentType)
 object_id = models.PositiveIntegerField()
 content_obj = generic.GenericForeignKey(ct_field="content_type",
 fk_field="object_id")

 }}}

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9549 - in django/branches/releases/1.0.X: . django/db/backends/oracle tests/regressiontests/model_fields

2008-12-02 Thread noreply

Author: ikelly
Date: 2008-12-02 12:42:30 -0600 (Tue, 02 Dec 2008)
New Revision: 9549

Modified:
   django/branches/releases/1.0.X/
   django/branches/releases/1.0.X/django/db/backends/oracle/creation.py
   django/branches/releases/1.0.X/tests/regressiontests/model_fields/models.py
Log:
[1.0.X] Fixed #9706: made SlugField honor max_length in Oracle, matching the 
other backends. Backport of [9548] from trunk.


Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-integrated
   - 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535,9543-9544,9546
   + 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535,9543-9544,9546,9548

Modified: django/branches/releases/1.0.X/django/db/backends/oracle/creation.py
===
--- django/branches/releases/1.0.X/django/db/backends/oracle/creation.py
2008-12-02 18:40:40 UTC (rev 9548)
+++ django/branches/releases/1.0.X/django/db/backends/oracle/creation.py
2008-12-02 18:42:30 UTC (rev 9549)
@@ -32,7 +32,7 @@
 'OneToOneField':'NUMBER(11)',
 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 
0)',
 'PositiveSmallIntegerField':'NUMBER(11) CHECK (%(qn_column)s >= 
0)',
-'SlugField':'NVARCHAR2(50)',
+'SlugField':'NVARCHAR2(%(max_length)s)',
 'SmallIntegerField':'NUMBER(11)',
 'TextField':'NCLOB',
 'TimeField':'TIMESTAMP',

Modified: 
django/branches/releases/1.0.X/tests/regressiontests/model_fields/models.py
===
--- django/branches/releases/1.0.X/tests/regressiontests/model_fields/models.py 
2008-12-02 18:40:40 UTC (rev 9548)
+++ django/branches/releases/1.0.X/tests/regressiontests/model_fields/models.py 
2008-12-02 18:42:30 UTC (rev 9549)
@@ -36,6 +36,9 @@
 class BigD(models.Model):
 d = models.DecimalField(max_digits=38, decimal_places=30)
 
+class BigS(models.Model):
+s = models.SlugField(max_length=255)
+
 __test__ = {'API_TESTS':"""
 # Create a couple of Places.
 >>> f = Foo.objects.create(a='abc', d=decimal.Decimal("12.34"))
@@ -88,4 +91,10 @@
 >>> bd = BigD.objects.get(pk=bd.pk)
 >>> bd.d == decimal.Decimal("12.9")
 True
+
+# Regression test for #9706: ensure SlugField honors max_length.
+>>> bs = BigS.objects.create(s = 'slug' * 50)
+>>> bs = BigS.objects.get(pk=bs.pk)
+>>> bs.s == 'slug' * 50
+True
 """}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9548 - in django/trunk: django/db/backends/oracle tests/regressiontests/model_fields

2008-12-02 Thread noreply

Author: ikelly
Date: 2008-12-02 12:40:40 -0600 (Tue, 02 Dec 2008)
New Revision: 9548

Modified:
   django/trunk/django/db/backends/oracle/creation.py
   django/trunk/tests/regressiontests/model_fields/models.py
Log:
Fixed #9706: made SlugField honor max_length in Oracle, matching the other 
backends.

Modified: django/trunk/django/db/backends/oracle/creation.py
===
--- django/trunk/django/db/backends/oracle/creation.py  2008-12-02 16:59:39 UTC 
(rev 9547)
+++ django/trunk/django/db/backends/oracle/creation.py  2008-12-02 18:40:40 UTC 
(rev 9548)
@@ -32,7 +32,7 @@
 'OneToOneField':'NUMBER(11)',
 'PositiveIntegerField': 'NUMBER(11) CHECK (%(qn_column)s >= 
0)',
 'PositiveSmallIntegerField':'NUMBER(11) CHECK (%(qn_column)s >= 
0)',
-'SlugField':'NVARCHAR2(50)',
+'SlugField':'NVARCHAR2(%(max_length)s)',
 'SmallIntegerField':'NUMBER(11)',
 'TextField':'NCLOB',
 'TimeField':'TIMESTAMP',

Modified: django/trunk/tests/regressiontests/model_fields/models.py
===
--- django/trunk/tests/regressiontests/model_fields/models.py   2008-12-02 
16:59:39 UTC (rev 9547)
+++ django/trunk/tests/regressiontests/model_fields/models.py   2008-12-02 
18:40:40 UTC (rev 9548)
@@ -36,6 +36,9 @@
 class BigD(models.Model):
 d = models.DecimalField(max_digits=38, decimal_places=30)
 
+class BigS(models.Model):
+s = models.SlugField(max_length=255)
+
 __test__ = {'API_TESTS':"""
 # Create a couple of Places.
 >>> f = Foo.objects.create(a='abc', d=decimal.Decimal("12.34"))
@@ -88,4 +91,10 @@
 >>> bd = BigD.objects.get(pk=bd.pk)
 >>> bd.d == decimal.Decimal("12.9")
 True
+
+# Regression test for #9706: ensure SlugField honors max_length.
+>>> bs = BigS.objects.create(s = 'slug' * 50)
+>>> bs = BigS.objects.get(pk=bs.pk)
+>>> bs.s == 'slug' * 50
+True
 """}


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9230: Iterating over checkboxes in CheckboxSelectMultiple should be possible

2008-12-02 Thread Django
#9230: Iterating over checkboxes in CheckboxSelectMultiple should be possible
--+-
  Reporter:  mtredinnick  | Owner:  mtredinnick
Status:  new  | Milestone: 
 Component:  Forms|   Version:  1.0
Resolution:   |  Keywords: 
 Stage:  Unreviewed   | Has_patch:  0  
Needs_docs:  0|   Needs_tests:  0  
Needs_better_patch:  0|  
--+-
Comment (by mullendr):

 Please have a look at: http://www.zoia.org/blog/2007/03/24/iterating-over-
 items-of-selection-fields-in-django-templates-using-newforms/
 This solution works for me.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9740: Bad example in "CACHE_BACKEND arguments" section

2008-12-02 Thread Django
#9740: Bad example in "CACHE_BACKEND arguments" section
---+
 Reporter:  djw|   Owner:  nobody
   Status:  new|   Milestone:
Component:  Documentation  | Version:  1.0   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 The second example in the section
 [http://docs.djangoproject.com/en/dev/topics/cache/#cache-backend-
 arguments CACHE_BACKEND arguments] is not a good one, as memcached doesn't
 support the max_entries argument. It would be better to switch this to
 locmem, db, or filebased.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #8375: It's better to allow using tables parameter with custom alias in extra query

2008-12-02 Thread Django
#8375: It's better to allow using tables parameter with custom alias in extra
query
---+
  Reporter:  Wonlay| Owner:  nobody 
   
Status:  new   | Milestone:  post-1.0   
   
 Component:  Database layer (models, ORM)  |   Version:  SVN
   
Resolution:|  Keywords:  query, 
extra, tables, custom alias
 Stage:  Design decision needed| Has_patch:  1  
   
Needs_docs:  1 |   Needs_tests:  1  
   
Needs_better_patch:  1 |  
---+
Changes (by Phillip Temple):

  * stage:  Someday/Maybe => Design decision needed

Comment:

 I think it's an excellent patch, and useful if you want to implement a
 tree branch totals query for django-mptt. It's backward compatible so I
 can't see any problem incorporating it. The only thing I could also
 suggest is having the syntax:
 {{{
 table = ['newtable as newalias']
 }}}

 This will allow additional arguments to be added, giving some future-
 proofing, with the added bonus you can simply cut and paste from your
 tried and tested SQL statement.

 Phillip.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #3566: Proposal: ORM aggregation support

2008-12-02 Thread Django
#3566: Proposal: ORM aggregation support
+---
  Reporter:  Honza Král <[EMAIL PROTECTED]>  | Owner:  russellm 
   
Status:  assigned   | Milestone:
  
 Component:  Database layer (models, ORM)   |   Version:  SVN   
  
Resolution: |  Keywords:  orm 
aggregation group by
 Stage:  Someday/Maybe  | Has_patch:  1 
  
Needs_docs:  0  |   Needs_tests:  1 
  
Needs_better_patch:  1  |  
+---
Changes (by amlau):

 * cc: [EMAIL PROTECTED] (added)

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9547 - in django/branches/releases/1.0.X: . django/db/backends django/db/models/fields

2008-12-02 Thread noreply

Author: ikelly
Date: 2008-12-02 10:59:39 -0600 (Tue, 02 Dec 2008)
New Revision: 9547

Modified:
   django/branches/releases/1.0.X/
   django/branches/releases/1.0.X/django/db/backends/__init__.py
   django/branches/releases/1.0.X/django/db/models/fields/related.py
Log:
[1.0.X] Fixed a pair of bugs in determining the set of models to flush that 
were causing test cause failures in Oracle after [9536].


Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-integrated
   - 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535,9543-9544
   + 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535,9543-9544,9546

Modified: django/branches/releases/1.0.X/django/db/backends/__init__.py
===
--- django/branches/releases/1.0.X/django/db/backends/__init__.py   
2008-12-02 16:58:06 UTC (rev 9546)
+++ django/branches/releases/1.0.X/django/db/backends/__init__.py   
2008-12-02 16:59:39 UTC (rev 9547)
@@ -404,7 +404,7 @@
 tables.add(model._meta.db_table)
 tables.update([f.m2m_db_table() for f in 
model._meta.local_many_to_many])
 if only_existing:
-tables = [t for t in tables if t in self.table_names()]
+tables = [t for t in tables if self.table_name_converter(t) in 
self.table_names()]
 return tables
 
 def installed_models(self, tables):

Modified: django/branches/releases/1.0.X/django/db/models/fields/related.py
===
--- django/branches/releases/1.0.X/django/db/models/fields/related.py   
2008-12-02 16:58:06 UTC (rev 9546)
+++ django/branches/releases/1.0.X/django/db/models/fields/related.py   
2008-12-02 16:59:39 UTC (rev 9547)
@@ -1,4 +1,5 @@
 from django.db import connection, transaction
+from django.db.backends import util
 from django.db.models import signals, get_model
 from django.db.models.fields import AutoField, Field, IntegerField, 
PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist
 from django.db.models.related import RelatedObject
@@ -771,7 +772,8 @@
 elif self.db_table:
 return self.db_table
 else:
-return '%s_%s' % (opts.db_table, self.name)
+return util.truncate_name('%s_%s' % (opts.db_table, self.name),
+  connection.ops.max_name_length())
 
 def _get_m2m_column_name(self, related):
 "Function that can be curried to provide the source column name for 
the m2m table"


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9546 - in django/trunk/django/db: backends models/fields

2008-12-02 Thread noreply

Author: ikelly
Date: 2008-12-02 10:58:06 -0600 (Tue, 02 Dec 2008)
New Revision: 9546

Modified:
   django/trunk/django/db/backends/__init__.py
   django/trunk/django/db/models/fields/related.py
Log:
Fixed a pair of bugs in determining the set of models to flush that were 
causing test cause failures in Oracle after [9536].

Modified: django/trunk/django/db/backends/__init__.py
===
--- django/trunk/django/db/backends/__init__.py 2008-12-02 13:34:00 UTC (rev 
9545)
+++ django/trunk/django/db/backends/__init__.py 2008-12-02 16:58:06 UTC (rev 
9546)
@@ -404,7 +404,7 @@
 tables.add(model._meta.db_table)
 tables.update([f.m2m_db_table() for f in 
model._meta.local_many_to_many])
 if only_existing:
-tables = [t for t in tables if t in self.table_names()]
+tables = [t for t in tables if self.table_name_converter(t) in 
self.table_names()]
 return tables
 
 def installed_models(self, tables):

Modified: django/trunk/django/db/models/fields/related.py
===
--- django/trunk/django/db/models/fields/related.py 2008-12-02 13:34:00 UTC 
(rev 9545)
+++ django/trunk/django/db/models/fields/related.py 2008-12-02 16:58:06 UTC 
(rev 9546)
@@ -1,4 +1,5 @@
 from django.db import connection, transaction
+from django.db.backends import util
 from django.db.models import signals, get_model
 from django.db.models.fields import AutoField, Field, IntegerField, 
PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist
 from django.db.models.related import RelatedObject
@@ -771,7 +772,8 @@
 elif self.db_table:
 return self.db_table
 else:
-return '%s_%s' % (opts.db_table, self.name)
+return util.truncate_name('%s_%s' % (opts.db_table, self.name),
+  connection.ops.max_name_length())
 
 def _get_m2m_column_name(self, related):
 "Function that can be curried to provide the source column name for 
the m2m table"


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9739: Admin does correctly prefill DataTimeField from URL (GET) + patch

2008-12-02 Thread Django
#9739: Admin does correctly prefill DataTimeField from URL (GET) + patch
---+
  Reporter:  gilhad| Owner:  nobody
Status:  new   | Milestone:
 Component:  django.contrib.admin  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by gilhad):

  * needs_docs:  0 => 1

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9739: Admin does correctly prefill DataTimeField from URL (GET) + patch

2008-12-02 Thread Django
#9739: Admin does correctly prefill DataTimeField from URL (GET) + patch
---+
  Reporter:  gilhad| Owner:  nobody
Status:  new   | Milestone:
 Component:  django.contrib.admin  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by gilhad):

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

Comment:

 Typo - (Admin does '''NOT''' correctly prefill DataTimeField from URL
 (GET) + patch)

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9739: Admin does correctly prefill DataTimeField from URL (GET) + patch

2008-12-02 Thread Django
#9739: Admin does correctly prefill DataTimeField from URL (GET) + patch
--+-
 Reporter:  gilhad|   Owner:  nobody
   Status:  new   |   Milestone:
Component:  django.contrib.admin  | Version:  1.0   
 Keywords:|   Stage:  Unreviewed
Has_patch:  1 |  
--+-
 I was not able to format URL for Admin interface to prefill DateTimeField
 with given value.

 It worked in 0.96, but does not work in 1.0 ( I used
 ../admin/MyApp/MyTable/add/?box=359&datum_date=2008-12-01&datum_time=17:30:27)


 After some looking on source code and testing i find a solution:

 - in /django/contrib/admin/options.py before line 520 add
 {{{
   if isinstance(f, models.DateTimeField):
  initial[k] = initial[k].split(",")
 }}}

 - use this format:
 https://../admin/MyApp/MyTable/add/?box=359&datum=2008-12-01,17:30:27

 For reference - the model of MyTable is such :
 {{{
 class MyTable(models.Model):
 box = models.ForeignKey(Boxes)
 datum =  models.DateTimeField(null=True, blank=True)
 }}}
 (plus some other insignificant fields.
 The "datum" field should be prefilled with some date, which is computed by
 long way (not simple now()) and the use must be able to edit it BEFORE
 saving it)

 

 The problem arises from DateTimeField be treated by MultiWidget, but not
 properly broken when got by URL (GET)

 -

 Patch:
 {{{
 --- options.py.old  2008-12-01 19:56:34.0 +0100
 +++ options.py  2008-12-01 19:40:34.0 +0100
 @@ -517,6 +517,8 @@
  continue
  if isinstance(f, models.ManyToManyField):
  initial[k] = initial[k].split(",")
 +if isinstance(f, models.DateTimeField):
 +initial[k] = initial[k].split(",")
  form = ModelForm(initial=initial)
  for FormSet in self.get_formsets(request):
  formset = FormSet(instance=self.model())

 }}}

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9738: unit test examples in docs use old "failUnless" methods instead of new "assert" methods

2008-12-02 Thread Django
#9738: unit test examples in docs use old "failUnless" methods instead of new
"assert" methods
---+
 Reporter:  brandon|   Owner:  nobody
   Status:  new|   Milestone:
Component:  Documentation  | Version:  1.0   
 Keywords: |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 The unit testing examples are using the old "failUnlessEqual" UnitTest
 method instead of the new "assertEquals" methods.  The "fail*" methods
 might become deprecated soon in the 2.x series, and I think have gone away
 completely in Python 3, so we should be teaching the Django legions to use
 the more modern names.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9737: XBpUukxbsF

2008-12-02 Thread Django
#9737: XBpUukxbsF
+---
  Reporter:  anonymous  | Owner:  nobody  
Status:  closed | Milestone:  post-1.0
 Component:  Uncategorized  |   Version:  1.0 
Resolution:  invalid|  Keywords:  iVxfsrrWlQPZ
 Stage:  Unreviewed | Has_patch:  0   
Needs_docs:  0  |   Needs_tests:  0   
Needs_better_patch:  0  |  
+---
Changes (by anonymous):

  * status:  new => closed
  * needs_better_patch:  => 0
  * resolution:  => invalid
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 spam

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9737: XBpUukxbsF

2008-12-02 Thread Django
#9737: XBpUukxbsF
---+
 Reporter:  anonymous  |   Owner:  nobody
   Status:  new|   Milestone:  post-1.0  
Component:  Uncategorized  | Version:  1.0   
 Keywords:  iVxfsrrWlQPZ   |   Stage:  Unreviewed
Has_patch:  0  |  
---+
 AmBUC5  http://rbftllonhqpg.com/";>rbftllonhqpg,
 [url=http://kifbcnaaebqv.com/]kifbcnaaebqv[/url],
 [link=http://plxntzbkstln.com/]plxntzbkstln[/link],
 http://glubgzaemdux.com/

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9636: Update zh_CN django.po

2008-12-02 Thread Django
#9636: Update zh_CN django.po
---+
  Reporter:  hutuworm  | Owner:  nobody
Status:  new   | Milestone:
 Component:  Translations  |   Version:  SVN   
Resolution:|  Keywords:
 Stage:  Accepted  | Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  1 |  
---+
Changes (by lidaobing):

 * cc: lidaobing (added)

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #8193: `__import__(mod, {}, {}, [''])` causes double import of modules ('module' and 'module' + '.')

2008-12-02 Thread Django
#8193: `__import__(mod, {}, {}, [''])` causes double import of modules ('module'
and 'module' + '.')
+---
  Reporter:  i_i| Owner:  mtredinnick
Status:  assigned   | Milestone:  post-1.0   
 Component:  Uncategorized  |   Version:  SVN
Resolution: |  Keywords:  import 
 Stage:  Accepted   | Has_patch:  1  
Needs_docs:  0  |   Needs_tests:  0  
Needs_better_patch:  1  |  
+---
Comment (by mrts):

 In short:

  * as `__import__` is not meant to be used directly, there will be a much
 simpler API for runtime loading of modules in `imp` in Python 3.1 (and
 perhaps 2.7)
  * until that the following idiom should be used:
 {{{
 import sys
 __import__(modname)
 mod = sys.modules[modname]
 }}}

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9545 - in django/branches/releases/1.0.X: . django/db/backends tests/regressiontests tests/regressiontests/custom_columns_regress tests/regressiontests/generic_inline_admin tests/regressi

2008-12-02 Thread noreply

Author: russellm
Date: 2008-12-02 07:34:00 -0600 (Tue, 02 Dec 2008)
New Revision: 9545

Added:
   django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/
   
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/__init__.py
   
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/models.py
Removed:
   
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/__init__.py
   
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/models.py
Modified:
   django/branches/releases/1.0.X/
   django/branches/releases/1.0.X/django/db/backends/creation.py
   django/branches/releases/1.0.X/tests/regressiontests/generic_inline_admin/
   django/branches/releases/1.0.X/tests/regressiontests/managers_regress/
Log:
[1.0.X] Fixed #9736 -- Added quoting to the SQL constraint names generated 
during table creation. This is to accommodate primary keys with spaces.

Merge of [9543] from trunk.



Property changes on: django/branches/releases/1.0.X
___
Name: svnmerge-integrated
   - 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535
   + 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9523,9535,9543-9544

Modified: django/branches/releases/1.0.X/django/db/backends/creation.py
===
--- django/branches/releases/1.0.X/django/db/backends/creation.py   
2008-12-02 13:27:30 UTC (rev 9544)
+++ django/branches/releases/1.0.X/django/db/backends/creation.py   
2008-12-02 13:34:00 UTC (rev 9545)
@@ -126,7 +126,7 @@
 # So we are careful with character usage here.
 r_name = '%s_refs_%s_%x' % (r_col, col, abs(hash((r_table, 
table
 final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s 
ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \
-(qn(r_table), truncate_name(r_name, 
self.connection.ops.max_name_length()),
+(qn(r_table), qn(truncate_name(r_name, 
self.connection.ops.max_name_length())),
 qn(r_col), qn(table), qn(col),
 self.connection.ops.deferrable_sql()))
 del pending_references[model]
@@ -186,7 +186,7 @@
 abs(hash((r_table, table
 output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD 
CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' %
 (qn(r_table),
-truncate_name(r_name, self.connection.ops.max_name_length()),
+qn(truncate_name(r_name, 
self.connection.ops.max_name_length())),
 qn(r_col), qn(table), qn(col),
 self.connection.ops.deferrable_sql()))
 

Copied: 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress 
(from rev 9544, django/trunk/tests/regressiontests/custom_columns_regress)


Property changes on: 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress
___
Name: svn:ignore
   + *.pyc


Deleted: 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/__init__.py
===

Copied: 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/__init__.py
 (from rev 9544, 
django/trunk/tests/regressiontests/custom_columns_regress/__init__.py)
===

Deleted: 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/models.py
===
--- django/trunk/tests/regressiontests/custom_columns_regress/models.py 
2008-12-02 13:27:30 UTC (rev 9544)
+++ 
django/branches/releases/1.0.X/tests/regressiontests/custom_columns_regress/models.py
   2008-12-02 13:34:00 UTC (rev 9545)
@@ -1,100 +0,0 @@
-"""
-Regression for #9736.
-
-Checks some pathological column naming to make sure it doesn't break
-table creation or queries.
-
-"""
-
-from django.db import models
-
-class Article(models.Model):
-Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
-headline = models.CharField(max_length=100)
-authors = models.ManyToManyField('Author', db_table='my m2m table')
-primary_author = models.ForeignKey('Author', db_column='Author ID', 
related_name='primary_set')
-
-def __unicode__(self):
-return self.headline
-
-class Meta:
-ordering = ('headline',)
-
-cla

[Changeset] r9544 - in django/trunk/tests/regressiontests: custom_columns_regress generic_inline_admin managers_regress

2008-12-02 Thread noreply

Author: russellm
Date: 2008-12-02 07:27:30 -0600 (Tue, 02 Dec 2008)
New Revision: 9544

Modified:
   django/trunk/tests/regressiontests/custom_columns_regress/
   django/trunk/tests/regressiontests/generic_inline_admin/
   django/trunk/tests/regressiontests/managers_regress/
Log:
Added svn:ignore properties on some recently added directories


Property changes on: django/trunk/tests/regressiontests/custom_columns_regress
___
Name: svn:ignore
   + *.pyc



Property changes on: django/trunk/tests/regressiontests/generic_inline_admin
___
Name: svn:ignore
   + *.pyc



Property changes on: django/trunk/tests/regressiontests/managers_regress
___
Name: svn:ignore
   + *.pyc



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Changeset] r9543 - in django/trunk: django/db/backends tests/regressiontests tests/regressiontests/custom_columns_regress

2008-12-02 Thread noreply

Author: russellm
Date: 2008-12-02 07:23:29 -0600 (Tue, 02 Dec 2008)
New Revision: 9543

Added:
   django/trunk/tests/regressiontests/custom_columns_regress/
   django/trunk/tests/regressiontests/custom_columns_regress/__init__.py
   django/trunk/tests/regressiontests/custom_columns_regress/models.py
Modified:
   django/trunk/django/db/backends/creation.py
Log:
Fixed #9736 -- Added quoting to the SQL constraint names generated during table 
creation. This is to accommodate primary keys with spaces.

Modified: django/trunk/django/db/backends/creation.py
===
--- django/trunk/django/db/backends/creation.py 2008-12-02 06:01:14 UTC (rev 
9542)
+++ django/trunk/django/db/backends/creation.py 2008-12-02 13:23:29 UTC (rev 
9543)
@@ -126,7 +126,7 @@
 # So we are careful with character usage here.
 r_name = '%s_refs_%s_%x' % (r_col, col, abs(hash((r_table, 
table
 final_output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s 
ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' % \
-(qn(r_table), truncate_name(r_name, 
self.connection.ops.max_name_length()),
+(qn(r_table), qn(truncate_name(r_name, 
self.connection.ops.max_name_length())),
 qn(r_col), qn(table), qn(col),
 self.connection.ops.deferrable_sql()))
 del pending_references[model]
@@ -186,7 +186,7 @@
 abs(hash((r_table, table
 output.append(style.SQL_KEYWORD('ALTER TABLE') + ' %s ADD 
CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' %
 (qn(r_table),
-truncate_name(r_name, self.connection.ops.max_name_length()),
+qn(truncate_name(r_name, 
self.connection.ops.max_name_length())),
 qn(r_col), qn(table), qn(col),
 self.connection.ops.deferrable_sql()))
 

Added: django/trunk/tests/regressiontests/custom_columns_regress/__init__.py
===

Added: django/trunk/tests/regressiontests/custom_columns_regress/models.py
===
--- django/trunk/tests/regressiontests/custom_columns_regress/models.py 
(rev 0)
+++ django/trunk/tests/regressiontests/custom_columns_regress/models.py 
2008-12-02 13:23:29 UTC (rev 9543)
@@ -0,0 +1,100 @@
+"""
+Regression for #9736.
+
+Checks some pathological column naming to make sure it doesn't break
+table creation or queries.
+
+"""
+
+from django.db import models
+
+class Article(models.Model):
+Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
+headline = models.CharField(max_length=100)
+authors = models.ManyToManyField('Author', db_table='my m2m table')
+primary_author = models.ForeignKey('Author', db_column='Author ID', 
related_name='primary_set')
+
+def __unicode__(self):
+return self.headline
+
+class Meta:
+ordering = ('headline',)
+
+class Author(models.Model):
+Author_ID = models.AutoField(primary_key=True, db_column='Author ID')
+first_name = models.CharField(max_length=30, db_column='first name')
+last_name = models.CharField(max_length=30, db_column='last name')
+
+def __unicode__(self):
+return u'%s %s' % (self.first_name, self.last_name)
+
+class Meta:
+db_table = 'my author table'
+ordering = ('last_name','first_name')
+
+
+__test__ = {'API_TESTS':"""
+# Create a Author.
+>>> a = Author(first_name='John', last_name='Smith')
+>>> a.save()
+
+>>> a.Author_ID
+1
+
+# Create another author
+>>> a2 = Author(first_name='Peter', last_name='Jones')
+>>> a2.save()
+
+# Create an article
+>>> art = Article(headline='Django lets you build web apps easily', 
primary_author=a)
+>>> art.save()
+>>> art.authors = [a, a2]
+
+# Although the table and column names on Author have been set to custom values,
+# nothing about using the Author model has changed...
+
+# Query the available authors
+>>> Author.objects.all()
+[, ]
+
+>>> Author.objects.filter(first_name__exact='John')
+[]
+
+>>> Author.objects.get(first_name__exact='John')
+
+
+>>> Author.objects.filter(firstname__exact='John')
+Traceback (most recent call last):
+...
+FieldError: Cannot resolve keyword 'firstname' into field. Choices are: 
Author_ID, article, first_name, last_name, primary_set
+
+>>> a = Author.objects.get(last_name__exact='Smith')
+>>> a.first_name
+u'John'
+>>> a.last_name
+u'Smith'
+>>> a.firstname
+Traceback (most recent call last):
+...
+AttributeError: 'Author' object has no attribute 'firstname'
+>>> a.last
+Traceback (most recent call last):
+...
+AttributeError: 'Author' object has no attribute 'last'
+
+# Although the Article table uses a custom m2m table,
+# nothing about using the m2m relationship has changed...
+
+# Get all the authors for an article
+>>> art

Re: [Django] #9736: Primary key with space in name generates invalid constraint SQL

2008-12-02 Thread Django
#9736: Primary key with space in name generates invalid constraint SQL
--+-
  Reporter:  russellm | Owner:  russellm
Status:  assigned | Milestone:  
 Component:  django-admin.py  |   Version:  1.0 
Resolution:   |  Keywords:  
 Stage:  Accepted | Has_patch:  0   
Needs_docs:  0|   Needs_tests:  0   
Needs_better_patch:  0|  
--+-
Changes (by russellm):

  * status:  new => assigned
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * owner:  nobody => russellm
  * needs_docs:  => 0
  * stage:  Unreviewed => Accepted

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9736: Primary key with space in name generates invalid constraint SQL

2008-12-02 Thread Django
#9736: Primary key with space in name generates invalid constraint SQL
-+--
 Reporter:  russellm |   Owner:  nobody
   Status:  new  |   Milestone:
Component:  django-admin.py  | Version:  1.0   
 Keywords:   |   Stage:  Unreviewed
Has_patch:  0|  
-+--
 The following models:
 {{{
 class Clue(models.Model):
clue_id = models.AutoField(primary_key=True)
entryRef = models.ForeignKey('Entry', db_column = 'Entry Ref')
clue = models.CharField(max_length=150)

 class Entry(models.Model):
entry_id = models.AutoField(primary_key=True, db_column='Entry ID')
entry = models.CharField(unique=True, max_length=50)
 }}}
 can't be created using syncdb. This is due to the SQL generated for the
 deferred foreign key constraint. The following is the SQL generated for
 Postgres:
 {{{
 ALTER TABLE "app2_clue" ADD CONSTRAINT Entry Ref_refs_Entry ID_692e28e3
 FOREIGN KEY ("Entry Ref") REFERENCES "app2_entry" ("Entry ID") DEFERRABLE
 INITIALLY DEFERRED;
 }}}
 Analogous code is generated for MySQL The problem is the name of the
 reference: Entry Ref_refs_Entry ID_692e28e3. While all other uses of
 column names are quoted, the constraint name (which is derived from the
 column names) is not quoted. As a result, the constraint name is invalid.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #17: Metasystem optimization: Share select_related in memory

2008-12-02 Thread Django
#17: Metasystem optimization: Share select_related in memory
---+
  Reporter:  adrian| Owner:  PhiR   

Status:  assigned  | Milestone:  post-1.0   

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

Resolution:|  Keywords:  feature 
caching
 Stage:  Accepted  | Has_patch:  1  

Needs_docs:  1 |   Needs_tests:  0  

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

 Ive worked up a quick "SingletonModel" piece of code. It allows you to
 define a model, by inheriting from SingletonModel, as a Singleton. It
 works almost identically to this patch, barring the removal of some
 unneeded code.

 http://github.com/dcramer/django-singletons/tree/master

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---