source: TI12-security/tags/ndg-security-1.5/Tests/decorator/test_decorator.py @ 4863

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/tags/ndg-security-1.5/Tests/decorator/test_decorator.py@6610
Revision 4863, 931 bytes checked in by pjkersha, 12 years ago (diff)
  • added initialisation decorator for use with derived classes if ndg.security.server.wsgi.NDGSecurityMiddlewareBase.call
  • fixed SSO Client Middleware - client interface for using Single Sign On Service from Pylons or other app
  • Added capability to pass in args to class to be instantiated from instantiateClass factory function in classfactory module
  • Modified SSO wayf template to enable login from this page if the user is at their home site - saves an extra login step
  • Added Signin interface plugin for OpenID Relying Party middleware. The plugin is itself middleware so that it can include other middleware filters such StaticURLParser to include static content used in template.
Line 
1
2def initCall(__call__):
3    '''Decorator to __call__ to enable convenient attribute initialisation
4    '''
5    def __call__wrapper(self, environ, start_response):
6        self._initCall(environ)
7        return __call__(self, environ, start_response)
8
9    return __call__wrapper
10
11class TestDecoratorWSGI(object):
12   
13    def _initCall(self, environ):
14        print "Initialising..."
15       
16    @initCall
17    def __call__(self, environ, start_response):
18        x = "__call__"
19        return x
20
21from ndg.security.server.wsgi import NDGSecurityMiddlewareBase
22
23class TestNDGSecurityMiddleware(NDGSecurityMiddlewareBase):
24    @NDGSecurityMiddlewareBase.initCall
25    def __call__(self, environ, start_response):
26        return self.environ
27       
28if __name__ == "__main__":
29    t = TestDecoratorWSGI()
30    print t.__call__(None, None)
31   
32    n = TestNDGSecurityMiddleware(None, {}, **{})
33    print n({'PATH_INFO': '/here'}, None)
Note: See TracBrowser for help on using the repository browser.