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