1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/BaseHTTPRequestHandler/VerySimpleApp.py Sun Apr 24 22:57:36 2005 +0000
1.3 @@ -0,0 +1,11 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +from WebStack.Adapters.BaseHTTPRequestHandler import deploy
1.7 +from VerySimple import VerySimpleResource
1.8 +
1.9 +# Special magic incantation.
1.10 +
1.11 +print "Serving..."
1.12 +deploy(VerySimpleResource())
1.13 +
1.14 +# vim: tabstop=4 expandtab shiftwidth=4
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/examples/CGI/VerySimpleHandler.py Sun Apr 24 22:57:36 2005 +0000
2.3 @@ -0,0 +1,14 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +# NOTE: Path manipulation requires manual customisation.
2.7 +
2.8 +import sys
2.9 +sys.path.append("/home/paulb/Software/Python/WebStack")
2.10 +sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")
2.11 +
2.12 +from WebStack.Adapters.CGI import deploy
2.13 +from VerySimple import VerySimpleResource
2.14 +
2.15 +deploy(VerySimpleResource())
2.16 +
2.17 +# vim: tabstop=4 expandtab shiftwidth=4
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/examples/Common/VerySimple/__init__.py Sun Apr 24 22:57:36 2005 +0000
3.3 @@ -0,0 +1,13 @@
3.4 +#!/usr/bin/env python
3.5 +
3.6 +"A very simple application for test purposes."
3.7 +
3.8 +class VerySimpleResource:
3.9 +
3.10 + "A very simple resource."
3.11 +
3.12 + def respond(self, trans):
3.13 + out = trans.get_response_stream()
3.14 + print >>out, "Hello world."
3.15 +
3.16 +# vim: tabstop=4 expandtab shiftwidth=4
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/examples/JavaServlet/VerySimpleApp.py Sun Apr 24 22:57:36 2005 +0000
4.3 @@ -0,0 +1,15 @@
4.4 +#!/usr/bin/env python
4.5 +
4.6 +from WebStack.Adapters import JavaServlet
4.7 +from VerySimple import VerySimpleResource
4.8 +from javax.servlet.http import HttpServlet
4.9 +
4.10 +class VerySimpleApp(HttpServlet):
4.11 + def __init__(self):
4.12 + HttpServlet.__init__(self)
4.13 + self.dispatcher = JavaServlet.Dispatcher(VerySimpleResource())
4.14 +
4.15 + def service(self, request, response):
4.16 + self.dispatcher.service(request, response)
4.17 +
4.18 +# vim: tabstop=4 expandtab shiftwidth=4
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/examples/ModPython/VerySimpleApp/VerySimpleHandler.py Sun Apr 24 22:57:36 2005 +0000
5.3 @@ -0,0 +1,20 @@
5.4 +#!/usr/bin/env python
5.5 +
5.6 +# NOTE: Path manipulation requires manual customisation.
5.7 +
5.8 +import sys
5.9 +sys.path.append("/home/paulb/Software/Python/WebStack")
5.10 +sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")
5.11 +
5.12 +from WebStack.Adapters import ModPython
5.13 +from VerySimple import VerySimpleResource
5.14 +
5.15 +# NOTE: Not sure if the resource should be maintained in a resource pool.
5.16 +
5.17 +resource = VerySimpleResource()
5.18 +
5.19 +def handler(req):
5.20 + global resource
5.21 + return ModPython.respond(req, resource, handle_errors=0)
5.22 +
5.23 +# vim: tabstop=4 expandtab shiftwidth=4
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/examples/Twisted/VerySimpleApp.py Sun Apr 24 22:57:36 2005 +0000
6.3 @@ -0,0 +1,9 @@
6.4 +#!/usr/bin/env python
6.5 +
6.6 +from WebStack.Adapters.Twisted import deploy
6.7 +from VerySimple import VerySimpleResource
6.8 +
6.9 +print "Serving..."
6.10 +deploy(VerySimpleResource(), handle_errors=0)
6.11 +
6.12 +# vim: tabstop=4 expandtab shiftwidth=4
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/examples/WSGI/VerySimpleHandler.py Sun Apr 24 22:57:36 2005 +0000
7.3 @@ -0,0 +1,14 @@
7.4 +#!/usr/bin/env python
7.5 +
7.6 +# NOTE: Path manipulation requires manual customisation.
7.7 +
7.8 +import sys
7.9 +sys.path.append("/home/paulb/Software/Python/WebStack")
7.10 +sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")
7.11 +
7.12 +from WebStack.Adapters.WSGI import deploy
7.13 +from VerySimple import VerySimpleResource
7.14 +
7.15 +deploy(VerySimpleResource())
7.16 +
7.17 +# vim: tabstop=4 expandtab shiftwidth=4
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/examples/Webware/VerySimpleApp/Properties.py Sun Apr 24 22:57:36 2005 +0000
8.3 @@ -0,0 +1,15 @@
8.4 +#!/usr/bin/env python
8.5 +
8.6 +name = "VerySimple"
8.7 +
8.8 +version = (0, 1, 0)
8.9 +
8.10 +status = "alpha"
8.11 +
8.12 +releaseDate = "?"
8.13 +
8.14 +requiredPyVersion = (2, 2, 0)
8.15 +
8.16 +synopsis = "A very simple WebStack application."
8.17 +
8.18 +# vim: tabstop=4 expandtab shiftwidth=4
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/examples/Webware/VerySimpleApp/__init__.py Sun Apr 24 22:57:36 2005 +0000
9.3 @@ -0,0 +1,25 @@
9.4 +#!/usr/bin/env python
9.5 +
9.6 +"""
9.7 +Webware plug-in code.
9.8 +"""
9.9 +
9.10 +__version__ = "0.1"
9.11 +
9.12 +from WebStack.Adapters.Webware import WebStackServletFactory
9.13 +from VerySimple import VerySimpleResource
9.14 +
9.15 +# NOTE: Initialising a shared resource.
9.16 +
9.17 +resource = VerySimpleResource()
9.18 +
9.19 +def InstallInWebKit(appServer):
9.20 + global resource
9.21 + app = appServer.application()
9.22 +
9.23 + # NOTE: Allow .verysimple files only. Really, we'd like any kind of file, but
9.24 + # NOTE: that would severely undermine the servlet factory concept.
9.25 +
9.26 + app.addServletFactory(WebStackServletFactory(app, resource, [".verysimple"], handle_errors=0))
9.27 +
9.28 +# vim: tabstop=4 expandtab shiftwidth=4
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/examples/Webware/VerySimpleContext/__init__.py Sun Apr 24 22:57:36 2005 +0000
10.3 @@ -0,0 +1,15 @@
10.4 +#!/usr/bin/env python
10.5 +
10.6 +"""
10.7 +Webware context for the VerySimple application (post Webware 0.8.1).
10.8 +"""
10.9 +
10.10 +from WebStack.Adapters.Webware import WebStackURLParser
10.11 +from VerySimple import VerySimpleResource
10.12 +
10.13 +# NOTE: Initialising a shared resource.
10.14 +
10.15 +resource = VerySimpleResource()
10.16 +urlParser = WebStackURLParser(resource, handle_errors=0)
10.17 +
10.18 +# vim: tabstop=4 expandtab shiftwidth=4
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/examples/Zope/VerySimpleProduct/__init__.py Sun Apr 24 22:57:36 2005 +0000
11.3 @@ -0,0 +1,51 @@
11.4 +#!/usr/bin/env python
11.5 +
11.6 +"A very simple Zope product."
11.7 +
11.8 +from VerySimple import VerySimpleResource
11.9 +from WebStack.Adapters.Zope import WebStackAdapterProduct
11.10 +from Globals import InitializeClass
11.11 +
11.12 +class VerySimpleProduct(WebStackAdapterProduct):
11.13 + meta_type = "VerySimple product"
11.14 + def __init__(self, id):
11.15 + WebStackAdapterProduct.__init__(self, id, VerySimpleResource())
11.16 +
11.17 +InitializeClass(VerySimpleProduct)
11.18 +
11.19 +def addVerySimpleProduct(self):
11.20 + """
11.21 + The HTML form used to add the product.
11.22 + """
11.23 +
11.24 + return """
11.25 + <html>
11.26 + <head>
11.27 + <title>Add VerySimple Product</title>
11.28 + </head>
11.29 + <body>
11.30 + <form action="addProduct">
11.31 + id <input name="id" type="text"><br>
11.32 + <input name="add" type="submit" value="Add!">
11.33 + </form>
11.34 + </body>
11.35 + </html>
11.36 + """
11.37 +
11.38 +def addProduct(self, id, REQUEST=None):
11.39 + """
11.40 + The function used to add the product.
11.41 + """
11.42 +
11.43 + product = VerySimpleProduct(id)
11.44 + self.Destination()._setObject(id, product)
11.45 + if REQUEST:
11.46 + return self.manage_main(self, REQUEST)
11.47 +
11.48 +def initialize(context):
11.49 + context.registerClass(
11.50 + VerySimpleProduct,
11.51 + constructors = (addVerySimpleProduct, addProduct)
11.52 + )
11.53 +
11.54 +# vim: tabstop=4 expandtab shiftwidth=4