def doIt(self, request): if request.method != 'POST': return False [email] = request.args.get('email', [None]) [password] = request.args.get('password', [None]) if not (email and password): request.session.addFlashMessage("Login failed: Email or password not given", _domain="_warp:login") return False avatar = avatar_store.find(Avatar, Avatar.email == email.decode("utf-8") ).one() checker = config.get('checkPassword', defaultCheckPassword) if avatar is None or not checker(avatar, password): request.session.addFlashMessage("Login failed: Email or password incorrect", _domain="_warp:login") return False request.session.setAvatarID(avatar.id) request.avatar = request.session.avatar return True
def ok(result, request): print >>config["log"], "Ok ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" data = json.loads(result) print >>config["log"], result if data.get("status") == "okay": email = uni(data.get("email")) avatar = avatar_store.find(Avatar, email = email).one() if not avatar: avatar = Avatar() avatar.email = email avatar_store.add(avatar) avatar_store.commit() request.session.setAvatarID(avatar.id) request.avatar = request.session.avatar return { "success": True, "data": data } else: raise Exception("Login failed")
def reindex(): import storm.database avatar_store.execute("DELETE FROM warp_fulltext") for klass in searchModels.itervalues(): for obj in avatar_store.find(klass): obj.__storm_flushed__()