0
votes

I use python-redmine and want to get wiki page text, but get error - attribute isn't exists (but text exists), here is my code:

from redmine import Redmine

redmine = Redmine('http://redmine.example.com', username='user', password='1234')
projects = redmine.project.all()

for project in projects:
    print('Project: '+project.name)
    try:
        for page in project.wiki_pages:
            try:
                print('Title: '+page.title)
            except:
                print('Title: none')

            try:
                print('Content: '+page.text)
            except:
                print('Content: none')
            print('\n===========================\n')
    except:
        print('None')

How can I get text from wiki page? Help me pease!

pS: Python 3, python-redmine installed by pip

2

2 Answers

1
votes

You can't get a wiki page text this way because project.wiki_pages returns just a list of all wiki pages available for a project with a few other details. To get a text, author and some other info for a wiki page you have to make a separate call for each wiki page:

from redmine import Redmine

redmine = Redmine('http://redmine.example.com', username='user', password='1234')
projects = redmine.project.all()

for project in projects:
    print('Project: ' + project.name)

    for wiki_page in project.wiki_pages:
        wiki_page_details = redmine.wiki_page.get(wiki_page.title, project_id=project.id)

        print('Title: ' + wiki_page_details.title)
        print('Content: ' + wiki_page_details.text)
        print('\n===========================\n')

This is not very efficient but Python Redmine is just an interface to the Redmine REST API, and Redmine doesn't provide a way to get all information about project wiki pages in one call, so making a separate call for each wiki page is the only way to go.

0
votes

Rails wraps attribute to methods so it is hard to say where you use attribute where it is just a method.

Here you can see that wiki_page has one content and here you can see method definition for text (attribute text belongs to content!).

I don't have experience to work with python-redmine but I can suppose that you need to call page.content.text not page.text. Or fetch page.content some other way.