Extension:Piwo

From MediaWiki.org
Jump to navigation Jump to search

Extension

The Piwo extension allows executing of Python scripts on MediaWiki (Python In, Wikitext Out).

Warning Warning: Do not use this extension on production wikis! This extension is still in development and no environment control exists yet besides the Gram namespace being protected by default.

Installation[edit]

  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'Piwo' );
    $wgGroupPermissions['bureaucrat']['gram-edit'] = true;
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage[edit]

This extension defines a custom namespace, "Gram", that stores Python scripts. Editing the Gram namespace requires the gram-edit right. To invoke a script, use the following parser function:

{{#piwo:name of script, without "Gram:"|parameter1|parameter2|...}}

In the Python script, the parameters can be accessed through mw.argv (no import is needed); an extra function, mw.hsc is provided as an equivalent to PHP's htmlspecialchars.

Any and all of the Python standard library can be imported, as of January 2018.

See Also[edit]