  
  
  class PygmentsRoot(Resource):
      """This example demonstrates a simple RESTful Web API aound the awesome pygments library.
      This top level resource is used to create  """
      form = PygmentsForm
      allowed_methods = anon_allowed_methods = ('POST',)
  
      def post(self, request, auth, content):
          # Generate a unique id by hashing the input
 
</s> remove     code_url = forms.URLField(required=False, label='Code URL',
                              help_text='eg. https://bitbucket.org/tomchristie/flywheel/raw/cc266285d879/flywheel/resource.py')
    code_text = forms.CharField(widget=forms.Textarea, required=False, label='Code Text',
                                help_text='Either supply a URL for the code to be highlighted or copy and paste the code text here.')
    title = forms.CharField(required=False, help_text='(Optional)')
 </s> add     code = forms.CharField(widget=forms.Textarea, label='Code Text', max_length=1000000, 
                           help_text='(Copy and paste the code text here.)')
    title = forms.CharField(required=False, help_text='(Optional)', max_length=100) </s> remove         self.__init__(request)
        return self._handle_request(request, *args, **kwargs)
 </s> add         if args:
            request = args[0]
            self.__init__(request)
            return self._handle_request(request, *args[1:], **kwargs)
        else:
            self.__init__()
            return self </s> remove         
 </s> add         print form_instance
 </s> remove     def __new__(cls, request, *args, **kwargs):
 </s> add     def __new__(cls, *args, **kwargs): </s> remove     
    def clean_code_url(self):
        """Custom field validation.
        Ensure that code URLs really are valid, and return the content they point to in the cleaned_data,
        rather than returning the URL itself."""
        cleaned_data = self.cleaned_data
        url = cleaned_data.get('code_url')
        if not url:
            return ''

        try:
            http = httplib.Http('.cache')
            resp, content = http.request(url)
        except:
            raise forms.ValidationError('The URL supplied cannot be reached')

        if int(resp.status/100) != 2:
            raise forms.ValidationError('The URL supplied does not return successfully')
        if not content:
            raise forms.ValidationError('The URL supplied returns no content')
        
        return content
        

    def clean(self):
        """Custom form validation.
        Ensure that only one of code_url and code_text is set, and return the content of whichever is set in 'code'."""
        cleaned_data = self.cleaned_data
        code_url = cleaned_data.get('code_url')
        code_text = cleaned_data.get('code_text')

        if not code_url and not code_text:
            raise forms.ValidationError('Either the URL or the code text must be supplied')
        if code_url and code_text:
            raise forms.ValidationError('You may not specify both the URL and the code text')

        if code_url:
            cleaned_data['code'] = code_url
            del cleaned_data['code_url']
        else:
            cleaned_data['code'] = code_text
            del cleaned_data['code_text']

        return cleaned_data
 </s> add 
    This top level resource is used to create highlighted code snippets."""
  
  
  class PygmentsRoot(Resource):
      """This example demonstrates a simple RESTful Web API aound the awesome pygments library.
    This top level resource is used to create highlighted code snippets."""
      form = PygmentsForm
      allowed_methods = anon_allowed_methods = ('POST',)
  
      def post(self, request, auth, content):
          # Generate a unique id by hashing the input
keep keep keep keep replace keep keep keep keep keep
 Minor bit of tidy up (all the stuff I noticed when demoing to francis) 
examples/pygments_api/views.py