Source

Webware / WebKit / Docs / Developing.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.8: http://docutils.sourceforge.net/" />
<title>Developing Webware</title>
<link rel="stylesheet" href="../../Docs/Doc.css" type="text/css" />
</head>
<body>
<div class="document" id="developing-webware">
<h1 class="title">Developing Webware</h1>

<p>This document should outline the details you need to understand
Webware and WebKit internals, and assist in becoming a more advanced
Webware programmer.</p>
<div class="section" id="style-guidelines">
<h1>Style Guidelines</h1>
<p>Webware developers are requested to observe the rules defined
in the <a class="reference external" href="../../Docs/StyleGuidelines.html">Webware Style Guidelines</a>.</p>
</div>
<div class="section" id="creating-plugins">
<h1>Creating Plugins</h1>
<p>Each plugin is a Python Package.  WebKit finds plugins using the
<tt class="docutils literal">PlugIns</tt> and <tt class="docutils literal">PluginDirs</tt> -- see <a class="reference external" href="Configuration.html#appserver-config">Configuration</a>.  See also the
<a class="reference external" href="http://www.python.org/doc/current/tut/node8.html#SECTION008400000000000000000">Python tutorial on packages</a> and the <tt class="docutils literal">PlugIn.py</tt> doc string.</p>
<p>A plug-in must have <tt class="docutils literal">__init__.py</tt> and <tt class="docutils literal">Properties.py</tt> files.
You can disable a specific plug-in by placing a <tt class="docutils literal">dontload</tt> file in it.</p>
<p><tt class="docutils literal">__init.py__</tt> must contain a function like:</p>
<pre class="literal-block">
def InstallInWebKit(appServer):
    pass
</pre>
<p>The function doesn't need to do anything, but this gives it the
opportunity to do something with the AppServer -- for instance, the
PSP plugin uses AppServer.addServletFactory to add a handler for <tt class="docutils literal">.psp</tt>
files.</p>
<p>The <tt class="docutils literal">Properties.py</tt> file should contain a number of assignments:</p>
<pre class="literal-block">
name = &quot;Plugin name&quot;
version = (1, 0, 0)
docs = [{'name': 'Quick Start Guide', 'file': 'QuickStart.html'},
        {'name': 'Reference Guide, 'file': 'Reference.html'}]
status = 'beta'
requiredPyVersion = (2, 4, 0)
requiredOpSys = 'posix'
synopsis = &quot;&quot;&quot;A paragraph-long description of the plugin&quot;&quot;&quot;
WebKitConfig = {
    'examplePages': [
        'Example1',
        'ComplexExample',
        ]
    }
def willRunFunc():
    if softwareNotInstalled:
        return &quot;some message to that effect&quot;
    else:
        return None
</pre>
<p>The documents (e.g. <tt class="docutils literal">QuickStart.html</tt>) should be located in a <tt class="docutils literal">Docs/</tt>
subdirectory.  The example pages go in an <tt class="docutils literal">Examples/</tt> subdirectory.</p>
<p>A plugin who's <tt class="docutils literal">requiredPyVersion</tt> or <tt class="docutils literal">requiredOpSys</tt> aren't satisfied will
simply be ignored.  <tt class="docutils literal">requiredOpSys</tt> should be something returned by
<tt class="docutils literal">os.name</tt>, like <tt class="docutils literal">posix</tt> or <tt class="docutils literal">nt</tt>.  Or you can define a function
<tt class="docutils literal">willRunFunc</tt> to test.  If there aren't requirements you can leave these
variables and functions out.</p>
</div>
</div>
</body>
</html>