1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Zope/SimpleProduct/__init__.py Thu Aug 26 23:12:57 2004 +0000
1.3 @@ -0,0 +1,59 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"A simple Zope product."
1.7 +
1.8 +from Simple import SimpleResource
1.9 +from WebStack.Adapters.Zope import WebStackAdapterProduct
1.10 +from Globals import InitializeClass
1.11 +
1.12 +class SimpleProduct(WebStackAdapterProduct):
1.13 + meta_type = "Simple product"
1.14 + def __init__(self, id):
1.15 + WebStackAdapterProduct.__init__(self, id, SimpleResource())
1.16 +
1.17 +InitializeClass(SimpleProduct)
1.18 +
1.19 +def addSimpleProduct(self):
1.20 + """
1.21 + The HTML form used to add the product.
1.22 + """
1.23 +
1.24 + return """
1.25 + <html>
1.26 + <head>
1.27 + <title>Add Simple Product</title>
1.28 + </head>
1.29 + <body>
1.30 + <form action="addProduct">
1.31 + id <input name="id" type="text"><br>
1.32 + <input name="add" type="submit" value="Add!">
1.33 + </form>
1.34 + </body>
1.35 + </html>
1.36 + """
1.37 +
1.38 +def addProduct(dispatcher, id):
1.39 + """
1.40 + The function used to add the product.
1.41 + """
1.42 +
1.43 + product = SimpleProduct(id)
1.44 + dispatcher.Destination()._setObject(id, product)
1.45 + return """
1.46 + <html>
1.47 + <head>
1.48 + <title>Simple Product Added</title>
1.49 + </head>
1.50 + <body>
1.51 + Simple product added to namespace!
1.52 + </body>
1.53 + </html>
1.54 + """
1.55 +
1.56 +def initialize(context):
1.57 + context.registerClass(
1.58 + SimpleProduct,
1.59 + constructors = (addSimpleProduct, addProduct)
1.60 + )
1.61 +
1.62 +# vim: tabstop=4 expandtab shiftwidth=4