diff options
author | Marcel Hellkamp <marc@gsites.de> | 2009-07-25 19:05:23 +0200 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2009-07-25 19:05:23 +0200 |
commit | 30d13b20fe84a43e63c75284ce7a7c9c6460d731 (patch) | |
tree | 59d04049033701380d440324d695259600d00a40 | |
parent | b3ed01d269db8d10a71414d89d757b71cb6ca953 (diff) | |
download | bottle-30d13b20fe84a43e63c75284ce7a7c9c6460d731.tar.gz |
New method optimize() and some code cleanup
-rw-r--r-- | bottle.py | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -132,15 +132,14 @@ class BreakTheBottle(BottleException): content of output """ def __init__(self, output): self.output = output - - -# WSGI abstraction: Request and response management +# WSGI abstraction: Request and response management + _default_app = None def default_app(): global _default_app @@ -149,7 +148,6 @@ def default_app(): return _default_app - class Bottle(object): def __init__(self, catchall=True, debug=False, optimize=False): @@ -168,7 +166,6 @@ class Bottle(object): if route: return (route, {}) - # Now search regexp routes routes = self.regexp_routes.get(method,[]) for i in range(len(routes)): match = routes[i][0].match(url) @@ -249,10 +246,6 @@ class Bottle(object): return output - - - - class Request(threading.local): """ Represents a single request using thread-local namespace. """ @@ -551,7 +544,6 @@ def run(app=None, server=WSGIRefServer, host='127.0.0.1', port=8080, **kargs): # Templates - class BaseTemplate(object): def __init__(self, template='', filename='<template>'): self.source = filename @@ -798,9 +790,9 @@ class BottleDB(threading.local): -def debug(mode=True): default_app().debug = bool(mode) -# Modul initialization + +# Modul initialization and configuration DB_PATH = './' TEMPLATE_PATH = ['./%s.tpl', './views/%s.tpl'] @@ -854,3 +846,7 @@ response = Response() db = BottleDB() local = threading.local() +def debug(mode=True): default_app().debug = bool(mode) +def optimize(mode=True): default_app().optimize = bool(mode) + + |