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