def get(self): logging.debug("WebController.get()") user = Login().getIrssiUser(self.request.params) tokensList = [] count = 0 if user is not None: tokens = C2dmToken.all() tokens.ancestor(user.key()) tokensList = tokens.fetch(10) messages = Message.all() messages.ancestor(user.key()) count = messages.count(1) template_values = { 'user': user, 'tokens': tokensList, 'loggedin': user is not None, 'login_url': users.create_login_url("#profile").replace("&", "&"), 'logout_url': users.create_logout_url("").replace("&", "&"), 'irssiworking': count != 0, 'c2dmtokencount': len(tokensList), } logging.debug(template_values) logging.debug(tokensList) template = jinja_environment.get_template('html/index.html') self.response.out.write(template.render(template_values))
def sendC2dmToUser(self, irssiuser, message): logging.debug("Sending c2dm message to user %s" % irssiuser.user_name) tokens = C2dmToken.all() tokens.ancestor(irssiuser.key()) tokensList = tokens.fetch(10) for token in tokensList: if token.enabled: self.sendC2dm(token.c2dm_token, message)
def sendC2dmToUser(self, irssiuser, message): logging.debug("Sending c2dm message to user %s" % irssiuser.user_name) tokens = C2dmToken.all() tokens.ancestor(irssiuser.key()) tokensList = tokens.fetch(10) for token in tokensList: if token.enabled: self.sendC2dm(token, message)
def handle(self, user): logging.info("Wiping everything for user %s" % user.user_id) query = C2dmToken.all() query.ancestor(user) db.delete(query) query = Message.all() query.ancestor(user) db.delete(query) query = AuthKey.all() query.ancestor(user) db.delete(query) user.delete()
def handle(self, user, array): logging.info("SettingsHandler.handle()") newToken = array["RegistrationId"] tokens = C2dmToken.all() tokens.ancestor(user.key()) tokens.filter("c2dm_token =", newToken) t = tokens.get() if not t: logging.debug("Adding new token: " + newToken) tokenToAdd = C2dmToken(parent = user.key()) tokenToAdd.c2dm_token = newToken tokenToAdd.enabled = bool(int(array["Enabled"])) tokenToAdd.name = array["Name"] tokenToAdd.put() else: logging.debug("Updating token: " + newToken) t.enabled = bool(int(array["Enabled"])) t.name = array["Name"] t.put()