Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. def register(context, request):
  2.     templatespath = resource_filename('governancetool', 'templates')
  3.     main = get_template(templatespath+'/main.pt')
  4.     notice = u''
  5.     login = u''
  6.     password = u''
  7.     confirmpassword = u''
  8.     root = request.root
  9.     if 'form.submitted' in request.params:
  10.         # Ensure that a 'userdb' key is present
  11.         # in the root
  12.         if not getattr(root, 'userdb', None):
  13.             root['userdb'] = OOBTree()
  14.         userdb = root['userdb']
  15.         login = request.params['login']
  16.         password = request.params['password']
  17.         confirmpassword = request.params['confirmpassword']
  18.         if password == confirmpassword:
  19.             if not userdb.get(login, None):
  20.                 # User doesn't exist
  21.                 newuser = User()
  22.                 newuser.id = login
  23.                 newuser.password = password
  24.                 # Add object to the BTree, keyed on the ID
  25.                 userdb[newuser.id] = newuser
  26.                 notice = u"User successfully created."
  27.             else:
  28.                 notice = u"That e-mail address already exists, please enter another one."
  29.         else:
  30.             notice = u"The passwords you entered don't match. Please re-enter them."
  31.  
  32.     return dict(
  33.         main = main,
  34.         notice = notice,
  35.         url = request.application_url + '/register',
  36.         login = login,
  37.         password = password,
  38.         confirmpassword = confirmpassword,
  39.         logged_in = None,
  40.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement