1 #!/usr/bin/env python 2 3 "A Zope login product." 4 5 from WebStack.Resources.Login import LoginResource, LoginAuthenticator 6 from WebStack.Adapters.Zope import WebStackAdapterProduct 7 from Globals import InitializeClass 8 9 class LoginProduct(WebStackAdapterProduct): 10 meta_type = "Login product" 11 def __init__(self, id): 12 WebStackAdapterProduct.__init__(self, id, 13 LoginResource( 14 LoginAuthenticator( 15 secret_key="horses", 16 credentials=( 17 ("badger", "abc"), 18 ("vole", "xyz"), 19 ) 20 ) 21 ) 22 ) 23 24 InitializeClass(LoginProduct) 25 26 def addLoginProduct(self): 27 """ 28 The HTML form used to add the product. 29 """ 30 31 return """ 32 <html> 33 <head> 34 <title>Add Login Product</title> 35 </head> 36 <body> 37 <form action="addProduct"> 38 id <input name="id" type="text"><br> 39 <input name="add" type="submit" value="Add!"> 40 </form> 41 </body> 42 </html> 43 """ 44 45 def addProduct(self, id, REQUEST=None): 46 """ 47 The function used to add the product. 48 """ 49 50 product = LoginProduct(id) 51 self.Destination()._setObject(id, product) 52 if REQUEST: 53 return self.manage_main(self, REQUEST) 54 55 def initialize(context): 56 context.registerClass( 57 LoginProduct, 58 constructors = (addLoginProduct, addProduct) 59 ) 60 61 # vim: tabstop=4 expandtab shiftwidth=4