~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/base/forms.py

  • Committer: William Grant
  • Date: 2010-02-18 06:43:57 UTC
  • Revision ID: grantw@unimelb.edu.au-20100218064357-a43eajvau1gpzw29
Add ivle.tests, move ivle.test_chat into there, and be slightly more idiomatic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 
18
 
import re
19
 
 
20
18
import formencode
21
 
import formencode.validators
22
19
from genshi.filters import HTMLFormFiller
23
20
 
24
21
from ivle.webapp.base.xhtml import XHTMLView
25
22
 
26
 
 
27
23
class BaseFormView(XHTMLView):
28
24
    """A base form view."""
29
25
 
106
102
            ctx['error_value'] = errors
107
103
 
108
104
 
109
 
VALID_URL_NAME = re.compile(r'^[a-z0-9][a-z0-9_\+\.\-]*$')
110
 
 
111
 
 
112
 
class URLNameValidator(formencode.validators.UnicodeString):
113
 
    def validate_python(self, value, state):
114
 
        super(URLNameValidator, self).validate_python(value, state)
115
 
        if not VALID_URL_NAME.match(value):
116
 
            raise formencode.Invalid(
117
 
                'Must consist of a lowercase alphanumeric character followed '
118
 
                'by any number of lowercase alphanumerics, ., +, - or _.',
119
 
                value, state)