Re: Problem with urllib2 and authentification

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Wolfe

    Re: Problem with urllib2 and authentification

    "Miguel Beltran R." <yourpadre@gmai l.comwrites:
    Using this script for connect to Zope I have this error
    You forgot to add the authentication handler to the list of handlers.
    See below.
    >
    ---script:
    import urllib2
    >
    protocolo='http ://'
    servidor='10.28 .1.239/'
    pagina='manage'
    fullurl=protoco lo+servidor+pag ina
    >
    aut=urllib2.HTT PBasicAuthHandl er()
    aut.add_passwor d(realm=None,
    uri=servidor,
    user='myadmin',
    passwd='mypass' )
    opener=urllib2. build_opener(au t, urllib2.HTTPHan dler(debuglevel =1))
    Add here:

    opener.add_hand ler(aut))

    print opener.open(ful lurl).read()
    HTH,
    Rob
  • Rob Wolfe

    #2
    Re: Problem with urllib2 and authentificatio n

    Rob Wolfe <rw@smsnet.plwr ites:
    >---script:
    >import urllib2
    >>
    >protocolo='htt p://'
    >servidor='10.2 8.1.239/'
    >pagina='manage '
    >fullurl=protoc olo+servidor+pa gina
    >>
    >aut=urllib2.HT TPBasicAuthHand ler()
    >aut.add_passwo rd(realm=None,
    > uri=servidor,
    > user='myadmin',
    > passwd='mypass' )
    >opener=urllib2 .build_opener(a ut, urllib2.HTTPHan dler(debuglevel =1))
    Please ignore me. I overlooked that you added this handler here.
    But anyway I would try this `add_handler` method. ;)

    Rob

    Comment

    Working...