Author: bouldersprinters
Date: 2007-06-04 11:12:35 -0500 (Mon, 04 Jun 2007)
New Revision: 5422

Modified:
   django/branches/boulder-oracle-sprint/AUTHORS
   django/branches/boulder-oracle-sprint/django/bin/daily_cleanup.py
   
django/branches/boulder-oracle-sprint/django/conf/project_template/settings.py
   django/branches/boulder-oracle-sprint/django/contrib/comments/feeds.py
   django/branches/boulder-oracle-sprint/django/core/serializers/json.py
   django/branches/boulder-oracle-sprint/django/core/serializers/pyyaml.py
   django/branches/boulder-oracle-sprint/django/db/backends/dummy/base.py
   django/branches/boulder-oracle-sprint/django/middleware/common.py
   django/branches/boulder-oracle-sprint/django/oldforms/__init__.py
   django/branches/boulder-oracle-sprint/docs/django-admin.txt
   django/branches/boulder-oracle-sprint/docs/generic_views.txt
   django/branches/boulder-oracle-sprint/docs/serialization.txt
   django/branches/boulder-oracle-sprint/docs/settings.txt
   django/branches/boulder-oracle-sprint/docs/templates_python.txt
   django/branches/boulder-oracle-sprint/docs/testing.txt
   django/branches/boulder-oracle-sprint/docs/tutorial04.txt
   django/branches/boulder-oracle-sprint/docs/url_dispatch.txt
   django/branches/boulder-oracle-sprint/tests/modeltests/serializers/models.py
   
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py
   
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/tests.py
Log:
boulder-oracle-sprint: Merged to [5421]

Modified: django/branches/boulder-oracle-sprint/AUTHORS
===================================================================
--- django/branches/boulder-oracle-sprint/AUTHORS       2007-06-04 07:48:51 UTC 
(rev 5421)
+++ django/branches/boulder-oracle-sprint/AUTHORS       2007-06-04 16:12:35 UTC 
(rev 5422)
@@ -142,6 +142,7 @@
     Joseph Kocherhans
     [EMAIL PROTECTED]
     [EMAIL PROTECTED]
+    Nick Lane <[EMAIL PROTECTED]>
     Stuart Langridge <http://www.kryogenix.org/>
     Nicola Larosa <[EMAIL PROTECTED]>
     Eugene Lazutkin <http://lazutkin.com/blog/>

Modified: django/branches/boulder-oracle-sprint/django/bin/daily_cleanup.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/bin/daily_cleanup.py   
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/bin/daily_cleanup.py   
2007-06-04 16:12:35 UTC (rev 5422)
@@ -7,13 +7,13 @@
 sessions at the moment).
 """
 
-from django.db import backend, connection, transaction
+import datetime
+from django.db import transaction
+from django.contrib.sessions.models import Session
 
 def clean_up():
-    # Clean up old database records
-    cursor = connection.cursor()
-    cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
-        (backend.quote_name('django_session'), 
backend.quote_name('expire_date')))
+    """Clean up expired sessions."""
+    Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
     transaction.commit_unless_managed()
 
 if __name__ == "__main__":

Modified: 
django/branches/boulder-oracle-sprint/django/conf/project_template/settings.py
===================================================================
--- 
django/branches/boulder-oracle-sprint/django/conf/project_template/settings.py  
    2007-06-04 07:48:51 UTC (rev 5421)
+++ 
django/branches/boulder-oracle-sprint/django/conf/project_template/settings.py  
    2007-06-04 16:12:35 UTC (rev 5422)
@@ -38,8 +38,9 @@
 # Example: "/home/media/media.lawrence.com/"
 MEDIA_ROOT = ''
 
-# URL that handles the media served from MEDIA_ROOT.
-# Example: "http://media.lawrence.com";
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com";, "http://example.com/media/";
 MEDIA_URL = ''
 
 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a

Modified: django/branches/boulder-oracle-sprint/django/contrib/comments/feeds.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/contrib/comments/feeds.py      
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/contrib/comments/feeds.py      
2007-06-04 16:12:35 UTC (rev 5422)
@@ -23,16 +23,19 @@
             self._site = Site.objects.get_current()
         return "Latest comments on %s" % self._site.name
 
+    def get_query_set(self):
+        return self.comments_class.objects.filter(site__pk=settings.SITE_ID, 
is_public=True)
+
     def items(self):
-        return self.comments_class.objects.filter(site__pk=settings.SITE_ID, 
is_public=True)[:40]
+        return self.get_query_set()[:40]
 
 class LatestCommentsFeed(LatestFreeCommentsFeed):
     """Feed of latest free comments on the current site"""
 
     comments_class = Comment
 
-    def items(self):
-        qs = LatestFreeCommentsFeed.items(self)
+    def get_query_set(self):
+        qs = super(LatestCommentsFeed, self).get_query_set()
         qs = qs.filter(is_removed=False)
         if settings.COMMENTS_BANNED_USERS_GROUP:
             where = ['user_id NOT IN (SELECT user_id FROM auth_users_group 
WHERE group_id = %s)']

Modified: django/branches/boulder-oracle-sprint/django/core/serializers/json.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/core/serializers/json.py       
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/core/serializers/json.py       
2007-06-04 16:12:35 UTC (rev 5422)
@@ -21,6 +21,8 @@
     Convert a queryset to JSON.
     """
     def end_serialization(self):
+        self.options.pop('stream', None)
+        self.options.pop('fields', None)
         simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, 
**self.options)
 
     def getvalue(self):

Modified: 
django/branches/boulder-oracle-sprint/django/core/serializers/pyyaml.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/core/serializers/pyyaml.py     
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/core/serializers/pyyaml.py     
2007-06-04 16:12:35 UTC (rev 5422)
@@ -18,6 +18,8 @@
     Convert a queryset to YAML.
     """
     def end_serialization(self):
+        self.options.pop('stream', None)
+        self.options.pop('fields', None)
         yaml.dump(self.objects, self.stream, **self.options)
         
     def getvalue(self):

Modified: django/branches/boulder-oracle-sprint/django/db/backends/dummy/base.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/db/backends/dummy/base.py      
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/db/backends/dummy/base.py      
2007-06-04 16:12:35 UTC (rev 5422)
@@ -12,6 +12,9 @@
 def complain(*args, **kwargs):
     raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting 
yet."
 
+def ignore(*args, **kwargs):
+    pass
+
 class DatabaseError(Exception):
     pass
 
@@ -21,7 +24,7 @@
 class DatabaseWrapper:
     cursor = complain
     _commit = complain
-    _rollback = complain
+    _rollback = ignore
 
     def __init__(self, **kwargs):
         pass

Modified: django/branches/boulder-oracle-sprint/django/middleware/common.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/middleware/common.py   
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/middleware/common.py   
2007-06-04 16:12:35 UTC (rev 5422)
@@ -75,7 +75,7 @@
         # Use ETags, if requested.
         if settings.USE_ETAGS:
             etag = md5.new(response.content).hexdigest()
-            if request.META.get('HTTP_IF_NONE_MATCH') == etag:
+            if response.status_code >= 200 and response.status_code < 300 and 
request.META.get('HTTP_IF_NONE_MATCH') == etag:
                 response = http.HttpResponseNotModified()
             else:
                 response['ETag'] = etag

Modified: django/branches/boulder-oracle-sprint/django/oldforms/__init__.py
===================================================================
--- django/branches/boulder-oracle-sprint/django/oldforms/__init__.py   
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/django/oldforms/__init__.py   
2007-06-04 16:12:35 UTC (rev 5422)
@@ -782,7 +782,7 @@
         try: 
             import decimal 
         except ImportError:
-            from django.utils import decimal
+            from django.utils import _decimal as decimal
         try: 
             return decimal.Decimal(data) 
         except decimal.InvalidOperation, e: 

Modified: django/branches/boulder-oracle-sprint/docs/django-admin.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/django-admin.txt 2007-06-04 
07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/django-admin.txt 2007-06-04 
16:12:35 UTC (rev 5422)
@@ -295,7 +295,7 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 By default, the development server doesn't serve any static files for your site
-(such as CSS files, images, things under ``MEDIA_ROOT_URL`` and so forth). If
+(such as CSS files, images, things under ``MEDIA_URL`` and so forth). If
 you want to configure Django to serve static media, read the `serving static 
files`_
 documentation.
 
@@ -403,9 +403,10 @@
 If you're installing the ``django.contrib.auth`` application, ``syncdb`` will
 give you the option of creating a superuser immediately.
 
-``syncdb`` will also search for and install any fixture named ``initial_data``.
-See the documentation for ``loaddata`` for details on the specification of
-fixture data files.
+``syncdb`` will also search for and install any fixture named ``initial_data``
+with an appropriate extension (e.g. ``json`` or ``xml``). See the
+documentation for ``loaddata`` for details on the specification of fixture
+data files.
 
 test
 ----

Modified: django/branches/boulder-oracle-sprint/docs/generic_views.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/generic_views.txt        
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/generic_views.txt        
2007-06-04 16:12:35 UTC (rev 5422)
@@ -99,6 +99,9 @@
       dictionary is callable, the generic view will call it
       just before rendering the template.
 
+    * ``mimetype``: The MIME type to use for the resulting document. Defaults
+      to the value of the ``DEFAULT_CONTENT_TYPE`` setting.
+
 **Example:**
 
 Given the following URL patterns::

Modified: django/branches/boulder-oracle-sprint/docs/serialization.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/serialization.txt        
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/serialization.txt        
2007-06-04 16:12:35 UTC (rev 5422)
@@ -44,6 +44,25 @@
 
 .. _HTTPResponse: ../request_response/#httpresponse-objects
 
+Subset of fields
+~~~~~~~~~~~~~~~~
+
+If you only want a subset of fields to be serialized, you can 
+specify a `fields` argument to the serializer::
+
+    from django.core import serializers
+    data = serializers.serialize('xml', SomeModel.objects.all(), 
fields=('name','size'))
+
+In this example, only the `name` and `size` attributes of each model will
+be serialized. 
+
+.. note::
+
+    Depending on your model, you may find that it is not possible to 
deserialize
+    a model that only serializes a subset of its fields. If a serialized object
+    doesn't specify all the fields that are required by a model, the 
deserializer
+    will not be able to save deserialized instances.
+
 Deserializing data
 ------------------
 
@@ -92,10 +111,14 @@
     ``python``  Translates to and from "simple" Python objects (lists, dicts,
                 strings, etc.).  Not really all that useful on its own, but
                 used as a base for other serializers.
+    
+    ``yaml``    Serializes to YAML (Yet Another Markup Lanuage). This 
+                serializer is only available if PyYAML_ is installed. 
     ==========  ==============================================================
 
 .. _json: http://json.org/
 .. _simplejson: http://undefined.org/python/#simplejson
+.. _PyYAML: http://www.pyyaml.org/
 
 Notes for specific serialization formats
 ----------------------------------------

Modified: django/branches/boulder-oracle-sprint/docs/settings.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/settings.txt     2007-06-04 
07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/settings.txt     2007-06-04 
16:12:35 UTC (rev 5422)
@@ -850,7 +850,7 @@
 Default: ``None``
 
 The collation order to use when creating the test database. This value is
-passed directly to the backend, so it's format is backend-specific.
+passed directly to the backend, so its format is backend-specific.
 
 Only supported for ``mysql`` and ``mysql_old`` backends (see `section 10.3.2`_
 of the MySQL manual for details).

Modified: django/branches/boulder-oracle-sprint/docs/templates_python.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/templates_python.txt     
2007-06-04 07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/templates_python.txt     
2007-06-04 16:12:35 UTC (rev 5422)
@@ -394,8 +394,8 @@
 django.core.context_processors.media
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processors, every
-``RequestContext`` will contain ``MEDIA_URL``,  providing the 
+If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every
+``RequestContext`` will contain a variable ``MEDIA_URL``, providing the
 value of the `MEDIA_URL setting`_.
 
 .. _MEDIA_URL setting: ../settings/#media-url

Modified: django/branches/boulder-oracle-sprint/docs/testing.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/testing.txt      2007-06-04 
07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/testing.txt      2007-06-04 
16:12:35 UTC (rev 5422)
@@ -571,14 +571,12 @@
 If you wish to use a name other than the default for the test database,
 you can use the ``TEST_DATABASE_NAME`` setting to provide a name.
 
+**New in Django development version:** For fine-grained control over the
+character encoding of your database, use the ``TEST_DATABASE_CHARSET`` setting.
+If you're using MySQL, you can also use the ``TEST_DATABASE_COLLATION`` setting
+to control the particular collation used by the test database. See the
+settings_ documentation for details of these advanced settings.
 
-**New in Django development version:** If you wish to have fine-grained
-control over the character set encoding used in your database, you can control
-this with the ``TEST_DATABASE_CHARSET`` setting. For MySQL users, you can also
-control the particular collation used by the test database with the
-``TEST_DATABASE_COLLATION`` setting. Refer to the settings_ documentation for
-details of these advanced settings.
-
 .. _settings: ../settings/
 
 The test database is created by the user in the ``DATABASE_USER`` setting.

Modified: django/branches/boulder-oracle-sprint/docs/tutorial04.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/tutorial04.txt   2007-06-04 
07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/tutorial04.txt   2007-06-04 
16:12:35 UTC (rev 5422)
@@ -67,7 +67,7 @@
             # Always return an HttpResponseRedirect after successfully dealing
             # with POST data. This prevents data from being posted twice if a
             # user hits the Back button.
-            return HttpResponseRedirect(reverse('results', args=(p.id,)))
+            return HttpResponseRedirect(reverse('mysite.polls.views.results', 
args=(p.id,)))
 
 This code includes a few things we haven't covered yet in this tutorial:
 
@@ -104,7 +104,8 @@
         '/polls/3/results/'
 
       ... where the ``3`` is the value of ``p.id``. This redirected URL will
-      then call the ``'results'`` view to display the final page.
+      then call the ``'results'`` view to display the final page. Note that
+      you need to use the full name of the view here (including the prefix).
 
       For more information about ``reverse()``, see the `URL dispatcher`_
       documentation.

Modified: django/branches/boulder-oracle-sprint/docs/url_dispatch.txt
===================================================================
--- django/branches/boulder-oracle-sprint/docs/url_dispatch.txt 2007-06-04 
07:48:51 UTC (rev 5421)
+++ django/branches/boulder-oracle-sprint/docs/url_dispatch.txt 2007-06-04 
16:12:35 UTC (rev 5422)
@@ -564,10 +564,11 @@
 
     reverse(viewname, urlconf=None, args=None, kwargs=None)
 
-The view name is either the function name or the `URL pattern name`_.
-Normally you will not need to worry about the ``urlconf`` parameter and will
-only pass in the positional and keyword arguments to use in the url matching.
-For example::
+``viewname`` is either the function name (either a function reference, or the
+string version of the name, if you used that form in ``urlpatterns``) or the
+`URL pattern name`_.  Normally, you won't need to worry about the
+``urlconf`` parameter and will only pass in the positional and keyword
+arguments to use in the URL matching. For example::
 
     from django.core.urlresolvers import reverse
 

Modified: 
django/branches/boulder-oracle-sprint/tests/modeltests/serializers/models.py
===================================================================
--- 
django/branches/boulder-oracle-sprint/tests/modeltests/serializers/models.py    
    2007-06-04 07:48:51 UTC (rev 5421)
+++ 
django/branches/boulder-oracle-sprint/tests/modeltests/serializers/models.py    
    2007-06-04 16:12:35 UTC (rev 5422)
@@ -159,4 +159,8 @@
 >>> article.author
 <Author: Agnes>
 
+# Serializer output can be restricted to a subset of fields
+>>> print serializers.serialize("json", Article.objects.all(), 
fields=('headline','pub_date'))
+[{"pk": "1", "model": "serializers.article", "fields": {"headline": "Just 
kidding; I love TV poker", "pub_date": "2006-06-16 11:00:00"}}, {"pk": "2", 
"model": "serializers.article", "fields": {"headline": "Time to reform 
copyright", "pub_date": "2006-06-16 13:00:00"}}, {"pk": "3", "model": 
"serializers.article", "fields": {"headline": "Forward references pose no 
problem", "pub_date": "2006-06-16 15:00:00"}}]
+
 """}

Modified: 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py
===================================================================
--- 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py
   2007-06-04 07:48:51 UTC (rev 5421)
+++ 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py
   2007-06-04 16:12:35 UTC (rev 5422)
@@ -205,3 +205,7 @@
 # class XMLPKData(models.Model):
 #     data = models.XMLField(primary_key=True)
 
+class ComplexModel(models.Model):
+    field1 = models.CharField(maxlength=10)
+    field2 = models.CharField(maxlength=10)
+    field3 = models.CharField(maxlength=10)

Modified: 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/tests.py
===================================================================
--- 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/tests.py
    2007-06-04 07:48:51 UTC (rev 5421)
+++ 
django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/tests.py
    2007-06-04 16:12:35 UTC (rev 5422)
@@ -9,6 +9,7 @@
 
 
 import unittest, datetime
+from cStringIO import StringIO
 
 from django.utils.functional import curry
 from django.core import serializers
@@ -295,5 +296,41 @@
     for (func, pk, klass, datum) in test_data:
         func[1](self, pk, klass, datum)
 
+def fieldsTest(format, self):
+    # Clear the database first
+    management.flush(verbosity=0, interactive=False)
+
+    obj = ComplexModel(field1='first',field2='second',field3='third')
+    obj.save()
+    
+    # Serialize then deserialize the test database
+    serialized_data = serializers.serialize(format, [obj], indent=2, 
fields=('field1','field3'))
+    result = serializers.deserialize(format, serialized_data).next()
+    
+    # Check that the deserialized object contains data in only the serialized 
fields.
+    self.assertEqual(result.object.field1, 'first')
+    self.assertEqual(result.object.field2, '')
+    self.assertEqual(result.object.field3, 'third')
+
+def streamTest(format, self):
+    # Clear the database first
+    management.flush(verbosity=0, interactive=False)
+
+    obj = ComplexModel(field1='first',field2='second',field3='third')
+    obj.save()
+    
+    # Serialize the test database to a stream
+    stream = StringIO()    
+    serializers.serialize(format, [obj], indent=2, stream=stream)
+    
+    # Serialize normally for a comparison
+    string_data = serializers.serialize(format, [obj], indent=2)
+
+    # Check that the two are the same
+    self.assertEqual(string_data, stream.buffer())
+    stream.close()
+    
 for format in serializers.get_serializer_formats():
     setattr(SerializerTests, 'test_'+format+'_serializer', 
curry(serializerTest, format))
+    setattr(SerializerTests, 'test_'+format+'_serializer_fields', 
curry(fieldsTest, format))
+    setattr(SerializerTests, 'test_'+format+'_serializer_stream', 
curry(fieldsTest, format))


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to