classification
Title: insert cookies into cookie jar - cookielib.py
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, jjlee, jondebonis, shirllu, terry.reedy
Priority: normal Keywords: patch

Created on 2009-07-28 02:07 by jondebonis, last changed 2014-08-29 20:02 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
cookie_update.diff jondebonis, 2009-07-28 02:07 patch review
Messages (5)
msg91000 - (view) Author: Jon Debonis (jondebonis) Date: 2009-07-28 02:07
Added ability to insert cookies into cookie jar.

Fixed problem where some domain names are prepended with '.' and others 
were not.

Fixed problem with _LWPCookieJar.py to handle case where version = None

----
import urllib2, urllib, time
import cookielib
            
req_url = 'http://google.com'

## OPEN COOKIE JAR - Optional
cj = cookielib.CookieJar()

cookie_handler = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_handler)
urllib2.install_opener(opener)

req = urllib2.Request(url=req_url)
    
cj.add_cookie(req, 'cname2', 'cval2',
                {'expires':  int(time.time()) + 3600,})

cj.add_cookie(req, 'cname3', 'cval3') 

print "-" * 45
print "Cookies before first request is sent:"
for index, cookie in enumerate(cj):
    print index, '  :  ', cookie

res = urllib2.urlopen(req)
# Google will redirect, and clear the additional cookies
print "-" * 45
print "Cookies after first request is sent:"
print "(google cleared extra cookies)"
for index, cookie in enumerate(cj):
    print index, '  :  ', cookie
---
msg105412 - (view) Author: John J Lee (jjlee) Date: 2010-05-09 19:36
Jon,

If you want to get these changes applied you need to:

 1. Split up these three separate issues
 2. Most important: explain in full detail exactly how you used cookielib, what you expected it to do, and what it actually did, and then justify why your expectation is correct.
 3. Ensure that automated tests cover each change
 4. Respond to the review comments that are likely to follow
msg105413 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-05-09 19:39
Minor remarks:
- generate your patch from the top-level directory, so that people can just apply the patch from there (see http://www.python.org/dev/patches/);
- don’t put two statements on one line (“if thing: dostuff()”), as per PEP 8.
msg221289 - (view) Author: SHIRLEY LU (shirllu) Date: 2014-06-22 18:05
Is this issue still relevant? Adding new cookies is supported in the cookiejar.py lib now. There does not seem to be an issue with null version.
msg226071 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-08-29 20:02
2.7 does not get enhancements and Lu's comment suggests that the enhancement is already in 3.x.
History
Date User Action Args
2014-08-29 20:02:45terry.reedysetstatus: open -> closed

nosy: + terry.reedy
messages: + msg226071

resolution: out of date
2014-06-22 18:05:45shirllusetnosy: + shirllu

messages: + msg221289
versions: + Python 2.7, - Python 3.2
2010-07-11 02:14:12terry.reedysetstage: test needed
versions: + Python 3.2, - Python 2.6
2010-05-09 19:39:45eric.araujosetnosy: + eric.araujo
messages: + msg105413
2010-05-09 19:36:31jjleesetnosy: + jjlee
messages: + msg105412
2009-07-28 02:07:11jondeboniscreate