import helper,database #,database maxuser = 1000 """ """ class CreateAccount: def index(self,username = None, password1 = None, password2 = None): """ checks if there are some parameters from the form. If not, displays creation form. Else processes form data """ if username != None and password1 != None and password2 != None: return self.process_form(username,password1,password2) else: return self.display_create_form() def display_create_form(self): """ returns a HTML page containing one name and two password fields. """ data = helper.header() data += """

Your username:

Your Password:

Please retype your Password:

""" data += helper.footer() return(data) def process_form(self,username, password1, password2): """ gets username, password1 and password2. If all data is there and correct, create the named user and return a 'success' page. Else fail with detailed error. """ data = helper.header() if (password1 == password2): #try: #.add_webgo_user(username,password1) newuser = database.Users(username=username,password=password1) created_user = True #except: # #user already exists # created_user = False if created_user: data += ('User %s has been successfully created. Click here to login.
' % username) else: data += ("User %s already exists. Please retry with another name." % username) data += self.display_create_form() else: if (password1 == "") or (password2 == "") or (password1 != password2): data += ("Both given passwords have to be the same and non-empty.
") data += self.display_create_form() data += helper.footer() return data index.exposed = True