In the documentation for SimpleUserFolder, it says def addUser(name, password, roles) This adds a user. It should raise an exception if the user already exists. What should it do if the user can't be added for any other reason? Any exception that I raise returns the error "user already exists" to the user, but the user doesn't already exist, I just don't want to allow him to be created. Surely I should be able to return different exceptions to give different reasons to the user as to why a new user cannot be created. Robert Munro
jamie@textmatters.com wrote:
In the documentation for SimpleUserFolder, it says
def addUser(name, password, roles)
This adds a user. It should raise an exception if the user already exists.
What should it do if the user can't be added for any other reason? Any exception that I raise returns the error "user already exists" to the user, but the user doesn't already exist, I just don't want to allow him to be created. Surely I should be able to return different exceptions to give different reasons to the user as to why a new user cannot be created.
Robert Munro _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Jamie, Im a little confused by your question so forgive if Im off the mark. But shouldn't you determine whether or not you wish to add a user *before* you call addUser? David
David Hassalevris wrote:
Im a little confused by your question so forgive if Im off the mark. But shouldn't you determine whether or not you wish to add a user *before* you call addUser?
Indeed, but if you really want to do things arse-about-face you can set a message on the REQUEST object in your addUser script (something like context.REQUEST.set('add_user_error','You smell funny')) and then catch the exception in the templating you're building for user management and display the message from the request. cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
David Hassalevris -
jamieï¼ textmatters.com