1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Zope/SessionsProduct/__init__.py Sun Aug 29 13:37:19 2004 +0000
1.3 @@ -0,0 +1,51 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"A Zope product testing sessions."
1.7 +
1.8 +from Sessions import SessionsResource
1.9 +from WebStack.Adapters.Zope import WebStackAdapterProduct
1.10 +from Globals import InitializeClass
1.11 +
1.12 +class SessionsProduct(WebStackAdapterProduct):
1.13 + meta_type = "Sessions product"
1.14 + def __init__(self, id):
1.15 + WebStackAdapterProduct.__init__(self, id, SessionsResource())
1.16 +
1.17 +InitializeClass(SessionsProduct)
1.18 +
1.19 +def addSessionsProduct(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 Sessions 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(self, id, REQUEST=None):
1.39 + """
1.40 + The function used to add the product.
1.41 + """
1.42 +
1.43 + product = SessionsProduct(id)
1.44 + self.Destination()._setObject(id, product)
1.45 + if REQUEST:
1.46 + return self.manage_main(self, REQUEST)
1.47 +
1.48 +def initialize(context):
1.49 + context.registerClass(
1.50 + SessionsProduct,
1.51 + constructors = (addSessionsProduct, addProduct)
1.52 + )
1.53 +
1.54 +# vim: tabstop=4 expandtab shiftwidth=4