The configuration files are written in XML and are very simple. PyWork works with 3 configuration files (you would normally use 2). These are read on the first request the server receives and on every request if specified by the user in pywork.xml.
This the global configuration file for PyWork. Below is the XML schema: (included in the distribution under conf/pywork.xsd)
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:element name="pywork" type="PyWorkType"/> <xsd:complexType name="PyWorkType"> <xsd:sequence> <xsd:element name="global" type="GlobalType" maxOccurs="unbounded" minOccurs="0"/> <xsd:element name="except" type="ExceptType" maxOccurs="unbounded" minOcccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="GlobalType"> <xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="value" use="required" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="ExceptType"> <xsd:attribute name="class" use="required" type="xsd:string"/> <xsd:attribute name="action" use="required" type="xsd:string"/> </xsd:complexType>
In the pywork.xml file there are a set some global names interpreted by PyWork:
Other names specified may be used for configuration vars in the other configuration files, or for your application to get via the Action api. An example would be:
<pywork> <global name="reload" value="1"/> <global name="PETSTORE" value="/petstore"/> <global name="PETSTORE_TEMPLATES" value="/apps.py/petstore/web"/> </pywork>
Also, (from version 0.4) two new features were added: A new directive, except. This element has a class and and action attribute that tells PyWork to redirect to a specified action uri if that exception is raised. It is handy to define your own exception handling pages. And the use of PythonOption of mod_python. You can specify replacable configuration directives that include PythonOption values. For example, if you have a PythonOption MYCONF myval directive in apache you could use it in a value attribute by specifying:
<global name="myconf" value="{$MYCONF}"/>
This file is the most important configuration file. It defines the mapping between the URLs and your PyWork Action classes. Bellow is the XML schema: (included in the distribution under conf/pywork-map.xsd)
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:element name="pywork-map" type="PyWorkMapType"/> <xsd:complexType name="PyWorkMapType"> <xsd:sequence> <xsd:element name="action" type="ActionType" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ActionType"> <xsd:sequence> <xsd:element name="alias" type="ActionAliasType" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="view" type="ActionViewType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="module" use="required" type="xsd:string"/> <xsd:attribute name="class" use="required" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="ActionViewType"> <xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="file" use="required" type="xsd:string"/> <xsd:attribute name="view-handler" use="optional" type="xsd:string"/> <xsd:attribute name="content-type" use="optional" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="ActionAliasType"> <xsd:attribute name="name" use="required" type="xsd:string"/> </xsd:complexType> </xsd:schema>
Here you will specify the URLs mapping. Here is a human description of the file:
For each url in your site (you wish to process with PyWork) you must define an "action" xml element where the full virtual path of the uri must be specified in name. For example http://mysite.mydomain/myapp/login.action , would be "/myapp/login.action". Normally you would specify "/myapp/"as a global name in pywork.xml, like
... <global name="MYAPP" value="/myapp/"/> ...
And then in the action name you could simple write:
... <action name="${MYAPP}/login.action" ... ...
Furthermore, you may specify aliases to your action. Using the "alias"XML element, with the name attribute.
For each action you would normally specify one or more views to process. This views are selected with the name depending on the result of your action execute method. See the Action chapter for more information
This the views configuration file for PyWork. Below is the XML schema: (included in the distribution under conf/pywork-views.xsd)
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:element name="pywork-views" type="PyWorkViewsType"/> <xsd:complexType name="PyWorkViewsType"> <xsd:sequence> <xsd:element name="view-handler" type="ViewHandlerType" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ViewHandlerType"> <xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="class" use="required" type="xsd:string"/> <xsd:attribute name="module" use="required" type="xsd:string"/> </xsd:complexType> </xsd:schema>
Here you will specify any specialized View Handlers you have written. This is the human description of the file:
Normally you would write a View Handler if you want to implement your specialized templating system.
See About this document... for information on suggesting changes.