1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/Zope/SimpleWithLoginProduct/__init__.py Sun Aug 29 16:28:18 2004 +0000
1.3 @@ -0,0 +1,61 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"A simple Zope product."
1.7 +
1.8 +from Simple import SimpleResource
1.9 +from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
1.10 +from WebStack.Adapters.Zope import WebStackAdapterProduct
1.11 +from Globals import InitializeClass
1.12 +
1.13 +class SimpleWithLoginProduct(WebStackAdapterProduct):
1.14 + meta_type = "Simple with login product"
1.15 + def __init__(self, id):
1.16 + WebStackAdapterProduct.__init__(self, id,
1.17 + LoginRedirectResource(
1.18 + login_url="http://localhost:9080/tests/login",
1.19 + app_url="http://localhost:9080",
1.20 + resource=SimpleResource(),
1.21 + authenticator=LoginRedirectAuthenticator(secret_key="horses"),
1.22 + anonymous_parameter_name="anonymous",
1.23 + logout_parameter_name="logout"
1.24 + )
1.25 + )
1.26 +
1.27 +InitializeClass(SimpleWithLoginProduct)
1.28 +
1.29 +def addSimpleWithLoginProduct(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 Simple with 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 = SimpleWithLoginProduct(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 + SimpleWithLoginProduct,
1.61 + constructors = (addSimpleWithLoginProduct, addProduct)
1.62 + )
1.63 +
1.64 +# vim: tabstop=4 expandtab shiftwidth=4