Commits

Martin Skala committed ab5e7d7 Merge

Merge and organize imports

Comments (0)

Files changed (2)

django_roa/db/models.py

 
 from django.conf import settings
 from django.core import serializers
-from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError
+from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned,\
+    FieldError
 from django.db import models
 from django.db.models import signals
 from django.db.models.options import Options
 from django.db.models.loading import register_models, get_model
-from django.db.models.base import ModelBase, subclass_exception, get_absolute_url
+from django.db.models.base import ModelBase, subclass_exception, \
+    get_absolute_url, method_get_order, method_set_order
 from django.db.models.fields.related import OneToOneField
 from django.utils.functional import curry, update_wrapper
 from django.utils.encoding import force_unicode, smart_unicode
 
 ROA_MODEL_NAME_MAPPING = getattr(settings, 'ROA_MODEL_NAME_MAPPING', [])
 ROA_HEADERS = getattr(settings, 'ROA_HEADERS', {})
+
 DEFAULT_CHARSET = getattr(settings, 'DEFAULT_CHARSET', 'utf-8')
 
 class ROAModelBase(ModelBase):
                             field_ids = getattr(self, '%s_updated_ids' % field.attname)
                         else:
                             field_ids = [obj.id for obj in field.value_from_object(self)]
-                        payload[field.attname] = ','.join(smart_unicode(id) for id in field_ids)
+                        payload[field.attname] = ','.join(smart_unicode(pk) for pk in field_ids)
             
             if force_update or pk_set and not self.id is None:
                 record_exists = True

django_roa/db/query.py

 ROA_MODEL_NAME_MAPPING = getattr(settings, 'ROA_MODEL_NAME_MAPPING', [])
 ROA_ARGS_NAMES_MAPPING = getattr(settings, 'ROA_ARGS_NAMES_MAPPING', {})
 ROA_HEADERS = getattr(settings, 'ROA_HEADERS', {})
+
 DEFAULT_CHARSET = getattr(settings, 'DEFAULT_CHARSET', 'utf-8')
 
 class Query(object):
             raise ROAException(e)
 
         response = force_unicode(response.body).encode(DEFAULT_CHARSET)
+
         for local_name, remote_name in ROA_MODEL_NAME_MAPPING:
             response = response.replace(remote_name, local_name)
         
         except Exception, e:
             raise ROAException(e)
         
-        return int(response.body)
+        return int(response.body_string())
 
     def _get_from_id_or_pk(self, id=None, pk=None):
         """
         except Exception, e:
             raise ROAException(e)
         
+
         response = force_unicode(response.body).encode(DEFAULT_CHARSET)
+
         for local_name, remote_name in ROA_MODEL_NAME_MAPPING:
             response = response.replace(remote_name, local_name)