"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/Cheetah/Servlet.py" (20 Apr 2021, 1249 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "Servlet.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3-3.0.1_vs_3-3.1.0.

    1 #!/usr/bin/env python
    2 '''
    3 Provides an abstract Servlet baseclass for Cheetah's Template class
    4 '''
    5 
    6 import os.path
    7 
    8 
    9 class Servlet(object):
   10     """
   11         This class is an abstract baseclass for Cheetah.Template.Template.
   12     """
   13 
   14     transaction = None
   15     application = None
   16     request = None
   17     session = None
   18 
   19     def respond(self, trans=None):
   20         raise NotImplementedError("""\
   21 couldn't find the template's main method.  If you are using #extends
   22 without #implements, try adding '#implements respond' to your template
   23 definition.""")
   24 
   25     def sleep(self, transaction):
   26         super(Servlet, self).sleep(transaction)
   27         self.session = None
   28         self.request = None
   29         self._request = None
   30         self.response = None
   31         self.transaction = None
   32 
   33     def shutdown(self):
   34         pass
   35 
   36     def serverSidePath(self, path=None,
   37                        normpath=os.path.normpath,
   38                        abspath=os.path.abspath
   39                        ):
   40 
   41         if path:
   42             return normpath(abspath(path.replace("\\", '/')))
   43         elif hasattr(self, '_filePath') and self._filePath:
   44             return normpath(abspath(self._filePath))
   45         else:
   46             return None
   47 
   48 # vim: shiftwidth=4 tabstop=4 expandtab