WebStack

docs/pythonpath.html

401:ca2a40e20036
2005-07-16 paulb [project @ 2005-07-16 20:32:56 by paulb] Enhanced the PYTHONPATH handling to respect the existing definition.
     1 <?xml version="1.0" encoding="iso-8859-1"?>     2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     3        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     4 <html xmlns="http://www.w3.org/1999/xhtml">     5 <head>     6   <title>Getting PYTHONPATH Right</title>     7   <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />     8   <link href="styles.css" rel="stylesheet" type="text/css" />     9 </head>    10     11 <body>    12 <h1>Getting PYTHONPATH Right</h1>    13     14 <p>When deploying your application, it is essential that it has access to all    15 the necessary libraries and packages that it uses. If such libraries and    16 packages were installed using the standard <code>setup.py</code> program,    17 then you may only need to worry about the application itself being found by    18 Python.</p>    19     20 <h2>Running Adapters Directly</h2>    21     22 <p>For those server environments where you can just run the adapter code    23 (BaseHTTPRequestHandler, Twisted), you can choose to specify the    24 <code>PYTHONPATH</code> on the command line when you run the code. Here is an    25 example of this (using <code>bash</code> on GNU/Linux or UNIX    26 distributions):</p>    27 <pre>PYTHONPATH=.:examples/Common python examples/BaseHTTPRequestHandler/SimpleApp.py</pre>    28     29 <h2>Adapters Run by the Web Server</h2>    30     31 <p>For those server environments where the Web server itself runs the adapter    32 code (CGI, mod_python, WSGI), you may need to either configure the Web server    33 to alter the <code>PYTHONPATH</code>, if possible, or to add some extra lines    34 in the adapter code to change Python's <code>sys.path</code> variable. Here    35 is an example of this:</p>    36 <pre>sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")</pre>    37     38 <h2>Configuring PYTHONPATH in Java Servlet Containers</h2>    39     40 <p>In servlet container deployments, all required libraries and packages are    41 typically bundled with the application itself. Since this bundling process is    42 usually very inconvenient, a script has been included in the    43 <code>tools/JavaServlet</code> directory to make it slightly easier.</p>    44     45 <h2>Configuring PYTHONPATH in Webware</h2>    46     47 <p>Since Webware's WebKit runs as a separate process, it is possible to    48 specify <code>PYTHONPATH</code> on the command line when you start that    49 process. Here is an example of this (using <code>bash</code> on GNU/Linux or    50 UNIX distributions):</p>    51 <pre>cd WebKit    52 PYTHONPATH=/home/paulb/Software/Python/WebStack/examples/Common ./AppServer</pre>    53     54 <h2>Configuring PYTHONPATH in Zope</h2>    55     56 <p>In Zope's <code>etc/zope.conf</code> file, <code>path</code> directives    57 can be used to indicate the location of various resources. Here is an example    58 of this:</p>    59 <pre>path /home/paulb/Software/Python/WebStack/examples/Common</pre>    60 </body>    61 </html>