Manual:Pywikibot/Flow

From MediaWiki.org
Jump to navigation Jump to search

Pywikibot includes basic support for Flow, the new discussion framework for Wikimedia wikis. This support will evolve over time as more features are added.

Examples[edit]

Determining if a page is a Flow board[edit]

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
page = pywikibot.Page(site, 'Talk:Sandbox')
if page.is_flow_page():
    board = pywikibot.flow.Board(page)

Loading topic titles[edit]

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Board(site, 'Talk:Sandbox')
topic_titles = []
for topic in board.topics():
    topic_titles.append(topic.root.get())

Creating new topics[edit]

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Board(site, 'Talk:Sandbox')
title = 'New topic'
content = 'This is a new topic.'
topic = board.new_topic(title, content)

Replying to topics[edit]

import pwb  # only needed if you haven't installed the framework as side-package
import pywikibot
import pywikibot.flow
site = pywikibot.Site('mediawiki', 'mediawiki')
board = pywikibot.flow.Topic(site, 'Topic:whatever')
content = 'This is a new reply.'
reply = topic.reply(content)


If you need more help on setting up your Pywikibot visit the #pywikibot IRC channel connect or pywikibot@ mailing list.