[Zope-CMF] Login from a script
Dieter Maurer
dieter@handshake.de
Mon, 3 Feb 2003 20:47:13 +0100
Kari-Hans Kommonen wrote at 2003-2-3 12:42 +0200:
> I have a very simple question. I am trying to do a two step login but
> make it seem like only one step to the user.
>
> I want to 1) ask for a username and a password, and 2) find the real
> userid from another source and 3) post the userid and the password to
> zope for authentication.
I assume "another source" is not a Zope source?
Otherwise, you could collapse step 2 and 3.
User Folders provide a (private; you need an External Method)
method "authenticate" to authenticate a user (see
"AccessControl.User.BasicUserFolder.authenticate").
If successful, it returns a User object, otherwise "None".
You can "install" a user for the current
request with "newSecurityManager(None,user)".
When you use "CookieCrumbler", it provides a similar method.
When you want to issue another HTTP request (e.g. a POST)
in an External Method, you can use "ZPublisher.Client"
or "urllib". The first is much easier for "POST".
You find some notes in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
Dieter