def url_validator(key, data, errors, context):
 import urlparse
 import string
 model = context['model']
 session = context['session']
 url = data.get(key, None)
 if (not url):
  return
 pieces = urlparse.urlparse(url)
 if (all([pieces.scheme, pieces.netloc]) and (set(pieces.netloc) <= set(((string.letters + string.digits) + '-.'))) and (pieces.scheme in ['http', 'https'])):
  return
 errors[key].append(_('Please provide a valid URL'))

def url_validator ( key , data , errors , context ) : import urlparse import string model = context [ 'model' ] session = context [ 'session' ] url = data . get ( key , None ) if ( not url ) : return pieces = urlparse . urlparse ( url ) if ( all ( [ pieces . scheme , pieces . netloc ] ) and ( set ( pieces . netloc ) <= set ( ( ( string . letters + string . digits ) + '-.' ) ) ) and ( pieces . scheme in [ 'http' , 'https' ] ) ) : return errors [ key ] . append ( _ ( 'Please provide a valid URL' ) )
checks that the provided value is a valid url .