def create_user(email, password): """ """ assert isinstance(email, unicode), type(email) assert isinstance(password, unicode), type(password) assert email assert password try: UserEntityDAO.select_by_email(email) raise UserAlreadyExistsException() except NoResultFound: pass salt = unicode(uuid.uuid4().hex) hashed_password = unicode(hashlib.sha512(password + salt).hexdigest()) user_entity = UserEntity(email, hashed_password, salt) UserEntityDAO.save(user_entity) # TODO: Send an email. return UserAService.login(email, password)