# HG changeset patch # User paulb # Date 1093796892 0 # Node ID 363f6c35cd021c20fe0651f7f59bf234b71fd3db # Parent d198926cb0c26a9b1ba7c93daa9632acacb65b70 [project @ 2004-08-29 16:28:12 by paulb] Added the login example. diff -r d198926cb0c2 -r 363f6c35cd02 examples/Zope/LoginProduct/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Zope/LoginProduct/__init__.py Sun Aug 29 16:28:12 2004 +0000 @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +"A Zope login product." + +from WebStack.Resources.Login import LoginResource, LoginAuthenticator +from WebStack.Adapters.Zope import WebStackAdapterProduct +from Globals import InitializeClass + +class LoginProduct(WebStackAdapterProduct): + meta_type = "Login product" + def __init__(self, id): + WebStackAdapterProduct.__init__(self, id, + LoginResource( + LoginAuthenticator( + secret_key="horses", + credentials=( + ("badger", "abc"), + ("vole", "xyz"), + ) + ) + ) + ) + +InitializeClass(LoginProduct) + +def addLoginProduct(self): + """ + The HTML form used to add the product. + """ + + return """ + + + Add Login Product + + +
+ id
+ +
+ + + """ + +def addProduct(self, id, REQUEST=None): + """ + The function used to add the product. + """ + + product = LoginProduct(id) + self.Destination()._setObject(id, product) + if REQUEST: + return self.manage_main(self, REQUEST) + +def initialize(context): + context.registerClass( + LoginProduct, + constructors = (addLoginProduct, addProduct) + ) + +# vim: tabstop=4 expandtab shiftwidth=4