Beispiel #1
0
 def setUp(self):
     self.config = Configurator()
     self.config.hook_zca()
     self.config.begin()
     self.config.load_zcml('eportfolio:configure.zcml')
     _initTestingDB()
Beispiel #2
0
    ]


def get_root(*args, **kw):
    return Root()


if __name__ == '__main__':
    # Configure the BFG application

    ## Set up security policies, root object, etc.
    authentication_policy = RemoteUserAuthenticationPolicy()
    authorization_policy = ACLAuthorizationPolicy()
    config = Configurator(
        root_factory=get_root,
        default_permission='view',
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy,
    )
    config.begin()

    ## Configure views
    config.add_view(unprotected)
    config.add_view(protected, 'protected.html', permission='view_protected')
    config.add_view(login, 'login.html')
    config.add_view(logout, 'logout.html')
    config.end()

    ## Create the app object.
    app = config.make_wsgi_app()

    # Configure the repoze.who middleware:
Beispiel #3
0
def wsgi_app(**settings):
    config = Configurator(root_factory=get_root, settings=settings)
    config.load_zcml("configure.zcml")
    return config.make_wsgi_app()
Beispiel #4
0
def get_form(request):
    schema = Registration()
    form = formish.Form(schema)
    form['password'].widget = formish.CheckedPassword()
    return form

def display_form(request):
    form = get_form(request)
    return {'form':form}

def validate_form(request):
    form = get_form(request)
    try:
        data = form.validate(request)
    except formish.FormError:
        return {'form':form}
    username, password = data['username'], data['password']
    return HTTPFound(location='thanks')

if __name__ == '__main__':
    from paste.httpserver import serve
    config = Configurator()
    config.begin()
    config.add_view(display_form, request_method='GET', renderer='register.pt')
    config.add_view(validate_form, request_method='POST',renderer='register.pt')
    config.add_view(name='thanks', renderer='thanks.pt')
    config.end()
    app = config.make_wsgi_app()
    serve(app)