1 #!/usr/bin/env python 2 3 "A simple Zope product." 4 5 from Simple import SimpleResource 6 from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator 7 from WebStack.Adapters.Zope import WebStackAdapterProduct 8 from Globals import InitializeClass 9 10 class SimpleWithLoginProduct(WebStackAdapterProduct): 11 meta_type = "Simple with login product" 12 def __init__(self, id): 13 WebStackAdapterProduct.__init__(self, id, 14 LoginRedirectResource( 15 login_url="http://localhost:9080/tests/login", 16 app_url="http://localhost:9080", 17 resource=SimpleResource(), 18 authenticator=LoginRedirectAuthenticator(secret_key="horses"), 19 anonymous_parameter_name="anonymous", 20 logout_parameter_name="logout" 21 ) 22 ) 23 24 InitializeClass(SimpleWithLoginProduct) 25 26 def addSimpleWithLoginProduct(self): 27 """ 28 The HTML form used to add the product. 29 """ 30 31 return """ 32 <html> 33 <head> 34 <title>Add Simple with 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 = SimpleWithLoginProduct(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 SimpleWithLoginProduct, 58 constructors = (addSimpleWithLoginProduct, addProduct) 59 ) 60 61 # vim: tabstop=4 expandtab shiftwidth=4