~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-23 06:19:51 UTC
  • Revision ID: grantw@unimelb.edu.au-20100223061951-rab91fqhc5o3pbin
Make the console example a bit more plausible (ie. use a real session transcript).

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 an alphanumeric character followed by any '
118
 
                'number of alphanumerics, ., + or -.',
119
 
                value, state)