I want to add support for sessions to fetch() from tools.py. This is so that I can call protected KML feeds from inside the Sahana Map Viewing Client. I think that what I need to do to achieve this is to forward the session cookie from request to the urllib2() call (yes, it seems that urllib() is insufficient for this).
I'm really struggling to get this working though. I've tried adding the header manually: import urllib2 cookie = response.session_id_name + "=" + response.session_id txheaders = {'Cookie' : cookie} req = urllib2.Request(url, None, txheaders) return urllib2.urlopen(req).read() But this seems to hang Web2Py completely! (Strangely it works fine when I direct at an unprotected external KML feed!) I also tried using cookielib: cookie = request.cookies[response.session_id_name] jar = cookielib.CookieJar() jar.set_cookie(cookie) handler = urllib2.HTTPCookieProcessor(jar) opener = urllib2.build_opener(handler) urllib2.install_opener(opener) return urllib2.urlopen(url).read() However this fails because it wants cookie.domain to be defined (I tried defining it as "" but this fails too): import Cookie, cookielib cookie = Cookie.SimpleCookie() cookie[response.session_id_name] = response.session_id cookie['path'] = "/" cookie['domain'] = "" This seems wrong anyway, as Set-Cookie is for Server->Client & I want Client->Server Any/All pointers very gratefully received :) Fran. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.