Django

Code

Changeset 8414

Show
Ignore:
Timestamp:
08/16/08 15:40:47 (4 months ago)
Author:
jbronn
Message:

Fixed #6547, added support for GeoRSS feeds in django.contrib.gis.feeds; added the feed_extra_kwargs and item_extra_kwargs to the Feed baseclass so that it's possible for subclasses to add dynamic attributes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/gis/tests/geoapp/tests_mysql.py

    r8219 r8414  
    174174        self.assertRaises(ImproperlyConfigured, Country.objects.all().gml, field_name='mpoly') 
    175175 
     176from test_feeds import GeoFeedTest 
    176177def suite(): 
    177178    s = unittest.TestSuite() 
    178179    s.addTest(unittest.makeSuite(GeoModelTest)) 
     180    s.addTest(unittest.makeSuite(GeoFeedTest)) 
    179181    return s 
  • django/trunk/django/contrib/gis/tests/geoapp/tests.py

    r8219 r8414  
    373373 
    374374    def test14_equals(self): 
    375         if DISABLE: return 
    376375        "Testing the 'same_as' and 'equals' lookup types." 
     376        if DISABLE: return 
    377377        pnt = fromstr('POINT (-95.363151 29.763374)', srid=4326) 
    378378        c1 = City.objects.get(point=pnt) 
     
    559559            self.assertEqual(c.mpoly.union(geom), c.union) 
    560560 
     561from test_feeds import GeoFeedTest 
    561562def suite(): 
    562563    s = unittest.TestSuite() 
    563564    s.addTest(unittest.makeSuite(GeoModelTest)) 
     565    s.addTest(unittest.makeSuite(GeoFeedTest)) 
    564566    return s 
  • django/trunk/django/contrib/gis/tests/__init__.py

    r8308 r8414  
    11import sys 
    2 from copy import copy 
    32from unittest import TestSuite, TextTestRunner 
    43 
     
    9594    from django.contrib.gis.tests.utils import mysql 
    9695    from django.db import connection 
     96    from django.db.models import loading 
    9797 
    9898    # Getting initial values. 
    9999    old_debug = settings.DEBUG 
    100     old_name = copy(settings.DATABASE_NAME) 
    101     old_installed = copy(settings.INSTALLED_APPS) 
    102     new_installed = copy(settings.INSTALLED_APPS) 
     100    old_name = settings.DATABASE_NAME 
     101    old_installed = settings.INSTALLED_APPS 
     102    old_root_urlconf = settings.ROOT_URLCONF 
     103 
     104    # Based on ALWAYS_INSTALLED_APPS from django test suite -- 
     105    # this prevents us from creating tables in our test database 
     106    # from locally installed apps. 
     107    new_installed =  ['django.contrib.contenttypes', 
     108                      'django.contrib.auth', 
     109                      'django.contrib.sites', 
     110                      'django.contrib.flatpages', 
     111                      'django.contrib.gis', 
     112                      'django.contrib.redirects', 
     113                      'django.contrib.sessions', 
     114                      'django.contrib.comments', 
     115                      'django.contrib.admin', 
     116                      ] 
     117 
     118    # Setting the URLs. 
     119    settings.ROOT_URLCONF = 'django.contrib.gis.tests.urls' 
    103120 
    104121    # Want DEBUG to be set to False. 
    105122    settings.DEBUG = False 
    106123 
    107     from django.db.models import loading 
    108  
    109124    # Creating the test suite, adding the test models to INSTALLED_APPS, and 
    110     # adding the model test suites to our suite package. 
     125    # adding the model test suites to our suite package. 
    111126    test_suite, test_models = geo_suite() 
    112127    for test_model in test_models: 
     
    118133        new_installed.append(module_name) 
    119134 
    120         # Getting the test suite 
    121         tsuite = getattr(__import__('django.contrib.gis.tests.%s' % test_model, globals(), locals(), [test_module_name]), test_module_name) 
     135        # Getting the model test suite 
     136        tsuite = getattr(__import__('django.contrib.gis.tests.%s' % test_model, globals(), locals(), [test_module_name]),  
     137                         test_module_name) 
    122138        test_suite.addTest(tsuite.suite()) 
    123139     
     
    139155    settings.DEBUG = old_debug 
    140156    settings.INSTALLED_APPS = old_installed 
    141      
     157    settings.ROOT_URLCONF = old_root_urlconf 
     158 
    142159    # Returning the total failures and errors 
    143160    return len(result.failures) + len(result.errors) 
  • django/trunk/django/contrib/syndication/feeds.py

    r8310 r8414  
    6060        return attr 
    6161 
     62    def feed_extra_kwargs(self, obj): 
     63        """ 
     64        Returns an extra keyword arguments dictionary that is used when 
     65        initializing the feed generator. 
     66        """ 
     67        return {} 
     68 
     69    def item_extra_kwargs(self, item): 
     70        """ 
     71        Returns an extra keyword arguments dictionary that is used with 
     72        the `add_item` call of the feed generator. 
     73        """ 
     74        return {} 
     75 
    6276    def get_object(self, bits): 
    6377        return None 
     
    101115            feed_guid = self.__get_dynamic_attr('feed_guid', obj), 
    102116            ttl = self.__get_dynamic_attr('ttl', obj), 
     117            **self.feed_extra_kwargs(obj) 
    103118        ) 
    104119 
     
    159174                categories = self.__get_dynamic_attr('item_categories', item), 
    160175                item_copyright = self.__get_dynamic_attr('item_copyright', item), 
     176                **self.item_extra_kwargs(item) 
    161177            ) 
    162178        return feed