def on_created(self, member): # In case the POSTed atom entry had the # app:control/app:draft set to 'yes' # Then we don't want the recipe to appear into the # public feed. if not member.draft: public = transform_member_resource(member) if public: member.collection.feed_handler.add(public) path = os.path.join(self.member_type.params['blog_entry_path'], member.media_id) servdoc = member.collection.workspace.service.service with self.lock: update_entry_page(servdoc, public, path) update_collection_page(servdoc, member.collection.feed_handler.public_feed, member.collection.name_or_id) atom_to_rss(member.collection.feed_handler.public_feed, member.collection.name_or_id) update_category_list(public.xml_root) manager = QueueManager.get_manager() handler = manager.get_handler(self.qid) if handler: n = Notification(u'create') categories = member.atom.get_children('category', ATOM10_NS) for cat in categories: n.categories.append(Category(cat.get_attribute_value('term'), cat.get_attribute_value('scheme'), cat.get_attribute_value('label'))) links = member.atom.get_children('link', ATOM10_NS) for link in links: n.links.append(Link(link.get_attribute_value('href'), link.get_attribute_value('rel'), link.get_attribute_value('type'))) authors = member.atom.get_children('author', ATOM10_NS) for author in authors: name = author.get_child('name', ATOM10_NS) if name: name = name.xml_text else: name = None uri = author.get_child('uri', ATOM10_NS) if uri: uri = uri.xml_text else: uri = None email = author.get_child('email', ATOM10_NS) if email: email = email.xml_text else: email = None n.authors.append(Author(name, uri, email)) m = PushMessage() m.request_id = str(time.time()) m.qid = self.qid m.payload = b64encode(n.xml()) handler.process(m)
def on_deleted(self, member): member.collection.feed_handler.remove(member.atom) with self.lock: path = os.path.join(self.member_type.params['blog_entry_path'], member.media_id) try: os.unlink(path) except OSError: pass update_collection_page(member.collection.workspace.service.service, member.collection.feed_handler.public_feed, member.collection.name_or_id) atom_to_rss(member.collection.feed_handler.public_feed, member.collection.name_or_id) manager = QueueManager.get_manager() handler = manager.get_handler(self.qid) if handler: n = Notification(u'delete') categories = member.atom.get_children('category', ATOM10_NS) for cat in categories: n.categories.append(Category(cat.get_attribute_value('term'), cat.get_attribute_value('scheme'), cat.get_attribute_value('label'))) links = member.atom.get_children('link', ATOM10_NS) for link in links: n.links.append(Link(link.get_attribute_value('href'), link.get_attribute_value('rel'), link.get_attribute_value('type'))) authors = member.atom.get_children('author', ATOM10_NS) for author in authors: name = author.get_child('name', ATOM10_NS) if name: name = name.xml_text else: name = None uri = author.get_child('uri', ATOM10_NS) if uri: uri = uri.xml_text else: uri = None email = author.get_child('email', ATOM10_NS) if email: email = email.xml_text else: email = None n.authors.append(Author(name, uri, email)) m = PushMessage() m.request_id = str(time.time()) m.qid = self.qid m.payload = b64encode(n.xml()) handler.process(m)