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