您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

24 行
809 B

  1. #!/usr/bin/python
  2. # -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
  3. from singleton import Singleton
  4. from template import render
  5. from functools import partial
  6. class WSGITemplate( object ):
  7. __metaclass__ = Singleton
  8. def __init__( self, basedir=None ):
  9. import os
  10. self.__basedir = os.path.normpath( os.path.join( os.path.split(__file__)[0], basedir ) ) + '/'
  11. def template(self, filename=None ):
  12. def real_decorator( wsgi_application ):
  13. def wrapper( environ, start_response ):
  14. environ[ 'template' ] = partial( render, filename= self.__basedir + filename )
  15. environ[ 'basedir' ] = self.__basedir
  16. return wsgi_application( environ, start_response )
  17. return wrapper
  18. return real_decorator