<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>HelpOnInstalling/TwistedWeb</title></articleinfo><section><title>Using MoinMoin with Twisted</title><para><ulink url="http://twistedmatrix.com/trac/wiki">Twisted</ulink> is an event-driven networking framework for many kinds of applications. For <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/MoinMoin#">MoinMoin</ulink> Twisted is used as a web server that just imports <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/MoinMoin#">MoinMoin</ulink> persistently. This has the advantage that the Python interpreter and all Python scripts (including Twisted itself and also <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/MoinMoin#">MoinMoin</ulink>) is only loaded and initialized one time, and that data can be cached in memory from request to request, enhancing the performance of <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/MoinMoin#">MoinMoin</ulink>. </para><itemizedlist><listitem override="none"><para><inlinemediaobject><imageobject><imagedata depth="16" fileref="https://wiki.hcoop.net/moin_static1911/moniker_bt/img/alert.png" width="16"/></imageobject><textobject><phrase>/!\</phrase></textobject></inlinemediaobject> First do <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/HelpOnInstalling/BasicInstallation#">../BasicInstallation</ulink> and <ulink url="https://wiki.hcoop.net/HelpOnInstalling/TwistedWeb/HelpOnInstalling/WikiInstanceCreation#">../WikiInstanceCreation</ulink>. </para></listitem></itemizedlist><para>Besides the general installation you need 3 files:  </para><orderedlist numeration="arabic"><listitem><para>the script <code>/path/to/cgi-dir/mointwisted</code> (see &quot;Starting the server&quot; below) </para></listitem><listitem><para>the webserver script file like <code>mointwisted.py</code> (which needs to be in the same directory where your working directory is). </para></listitem><listitem><para>the configuration file like  <code>/path/to/wikiconfig-dir/wikiconfig.py</code> </para></listitem></orderedlist><section><title>Install Twisted</title><para>First, install Twisted (see URL above). Many Linux distributions have Twisted packages. Please refer to the documentation of Twisted for installation information. </para></section><section><title>Configuring the Twisted server</title><para>Copy the file <code>wiki/server/mointwisted.py</code> to your wiki directory. Edit and adapt the settings to your needs. </para><section><title>System path configuration</title><para>If you did a standard install, and you are not a developer, you probably want to skip this section. Otherwise, you might want to add the path to moin and config file, like that: </para><screen><![CDATA[sys.path.insert(0, '/path/to/moin')
sys.path.insert(0, '/path/to/wikiconfig')]]></screen></section><section><title>Config class options</title><para>If you did a standard install, the default options might be just what you need. Check and change what you like: </para><informaltable><tgroup cols="3"><colspec colname="col_0"/><colspec colname="col_1"/><colspec colname="col_2"/><tbody><row rowsep="1"><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Option</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Default</emphasis> </para></entry><entry colsep="1" rowsep="1"><para> <emphasis role="strong">Comment</emphasis> </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> docs </para></entry><entry colsep="1" rowsep="1"><para> '/usr/share/moin/wiki/htdocs' </para></entry><entry colsep="1" rowsep="1"><para> Path to moin shared files </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> user </para></entry><entry colsep="1" rowsep="1"><para> 'www-data' </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run as this user </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> group </para></entry><entry colsep="1" rowsep="1"><para> 'www-data' </para></entry><entry colsep="1" rowsep="1"><para> If you run as root, the server will run as this group </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> port </para></entry><entry colsep="1" rowsep="1"><para> 8080 </para></entry><entry colsep="1" rowsep="1"><para> Port to serve. To serve a privileged port below 1024 you will have to run as root </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> interfaces </para></entry><entry colsep="1" rowsep="1"><para> <code>['']</code> </para></entry><entry colsep="1" rowsep="1"><para> A list of interfaces the server will listen to. If the list contains the entry <code>''</code> (like for the default configuration), all other entries are ignored and the server will listen to all interfaces. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> logPath </para></entry><entry colsep="1" rowsep="1"><para> 'mointwisted.log' </para></entry><entry colsep="1" rowsep="1"><para> Log file. </para></entry></row><row rowsep="1"><entry colsep="1" rowsep="1"><para> profiler </para></entry><entry colsep="1" rowsep="1"><para> commented python code </para></entry><entry colsep="1" rowsep="1"><para> Useful only if you are a moin developer. </para></entry></row></tbody></tgroup></informaltable></section></section><section><title>Configuring wikiconfig.py</title><para>The sample config file should be just fine. </para><para>Don't change <code>url_prefix_static</code> as the default value is hardcoded in the Twisted server. </para></section><section><title>Starting the server</title><section><title>on Unix</title><para>On GNU/Linux, Mac OS X or another POSIX-like OS, copy <code>wiki/server/mointwisted</code> to your wiki directory. You might want to adapt <code>PYTHONPATH</code> and the path to <code>twistd</code>.  </para><para>Start the server with <code>./mointwisted start</code> and test your wiki at <ulink url="http://localhost:8080/"/>. Stop the server with <code>./mointwisted stop</code>. </para><para>For more options run <code>./mointwisted</code> without arguments. </para><para>If you want to start the server via initscript make sure <code>mointwisted</code> finds <code>montwisted.py</code> on startup!  </para></section><section><title>on Windows</title><para>Copy <code>wiki/server/mointwisted.cmd</code> to your wiki directory. You might have to change the path pointing to the python-scripts directory. </para><para>Double click <code>mointwisted.cmd</code> to start the server. It will create a new terminal window. To stop the server, close the terminal window. </para></section></section></section></article>