Exemple #1
0
 def _get_serializer(self, content_type=None):
     # Import here to avoid a circular import
     from piston_mini_client.serializers import get_serializer
     if content_type is None:
         content_type = self._default_content_type
     default_serializer = get_serializer(content_type)
     return self._serializers.get(content_type, default_serializer)
Exemple #2
0
 def _get_serializer(self, content_type=None):
     # Import here to avoid a circular import
     from piston_mini_client.serializers import get_serializer
     if content_type is None:
         content_type = self.default_content_type
     default_serializer = get_serializer(content_type)
     return self.serializers.get(content_type, default_serializer)
 def _prepare_request(self, path, data=None, content_type=None):
     """Parse data and return request body and headers."""
     body = data
     if content_type is None:
         content_type = self.default_content_type
     if not isinstance(data, basestring):
         # Import here to avoid a circular import
         from piston_mini_client.serializers import get_serializer
         serializer = get_serializer(content_type)
         body = serializer.serialize(data)
     headers = {
         'Content-type': content_type,
     }
     return (body, headers)