</html>""" def GET(self, request, response): response['Content-Type'] = 'text/html' response.append(self.template % 'GET: <i>[no data input]</i>') def POST(self, request, response): try: msg = "Data posted: %s" % request.cgi_fields['data'].value.strip() except KeyError: msg = 'Data posted: <b>no input data provided!</b>' response['Content-Type'] = 'text/html' response.append(self.template % msg) application = Application() # Simple functions as processors application.add_map(r'^/?$', GET=home) application.add_map(r'^/conflict$', GET=conflict) # Processors can be chained by giving a list of them in 'add_map' application.add_map(r'^/login$', GET=[BasicAuthenticate(realm='example'), EchoProcessor()]) # A Dispatcher class for handling all methods for a URL application.add_dispatcher(r'^/page$', Dispatcher) # Using a predefined processor: a callable class instance application.add_map(r'^/file/.+$', GET=FileProcessor('/home/pjk/python', '/file'))
from slog.search import Search from slog.account import Account, AccountCreate, Accounts from slog.protocol import Protocol, ProtocolCreate, Protocols from slog.project import Project, ProjectCreate, Projects from slog.sample import Sample, SampleCreate, Samples from slog.workset import Workset, WorksetCreate, Worksets from slog.instrument import Instrument, InstrumentCreate, Instruments from slog.task import Task, TaskCreate, Tasks from slog.tool import ToolDispatcher from slog.dispatcher import Id, Doc, Static, Attachment logging.basicConfig(level=logging.INFO) application = WsgiApplication(human_debug_output=True) # Linear search: put most used at beginning of list! application.add_class(r'^/?$', Home) application.add_class(r'^/search$', Search) application.add_class(r'^/static/(?P<filename>[^/]+)$', Static) application.add_class(r'^/attachment/(?P<id>[a-f0-9]{32,32})/(?P<filename>[^/]+)$', Attachment) application.add_class(r'^/accounts$', Accounts) application.add_class(r'^/account/(?P<name>[^/]+)$', Account) application.add_class(r'^/account/?$', AccountCreate) application.add_class(r'^/protocols$', Protocols) application.add_class(r'^/protocol/(?P<name>[^/]+)$', Protocol) application.add_class(r'^/protocol/?$', ProtocolCreate) application.add_class(r'^/projects$', Projects) application.add_class(r'^/project/(?P<name>[^/]+)$', Project) application.add_class(r'^/project/?$', ProjectCreate)