Matthew Schinckel committed 835a4cc

Remove any \\r characters in the string, as they will be invalid when compiling.

Comments (0)

Files changed (1)


 from django.db import models
 from django import forms
-class PythonCodeWidget(forms.TextArea):
+class PythonCodeWidget(forms.Textarea):
     def render(self, name, value, attrs=None):
         TODO: have a syntax hilight feature, where instead of a TextArea,
             value = json.dumps(value, indent=4)
         return super(PythonCodeWidget, self).render(name, value, attrs=attrs)
-def PythonCodeFormField(forms.CharField):
+class PythonCodeFormField(forms.CharField):
     def __init__(self, *args, **kwargs):
         kwargs['widget'] = PythonCodeWidget
         super(PythonCodeFormField, self).__init__(*args, **kwargs)
         if isinstance(value, basestring):
+                value = value.replace('\r', '')
                 compile(value, "<string>", 'exec')
             except SyntaxError, arg:
                 raise forms.ValidationError(u'Syntax Error: %s' % unicode(arg))
             return value
-def PythonCodeField(models.TextField):
+class PythonCodeField(models.TextField):
     A field that will ensure that data that is entered into it is syntactically
     valid python code.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.