paulb@197 | 1 | #!/usr/bin/env python |
paulb@197 | 2 | |
paulb@197 | 3 | "A Zope product testing forms." |
paulb@197 | 4 | |
paulb@197 | 5 | from Form import FormResource |
paulb@197 | 6 | from WebStack.Adapters.Zope import WebStackAdapterProduct |
paulb@197 | 7 | from Globals import InitializeClass |
paulb@197 | 8 | |
paulb@197 | 9 | class FormProduct(WebStackAdapterProduct): |
paulb@197 | 10 | meta_type = "Form product" |
paulb@197 | 11 | def __init__(self, id): |
paulb@197 | 12 | WebStackAdapterProduct.__init__(self, id, FormResource()) |
paulb@197 | 13 | |
paulb@197 | 14 | InitializeClass(FormProduct) |
paulb@197 | 15 | |
paulb@197 | 16 | def addFormProduct(self): |
paulb@197 | 17 | """ |
paulb@197 | 18 | The HTML form used to add the product. |
paulb@197 | 19 | """ |
paulb@197 | 20 | |
paulb@197 | 21 | return """ |
paulb@197 | 22 | <html> |
paulb@197 | 23 | <head> |
paulb@197 | 24 | <title>Add Form Product</title> |
paulb@197 | 25 | </head> |
paulb@197 | 26 | <body> |
paulb@197 | 27 | <form action="addProduct"> |
paulb@197 | 28 | id <input name="id" type="text"><br> |
paulb@197 | 29 | <input name="add" type="submit" value="Add!"> |
paulb@197 | 30 | </form> |
paulb@197 | 31 | </body> |
paulb@197 | 32 | </html> |
paulb@197 | 33 | """ |
paulb@197 | 34 | |
paulb@197 | 35 | def addProduct(self, id, REQUEST=None): |
paulb@197 | 36 | """ |
paulb@197 | 37 | The function used to add the product. |
paulb@197 | 38 | """ |
paulb@197 | 39 | |
paulb@197 | 40 | product = FormProduct(id) |
paulb@197 | 41 | self.Destination()._setObject(id, product) |
paulb@197 | 42 | if REQUEST: |
paulb@197 | 43 | return self.manage_main(self, REQUEST) |
paulb@197 | 44 | |
paulb@197 | 45 | def initialize(context): |
paulb@197 | 46 | context.registerClass( |
paulb@197 | 47 | FormProduct, |
paulb@197 | 48 | constructors = (addFormProduct, addProduct) |
paulb@197 | 49 | ) |
paulb@197 | 50 | |
paulb@197 | 51 | # vim: tabstop=4 expandtab shiftwidth=4 |