Skip to content

Instantly share code, notes, and snippets.

@shimbaco
Created November 3, 2010 20:59
Show Gist options
  • Save shimbaco/661708 to your computer and use it in GitHub Desktop.
Save shimbaco/661708 to your computer and use it in GitHub Desktop.
# -*- 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