def opener(self):
        "A reusable connection manager"
        if self._opener is None:
            log.debug("Creating connection handler")
            opener = build_opener()
            if self._cookies:
                log.debug("Appending cookies")
            else:
                log.debug("No cookies to append")
            for cookie in self._cookies:
                cookie_str = cookie.name + '=' + cookie.value
                opener.addheaders.append(('Cookie', cookie_str))
            self._opener = opener
        else:
            log.debug("Reusing connection manager")
        return self._opener
def opener ( self ) : if self . _opener is None : log . debug ( "Creating connection handler" ) opener = build_opener ( ) if self . _cookies : log . debug ( "Appending cookies" ) else : log . debug ( "No cookies to append" ) for cookie in self . _cookies : cookie_str = cookie . name + '=' + cookie . value opener . addheaders . append ( ( 'Cookie' , cookie_str ) ) self . _opener = opener else : log . debug ( "Reusing connection manager" ) return self . _opener
A reusable connection manager