from wsgiref.util import shift_path_info, application_uri |
from wsgiref.util import shift_path_info, application_uri |
|
|
__all__ = [ |
__all__ = [ |
"Page", "form_handler", "HTML", "Text", "Template", "HTTP", "test", |
"Page", "form_handler", "HTML", "Text", "Template", "HTTP", "expose", |
"EvalTemplate", "EvalMap", "Method", |
"test", "Redirector", "EvalTemplate", "EvalMap", "Method", |
] |
] |
|
|
class Method(object): |
class Method(object): |
|
|
|
|
|
|
|
def expose(func): |
|
"""Wrapper/decorator that marks a method as a subpage""" |
|
class _Page(Page): |
|
def body(self): |
|
return func(self.parent) |
|
return _Page |
|
|
|
|
class Page(object): |
class Page(object): |
"""A generic web location""" |
"""A generic web location""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def HEAD(self): |
def HEAD(self): |
def write(txt): |
def write(txt): |
sr.length += len(txt) |
sr.length += len(txt) |
TestContainer.c = TestContainer # allow some depth to the test... |
TestContainer.c = TestContainer # allow some depth to the test... |
|
|
|
|
|
def Redirector(url): |
|
"""Create a method that will go to a predefined URL (w/embedded vars)""" |
|
url = Text(url) |
|
def method(self): |
|
return self.redirect(url.render(self)) |
|
return method |
|
|
def additional_tests(): |
def additional_tests(): |
import doctest |
import doctest |
return doctest.DocFileSuite( |
return doctest.DocFileSuite( |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|