Beispiel #1
0
 def get_serializer(self, name=None, content_type=None):
     if name is None and content_type is None:
         return self.serializers[self.default]
     elif name is not None and content_type is None:
         if not name in self.serializers:
             raise exceptions.SerializerNotAvailable("%s is not an available serializer" % name)
         return self.serializers[name]
     else:
         for x in self.serializers.values():
             for ctype in x.content_types:
                 if content_type == ctype:
                     return x
         raise exceptions.SerializerNotAvailable("%s is not an available serializer" % content_type)
Beispiel #2
0
 def get_serializer(self, name=None):
     if name is None:
         return self.default_format
     else:
         if not name in self.available_serializers:
             raise exceptions.SerializerNotAvailable("%s is not an available serializer" % name)
         return self._serializers[name]