Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def register(context, request):
- templatespath = resource_filename('governancetool', 'templates')
- main = get_template(templatespath+'/main.pt')
- notice = u''
- login = u''
- password = u''
- confirmpassword = u''
- root = request.root
- if 'form.submitted' in request.params:
- # Ensure that a 'userdb' key is present
- # in the root
- if not getattr(root, 'userdb', None):
- root['userdb'] = OOBTree()
- userdb = root['userdb']
- login = request.params['login']
- password = request.params['password']
- confirmpassword = request.params['confirmpassword']
- if password == confirmpassword:
- if not userdb.get(login, None):
- # User doesn't exist
- newuser = User()
- newuser.id = login
- newuser.password = password
- # Add object to the BTree, keyed on the ID
- userdb[newuser.id] = newuser
- notice = u"User successfully created."
- else:
- notice = u"That e-mail address already exists, please enter another one."
- else:
- notice = u"The passwords you entered don't match. Please re-enter them."
- return dict(
- main = main,
- notice = notice,
- url = request.application_url + '/register',
- login = login,
- password = password,
- confirmpassword = confirmpassword,
- logged_in = None,
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement