[Zope-dev] adduser command: give feedback about success
Maurits van Rees
m.van.rees at zestsoftware.nl
Mon Jan 10 19:20:09 EST 2011
Op 09-01-11 10:32, Marius Gedminas schreef:
> On Fri, Jan 07, 2011 at 11:55:53PM +0100, Maurits van Rees wrote:
>> I propose to add this feedback. This needs a few simple changes in
>> Zope2/utilities, Zope2/Startup, AccessControl,
>> Products.PluggableAuthService, and a few doctest fixes in Products.Five.
>> The change to Zope2/utilities/adduser.py would be this:
>>
>> ===================================================================
>> - adduser(app, user, pwd)
>> + result = adduser(app, user, pwd)
>> + if result:
>> + print "User %s created." % user
>> + else:
>> + print "Got no result back. User creation may have failed."
>> + print "Maybe the user already exists and nothing is done then."
>> + print "Or the implementation does not give info when it succeeds."
>
> I don't suppose you could somehow change the API so the script can
> report something useful? "I don't even know if I succeeded or not"
> sounds pretty pathetic.
Agreed. But with current releases of Products.PluggableAuthService
(until and including 1.7.2) no result is given back, so we cannot be
sure here if there is no result because the PAS is too old or because it
really failed.
With the proposed changes, either the created user or None is returned,
which you might consider an API change. At least I mention in the
interface in AccessControl that implementations should return the
created user or None.
> Maybe it's better than surly silence.
That's the general idea.
I committed the changes on Zope2 trunk and branch 2.13, AccessControl
trunk, and Products.PluggableAuthService trunk (used by Plone 4.0 and
4.1). Note that Zope2 2.13 also uses AccessControl trunk and in fact
there are no official branches of that.
Note that in the do_adduser method that is used in 'bin/zopectl adduser'
I used shorter output as that code gets printed on the command line so
it should be very simple. It either prints "Created user joe" or
"Created user None".
Cheers,
--
Maurits van Rees
Programmer at Zest Software http://zestsoftware.nl
Personal website http://maurits.vanrees.org/
More information about the Zope-Dev
mailing list