In a
plugin you can create or update a
User object as follows:
username = 'foo'
password = 'monkey'
roles = ['ADMIN', 'science']
user = User(username)
user.set_password(password)
for role in roles:
user.add_role(role)
environ['tiddlyweb.store'].put(user)
The code assumes you have the necessary modules imported and that
environ has been populated as expected in a WSGI application. See the
Plugin List for links to existing plugins which have examples of some of the other ways to do this.
Note that there is no requirement for
roles to be pre-existing. You can use any string you like. It is up to you to manage that.