Ejemplo n.º 1
0
    def get_recent_topics(self, login_bundle, atom_tag, count):
        """Get count topics in most-recent order from atom_tag.

        Parameters:
            login_bundle: login_bundle from login()
            atom_tag: group's atom_tag
            count: int

        Returns:
            array of:
                (see return description of item_data())
        """
        user = self._check_login(login_bundle)
        blog = self._get_blog(user, atom_tag)
        items = blog.recent_items(count=count)

        result = []
        for item in items:
            api = BlogItemAPI(item, user)
            result.append(api.get_item([]))
        return result
Ejemplo n.º 2
0
    def item_data(self, login_bundle, atom_tag, fields):
        """Return struct containing requested fields for specified item.

        Parameters:
            atom_tag:        atom_tag of item.
            fields: array of requested information:
                feedback:   extended feedback information
                text:       full raw (reStructuredText) text
                html:       html of item text

        Returns:
            struct of requested information (fields) as well as:
                atom_tag:       atom_tag of item
                title:          title of item
                author:         author of item
                created:        date item created
                modified:       date item modifed (only if modified)
                feedback_score: feedback score of item
                comment_count:  number of comments (only if item is a discussion topic)
                revision_count: number of revisions (only if item is a workspace page)

        For example, if fields is an empty array, the returned struct will
        include all of the above fields, but not the detailed feedback, nor
        the actual text of the item itself.
        """
        user = self._check_login(login_bundle)
        obj = lookup_atom_id(atom_tag)
        if not obj:
            raise xmlrpclib.Fault(FAULT_INVALID_ITEM, 'Invalid atom_tag.')

        api = adapt(obj, IItemAPI, None)
        if api:
            api.set_user(user)
            return api.get_item(fields)

        raise xmlrpclib.Fault(FAULT_INVALID_ITEM, 'Could not dispatch to API.')