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