1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Zope/LoginProduct/__init__.py Sun Aug 29 16:28:12 2004 +0000
1.3 @@ -0,0 +1,61 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"A Zope login product."
1.7 +
1.8 +from WebStack.Resources.Login import LoginResource, LoginAuthenticator
1.9 +from WebStack.Adapters.Zope import WebStackAdapterProduct
1.10 +from Globals import InitializeClass
1.11 +
1.12 +class LoginProduct(WebStackAdapterProduct):
1.13 + meta_type = "Login product"
1.14 + def __init__(self, id):
1.15 + WebStackAdapterProduct.__init__(self, id,
1.16 + LoginResource(
1.17 + LoginAuthenticator(
1.18 + secret_key="horses",
1.19 + credentials=(
1.20 + ("badger", "abc"),
1.21 + ("vole", "xyz"),
1.22 + )
1.23 + )
1.24 + )
1.25 + )
1.26 +
1.27 +InitializeClass(LoginProduct)
1.28 +
1.29 +def addLoginProduct(self):
1.30 + """
1.31 + The HTML form used to add the product.
1.32 + """
1.33 +
1.34 + return """
1.35 + <html>
1.36 + <head>
1.37 + <title>Add Login Product</title>
1.38 + </head>
1.39 + <body>
1.40 + <form action="addProduct">
1.41 + id <input name="id" type="text"><br>
1.42 + <input name="add" type="submit" value="Add!">
1.43 + </form>
1.44 + </body>
1.45 + </html>
1.46 + """
1.47 +
1.48 +def addProduct(self, id, REQUEST=None):
1.49 + """
1.50 + The function used to add the product.
1.51 + """
1.52 +
1.53 + product = LoginProduct(id)
1.54 + self.Destination()._setObject(id, product)
1.55 + if REQUEST:
1.56 + return self.manage_main(self, REQUEST)
1.57 +
1.58 +def initialize(context):
1.59 + context.registerClass(
1.60 + LoginProduct,
1.61 + constructors = (addLoginProduct, addProduct)
1.62 + )
1.63 +
1.64 +# vim: tabstop=4 expandtab shiftwidth=4