Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
http.cookiejar.Cookie Class Reference

List of all members.

Public Member Functions

def __init__
def has_nonstandard_attr
def get_nonstandard_attr
def set_nonstandard_attr
def is_expired
def __str__
def __repr__

Public Attributes

 version
 name
 value
 port
 port_specified
 domain
 domain_specified
 domain_initial_dot
 path
 path_specified
 secure
 expires
 discard
 comment
 comment_url
 rfc2109

Private Attributes

 _rest

Detailed Description

HTTP Cookie.

This class represents both Netscape and RFC 2965 cookies.

This is deliberately a very simple class.  It just holds attributes.  It's
possible to construct Cookie instances that don't comply with the cookie
standards.  CookieJar.make_cookies is the factory function for Cookie
objects -- it deals with cookie parsing, supplying defaults, and
normalising to the representation used in this class.  CookiePolicy is
responsible for checking them to see whether they should be accepted from
and returned to the server.

Note that the port may be present in the headers, but unspecified ("Port"
rather than"Port=80", for example); if this is the case, port is None.

Definition at line 713 of file cookiejar.py.


Constructor & Destructor Documentation

def http.cookiejar.Cookie.__init__ (   self,
  version,
  name,
  value,
  port,
  port_specified,
  domain,
  domain_specified,
  domain_initial_dot,
  path,
  path_specified,
  secure,
  expires,
  discard,
  comment,
  comment_url,
  rest,
  rfc2109 = False 
)

Definition at line 742 of file cookiejar.py.

00742 
00743                  ):
00744 
00745         if version is not None: version = int(version)
00746         if expires is not None: expires = int(expires)
00747         if port is None and port_specified is True:
00748             raise ValueError("if port is None, port_specified must be false")
00749 
00750         self.version = version
00751         self.name = name
00752         self.value = value
00753         self.port = port
00754         self.port_specified = port_specified
00755         # normalise case, as per RFC 2965 section 3.3.3
00756         self.domain = domain.lower()
00757         self.domain_specified = domain_specified
00758         # Sigh.  We need to know whether the domain given in the
00759         # cookie-attribute had an initial dot, in order to follow RFC 2965
00760         # (as clarified in draft errata).  Needed for the returned $Domain
00761         # value.
00762         self.domain_initial_dot = domain_initial_dot
00763         self.path = path
00764         self.path_specified = path_specified
00765         self.secure = secure
00766         self.expires = expires
00767         self.discard = discard
00768         self.comment = comment
00769         self.comment_url = comment_url
00770         self.rfc2109 = rfc2109
00771 
00772         self._rest = copy.copy(rest)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 796 of file cookiejar.py.

00796 
00797     def __repr__(self):
00798         args = []
00799         for name in ("version", "name", "value",
00800                      "port", "port_specified",
00801                      "domain", "domain_specified", "domain_initial_dot",
00802                      "path", "path_specified",
00803                      "secure", "expires", "discard", "comment", "comment_url",
00804                      ):
00805             attr = getattr(self, name)
00806             args.append("%s=%s" % (name, repr(attr)))
00807         args.append("rest=%s" % repr(self._rest))
00808         args.append("rfc2109=%s" % repr(self.rfc2109))
00809         return "Cookie(%s)" % ", ".join(args)
00810 

Here is the call graph for this function:

Definition at line 786 of file cookiejar.py.

00786 
00787     def __str__(self):
00788         if self.port is None: p = ""
00789         else: p = ":"+self.port
00790         limit = self.domain + p + self.path
00791         if self.value is not None:
00792             namevalue = "%s=%s" % (self.name, self.value)
00793         else:
00794             namevalue = self.name
00795         return "<Cookie %s for %s>" % (namevalue, limit)

def http.cookiejar.Cookie.get_nonstandard_attr (   self,
  name,
  default = None 
)

Definition at line 775 of file cookiejar.py.

00775 
00776     def get_nonstandard_attr(self, name, default=None):
        return self._rest.get(name, default)
def http.cookiejar.Cookie.has_nonstandard_attr (   self,
  name 
)

Definition at line 773 of file cookiejar.py.

00773 
00774     def has_nonstandard_attr(self, name):
        return name in self._rest
def http.cookiejar.Cookie.is_expired (   self,
  now = None 
)

Definition at line 780 of file cookiejar.py.

00780 
00781     def is_expired(self, now=None):
00782         if now is None: now = time.time()
00783         if (self.expires is not None) and (self.expires <= now):
00784             return True
00785         return False

def http.cookiejar.Cookie.set_nonstandard_attr (   self,
  name,
  value 
)

Definition at line 777 of file cookiejar.py.

00777 
00778     def set_nonstandard_attr(self, name, value):
00779         self._rest[name] = value


Member Data Documentation

Definition at line 771 of file cookiejar.py.

Definition at line 767 of file cookiejar.py.

Definition at line 768 of file cookiejar.py.

Definition at line 766 of file cookiejar.py.

Definition at line 755 of file cookiejar.py.

Definition at line 761 of file cookiejar.py.

Definition at line 756 of file cookiejar.py.

Definition at line 765 of file cookiejar.py.

Definition at line 750 of file cookiejar.py.

Definition at line 762 of file cookiejar.py.

Definition at line 763 of file cookiejar.py.

Definition at line 752 of file cookiejar.py.

Definition at line 753 of file cookiejar.py.

Definition at line 769 of file cookiejar.py.

Definition at line 764 of file cookiejar.py.

Definition at line 751 of file cookiejar.py.

Definition at line 749 of file cookiejar.py.


The documentation for this class was generated from the following file: