| 1 |
|
| 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 |
|