I try some tests with my zope (2.9.4-final on Debian) and Python about
accessing private pages.
I'm using the examples on page
the HTTPBasicAuthentication. Unfortunately that does not work.
I set the View Permission to "Member" to one page. Of course I cannot
access it if I'm not authenticated. I use the code below (extracted from
the URL I gave above) but I only receive the "Please login page".
How can I do ?
The code :
theurl = 'www.someserver.com/toplevelurl/somepage.htm'
protocol = 'http://'
username = 'johnny'
password = 'XXXXXX'
# a great password
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
# this creates a password manager
passman.add_password(None, theurl, username, password)
# because we have put None at the start it will always
# use this username/password combination for urls
# for which `theurl` is a super-url
authhandler = urllib2.HTTPBasicAuthHandler(passman)
# create the AuthHandler
opener = urllib2.build_opener(authhandler)
# All calls to urllib2.urlopen will now use our handler
# Make sure not to include the protocol in with the URL, or
# HTTPPasswordMgrWithDefaultRealm will be very confused.
# You must (of course) use it when fetching the page though.
pagehandle = urllib2.urlopen(protocol + theurl)
# authentication is now handled automatically for us
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -