コード例 #1
0
ファイル: __init__.py プロジェクト: pombreda/dist-packages
 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)
コード例 #2
0
ファイル: __init__.py プロジェクト: thnguyn2/ECE_527_MP
 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)
コード例 #3
0
 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)