def _after_subscription_add(self, username): """ Creates rabbitmq bindings after new subscription """ if self.get("notifications", False): notifier = RabbitNotifications(self.request) notifier.bind_user_to_context(self, username)
def modifyContext(self, properties): """Update the user object with the given properties""" # If updating the twitterUsername, get its Twitter ID if properties.get("twitterUsername", None): api = get_twitter_api(self.request.registry) properties["twitterUsernameId"] = get_userid_from_twitter(api, properties["twitterUsername"]) self.updateFields(properties) if self.get("twitterUsername", None) is None and self.get("twitterUsernameId", None) is not None: del self["twitterUsernameId"] # someone changed notifications settings for this context if "notifications" in properties: notifier = RabbitNotifications(self.request) if self.get("notifications", False): for user in self.subscribedUsers(): notifier.bind_user_to_context(self, user["username"]) else: for user in self.subscribedUsers(): notifier.unbind_user_from_context(self, user["username"]) if "url" in properties: self["hash"] = sha1(self["url"]).hexdigest() self.save()