Django

Code

Changeset 5422

Show
Ignore:
Timestamp:
06/04/07 11:12:35 (1 year ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Merged to [5421]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/AUTHORS

    r5384 r5422  
    143143    konrad@gwu.edu 
    144144    lakin.wecker@gmail.com 
     145    Nick Lane <nick.lane.au@gmail.com> 
    145146    Stuart Langridge <http://www.kryogenix.org/> 
    146147    Nicola Larosa <nico@teknico.net> 
  • django/branches/boulder-oracle-sprint/django/bin/daily_cleanup.py

    r4279 r5422  
    88""" 
    99 
    10 from django.db import backend, connection, transaction 
     10import datetime 
     11from django.db import transaction 
     12from django.contrib.sessions.models import Session 
    1113 
    1214def clean_up(): 
    13     # Clean up old database records 
    14     cursor = connection.cursor() 
    15     cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \ 
    16         (backend.quote_name('django_session'), backend.quote_name('expire_date'))) 
     15    """Clean up expired sessions.""" 
     16    Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() 
    1717    transaction.commit_unless_managed() 
    1818 
  • django/branches/boulder-oracle-sprint/django/conf/project_template/settings.py

    r4695 r5422  
    3939MEDIA_ROOT = '' 
    4040 
    41 # URL that handles the media served from MEDIA_ROOT. 
    42 # Example: "http://media.lawrence.com" 
     41# URL that handles the media served from MEDIA_ROOT. Make sure to use a 
     42# trailing slash if there is a path component (optional in other cases). 
     43# Examples: "http://media.lawrence.com", "http://example.com/media/" 
    4344MEDIA_URL = '' 
    4445 
  • django/branches/boulder-oracle-sprint/django/contrib/comments/feeds.py

    r4279 r5422  
    2424        return "Latest comments on %s" % self._site.name 
    2525 
     26    def get_query_set(self): 
     27        return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True) 
     28 
    2629    def items(self): 
    27         return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)[:40] 
     30        return self.get_query_set()[:40] 
    2831 
    2932class LatestCommentsFeed(LatestFreeCommentsFeed): 
     
    3235    comments_class = Comment 
    3336 
    34     def items(self): 
    35         qs = LatestFreeCommentsFeed.items(self
     37    def get_query_set(self): 
     38        qs = super(LatestCommentsFeed, self).get_query_set(
    3639        qs = qs.filter(is_removed=False) 
    3740        if settings.COMMENTS_BANNED_USERS_GROUP: 
  • django/branches/boulder-oracle-sprint/django/core/serializers/json.py

    r5319 r5422  
    2222    """ 
    2323    def end_serialization(self): 
     24        self.options.pop('stream', None) 
     25        self.options.pop('fields', None) 
    2426        simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) 
    2527 
  • django/branches/boulder-oracle-sprint/django/core/serializers/pyyaml.py

    r4755 r5422  
    1919    """ 
    2020    def end_serialization(self): 
     21        self.options.pop('stream', None) 
     22        self.options.pop('fields', None) 
    2123        yaml.dump(self.objects, self.stream, **self.options) 
    2224         
  • django/branches/boulder-oracle-sprint/django/db/backends/dummy/base.py

    r5079 r5422  
    1313    raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet." 
    1414 
     15def ignore(*args, **kwargs): 
     16    pass 
     17 
    1518class DatabaseError(Exception): 
    1619    pass 
     
    2225    cursor = complain 
    2326    _commit = complain 
    24     _rollback = complain 
     27    _rollback = ignore 
    2528 
    2629    def __init__(self, **kwargs): 
  • django/branches/boulder-oracle-sprint/django/middleware/common.py

    r5100 r5422  
    7676        if settings.USE_ETAGS: 
    7777            etag = md5.new(response.content).hexdigest() 
    78             if request.META.get('HTTP_IF_NONE_MATCH') == etag: 
     78            if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag: 
    7979                response = http.HttpResponseNotModified() 
    8080            else: 
  • django/branches/boulder-oracle-sprint/django/oldforms/__init__.py

    r5307 r5422  
    783783            import decimal  
    784784        except ImportError: 
    785             from django.utils import decimal 
     785            from django.utils import _decimal as decimal 
    786786        try:  
    787787            return decimal.Decimal(data)  
  • django/branches/boulder-oracle-sprint/docs/django-admin.txt

    r5047 r5422  
    296296 
    297297By default, the development server doesn't serve any static files for your site 
    298 (such as CSS files, images, things under ``MEDIA_ROOT_URL`` and so forth). If 
     298(such as CSS files, images, things under ``MEDIA_URL`` and so forth). If 
    299299you want to configure Django to serve static media, read the `serving static files`_ 
    300300documentation. 
     
    404404give you the option of creating a superuser immediately. 
    405405 
    406 ``syncdb`` will also search for and install any fixture named ``initial_data``. 
    407 See the documentation for ``loaddata`` for details on the specification of 
    408 fixture data files. 
     406``syncdb`` will also search for and install any fixture named ``initial_data`` 
     407with an appropriate extension (e.g. ``json`` or ``xml``). See the 
     408documentation for ``loaddata`` for details on the specification of fixture 
     409data files. 
    409410 
    410411test 
  • django/branches/boulder-oracle-sprint/docs/generic_views.txt

    r5079 r5422  
    100100      just before rendering the template. 
    101101 
     102    * ``mimetype``: The MIME type to use for the resulting document. Defaults 
     103      to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
     104 
    102105**Example:** 
    103106 
  • django/branches/boulder-oracle-sprint/docs/serialization.txt

    r5174 r5422  
    4444 
    4545.. _HTTPResponse: ../request_response/#httpresponse-objects 
     46 
     47Subset of fields 
     48~~~~~~~~~~~~~~~~ 
     49 
     50If you only want a subset of fields to be serialized, you can  
     51specify a `fields` argument to the serializer:: 
     52 
     53    from django.core import serializers 
     54    data = serializers.serialize('xml', SomeModel.objects.all(), fields=('name','size')) 
     55 
     56In this example, only the `name` and `size` attributes of each model will 
     57be serialized.  
     58 
     59.. note:: 
     60 
     61    Depending on your model, you may find that it is not possible to deserialize 
     62    a model that only serializes a subset of its fields. If a serialized object 
     63    doesn't specify all the fields that are required by a model, the deserializer 
     64    will not be able to save deserialized instances. 
    4665 
    4766Deserializing data 
     
    93112                strings, etc.).  Not really all that useful on its own, but 
    94113                used as a base for other serializers. 
     114     
     115    ``yaml``    Serializes to YAML (Yet Another Markup Lanuage). This  
     116                serializer is only available if PyYAML_ is installed.  
    95117    ==========  ============================================================== 
    96118 
    97119.. _json: http://json.org/ 
    98120.. _simplejson: http://undefined.org/python/#simplejson 
     121.. _PyYAML: http://www.pyyaml.org/ 
    99122 
    100123Notes for specific serialization formats 
  • django/branches/boulder-oracle-sprint/docs/settings.txt

    r5384 r5422  
    851851 
    852852The collation order to use when creating the test database. This value is 
    853 passed directly to the backend, so it's format is backend-specific. 
     853passed directly to the backend, so its format is backend-specific. 
    854854 
    855855Only supported for ``mysql`` and ``mysql_old`` backends (see `section 10.3.2`_ 
  • django/branches/boulder-oracle-sprint/docs/templates_python.txt

    r5384 r5422  
    395395~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    396396 
    397 If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processors, every 
    398 ``RequestContext`` will contain ``MEDIA_URL``,  providing the  
     397If ``TEMPLATE_CONTEXT_PROCESSORS`` contains this processor, every 
     398``RequestContext`` will contain a variable ``MEDIA_URL``, providing the 
    399399value of the `MEDIA_URL setting`_. 
    400400 
  • django/branches/boulder-oracle-sprint/docs/testing.txt

    r5393 r5422  
    572572you can use the ``TEST_DATABASE_NAME`` setting to provide a name. 
    573573 
    574  
    575 **New in Django development version:** If you wish to have fine-grained 
    576 control over the character set encoding used in your database, you can control 
    577 this with the ``TEST_DATABASE_CHARSET`` setting. For MySQL users, you can also 
    578 control the particular collation used by the test database with the 
    579 ``TEST_DATABASE_COLLATION`` setting. Refer to the settings_ documentation for 
    580 details of these advanced settings. 
     574**New in Django development version:** For fine-grained control over the 
     575character encoding of your database, use the ``TEST_DATABASE_CHARSET`` setting. 
     576If you're using MySQL, you can also use the ``TEST_DATABASE_COLLATION`` setting 
     577to control the particular collation used by the test database. See the 
     578settings_ documentation for details of these advanced settings. 
    581579 
    582580.. _settings: ../settings/ 
  • django/branches/boulder-oracle-sprint/docs/tutorial04.txt

    r5384 r5422  
    6868            # with POST data. This prevents data from being posted twice if a 
    6969            # user hits the Back button. 
    70             return HttpResponseRedirect(reverse('results', args=(p.id,))) 
     70            return HttpResponseRedirect(reverse('mysite.polls.views.results', args=(p.id,))) 
    7171 
    7272This code includes a few things we haven't covered yet in this tutorial: 
     
    105105 
    106106      ... where the ``3`` is the value of ``p.id``. This redirected URL will 
    107       then call the ``'results'`` view to display the final page. 
     107      then call the ``'results'`` view to display the final page. Note that 
     108      you need to use the full name of the view here (including the prefix). 
    108109 
    109110      For more information about ``reverse()``, see the `URL dispatcher`_ 
  • django/branches/boulder-oracle-sprint/docs/url_dispatch.txt

    r5384 r5422  
    565565    reverse(viewname, urlconf=None, args=None, kwargs=None) 
    566566 
    567 The view name is either the function name or the `URL pattern name`_. 
    568 Normally you will not need to worry about the ``urlconf`` parameter and will 
    569 only pass in the positional and keyword arguments to use in the url matching. 
    570 For example:: 
     567``viewname`` is either the function name (either a function reference, or the 
     568string version of the name, if you used that form in ``urlpatterns``) or the 
     569`URL pattern name`_.  Normally, you won't need to worry about the 
     570``urlconf`` parameter and will only pass in the positional and keyword 
     571arguments to use in the URL matching. For example:: 
    571572 
    572573    from django.core.urlresolvers import reverse 
  • django/branches/boulder-oracle-sprint/tests/modeltests/serializers/models.py

    r4841 r5422  
    160160<Author: Agnes> 
    161161 
     162# Serializer output can be restricted to a subset of fields 
     163>>> print serializers.serialize("json", Article.objects.all(), fields=('headline','pub_date')) 
     164[{"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"}}] 
     165 
    162166"""} 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/models.py

    r5384 r5422  
    206206#     data = models.XMLField(primary_key=True) 
    207207 
     208class ComplexModel(models.Model): 
     209    field1 = models.CharField(maxlength=10) 
     210    field2 = models.CharField(maxlength=10) 
     211    field3 = models.CharField(maxlength=10) 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/serializers_regress/tests.py

    r5384 r5422  
    1010 
    1111import unittest, datetime 
     12from cStringIO import StringIO 
    1213 
    1314from django.utils.functional import curry 
     
    296297        func[1](self, pk, klass, datum) 
    297298 
     299def fieldsTest(format, self): 
     300    # Clear the database first 
     301    management.flush(verbosity=0, interactive=False) 
     302 
     303    obj = ComplexModel(field1='first',field2='second',field3='third') 
     304    obj.save() 
     305     
     306    # Serialize then deserialize the test database 
     307    serialized_data = serializers.serialize(format, [obj], indent=2, fields=('field1','field3')) 
     308    result = serializers.deserialize(format, serialized_data).next() 
     309     
     310    # Check that the deserialized object contains data in only the serialized fields. 
     311    self.assertEqual(result.object.field1, 'first') 
     312    self.assertEqual(result.object.field2, '') 
     313    self.assertEqual(result.object.field3, 'third') 
     314 
     315def streamTest(format, self): 
     316    # Clear the database first 
     317    management.flush(verbosity=0, interactive=False) 
     318 
     319    obj = ComplexModel(field1='first',field2='second',field3='third') 
     320    obj.save() 
     321     
     322    # Serialize the test database to a stream 
     323    stream = StringIO()     
     324    serializers.serialize(format, [obj], indent=2, stream=stream) 
     325     
     326    # Serialize normally for a comparison 
     327    string_data = serializers.serialize(format, [obj], indent=2) 
     328 
     329    # Check that the two are the same 
     330    self.assertEqual(string_data, stream.buffer()) 
     331    stream.close() 
     332     
    298333for format in serializers.get_serializer_formats(): 
    299334    setattr(SerializerTests, 'test_'+format+'_serializer', curry(serializerTest, format)) 
     335    setattr(SerializerTests, 'test_'+format+'_serializer_fields', curry(fieldsTest, format)) 
     336    setattr(SerializerTests, 'test_'+format+'_serializer_stream', curry(fieldsTest, format))