當前位置: 首頁>>代碼示例>>Python>>正文


Python _clientcookie.CookieJar類代碼示例

本文整理匯總了Python中_clientcookie.CookieJar的典型用法代碼示例。如果您正苦於以下問題:Python CookieJar類的具體用法?Python CookieJar怎麽用?Python CookieJar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CookieJar類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

 def __init__(self, filename, autoconnect=True, policy=None):
     experimental("Firefox3CookieJar is experimental code")
     CookieJar.__init__(self, policy)
     if filename is not None and not isstringlike(filename):
         raise ValueError("filename must be string-like")
     self.filename = filename
     self._conn = None
     if autoconnect:
         self.connect()
開發者ID:BillTheBest,項目名稱:Community-Zenpacks,代碼行數:9,代碼來源:_firefox3cookiejar.py

示例2: _cookies_for_domain

 def _cookies_for_domain(self, domain, request):
     if not self._policy.domain_return_ok(domain, request):
         return []
     debug("Checking %s for cookies to return", domain)
     if self.delayload:
         self._delayload_domain(domain)
     return CookieJar._cookies_for_domain(self, domain, request)
開發者ID:ppizarror,項目名稱:korektor,代碼行數:7,代碼來源:_msiecookiejar.py

示例3: set_cookie

    def set_cookie(self, cookie):
        if cookie.discard:
            CookieJar.set_cookie(self, cookie)
            return

        def set_cookie(cur):
            # XXX
            # is this RFC 2965-correct?
            # could this do an UPDATE instead?
            row = self._row_from_cookie(cookie, cur)
            name, unused, domain, path = row[1:5]
            cur.execute("""\
DELETE FROM moz_cookies WHERE host = ? AND path = ? AND name = ?""",
                        (domain, path, name))
            cur.execute("""\
INSERT INTO moz_cookies VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""", row)
        self._transaction(set_cookie)
開發者ID:BillTheBest,項目名稱:Community-Zenpacks,代碼行數:18,代碼來源:_firefox3cookiejar.py

示例4: clear

 def clear(self, domain=None, path=None, name=None):
     CookieJar.clear(self, domain, path, name)
     where_parts = []
     sql_params = []
     if domain is not None:
         where_parts.append("host = ?")
         sql_params.append(domain)
         if path is not None:
             where_parts.append("path = ?")
             sql_params.append(path)
             if name is not None:
                 where_parts.append("name = ?")
                 sql_params.append(name)
     where = " AND ".join(where_parts)
     if where:
         where = " WHERE " + where
     def clear(cur):
         cur.execute("DELETE FROM moz_cookies%s" % where,
                     tuple(sql_params))
     self._transaction(clear)
開發者ID:BillTheBest,項目名稱:Community-Zenpacks,代碼行數:20,代碼來源:_firefox3cookiejar.py

示例5: _cookies_for_request

 def _cookies_for_request(self, request):
     session_cookies = CookieJar._cookies_for_request(self, request)
     def get_cookies(cur):
         query = cur.execute("SELECT host from moz_cookies")
         domains = [row[0] for row in query.fetchmany()]
         cookies = []
         for domain in domains:
             cookies += self._persistent_cookies_for_domain(domain,
                                                            request, cur)
         return cookies
     persistent_coookies = self._transaction(get_cookies)
     return session_cookies + persistent_coookies
開發者ID:BillTheBest,項目名稱:Community-Zenpacks,代碼行數:12,代碼來源:_firefox3cookiejar.py

示例6: set_cookie

 def set_cookie(self, cookie):
     if self.delayload:
         self._delayload_domain(cookie.domain)
     CookieJar.set_cookie(self, cookie)
開發者ID:ppizarror,項目名稱:korektor,代碼行數:4,代碼來源:_msiecookiejar.py

示例7: load_cookie_data

    def load_cookie_data(self, filename,
                         ignore_discard=False, ignore_expires=False):
        """Load cookies from file containing actual cookie data.

        Old cookies are kept unless overwritten by newly loaded ones.

        You should not call this method if the delayload attribute is set.

        I think each of these files contain all cookies for one user, domain,
        and path.

        filename: file containing cookies -- usually found in a file like
         C:\WINNT\Profiles\joe\Cookies\[email protected][1].txt

        """
        now = int(time.time())

        cookie_data = self._load_cookies_from_file(filename)

        for cookie in cookie_data:
            flags = cookie["FLAGS"]
            secure = ((flags & 0x2000) != 0)
            filetime = (cookie["HIXP"] << 32) + cookie["LOXP"]
            expires = epoch_time_offset_from_win32_filetime(filetime)
            if expires < now:
                discard = True
            else:
                discard = False
            domain = cookie["DOMAIN"]
            initial_dot = domain.startswith(".")
            if initial_dot:
                domain_specified = True
            else:
                # MSIE 5 does not record whether the domain cookie-attribute
                # was specified.
                # Assuming it wasn't is conservative, because with strict
                # domain matching this will match less frequently; with regular
                # Netscape tail-matching, this will match at exactly the same
                # times that domain_specified = True would.  It also means we
                # don't have to prepend a dot to achieve consistency with our
                # own & Mozilla's domain-munging scheme.
                domain_specified = False

            # assume path_specified is false
            # XXX is there other stuff in here? -- e.g. comment, commentURL?
            c = Cookie(0,
                       cookie["KEY"], cookie["VALUE"],
                       None, False,
                       domain, domain_specified, initial_dot,
                       cookie["PATH"], False,
                       secure,
                       expires,
                       discard,
                       None,
                       None,
                       {"flags": flags})
            if not ignore_discard and c.discard:
                continue
            if not ignore_expires and c.is_expired(now):
                continue
            CookieJar.set_cookie(self, c)
開發者ID:ppizarror,項目名稱:korektor,代碼行數:61,代碼來源:_msiecookiejar.py


注:本文中的_clientcookie.CookieJar類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。