Commits

Martin Skala committed 1528ca2

Code clean up

  • Participants
  • Parent commits 6fe4eaa

Comments (0)

Files changed (18)

File django_roa/__init__.py

         cls.add_to_class('_default_manager', Manager())
 
 signals.class_prepared.connect(ensure_roa_manager)
-

File django_roa/db/exceptions.py

         if ROA_DJANGO_ERRORS and '<body>' in self.msg:
             return self.parse_django_error()
         return self.msg
-    
+
     def parse_django_error(self):
         """Extract the summary part of a Django HTML error."""
         try:

File django_roa/db/managers.py

     """
     use_for_related_fields = True
     is_roa_manager = True # ugly but useful because isinstance is evil
-    
+
     def get_query_set(self):
         """
         Returns a QuerySet which access remote resources.

File django_roa/db/models.py

     Model which access remote resources.
     """
     __metaclass__ = ROAModelBase
-    
+
     @staticmethod
     def get_resource_url_list():
         raise Exception, "Static method get_resource_url_list is not defined."

File django_roa/db/query.py

         self.select_related = False
         self.max_depth = None
         self.extra_select = {}
-    
+
     def can_filter(self):
         return self.filterable
-    
+
     def clone(self):
         return self
-    
+
     def clear_ordering(self):
         self.order_by = []
-    
+
     def filter(self, *args, **kwargs):
         self.filters.update(kwargs)
 
     def exclude(self, *args, **kwargs):
         self.excludes.update(kwargs)
-    
+
     def set_limits(self, start=None, stop=None):
         self.limit_start = start
         self.limit_stop = stop
         self.filterable = False
-    
+
     def add_select_related(self, fields):
         """
         Sets up the select_related data structure so that we only select
         Returns useful parameters as a dictionary.
         """
         parameters = {}
-        
+
         # Filtering
         for k, v in self.filters.iteritems():
             key = '%s%s' % (ROA_ARGS_NAMES_MAPPING.get('FILTER_', 'filter_'), k)
                 parameters[ROA_ARGS_NAMES_MAPPING[key]] = v
             else:
                 parameters[key] = v
-        
+
         # Ordering
         if self.order_by:
             order_by = ','.join(self.order_by)
             parameters[ROA_ARGS_NAMES_MAPPING.get('ORDER_BY', 'order_by')] = order_by
-        
+
         # Slicing
         if self.limit_start:
             parameters[ROA_ARGS_NAMES_MAPPING.get('LIMIT_START', 'limit_start')] = self.limit_start
         if self.limit_stop:
             parameters[ROA_ARGS_NAMES_MAPPING.get('LIMIT_STOP', 'limit_stop')] = self.limit_stop
-        
+
         # Format
         parameters[ROA_ARGS_NAMES_MAPPING.get('FORMAT', 'format')] = ROA_FORMAT
-        
+
         parameters.update(getattr(settings, 'ROA_CUSTOM_ARGS', {}))
         return parameters
-    
+
     ##########################################
     # Fake methods required by admin options #
     ##########################################
-    
+
     def add_fields(self, field_names, allow_m2m=True):
         """ Fake method. """
         pass
-    
+
     def trim_extra_select(self, names):
         """ Fake method. """
         pass
-    
+
     def results_iter(self):
         """ Fake method. """
         return []
         self._iter = None
         self._sticky_filter = False
         self._db = False
-        
+
         self.params = {}
-    
+
     ########################
     # PYTHON MAGIC METHODS #
     ########################
             parameters = self.query.parameters
             logger.debug(u"""Requesting: "%s" through %s
                           with parameters "%s" """ % (
-                          self.model.__name__, 
-                          resource.uri, 
+                          self.model.__name__,
+                          resource.uri,
                           force_unicode(parameters)))
             response = resource.get(**parameters)
         except ResourceNotFound:
 
         for local_name, remote_name in ROA_MODEL_NAME_MAPPING:
             response = response.replace(remote_name, local_name)
-        
+
         for res in serializers.deserialize(ROA_FORMAT, response):
             obj = res.object
             yield obj
-        
+
     def count(self):
         """
         Returns the number of records as an integer.
-        
+
         The result is not cached nor comes from cache, cache must be handled
         by the server.
         """
         clone = self._clone()
-        
+
         # Instantiation of clone.model is necessary because we can't set
         # a staticmethod for get_resource_url_count and avoid to set it
         # for all model without relying on get_resource_url_list
             parameters = clone.query.parameters
             logger.debug(u"""Counting  : "%s" through %s
                           with parameters "%s" """ % (
-                clone.model.__name__, 
-                resource.uri, 
+                clone.model.__name__,
+                resource.uri,
                 force_unicode(parameters)))
             response = resource.get(**parameters)
         except Exception, e:
             parameters = clone.query.parameters
             logger.debug(u"""Retrieving : "%s" through %s
                           with parameters "%s" """ % (
-                clone.model.__name__, 
-                resource.uri, 
+                clone.model.__name__,
+                resource.uri,
                 force_unicode(parameters)))
             response = resource.get(**parameters)
         except Exception, e:
 
         # keep the custom attribute name of model for later use
         custom_pk = self.model._meta.pk.attname
-        # check PK, ID or custom PK attribute name for exact match filters 
+        # check PK, ID or custom PK attribute name for exact match filters
         exact_match = [attr for attr in ['id__exact', 'pk__exact', '%s__exact' % custom_pk] if attr in kwargs.keys()]
         # common way of getting particular object
         if kwargs.keys() == ['id']:
         """
         latest_by = field_name or self.model._meta.get_latest_by
         assert bool(latest_by), "latest() requires either a field_name parameter or 'get_latest_by' in the model"
-        
+
         self.query.order_by.append('-%s' % latest_by)
         return self.iterator().next()
 
         """
         assert self.query.can_filter(), \
                 "Cannot reorder a query once a slice has been taken."
-        
+
         clone = self._clone()
         for field_name in field_names:
             clone.query.order_by.append(field_name)
         """
         Only to handle the case of the "cute trick" used in ModelForms (and
         per extension admin) for unique and date constraints.
-        
+
         Example: ``.extra(select={'a': 1}).values('a').order_by()``.
-        
+
         http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L322
         is an interesting documentation for details.
         """
             class FakeInt(object):
                 def __init__(self, count):
                     self.count = count
-                
+
                 def values(self, *fields):
                     if fields == ('a',): # double check that it's our case
                         return self
-                
+
                 def order_by(self):
                     return self.count
-            
+
             return FakeInt(self.count())
         raise ROANotImplementedYetException, 'extra is not yet fully implemented.'
 
 
     def _as_url(self):
         """
-        Returns the internal query's URL and parameters 
-        
+        Returns the internal query's URL and parameters
+
         as (u'url', {'arg_key': 'arg_value'}).
         """
         return self.model.get_resource_url_list(), self.query.parameters

File django_roa/remoteauth/models.py

     name = models.CharField(_('name'), max_length=80, unique=True)
     permissions = models.ManyToManyField(Permission,
                                          through=GroupPermissionThrough,
-                                         verbose_name=_('permissions'), 
+                                         verbose_name=_('permissions'),
                                          blank=True)
 
     @staticmethod
     first_name = models.CharField(_('first name'), max_length=30, blank=True)
     last_name = models.CharField(_('last name'), max_length=30, blank=True)
     email = models.EmailField(_('e-mail address'), blank=True)
-    password = models.CharField(_('password'), max_length=128, 
+    password = models.CharField(_('password'), max_length=128,
         help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
-    is_staff = models.BooleanField(_('staff status'), default=False, 
+    is_staff = models.BooleanField(_('staff status'), default=False,
         help_text=_("Designates whether the user can log into this admin site."))
-    is_active = models.BooleanField(_('active'), default=True, 
+    is_active = models.BooleanField(_('active'), default=True,
         help_text=_("Designates whether this user should be treated as active."\
                     " Unselect this instead of deleting accounts."))
-    is_superuser = models.BooleanField(_('superuser status'), default=False, 
+    is_superuser = models.BooleanField(_('superuser status'), default=False,
         help_text=_("Designates that this user has all permissions without explicitly assigning them."))
     last_login = models.DateTimeField(_('last login'), default=datetime.datetime.now)
     date_joined = models.DateTimeField(_('date joined'), default=datetime.datetime.now)

File examples/django_roa_client/models.py

 
 class RemotePage(Model):
     title = models.CharField(max_length=50, blank=True, null=True)
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
 
     time_field = models.TimeField(blank=True, null=True)
     url_field = models.URLField(blank=True, null=True)
     xml_field = models.XMLField(blank=True, null=True)
-    
+
     file_field = models.FileField(upload_to="files", blank=True, null=True)
     image_field = models.ImageField(upload_to="images", blank=True, null=True)
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.__class__.__name__, self.pk)
 
 class RemotePageWithCustomSlug(Model):
     title = models.CharField(max_length=50)
     slug = models.SlugField()
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
 
 
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
-    
+
     @staticmethod
     def get_resource_url_list():
         return u'http://127.0.0.1:8081/django_roa_server/remotepagewithrelationsthrough/'
 
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
-    
+
     @staticmethod
     def get_resource_url_list():
         return u'http://127.0.0.1:8081/django_roa_server/remotepagewithrelations/'
 
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
-    
+
     @staticmethod
     def get_resource_url_list():
         return u'http://127.0.0.1:8081/django_roa_server/remotepagewithnamedrelations/'
 
 
 class RemotePageWithProxy(RemotePage):
-    
+
     class Meta:
         proxy = True
-    
+
     @staticmethod
     def get_resource_url_list():
         return u'http://127.0.0.1:8081/django_roa_server/remotepagewithproxy/'

File examples/django_roa_client/serializers.py

     A test serializer which removes ``django-objects`` xml tag from default
     Django's xml serializer, adapt it to your own usage.
     """
-    
+
     def start_serialization(self):
         """
         Start serialization -- open the XML document and the root element.

File examples/django_roa_client/settings.py

 # specify the headers sent to the ws from restkit
 ROA_HEADERS = {
     'Content-Type': 'application/x-www-form-urlencoded',
-} 
+}
 ROA_DJANGO_ERRORS = True # useful to ease debugging if you use test server
 
 ROA_URL_OVERRIDES_LIST = {

File examples/django_roa_client/tests.py

 These tests assume that you've completed all the prerequisites for
 getting django-roa running in the default setup, to wit:
 
-1.  You have created the remote database: go to ``examples/django_roa_server`` 
-    and run ``syncdb`` command with ``--noinput`` option in order to create 
+1.  You have created the remote database: go to ``examples/django_roa_server``
+    and run ``syncdb`` command with ``--noinput`` option in order to create
     a superuser named "roa_user" from fixtures:
 
         $ python manage.py syncdb --noinput
 
-2.  You have launched the project's server on port 8081 in order to test this 
+2.  You have launched the project's server on port 8081 in order to test this
     suite against it with this command:
 
         $ python manage.py runserver 8081
 It should return no error and you will be able to see logs from the test
 server which confirm that it works as expected: remote requests are done.
 
-Note: do not try to launch tests' projects if you put ``django_roa`` 
-application into your own project, otherwise it will fail. Django do not 
+Note: do not try to launch tests' projects if you put ``django_roa``
+application into your own project, otherwise it will fail. Django do not
 handle very well projects inside projects.
 """
 from datetime import time, date, datetime
 ROA_FILTERS = getattr(settings, 'ROA_FILTERS', {})
 
 class ROATestCase(TestCase):
-    
+
     def setUp(self):
         RemotePage.objects.all().delete()
 
         RemotePage.objects.all().delete()
 
 class ROAUserTestCase(ROATestCase):
-    
+
     def setUp(self):
         super(ROAUserTestCase, self).setUp()
         User.objects.all().delete()
         Message.objects.all().delete()
         Group.objects.all().delete()
         Permission.objects.all().delete()
- 
+
 
 class ROAInitializationTests(ROATestCase):
-    
+
     def test_inheritance(self):
         self.assertEqual(str(RemotePage.objects.__class__), "<class 'django_roa.db.managers.ROAManager'>")
         self.assertEqual(str(RemotePage.__class__), "<class 'django_roa.db.models.ROAModelBase'>")
 
 
 class ROABaseTests(ROATestCase):
-    
+
     def test_basic_crud(self):
         page = RemotePage.objects.create(title=u'A first remote page')
         self.assertEqual(repr(page), '<RemotePage: A first remote page (1)>')
         self.assertEqual(repr(RemotePage.objects.all()), '[]')
         # test custom mapping of arguments too
         self.assertEqual(RemotePage.objects.count(), 0)
-        
+
     def test_complex_crud(self):
         page = RemotePage.objects.create(title=u'')
         self.assertEqual(page.title, u'')
 
 
 class ROAUnicodeTests(ROATestCase):
-    
+
     def test_remotepage(self):
         emilie = RemotePage.objects.create(title=u"Émilie")
         self.assertEqual(emilie.title, u'Émilie')
 
 
 class ROAFieldsTests(ROATestCase):
-    
+
     def tearDown(self):
         super(ROAFieldsTests, self).tearDown()
         RemotePageWithManyFields.objects.all().delete()
         self.assertEqual(repr(default_page.file_field), repr(retrieved_default_page.file_field))
         self.assertEqual(repr(default_page.image_field), repr(retrieved_default_page.image_field))
         default_page.delete()
-            
+
     def test_empty_boolean_values(self):
         boolean_page = RemotePageWithBooleanFields.objects.create(boolean_field=True)
         self.assertEqual(boolean_page.id, 1)
 
 
 class ROARelationsTests(ROATestCase):
-    
+
     def tearDown(self):
         super(ROARelationsTests, self).tearDown()
         RemotePageWithManyFields.objects.all().delete()
         self.assertEqual(relations_page.title, retrieved_relations_page.title)
         self.assertEqual(relations_page.remote_page, retrieved_relations_page.remote_page)
         relations_page.delete()
-    
+
     def test_foreignkey_relation(self):
         remote_page = RemotePage.objects.create(title=u'A remote page')
         another_remote_page = RemotePage.objects.create(title=u'Another remote page')
         relations_page.delete()
         another_remote_page.delete()
         remote_page.delete()
-        
+
     def test_manytomany_relation(self):
         remote_page = RemotePageWithManyFields.objects.create(char_field=u'A remote page')
         another_remote_page = RemotePageWithManyFields.objects.create(char_field=u'Another remote page')
         relations_page = RemotePageWithRelations.objects.create(title=u'A remote relation page')
-        relations_page_through = RemotePageWithRelationsThrough.objects.create(title=u'A remote relation page through', 
+        relations_page_through = RemotePageWithRelationsThrough.objects.create(title=u'A remote relation page through',
                                                                                remote_page_with_relations=relations_page,
                                                                                remote_page_with_many_fields=remote_page)
         self.assertEqual(repr(relations_page.remote_page_fields.all()), '[<RemotePageWithManyFields: RemotePageWithManyFields (1)>]')
         relations_page = RemotePageWithRelations.objects.get(id=relations_page.id)
         self.assertEqual(repr(relations_page.remote_page_fields.all()), '[<RemotePageWithManyFields: RemotePageWithManyFields (1)>]')
-        another_relations_page_through = RemotePageWithRelationsThrough.objects.create(title=u'Another remote relation page through', 
+        another_relations_page_through = RemotePageWithRelationsThrough.objects.create(title=u'Another remote relation page through',
                                                                                        remote_page_with_relations=relations_page,
                                                                                        remote_page_with_many_fields=another_remote_page)
         relations_page = RemotePageWithRelations.objects.get(id=relations_page.id)
         relations_page.delete()
         another_remote_page.delete()
         remote_page.delete()
-        
+
     def test_named_relation(self):
         remote_page = RemotePage.objects.create(title=u'A remote page')
         another_remote_page = RemotePage.objects.create(title=u'Another remote page')
-        named_relations_page = RemotePageWithNamedRelations.objects.create(first_page=remote_page, 
+        named_relations_page = RemotePageWithNamedRelations.objects.create(first_page=remote_page,
                                                                            last_page=another_remote_page)
         self.assertEqual(repr(named_relations_page.first_page), '<RemotePage: A remote page (1)>')
         named_relations_page = RemotePageWithNamedRelations.objects.get(id=named_relations_page.id)
 
 
 class ROAQuerysetTests(ROATestCase):
-    
+
     def setUp(self):
         super(ROAQuerysetTests, self).setUp()
         self.remote_page1 = RemotePage.objects.create(title='A remote page')
     def test_ordering(self):
         self.assertEqual(repr(RemotePage.objects.order_by('title')), '[<RemotePage: A remote page (1)>, <RemotePage: Another remote page (2)>, <RemotePage: Still another remote page (4)>, <RemotePage: Yet another remote page (3)>]')
         self.assertEqual(repr(RemotePage.objects.order_by('-title', '-id')), '[<RemotePage: Yet another remote page (3)>, <RemotePage: Still another remote page (4)>, <RemotePage: Another remote page (2)>, <RemotePage: A remote page (1)>]')
-        
+
     def test_slicing(self):
         self.assertEqual(repr(RemotePage.objects.all()[1:3]), '[<RemotePage: Another remote page (2)>, <RemotePage: Yet another remote page (3)>]')
         self.assertEqual(repr(RemotePage.objects.all()[0]), '<RemotePage: A remote page (1)>')
-        
+
     def test_extra(self):
         self.assertEqual(bool(RemotePage.objects.all().extra(select={'a': 1}).values('a').order_by()), True)
         RemotePage.objects.all().delete()
         self.assertEqual(bool(RemotePage.objects.all().extra(select={'a': 1}).values('a').order_by()), False)
-        
+
     def test_combined(self):
         self.assertEqual(repr(RemotePage.objects.exclude(title__contains='yet').order_by('title', '-id')[:2]), '[<RemotePage: A remote page (1)>, <RemotePage: Another remote page (2)>]')
 
-
 class ROAAdminTests(ROAUserTestCase):
 
     def test_admin_views(self):
         response = c.login(username=u'bob', password=u'secret')
         self.assertEqual(response, True)
         response = c.get('/admin/')
-        # ._wrapped necessary because we compare string, comparison should 
+        # ._wrapped necessary because we compare string, comparison should
         # work with User.objects.get(username="bob") but slower...
         self.assertEqual(repr(response.context[-1]["user"]._wrapped), '<User: bob>')
         response = c.get('/admin/django_roa_client/remotepage/')
         self.assertEqual(form.is_valid(), False)
         form = TestForm(data={u'test_field': u'Test data', u'remote_page': remote_page1.id})
         self.assertEqual(form.is_valid(), True)
-        
+
     def test_modelform_validation(self):
         form = RemotePageForm()
         self.assertEqual(form.is_valid(), False)
         self.assertEqual(form.is_valid(), True)
         remote_page = form.save()
         self.assertEqual(repr(remote_page), '<RemotePage: Test data (1)>')
-        
+
     def test_modelform_rendering(self):
         c = Client()
         remote_page1 = RemotePage.objects.create(title='A remote page')
         response = c.get('/')
         self.assertEqual('<select name="remote_page" id="id_remote_page">\n<option value="" selected="selected">---------</option>\n<option value="1">A remote page (1)</option>\n</select>' in response.content, True)
-        
+
 
 class ROARemoteAuthTests(ROAUserTestCase):
 
         message = Message.objects.create(user=alice, message=u'Test message')
         self.assertEqual(repr(Message.objects.all().select_related()), '[<Message: Test message>]')
         self.assertEqual(repr(Message.objects.all().select_related('user')), '[<Message: Test message>]')
-    
+
     def test_groups(self):
         bob = User.objects.create_superuser(username=u'bob', password=u'secret', email=u'bob@example.com')
         self.assertEqual(repr(Group.objects.all()), '[]')
         #self.assertEqual(bob.get_all_permissions(), set([u'remoteauth.custom_group_permission', u'remoteauth.custom_user_permission']))
         self.assertEqual(bob.get_group_permissions(), set([]))
         self.assertEqual(bob.get_all_permissions(), set([]))
-        
+
 
 class ROAExceptionsTests(ROAUserTestCase):
 
     def test_roa_errors(self):
         """
         FIXME: Find a way to do the same test with unittests:
-        
+
         > User.objects.create_user(username="alice", password="secret", email="alice@example.com")
         Traceback (most recent call last):
         ...
         page_custom = RemotePageWithCustomSlug.objects.get(title=u"Test custom page")
         self.assertEqual(repr(page_custom), '<RemotePageWithCustomSlug: Test custom page (1)>')
         page_custom.delete()
-    
+
     def test_roa_url_overrides(self):
         page_overridden = RemotePageWithOverriddenUrls.objects.create(title=u"Test overridden urls")
         self.assertEqual(page_overridden.slug, u'test-overridden-urls')
         page_overridden = RemotePageWithOverriddenUrls.objects.get(title=u"Test overridden urls")
         self.assertEqual(repr(page_overridden), '<RemotePageWithOverriddenUrls: Test overridden urls (1)>')
         self.assertEqual(RemotePageWithOverriddenUrls.objects.all()._as_url(), (u'http://127.0.0.1:8081/django_roa_server/remotepagewithoverriddenurls/', {'format': 'django'}))
-        
+
     def test_custom_serializer(self):
         register_serializer('custom', 'examples.django_roa_client.serializers')
         initial_roa_format_setting = settings.ROA_FORMAT

File examples/django_roa_server/emitters.py

 class ROADjangoEmitter(DjangoEmitter):
     """
     ROA Django XML emitter.
-    
+
     Just log the response with logging module.
     """
     def render(self, request):
         response = super(ROADjangoEmitter, self).render(request, 'xml')
         logger.debug(u"Response:\n%s" % str(response).decode(DEFAULT_CHARSET))
         return response
-    
+
 Emitter.register('django', ROADjangoEmitter, 'application/xml; charset=utf-8')
 
 class CustomDjangoEmitter(DjangoEmitter):
     """
     Custom Django XML emitter.
-    
+
     Use a custom serializer.
     """
     def render(self, request):
         response = super(CustomDjangoEmitter, self).render(request, 'custom')
         logger.debug(u"Response:\n%s" % response.decode(DEFAULT_CHARSET))
         return response
-    
+
 Emitter.register('custom', CustomDjangoEmitter, 'application/xml; charset=utf-8')
-

File examples/django_roa_server/handlers.py

             obj = self._get_object(self.model, *args, **kwargs)
             obj.delete()
             logger.debug(u'Object "%s" deleted, remains %s' % (
-                unicode(obj), 
+                unicode(obj),
                 [unicode(obj) for obj in self.model.objects.all()]))
 
             return rc.DELETED

File examples/django_roa_server/manage.py

 
 try:
     import settings # Assumed to be in the same directory.
-    
 except ImportError:
     import sys
     sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)

File examples/django_roa_server/models.py

     time_field = models.TimeField(blank=True, null=True)
     url_field = models.URLField(blank=True, null=True)
     xml_field = models.XMLField(blank=True, null=True)
-    
+
     file_field = models.FileField(upload_to="files", blank=True, null=True)
     image_field = models.ImageField(upload_to="images", blank=True, null=True)
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.__class__.__name__, self.pk)
 
 class RemotePageWithCustomSlug(models.Model):
     title = models.CharField(max_length=50)
     slug = models.SlugField()
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
 
 class RemotePageWithOverriddenUrls(models.Model):
     title = models.CharField(max_length=50)
     slug = models.SlugField()
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.title, self.pk)
 

File examples/django_roa_server/urls.py

 
 # Enable HTTP authentication through django-piston
 ad = { 'authentication': HttpBasicAuthentication(
-   realm="django-roa-server", 
+   realm="django-roa-server",
    auth_func = lambda username, password: username == 'django-roa' and password == 'roa'
 )}
 # Disable authentication through django-piston
     url(r'^django_roa_server/remotepagewithrelationsthrough/count/$', remote_pages_with_relations_through_count),
     url(r'^django_roa_server/remotepagewithnamedrelations/count/$', remote_pages_with_named_relations_count),
     url(r'^django_roa_server/remotepagewithproxy/count/$', remote_pages_count),
-    
+
     # Remote pages
     url(r'^django_roa_server/remotepage/?(?P<pk>\d+)?/?$', remote_pages),
     url(r'^django_roa_server/remotepagewithmanyfields/?(?P<pk>\d+)?/?$', remote_pages_with_many_fields),
     url(r'^django_roa_server/remotepagewithrelationsthrough/?(?P<pk>\d+)?/?$', remote_pages_with_relations_through),
     url(r'^django_roa_server/remotepagewithnamedrelations/?(?P<pk>\d+)?/?$', remote_pages_with_named_relations),
     url(r'^django_roa_server/remotepagewithproxy/?(?P<pk>\d+)?/?$', remote_pages),
-    
+
     # Auth application
     url(r'^auth/user/?(?P<pk>\d+)?/?$', users),
     url(r'^auth/message/?(?P<pk>\d+)?/?$', messages),

File examples/twitter_roa/models.py

     @staticmethod
     def get_resource_url_list():
         return u'http://api.twitter.com/1/users/lookup.json?screen_name=twitterapi,twitter,twittersearch,twittermedia,twittermobile'
-    
+
     def get_resource_url_count(self):
         return User.get_resource_url_list()
 
     text = models.TextField()
     source = models.CharField(max_length=50)
     user = models.ForeignKey(User)
-    
+
     objects = TweetManager()
-    
+
     def __unicode__(self):
         return u'%s (%s)' % (self.text, self.id)
 

File examples/twitter_roa/serializers.py

             Model = _get_model("twitter_roa.tweet")
         data = {}
         m2m_data = {}
-        
+
         # Handle each field
         for (field_name, field_value) in obj.iteritems():
             if isinstance(field_value, str):
                 field_value = smart_unicode(
-                                field_value, 
+                                field_value,
                                 options.get("encoding", DEFAULT_CHARSET),
                                 strings_only=True)
-        
+
             try:
                 field = Model._meta.get_field(field_name)
             except models.FieldDoesNotExist:
                 continue
-        
+
             # Handle FK fields
             if field.rel and isinstance(field.rel, models.ManyToOneRel):
                 if field_value is not None:
     try:
         import pkg_resources
     except ImportError:
-        return do_download()       
+        return do_download()
     try:
         pkg_resources.require("setuptools>="+version); return
     except pkg_resources.VersionConflict, e: