[Cubicweb] [PROVENANCE INTERNET] Re: Apache authentication: which CubicWeb API?

Sylvain Thénault sylvain.thenault at logilab.fr
Wed Oct 9 09:33:35 CEST 2013

On 08 octobre 22:38, Nicolas Chauvat wrote:
> Hi Dimitri,
> On Tue, Oct 08, 2013 at 09:41:43PM +0200, Dimitri Papadopoulos Orfanos wrote:
> > How to programatically access the URL from a client program, not a
> > Web browser?
> pydoc urllib2 ?
> > Are cookies needed?
> Only if your site requires cookies to log in and the information you
> are looking for is not available to anonymous users.
> http://docs.python.org/2/library/cookielib.html

You need cookie handling if you want a session, so almost always when you start
doing more than a single HTTP request. Extract from

  _OPENER = urllib2.build_opener()
  # this is for Kerberos authentication support
      from logilab.common import urllib2ext
  except ImportError: # python-kerberos not available
  # and this for cookies

Then you can use _OPENER.open(url), authenticating the first time using __login
and __password and next request will have the session cookie set.
Sylvain Thénault, LOGILAB, Paris ( - Toulouse (
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org

More information about the Cubicweb mailing list