Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/_LWPCookieJar.html
Дата изменения: Mon Aug 3 10:14:09 2009
Дата индексирования: Sat Mar 1 16:40:29 2014
Кодировка:
_LWPCookieJar


 
 _LWPCookieJar
 /usr/local/Python-2.4.1/lib/python2.4/_LWPCookieJar.py

Load / save to libwww-perl (LWP) format files.
 
Actually, the format is slightly extended from that used by LWP's
(libwww-perl's) HTTP::Cookies, to avoid losing some RFC 2965 information
not recorded by LWP.
 
It uses the version string "2.0", though really there isn't an LWP Cookies
2.0 format.  This indicates that there is extra information in here
(domain_dot and # port_spec) while still being compatible with
libwww-perl, I hope.


 Modules
                                                                                                                                                                                                                               
logging
re
time


 Classes
                                                                                                                                                                                                                               
cookielib.FileCookieJar(cookielib.CookieJar)
LWPCookieJar


 class LWPCookieJar(cookielib.FileCookieJar)
          
The LWPCookieJar saves a sequence of"Set-Cookie3" lines.
"Set-Cookie3" is the format used by the libwww-perl libary, not known
to be compatible with any browser, but which is easy to read and
doesn't lose information about RFC 2965 cookies.
 
Additional methods
 
as_lwp_str(ignore_discard=True, ignore_expired=True)
 
                                                                                                                                                                                                                     
__init__(self, filename=None, delayload=False, policy=None)
Cookies are NOT loaded from the named file until either the .load() or
.revert() method is called.
__iter__(self)
no doc string
__len__(self)
Return number of contained cookies.
__repr__(self)
no doc string
__str__(self)
no doc string
_cookie_attrs(self, cookies)
Return a list of cookie-attributes to be returned to server.
 
like ['foo="bar"; $Path="/"', ...]
 
The $Version attribute is also added when appropriate (currently only
once per request).
_cookie_from_cookie_tuple(self, tup, request)
no doc string
_cookies_for_domain(self, domain, request)
no doc string
_cookies_for_request(self, request)
Return a list of cookies to be returned to server.
_cookies_from_attrs_set(self, attrs_set, request)
no doc string
_normalized_cookie_tuples(self, attrs_set)
Return list of tuples containing normalised cookie information.
 
attrs_set is the list of lists of key,value pairs extracted from
the Set-Cookie or Set-Cookie2 headers.
 
Tuples are name, value, standard, rest, where name and value are the
cookie name and value, standard is a dictionary containing the standard
cookie-attributes (discard, secure, version, expires or max-age,
domain, path and port) and rest is a dictionary containing the rest of
the cookie-attributes.
_really_load(self, f, filename, ignore_discard, ignore_expires)
no doc string
add_cookie_header(self, request)
Add correct Cookie: header to request (urllib2.Request object).
 
The Cookie2 header is also added unless policy.hide_cookie2 is true.
as_lwp_str(self, ignore_discard=True, ignore_expires=True)
Return cookies as a string of "
"-separated "Set-Cookie3" headers.
 
        ignore_discard and ignore_expires: see docstring for FileCookieJar.save
clear(self, domain=None, path=None, name=None)
Clear some cookies.
 
Invoking this method without arguments will clear all cookies.  If
given a single argument, only cookies belonging to that domain will be
removed.  If given two arguments, cookies belonging to the specified
path within that domain are removed.  If given three arguments, then
the cookie with the specified name, path and domain is removed.
 
Raises KeyError if no matching cookie exists.
clear_expired_cookies(self)
Discard all expired cookies.
 
You probably don't need to call this method: expired cookies are never
sent back to the server (provided you're using DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() method won't save expired cookies anyway (unless you ask
otherwise by passing a true ignore_expires argument).
clear_session_cookies(self)
Discard all session cookies.
 
Note that the .save() method won't save session cookies anyway, unless
you ask otherwise by passing a true ignore_discard argument.
extract_cookies(self, response, request)
Extract cookies from response, where allowable given the request.
load(self, filename=None, ignore_discard=False, ignore_expires=False)
Load cookies from a file.
make_cookies(self, response, request)
Return sequence of Cookie objects extracted from response object.
revert(self, filename=None, ignore_discard=False, ignore_expires=False)
Clear all cookies and reload cookies from a saved file.
 
Raises LoadError (or IOError) if reversion is not successful; the
object's state will not be altered if this happens.
save(self, filename=None, ignore_discard=False, ignore_expires=False)
no doc string
set_cookie(self, cookie)
Set a cookie, without checking whether or not it should be set.
set_cookie_if_ok(self, cookie, request)
Set a cookie if policy says it's OK to do so.
set_policy(self, policy)
no doc string


 Functions
                                                                                                                                                                                                                               
lwp_cookie_str(cookie)
Return string representation of Cookie in an the LWP cookie file format.
 
Actually, the format is extended a bit -- see module docstring.


 Constants
                                                                                                                                                                                                                               
MISSING_FILENAME_TEXT = 'a filename was not supplied (nor was the CookieJar instance initialised with one)'