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.Resources.Login import LoginResource, LoginAuthenticator 8 from WebStack.Resources.ResourceMap import MapResource 9 from WebStack.Adapters.Zope import WebStackAdapterProduct 10 from Globals import InitializeClass 11 12 class SimpleWithLoginProduct(WebStackAdapterProduct): 13 meta_type = "Simple with login product" 14 def __init__(self, id): 15 WebStackAdapterProduct.__init__(self, id, 16 MapResource({ 17 "simple" : 18 LoginRedirectResource( 19 login_url="http://localhost:9080/tests/login", 20 app_url="http://localhost:9080", 21 resource=SimpleResource(), 22 authenticator=LoginRedirectAuthenticator(secret_key="horses"), 23 anonymous_parameter_name="anonymous", 24 logout_parameter_name="logout" 25 ), 26 "login" : 27 LoginResource( 28 LoginAuthenticator( 29 secret_key="horses", 30 credentials=( 31 ("badger", "abc"), 32 ("vole", "xyz"), 33 ) 34 ) 35 ) 36 }) 37 ) 38 39 InitializeClass(SimpleWithLoginProduct) 40 41 def addSimpleWithLoginProduct(self): 42 """ 43 The HTML form used to add the product. 44 """ 45 46 return """ 47 <html> 48 <head> 49 <title>Add Simple with Login Product</title> 50 </head> 51 <body> 52 <form action="addProduct"> 53 id <input name="id" type="text"><br> 54 <input name="add" type="submit" value="Add!"> 55 </form> 56 </body> 57 </html> 58 """ 59 60 def addProduct(self, id, REQUEST=None): 61 """ 62 The function used to add the product. 63 """ 64 65 product = SimpleWithLoginProduct(id) 66 self.Destination()._setObject(id, product) 67 if REQUEST: 68 return self.manage_main(self, REQUEST) 69 70 def initialize(context): 71 context.registerClass( 72 SimpleWithLoginProduct, 73 constructors = (addSimpleWithLoginProduct, addProduct) 74 ) 75 76 # vim: tabstop=4 expandtab shiftwidth=4