コード例 #1
0
ファイル: blog.py プロジェクト: 3rdandUrban-dev/Nuxleus
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
コード例 #2
0
ファイル: event.py プロジェクト: 3rdandUrban-dev/Nuxleus
    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)