|
- #!/usr/bin/python
- # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
-
- from decorators import WSGITemplate # decoratore ( singleton )
-
- wsgitmpl = WSGITemplate()
-
- #
- # esempio minimo di controller WSGI
- #
- @wsgitmpl.template( 'template1.tmpl' )
- def application( environ, start_response ):
- from pprint import pformat
- v1=1
- v2='pippo'
-
- gino = 'quarantadue'
-
- #html = environ['template']( context=locals() )
- html = environ['template']( context=dict( v1=v2, v2=v1, gino='ciao' ) )
-
- start_response( '200 OK', [('content-type', 'text/html; charset=utf-8')] )
-
- return [ html, pformat( environ, width=132 ).replace('\n','<br>\n') ] # TODO: pformat..... ---> trasformarlo in un decoratore
|