# HG changeset patch # User paulb # Date 1113049948 0 # Node ID e870f9802b372a90613aa8f3548a39fbc327751e # Parent bc524d856696f11ad82a33554760fc36830b6e34 [project @ 2005-04-09 12:32:28 by paulb] Improved and expanded the deployment documentation. diff -r bc524d856696 -r e870f9802b37 docs/deploying-applications.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/deploying-applications.html Sat Apr 09 12:32:28 2005 +0000 @@ -0,0 +1,87 @@ + + + + + Deploying an Application + + + + + +

Deploying an Application

+ +

Here is a table which summarises the steps required to actually deploy +your application in the different server environments or frameworks:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FrameworkDeployment Steps
BaseHTTPRequestHandlerJust run the adapter code
CGIDeclare a script directory in the Web server
+ Deploy application code in the specified script directory
+ Restart the Web server
Java ServletUse the supplied script in tools/JavaServlet and + follow your servlet container's instructions
mod_pythonDeclare a handler directory in Apache
+ Deploy application code in the specified handler directory
+ Restart Apache
TwistedJust run the adapter code
WebwareCopy or symbolically link your application code directory to reside + alongside other Webware plug-ins
+ Configure your application within Webware
+ Start Webware
WSGI(Follow the instructions for CGI - this may change in future.)
ZopeCopy or symbolically link your application code directory to reside + in the Zope Products directory
+ Configure etc/zope.conf
+ Start Zope
+ Add a product instance for your application at the desired location + in the Zope filesystem
+ +

More Information

+ +

Notes on each server environment can be found in subdirectories within the +docs directory:

+ + + diff -r bc524d856696 -r e870f9802b37 docs/deploying.html --- a/docs/deploying.html Fri Apr 08 23:11:22 2005 +0000 +++ b/docs/deploying.html Sat Apr 09 12:32:28 2005 +0000 @@ -1,6 +1,6 @@ + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Deploying a WebStack Application @@ -9,70 +9,87 @@ -

Deploying a WebStack Application
-

+

Deploying a WebStack Application

+ +

The process of deploying a WebStack application should be as +straightforward as taking some adapter or "glue" code and either running it +or using the deployment processes of the server environment or framework in +which the application will be living.

+ +

The Adapter Code

-

When deploying an application, it is possible to use a one-shot deploy -function for certain frameworks. The deploy function is called -as follows:

-
deploy(resource)
-deploy(resource, authenticator) # where authenticators are used
+

What adapter or "glue" code does is to set up your applications main +resource object and to hook that object up with the underlying server +environment. It typically looks something like this:

+
from WebStack.Adapters.CGI import deploy    # import the support for the server environment
+from MyApplication import MyResource        # import the main resource class
+deploy(MyResource())                        # connect a resource object to the server environment
-

For some frameworks, an address may be specified:

-
deploy(resource, address=(host_string, port_integer))
-deploy(resource, authenticator, address=(host_string, port_integer))
+

Unfortunately, not all server environments can be connected up with +applications this easily. Some environments require special classes and +functions to be defined in the adapter code in order for the applications to +be properly integrated into the environments. Here is a summary which +indicates the server environments or frameworks which need most work:

- +
- + + - + + - + + + + + + + + + + + + - + + + + + + + - + + + + + + +
FrameworkAddress InformationAdapter Code RequirementsDeployment Process
BaseHTTPRequestHandlerSupportedSimple - see aboveRun the adapter code directly
CGIIgnoredSimple - see aboveWeb server runs the adapter code
Java ServletMust subclass HttpServletApplication must be deployed using supplied tools
mod_pythonMust implement handler functionWeb server runs the adapter code (which must be declared within + Apache)
TwistedSupported (host_string is ignored)Simple - see aboveRun the adapter code directly
Webware<= 0.8.1: Must implement InstallInWebKit + function
+ > 0.8.1: Simple, but must provide a urlParser + object
Application must be deployed within WebKit
WSGIIgnoredSimple - see aboveWeb server runs the adapter code
ZopeMust provide lots of Zope administative classes and functionsApplication must be deployed within Zope
-

The other frameworks do not support the deploy function due to the way -applications are typically integrated into the various server mechanisms:

- - - - - - - - - - - - - - - - - - - - - - - - -
FrameworkDeployment Details
JavaServletApplications are packaged specially
ModPythonApplications must expose certain functions
WebwareApplications must expose certain classes
ZopeApplications must expose certain functions/classes
+

The Deployment Process

+ diff -r bc524d856696 -r e870f9802b37 docs/pythonpath.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/pythonpath.html Sat Apr 09 12:32:28 2005 +0000 @@ -0,0 +1,61 @@ + + + + + Getting PYTHONPATH Right + + + + + +

Getting PYTHONPATH Right

+ +

When deploying your application, it is essential that it has access to all +the necessary libraries and packages that it uses. If such libraries and +packages were installed using the standard setup.py program, +then you may only need to worry about the application itself being found by +Python.

+ +

Running Adapters Directly

+ +

For those server environments where you can just run the adapter code +(BaseHTTPRequestHandler, Twisted), you can choose to specify the +PYTHONPATH on the command line when you run the code. Here is an +example of this (using bash on GNU/Linux or UNIX +distributions):

+
PYTHONPATH=.:examples/Common python examples/BaseHTTPRequestHandler/SimpleApp.py
+ +

Adapters Run by the Web Server

+ +

For those server environments where the Web server itself runs the adapter +code (CGI, mod_python, WSGI), you may need to either configure the Web server +to alter the PYTHONPATH, if possible, or to add some extra lines +in the adapter code to change Python's sys.path variable. Here +is an example of this:

+
sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")
+ +

Configuring PYTHONPATH in Java Servlet Containers

+ +

In servlet container deployments, all required libraries and packages are +typically bundled with the application itself. Since this bundling process is +usually very inconvenient, a script has been included in the +tools/JavaServlet directory to make it slightly easier.

+ +

Configuring PYTHONPATH in Webware

+ +

Since Webware's WebKit runs as a separate process, it is possible to +specify PYTHONPATH on the command line when you start that +process. Here is an example of this (using bash on GNU/Linux or +UNIX distributions):

+
cd WebKit
+PYTHONPATH=/home/paulb/Software/Python/WebStack/examples/Common ./AppServer
+ +

Configuring PYTHONPATH in Zope

+ +

In Zope's etc/zope.conf file, path directives +can be used to indicate the location of various resources. Here is an example +of this:

+
path /home/paulb/Software/Python/WebStack/examples/Common
+ + diff -r bc524d856696 -r e870f9802b37 docs/writing-adapters.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docs/writing-adapters.html Sat Apr 09 12:32:28 2005 +0000 @@ -0,0 +1,67 @@ + + + + + Writing Adapters + + + + + +

Writing Adapters

+ +

Depending on how "simple" the adapter code is allowed to be for a given +server environment (see the table for a +summary), you will either need to write a small piece of code which +initialises and deploys your application, or to produce a more complicated +piece of code which satisfies some more demanding server requirements.

+ +

Simple Adapters - Using the deploy Function

+ +

When deploying an application, it is possible to use a one-shot deployment +function for BaseHTTPRequestServer, CGI, Twisted and WSGI. The +deploy function is called as follows:

+
deploy(resource)
+deploy(resource, authenticator) # where authenticators are used
+ +

For some frameworks, an address may be specified:

+
deploy(resource, address=(host_string, port_integer))
+deploy(resource, authenticator, address=(host_string, port_integer))
+ +

Here is a summary of which frameworks require address information:

+ + + + + + + + + + + + + + + + + + + + + + + + +
FrameworkAddress Information
BaseHTTPRequestHandlerSupported
CGIIgnored
TwistedSupported (host_string is ignored)
WSGIIgnored
+ +

Complicated Adapters - Providing Framework-Specific Objects

+ +

The remaining frameworks (Java Servlet, mod_python, Webware and Zope) do +not support the deploy function due to the way applications are +typically integrated into the various server mechanisms. In these cases, it +may be worth investigating the examples provided and using their adapter code +as a template for the code for your own applications.

+ +