# HG changeset patch
# User paulb
# Date 1191623528 0
# Node ID 4e4acfa9aeaa5cf144a4ad58ec05e460e1e1622f
# Parent 6bf5e8aaddd5af8d6de42197ab0fde2feb47dd69
[project @ 2007-10-05 22:32:08 by paulb]
Updated the build tools to support separate WebStack package and tools
locations, and root resources such as JSP files.
Added an example deployment descriptor for JSP-related applications.
diff -r 6bf5e8aaddd5 -r 4e4acfa9aeaa tools/JavaServlet/jsp-web.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/JavaServlet/jsp-web.xml Fri Oct 05 22:32:08 2007 +0000
@@ -0,0 +1,43 @@
+
+
+
+
+ WebStack application
+
+ An application based on WebStack and JSP resources
+
+
+
+ pyservlet
+ uk.org.boddie.webstack.util.PyServlet
+
+ python.home
+ %s
+
+
+ python.path
+ %s
+
+
+ python.cachedir
+ %s
+
+
+ servlet.file
+ %s
+
+
+
+
+ jsp
+ /test.jsp
+
+
+
+ pyservlet
+ /test/*
+
+
+
diff -r 6bf5e8aaddd5 -r 4e4acfa9aeaa tools/JavaServlet/webstack_java_build.py
--- a/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:30:40 2007 +0000
+++ b/tools/JavaServlet/webstack_java_build.py Fri Oct 05 22:32:08 2007 +0000
@@ -75,14 +75,17 @@
def get_appname(handler):
return os.path.split(os.path.splitext(handler)[0])[1]
-def make_app(handler, webstack_home, jython_cachedir, web_xml_template_name, packages):
+def make_app(handler, root_resources, webstack_tools_home, webstack_package_home,
+ jython_cachedir, web_xml_template_name, packages, libraries):
"""
- Make the application directory from the given 'handler', the 'webstack_home'
- where the WebStack package can be found, the 'jython_cachedir' where Jython
- classes are cached, the deployment descriptor with the given
- 'web_xml_template_name', and the specified 'packages' (locations of
- application packages).
+ Make the application directory from the given 'handler' and
+ 'root_resources', the 'webstack_tools_home' where the tools directory is
+ found, the 'webstack_package_home' where the WebStack package is found, the
+ 'jython_cachedir' where Jython classes are cached, the deployment descriptor
+ with the given 'web_xml_template_name', and the specified 'packages'
+ (locations of application packages) and 'libraries' (locations of required
+ library files).
"""
appname = get_appname(handler)
@@ -101,12 +104,12 @@
# Copy the special PyServlet classes.
- copy_directory(os.path.join(webstack_home, "tools", "JavaServlet", "classes"),
+ copy_directory(os.path.join(webstack_tools_home, "tools", "JavaServlet", "classes"),
os.path.join(appname, "WEB-INF"))
# Copy the WebStack package.
- copy_directory(os.path.join(webstack_home, "WebStack"),
+ copy_directory(os.path.join(webstack_package_home, "WebStack"),
os.path.join(appname, "WEB-INF", "jython"))
# Copy the application packages.
@@ -114,11 +117,25 @@
for appdir in packages:
copy_directory(appdir, os.path.join(appname, "WEB-INF", "jython"))
+ # Copy the libraries.
+
+ if libraries:
+ for library in libraries:
+ library_dir, library_name = os.path.split(library)
+ library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
+ copy_file(library, library_dest)
+
# Copy the handler.
handler_filename = os.path.split(handler)[1]
copy_file(handler, os.path.join(appname, handler_filename))
+ # Copy the root resources.
+
+ for root_resource in root_resources:
+ root_resource_filename = os.path.split(root_resource)[1]
+ copy_file(root_resource, os.path.join(appname, root_resource_filename))
+
# Find additional Jython paths.
jython_paths = []
@@ -135,7 +152,7 @@
# Configure the deployment descriptor.
- f = open(os.path.join(webstack_home, "tools", "JavaServlet", web_xml_template_name))
+ f = open(os.path.join(webstack_tools_home, "tools", "JavaServlet", web_xml_template_name))
web_xml = f.read()
f.close()
web_xml = web_xml % (jython_home, jython_path, jython_cachedir, handler_filename)
@@ -148,15 +165,32 @@
if __name__ == "__main__":
import sys
- if len(sys.argv) < 5:
+ if len(sys.argv) < 8:
+ print "Syntax:"
+ print
+ print "jython webstack_java_build.py [ ... ] \\"
+ print " --webstack \\"
+ print " [ --libraries ... ]"
+ print
print "Please specify..."
print
print "The location of the application handler. For example:"
print
print " .../WebStack-x.y/examples/JavaServlet/SimpleApp.py"
print
- print "The location of the WebStack package distribution or where WebStack"
- print "documentation and extras have been installed. For example:"
+ print "Any other top-level resources, such as JSP templates. For example:"
+ print
+ print " .../WebStack-x.y/examples/JavaServlet/test.jsp"
+ print
+ print "After the --webstack marker, the details of the WebStack distribution"
+ print "are required, such as..."
+ print
+ print "The location of the WebStack package distribution. For example:"
+ print
+ print " .../WebStack-x.y"
+ print " /usr/lib/python2.4/site-packages"
+ print
+ print "The location of the WebStack tools have been installed. For example:"
print
print " .../WebStack-x.y"
print " /usr/share/doc/python2.4-webstack"
@@ -168,6 +202,8 @@
print "The name of the deployment descriptor template. For example:"
print
print " web.xml"
+ print " jsp-web.xml"
+ print " protected-web.xml"
print
print "The location of the application packages. For example:"
print
@@ -178,28 +214,36 @@
print
print " $CATALINA_HOME/common/lib/activation.jar"
print " $CATALINA_HOME/common/lib/mail.jar"
+ print
+ print "With Apache Tomcat 4.1.x, activation.jar and mail.jar are usually"
+ print "required."
sys.exit(1)
- handler, webstack_home, jython_cachedir, web_xml = sys.argv[1:5]
+ webstack_index = sys.argv.index("--webstack")
try:
libraries_index = sys.argv.index("--libraries")
- packages = sys.argv[5:libraries_index]
- libraries = sys.argv[libraries_index+1:]
except ValueError:
- packages = sys.argv[5:]
- libraries = []
+ libraries_index = len(sys.argv)
+
+ print "Handler, root resources are..."
+ handler, root_resources = sys.argv[1], sys.argv[2:webstack_index]
+ print handler, root_resources
+
+ print "WebStack distribution details are..."
+ webstack_package_home, webstack_tools_home, jython_cachedir, web_xml = sys.argv[webstack_index+1:webstack_index+5]
+ print webstack_package_home, webstack_tools_home
+
+ print "Packages..."
+ packages = sys.argv[webstack_index+5:libraries_index]
+ print packages
+
+ print "Libraries..."
+ libraries = sys.argv[libraries_index+1:]
+ print libraries
print "Making application directory..."
- make_app(handler, webstack_home, jython_cachedir, web_xml, packages)
-
- if libraries:
- print "Copying additional libraries..."
- appname = get_appname(sys.argv[1])
- for library in libraries:
- library_dir, library_name = os.path.split(library)
- library_dest = os.path.join(appname, "WEB-INF", "lib", library_name)
- copy_file(library, library_dest)
+ make_app(handler, root_resources, webstack_package_home, webstack_tools_home, jython_cachedir, web_xml, packages, libraries)
print "Now copy or move the application directory to your servlet container."