code: def serializer(self, req):
          
  
          # Select the best match serializer
          content_types = self.method.serializers.get_types()
          content_type = req.accept.best_match(content_types)
          if content_type is None:
              raise webob.exc.HTTPNotAcceptable()
  
          # Select the serializer to use
          try:
              serializer = self.method.serializers(content_type)
          except KeyError:
              raise webob.exc.HTTPNotAcceptable()
  
          # If it has an attacher, attach all the serializers for the
          # extensions
          if hasattr(serializer, 'attach'):
              for ext in reversed(self.extensions):
                  try:
                      serializer.attach(ext.serializers(content_type))
                  except KeyError:
                      pass
  
          # Return content type and serializer
          return content_type, serializer
docs: Selects and returns the serializer to use, based on the
          serializers declared on the action method and its extensions.
          The returned content type is selected based on the types
          available and the best match generated from the HTTP `Accept`
          header.  Raises `HTTPNotAcceptable` if the request cannot be
          serialized to an acceptable media type.  Returns a tuple of
          the content type and the serializer.