def verify_exists_urls(existing_urls=()):
 def decorator(func):
  @wraps(func)
  def wrapper(*args, **kwargs):
   from django.core import validators
   original_open = validators.urllib2.OpenerDirector.open
   def custom_open(self, req, data=None, timeout=None):
    if (req.get_full_url() in existing_urls):
     return True
    raise Exception()
   try:
    urllib2.OpenerDirector.open = custom_open
    func(*args, **kwargs)
   finally:
    validators.urllib2.OpenerDirector.open = original_open
  return wrapper
 return decorator

def verify_exists_urls ( existing_urls = ( ) ) : def decorator ( func ) : @ wraps ( func ) def wrapper ( * args , ** kwargs ) : from django . core import validators original_open = validators . urllib2 . OpenerDirector . open def custom_open ( self , req , data = None , timeout = None ) : if ( req . get_full_url ( ) in existing_urls ) : return True raise Exception ( ) try : urllib2 . OpenerDirector . open = custom_open func ( * args , ** kwargs ) finally : validators . urllib2 . OpenerDirector . open = original_open return wrapper return decorator
patches urllib to simulate the availability of some urls even when there is no internet connection .