Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications. :param catchall: If true (default), handle all exceptions. Turn off to
| 600 | |
| 601 | |
| 602 | class Bottle(object): |
| 603 | """ Each Bottle object represents a single, distinct web application and |
| 604 | consists of routes, callbacks, plugins, resources and configuration. |
| 605 | Instances are callable WSGI applications. |
| 606 | |
| 607 | :param catchall: If true (default), handle all exceptions. Turn off to |
| 608 | let debugging middleware handle exceptions. |
| 609 | """ |
| 610 | |
| 611 | @lazy_attribute |
| 612 | def _global_config(cls): |
| 613 | cfg = ConfigDict() |
| 614 | cfg.meta_set('catchall', 'validate', bool) |
| 615 | return cfg |
| 616 | |
| 617 | def __init__(self, **kwargs): |
| 618 | #: A :class:`ConfigDict` for app specific configuration. |
| 619 | self.config = self._global_config._make_overlay() |
| 620 | self.config._add_change_listener( |
| 621 | functools.partial(self.trigger_hook, 'config')) |
| 622 | |
| 623 | self.config.update({ |
| 624 | "catchall": True |
| 625 | }) |
| 626 | |
| 627 | if kwargs.get('catchall') is False: |
| 628 | depr(0, 13, "Bottle(catchall) keyword argument.", |
| 629 | "The 'catchall' setting is now part of the app " |
| 630 | "configuration. Fix: `app.config['catchall'] = False`") |
| 631 | self.config['catchall'] = False |
| 632 | if kwargs.get('autojson') is False: |
| 633 | depr(0, 13, "Bottle(autojson) keyword argument.", |
| 634 | "The 'autojson' setting is now part of the app " |
| 635 | "configuration. Fix: `app.config['json.enable'] = False`") |
| 636 | self.config['json.disable'] = True |
| 637 | |
| 638 | self._mounts = [] |
| 639 | |
| 640 | #: A :class:`ResourceManager` for application files |
| 641 | self.resources = ResourceManager() |
| 642 | |
| 643 | self.routes = [] # List of installed :class:`Route` instances. |
| 644 | self.router = Router() # Maps requests to :class:`Route` instances. |
| 645 | self.error_handler = {} |
| 646 | |
| 647 | # Core plugins |
| 648 | self.plugins = [] # List of installed plugins. |
| 649 | self.install(JSONPlugin()) |
| 650 | self.install(TemplatePlugin()) |
| 651 | |
| 652 | #: If true, most exceptions are caught and returned as :exc:`HTTPError` |
| 653 | catchall = DictProperty('config', 'catchall') |
| 654 | |
| 655 | __hook_names = 'before_request', 'after_request', 'app_reset', 'config' |
| 656 | __hook_reversed = {'after_request'} |
| 657 | |
| 658 | @cached_property |
| 659 | def _hooks(self): |
no test coverage detected
searching dependent graphs…