cogAdds ability to write scripts in Python in wiki pages
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise, XWiki Enterprise Manager

Description

This is a shortcut for Script Macro equivalent to {{script language="python"}} to execute python scripts based on any JSR-223 Python provider like Jython.

Usage

{{python}}
print "Hello World"
{{/python}}

Parameters definition

See the Script Macro for details.

Example

{{python}}
print "Hello World"
{{/python}}

Result

Hello World

External Libraries

External libraries can be used with XWiki by adding them to the proper classpath and importing them.

In order to determine what your classpath and pyclasspath locations are, use the following code:

{{python}}
import sys
print sys.path
{{/python}}

Once you have the proper location, you can install your libraries through your normal means (pip, dnf, apt-get, etc), and copy the library to the classpath/pyclasspath locations respectively.  After installation, a restart is required to load the new library/libraries.

Caveats

Though you can add additional libraries, there may be conflicts that you have to work through to be able to use that library with Xwiki.  An example is the 'boto' library, which conflicts due to function and class definitions that overlap.

Tags:
    

Get Connected