The URL class is accessible via the formencode.validators module.
If add_http is true, then if no scheme is present we'll add http://
>>> u = URL(add_http=True)
>>> u.to_python('foo.com')
'http://foo.com'
>>> u.to_python('http://hahaha/bar.html')
'http://hahaha/bar.html'
>>> u.to_python('https://test.com')
'https://test.com'
>>> u = URL(add_http=False, check_exists=True)
>>> u.to_python('http://google.com')
'http://google.com'
>>> u.to_python('http://colorstudy.com/doesnotexist.html')
Traceback (most recent call last):
...
Invalid: The server responded that the page could not be found
>>> u.to_python('http://this.domain.does.not.exists.formencode.org/test.html')
Traceback (most recent call last):
...
Invalid: An error occured when trying to connect to the server: ...
Messages
See the source for more information.