Esempio n. 1
0
def setup_apps():
    indexer = setup_indexer()
    service, conf = setup_store()

    initialize_queues(conf)
    
    servdoc = service.service

    update_home_page(servdoc)
    generate_default_resource_not_found(servdoc)
    generate_event_form_page(servdoc)
    update_category_list(E.load(file(os.path.join(base_dir, 'static', 'catlist.atom'), 'r').read()).xml_root)
    
    workspace = service.get_workspace('blog')

    root = Blog(service, indexer)
    root.pub = Service(service)
    
    col = workspace.get_collection('music')
    col.add_indexer(indexer)
    col.reload_members()
    update_collection_page(servdoc, col.feed_handler.public_feed, col.name_or_id)
    
    root.music = Section(col)
    root.pub.music = Store(col, strict=True)
    
    col = workspace.get_collection('event')
    col.add_indexer(indexer)
    col.reload_members()
    update_collection_page(servdoc, col.feed_handler.public_feed, col.name_or_id)
    
    root.event = Event(col)
    root.pub.event = Store(col, strict=True)

    return root, conf
Esempio n. 2
0
 def on_updated(self, member):
     path = os.path.join(self.member_type.params['blog_entry_path'], member.media_id)
     if not member.draft:
         public = transform_member_resource(member)
         if public:
             member.collection.feed_handler.replace(public)
             servdoc = member.collection.workspace.service.service
             
             try:
                 self.lock.acquire()
                 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)
             finally:
                 self.lock.release()
     else:
         member.collection.feed_handler.remove(entry)
         try:
             self.lock.acquire()
             try:
                 os.unlink(path)
             except OSError:
                 pass
             init_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)
         finally:
             self.lock.release()
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
 def on_deleted(self, member):
     """
     On a delete operatuion we simply remove the atom entry
     from the collection feed.
     """
     member.collection.feed_handler.remove(member.atom)
     try:
         self.lock.acquire()
         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)
     finally:
         self.lock.release()
Esempio n. 6
0
 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
             try:
                 self.lock.acquire()
                 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)
             finally:
                 self.lock.release()