WebStack

Annotated examples/Zope/SessionsProduct/__init__.py

775:127c9715df14
2009-11-25 Paul Boddie Added a test for empty identifiers in OpenID initiation. Changed the user identity to be the claimed identity (not the local identity from the provider) for users authenticated via OpenID. Made the local identities distinct from the claimed identities in the login/provider example.
paulb@207 1
#!/usr/bin/env python
paulb@207 2
paulb@207 3
"A Zope product testing sessions."
paulb@207 4
paulb@207 5
from Sessions import SessionsResource
paulb@207 6
from WebStack.Adapters.Zope import WebStackAdapterProduct
paulb@207 7
from Globals import InitializeClass
paulb@207 8
paulb@207 9
class SessionsProduct(WebStackAdapterProduct):
paulb@207 10
    meta_type = "Sessions product"
paulb@207 11
    def __init__(self, id):
paulb@207 12
        WebStackAdapterProduct.__init__(self, id, SessionsResource())
paulb@207 13
paulb@207 14
InitializeClass(SessionsProduct)
paulb@207 15
paulb@207 16
def addSessionsProduct(self):
paulb@207 17
    """
paulb@207 18
    The HTML form used to add the product.
paulb@207 19
    """
paulb@207 20
paulb@207 21
    return """
paulb@207 22
        <html>
paulb@207 23
            <head>
paulb@207 24
                <title>Add Sessions Product</title>
paulb@207 25
            </head>
paulb@207 26
            <body>
paulb@207 27
                <form action="addProduct">
paulb@207 28
                    id <input name="id" type="text"><br>
paulb@207 29
                    <input name="add" type="submit" value="Add!">
paulb@207 30
                </form>
paulb@207 31
            </body>
paulb@207 32
        </html>
paulb@207 33
        """
paulb@207 34
paulb@207 35
def addProduct(self, id, REQUEST=None):
paulb@207 36
    """
paulb@207 37
    The function used to add the product.
paulb@207 38
    """
paulb@207 39
paulb@207 40
    product = SessionsProduct(id)
paulb@207 41
    self.Destination()._setObject(id, product)
paulb@207 42
    if REQUEST:
paulb@207 43
        return self.manage_main(self, REQUEST)
paulb@207 44
paulb@207 45
def initialize(context):
paulb@207 46
    context.registerClass(
paulb@207 47
        SessionsProduct,
paulb@207 48
        constructors = (addSessionsProduct, addProduct)
paulb@207 49
    )
paulb@207 50
paulb@207 51
# vim: tabstop=4 expandtab shiftwidth=4