<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<STYLE title=owaParaStyle>P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>

<META name=GENERATOR content="MSHTML 8.00.6001.19394"></HEAD>
<BODY ocsi="x">
<DIV dir=ltr align=left><SPAN class=205302922-19052013><FONT color=#0000ff 
size=2 face=Arial>You need to pass the cookie as a string. You can get the 
cookie text from the 'set-cookie' header in the http response ('handle' in your 
code).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=205302922-19052013><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=205302922-19052013><FONT color=#0000ff 
size=2 face=Arial>So I *think* something like this should 
work:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=205302922-19052013></SPAN><SPAN 
class=205302922-19052013></SPAN><SPAN class=205302922-19052013><FONT 
color=#0000ff size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=205302922-19052013><FONT face=Arial>
<DIV dir=ltr><FONT color=#0000ff size=2 face=Tahoma># HTTP request</FONT></DIV>
<DIV dir=ltr><FONT color=#0000ff size=2 face=Tahoma>req</FONT><FONT 
color=#0000ff size=2 face=Tahoma> = urllib2.Request(login_url, postfields, 
txheaders)<BR>handle = urllib2.urlopen(req)</FONT></DIV>
<DIV dir=ltr><FONT face=Tahoma><SPAN class=205302922-19052013><FONT 
color=#0000ff size=2 face=Arial>cookiestr = 
handle.headers['set-cookie']</FONT></SPAN></FONT></DIV>
<DIV dir=ltr><FONT color=#0000ff size=2 face=Tahoma></FONT> </DIV>
<DIV dir=ltr><FONT color=#0000ff size=2 face=Tahoma># WCS handler</FONT></DIV>
<DIV dir=ltr><FONT color=#0000ff size=2 face=Tahoma>wcs = 
WebCoverageService(url=wcs_url, version='1.0.0', cookies=c<SPAN 
class=205302922-19052013>ookiestr</SPAN>)</FONT></DIV></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=205302922-19052013><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV><FONT color=#0000ff size=2 face=Tahoma></FONT> </DIV>
<DIV><SPAN class=205302922-19052013><FONT color=#0000ff size=2 
face=Tahoma>Cheers,</FONT></SPAN></DIV>
<DIV><SPAN class=205302922-19052013><FONT color=#0000ff size=2 
face=Tahoma>Dom</FONT></SPAN></DIV>
<DIV><BR></DIV>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> owslib-users-bounces@lists.osgeo.org 
[mailto:owslib-users-bounces@lists.osgeo.org] <B>On Behalf Of </B>Iñigo Hernáez 
Corres<BR><B>Sent:</B> Friday, 17 May 2013 5:47 PM<BR><B>To:</B> 
owslib-users@lists.osgeo.org<BR><B>Subject:</B> Re: [OWSLib-users] WCS Cookie 
Generation [SEC=UNCLASSIFIED]<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma>Yes, I think this is the way to do this. 
However, I still have some doubts...</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=tahoma></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=tahoma>I handle the login cookie with 
urllib2 and cookielib, but then I am not sure about how is this passed to the 
WCS handler:</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=tahoma></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma># Cookie handler</FONT></DIV><FONT 
size=2><FONT face=Tahoma>cj = cookielib.LWPCookieJar()</FONT></FONT> 
<DIV dir=ltr><FONT size=2><FONT face=Tahoma>opener</FONT><FONT face=Tahoma> = 
urllib2.build_opener(urllib2.HTTPSHandler, 
urllib2.HTTPCookieProcessor(cj))<BR>urllib2.install_opener(opener)</FONT></FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma># HTTP request</FONT></DIV>
<DIV dir=ltr><FONT size=2><FONT face=Tahoma>req</FONT><FONT face=Tahoma> = 
urllib2.Request(login_url, postfields, txheaders)<BR>handle = 
urllib2.urlopen(req)</FONT></FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma># WCS handler</FONT></DIV>
<DIV dir=ltr><FONT face=Tahoma><FONT size=2>wcs = 
WebCoverageService(url=wcs_url, version='1.0.0', cookies=cj)</FONT></FONT></DIV>
<P><FONT face=Tahoma><FONT size=2 face=tahoma></FONT></FONT> </P>
<P><FONT face=Tahoma><FONT size=2 face=tahoma>Not sure if the "cj" should be 
included directly, as "cj.as_lwp.str()" or any other 
way...</FONT><BR></P></FONT>
<DIV dir=ltr><FONT size=2 face=Tahoma></FONT> </DIV>
<DIV>
<DIV class=BodyFragment><FONT size=2>
<DIV class=PlainText><FONT color=#808080 size=3 face=Arial>Iñigo Hernáez 
Corres</FONT></DIV>
<DIV class=PlainText><FONT face=arial><FONT 
color=#808080></FONT></FONT> </DIV>
<DIV class=PlainText><FONT face=arial><FONT color=#808080>email: </FONT><A 
href="mailto:ihernaez@adasasistemas.com"><FONT 
color=#808080>ihernaez@adasasistemas.com</FONT></A></FONT></DIV>
<DIV class=PlainText><FONT color=#808080 face=arial>tlf: (+34) 945 
064483</FONT></DIV>
<DIV class=PlainText><FONT color=#808080 face=arial>C/Portal de Foronda, 
41</FONT></DIV>
<DIV class=PlainText><FONT color=#808080 face=arial>01010, 
Vitoria-Gasteiz</FONT></DIV>
<DIV class=PlainText><FONT color=#808080 face=arial></FONT> </DIV>
<DIV class=PlainText><FONT color=#4d4e53 face=Arial>Maintenance & Logistics 
Services (M&LS)</FONT></DIV>
<DIV class=PlainText>
<DIV><FONT color=#808080 size=1 face=Arial><SPAN 
style="FONT-FAMILY: Arial; COLOR: #4d4e53; FONT-SIZE: 9pt"><IMG id=_x0000_i1026 
width=146 height=53></SPAN></FONT></DIV>
<DIV>
<P class=MsoNormal><FONT size=1 face=Arial><SPAN 
style="FONT-FAMILY: Arial; COLOR: #4d4e53; FONT-SIZE: 9pt"><FONT 
color=#808080>José Agustín Goytisolo, 30-32<BR>08908 L'Hospitalet de Llobregat - 
Barcelona<BR>T. (+34) 93 264 06 02<BR>F. (+34) 93 264 06 56<BR></FONT><A 
href="https://correo.adasasistemas.com/owa/UrlBlockedError.aspx" 
target=_blank><SPAN style="COLOR: #4d4e53"><FONT 
color=#808080>www.comsaemte.com</FONT></SPAN></A></SPAN></FONT></P></DIV></DIV></FONT></DIV></DIV><BR><FONT 
color=green size=1 face=Verdana>No imprimir si no es necesario. Protejamos el 
Medio Ambiente.<BR>Please consider the environment before printing this 
email.<BR></FONT><BR><FONT color=gray size=1 face=Verdana>Este mensaje, y en su 
caso cualquier fichero anexo al mismo, es sólo para el destinatario a quien va 
dirigido y puede contener información privilegiada, profesional o privada. Si lo 
ha recibido por error, por favor notifíquelo inmediatamente el remitente y 
elimine el original. Cualquier otro uso que haga de este mensaje está 
prohibido.<BR><BR>This message and its attachments, if any, is solely for the 
attention of the addressee and may contain privileged confidential information 
of a professional or other nature. If you have received this message by mistake, 
please notify the senderimmediately and delete the original. It is prohibited to 
use this message for any other purpose.<BR></FONT></BODY></HTML>