471,330 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

issue with cookielib.LWPCookieJar

Greetings:

My cookiejar contains the cookie that I need however when I do
cj.save(file) it does not actually save out to the cookies.lwj Does
anyone have any clue what would keep this from saving? It CREATED my
cookies.lwj file so I know it's not permissions.

cookies.lwp:
#LWP-Cookies-2.0
test.py:
def requestXML(frag, server='US', data=None):
import urllib
import urllib2
import os.path
import cookielib

base_urls = {
"US":"http://www.wowarmory.com/",
"EU":"http://eu.wowarmory.com/",
"US_SECURE":"https://www.wowarmory.com/",
"EU_SECURE":"https://eu.wowarmory.com/"
}

COOKIEFILE = 'cookies.lwp'
cj = cookielib.LWPCookieJar()

if os.path.isfile(COOKIEFILE):
cj.load(COOKIEFILE)

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(c j))

try:
if data is not None:
data = urllib.urlencode(data)

req = urllib2.Request(base_urls[server] + frag, data)
req.add_header('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT
6.0; en-US; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10')
handle = opener.open(req)
except IOError, e:
if hasattr(e, 'code'):
return 'We failed to open "%s".' % base_urls[server] + frag
elif hasattr(e, 'reason'):
return "The error object hast he following 'reason' attribute:
%s" % e.reason

headers = handle.info()
xml = handle.read()
print xml
print headers
print data

for index, cookie in enumerate(cj):
print index, ' : ', cookie
Nov 30 '07 #1
1 4176
JD Smith <jd*********@gmail.comwrites:
Greetings:

My cookiejar contains the cookie that I need however when I do
cj.save(file) it does not actually save out to the cookies.lwj Does
anyone have any clue what would keep this from saving? It CREATED my
cookies.lwj file so I know it's not permissions.
You want a true ignore_discard argument to .save() and .load() (or
..revert()).
John
Dec 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Alex Hunsley | last post: by
reply views Thread by dmbkiwi | last post: by
1 post views Thread by BJörn Lindqvist | last post: by
6 posts views Thread by Alessandro Fachin | last post: by
1 post views Thread by Marko.Cain.23 | last post: by
3 posts views Thread by Olivier Oost | last post: by
1 post views Thread by Boris Ozegovic | last post: by
1 post views Thread by bruce | last post: by
2 posts views Thread by Felipe De Bene | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.