  from django.template import RequestContext, loader
  from django import forms
  
  from djangorestframework.response import NoContent
  from djangorestframework.utils import dict2xml, url_resolves
  
  from urllib import quote_plus
  import string
  try:
      import json
 
</s> remove # TODO: Make all parsers only list a single media_type, rather than a list
 </s> add class ParserMixin(object):
    parsers = ()

    def parse(self, content_type, content):
        # See RFC 2616 sec 3 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
        split = content_type.split(';', 1)
        if len(split) > 1:
            content_type = split[0]
        content_type = content_type.strip()

        media_type_to_parser = dict([(parser.media_type, parser) for parser in self.parsers])

        try:
            parser = media_type_to_parser[content_type]
        except KeyError:
            raise ResponseException(status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
                                    {'error': 'Unsupported media type in request \'%s\'.' % content_type})
        
        return parser(self).parse(content)

    @property
    def parsed_media_types(self):
        """Return an list of all the media types that this ParserMixin can parse."""
        return [parser.media_type for parser in self.parsers]
    
    @property
    def default_parser(self):
        """Return the ParerMixin's most prefered emitter.
        (This has no behavioural effect, but is may be used by documenting emitters)"""        
        return self.parsers[0]
 </s> remove         form_instance = resource.form_instance

        # Otherwise if this isn't an error response
        # then attempt to get a form bound to the response object
        if not form_instance and resource.response.has_content_body:
            try:
                form_instance = resource.get_form(resource.response.raw_content)
                if form_instance:
                    form_instance.is_valid()
            except:
                form_instance = None
        
        # If we still don't have a form instance then try to get an unbound form
        if not form_instance:
            try:
                form_instance = self.resource.get_form()
            except:
                pass
 </s> add         #form_instance = resource.form_instance
        # TODO! Reinstate this

        form_instance = None

        if isinstance(self, FormValidatorMixin):
            # Otherwise if this isn't an error response
            # then attempt to get a form bound to the response object
            if not form_instance and resource.response.has_content_body:
                try:
                    form_instance = resource.get_bound_form(resource.response.raw_content)
                    if form_instance:
                        form_instance.is_valid()
                except:
                    form_instance = None
            
            # If we still don't have a form instance then try to get an unbound form
            if not form_instance:
                try:
                    form_instance = self.resource.get_bound_form()
                except:
                    pass </s> remove     ACCEPT_QUERY_PARAM = '_accept'        # Allow override of Accept header in URL query params
    METHOD_PARAM = '_method'              # Allow POST overloading in form params
    CONTENTTYPE_PARAM = '_contenttype'    # Allow override of Content-Type header in form params (allows sending arbitrary content with standard forms)
    CONTENT_PARAM = '_content'            # Allow override of body content in form params (allows sending arbitrary content with standard forms) 
 </s> add     ACCEPT_QUERY_PARAM = '_accept'        # Allow override of Accept header in URL query params    CONTENTTYPE_PARAM = '_contenttype'    # Allow override of Content-Type header in form params (allows sending arbitrary content with standard forms) </s> remove     def determine_parser(self, request):
        """Return the appropriate parser for the input, given the client's 'Content-Type' header,
        and the content types that this Resource knows how to parse."""
        content_type = request.META.get('CONTENT_TYPE', 'application/x-www-form-urlencoded')
        raw_content = request.raw_post_data
    
        split = content_type.split(';', 1)
        if len(split) > 1:
            content_type = split[0]
        content_type = content_type.strip()
        
        # If CONTENTTYPE_PARAM is turned on, and this is a standard POST form then allow the content type to be overridden
        if (content_type == 'application/x-www-form-urlencoded' and
            request.method == 'POST' and
            self.CONTENTTYPE_PARAM and
            self.CONTENT_PARAM and
            request.POST.get(self.CONTENTTYPE_PARAM, None) and
            request.POST.get(self.CONTENT_PARAM, None)):
            raw_content = request.POST[self.CONTENT_PARAM]
            content_type = request.POST[self.CONTENTTYPE_PARAM]

        # Create a list of list of (media_type, Parser) tuples
        media_type_to_parser = dict([(parser.media_type, parser) for parser in self.parsers])

        try:
            return (media_type_to_parser[content_type], raw_content)
        except KeyError:
            raise ResponseException(status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
                                    {'detail': 'Unsupported media type \'%s\'' % content_type})


 </s> add 
from djangorestframework.validators import FormValidatorMixin
  from django.template import RequestContext, loader
  from django import forms
  
  from djangorestframework.response import NoContent
from djangorestframework.validators import FormValidatorMixin
  from djangorestframework.utils import dict2xml, url_resolves
  
  from urllib import quote_plus
  import string
  try:
      import json
keep keep keep add keep keep keep keep keep keep
 Refactor a bunch of stuff into mixins, more tests 
djangorestframework/emitters.py