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 # Change this to be the URL base for your server. 13 # eg. http://localhost:8000 14 15 app_url = "http://localhost" # No trailing "/"! 16 17 # Must match the key used elsewhere. 18 19 secret_key = "horses" 20 21 class SimpleWithLoginProduct(WebStackAdapterProduct): 22 23 meta_type = "Simple with login product" 24 25 def __init__(self, id, parent_url): 26 login_url = parent_url + "/" + id + "/login" 27 resource = get_site_map(app_url, login_url, secret_key) 28 WebStackAdapterProduct.__init__(self, id, resource) 29 30 InitializeClass(SimpleWithLoginProduct) 31 32 def addSimpleWithLoginProduct(self): 33 """ 34 The HTML form used to add the product. 35 """ 36 37 return """ 38 <html> 39 <head> 40 <title>Add Simple with Login Product</title> 41 </head> 42 <body> 43 <form action="addProduct"> 44 id <input name="id" type="text"><br> 45 <input name="add" type="submit" value="Add!"> 46 </form> 47 </body> 48 </html> 49 """ 50 51 def addProduct(self, id, REQUEST=None): 52 """ 53 The function used to add the product. 54 """ 55 56 product = SimpleWithLoginProduct(id, self.DestinationURL()) 57 self.Destination()._setObject(id, product) 58 if REQUEST: 59 return self.manage_main(self, REQUEST) 60 61 def initialize(context): 62 context.registerClass( 63 SimpleWithLoginProduct, 64 constructors = (addSimpleWithLoginProduct, addProduct) 65 ) 66 67 # vim: tabstop=4 expandtab shiftwidth=4