Created
November 3, 2010 20:59
-
-
Save shimbaco/661708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import re | |
from kay.i18n import lazy_gettext | |
from kay.utils.forms import RegexField | |
link_re = re.compile( | |
'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+') | |
class LinkField(RegexField): | |
messages = { | |
'invalid': lazy_gettext(u'Enter a valid URL.'), | |
} | |
def __init__(self, *args, **kwargs): | |
RegexField.__init__(self, link_re, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment