pax_global_header00006660000000000000000000000064147036742250014524gustar00rootroot0000000000000052 comment=82c2dcc0dea4d27540301f4362ac278f862f4500 python-bottle-0.13.2/000077500000000000000000000000001470367422500144175ustar00rootroot00000000000000python-bottle-0.13.2/.coveragerc000066400000000000000000000000641470367422500165400ustar00rootroot00000000000000[run] branch = True parallel = True source = bottle python-bottle-0.13.2/.github/000077500000000000000000000000001470367422500157575ustar00rootroot00000000000000python-bottle-0.13.2/.github/workflows/000077500000000000000000000000001470367422500200145ustar00rootroot00000000000000python-bottle-0.13.2/.github/workflows/install-deps.sh000077500000000000000000000001421470367422500227470ustar00rootroot00000000000000#!/usr/bin/env bash set -e set -x # Test utilities pip install -U pytest pytest-cov mako jinja2 python-bottle-0.13.2/.github/workflows/run_tests.yml000066400000000000000000000010241470367422500225620ustar00rootroot00000000000000name: Tests on: [push, pull_request] jobs: build: runs-on: ubuntu-latest strategy: max-parallel: 5 matrix: python-version: - "2.7" - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" container: image: "python:${{ matrix.python-version }}" steps: - uses: actions/checkout@v2 - name: Install dependencies run: .github/workflows/install-deps.sh - name: Run tests run: pytest . -ra -q --cov=bottle --cov-report=term python-bottle-0.13.2/.readthedocs.yaml000066400000000000000000000011331470367422500176440ustar00rootroot00000000000000# Read the Docs configuration file for Sphinx projects # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Set the OS, Python version and other tools you might need build: os: ubuntu-22.04 tools: python: latest # Build documentation in the "docs/" directory with Sphinx sphinx: configuration: docs/conf.py # Optional but recommended, declare the Python requirements required # to build your documentation # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html python: install: - requirements: docs/requirements.txtpython-bottle-0.13.2/AUTHORS000066400000000000000000000024601470367422500154710ustar00rootroot00000000000000Bottle is written and maintained by Marcel Hellkamp . Thanks to all the people who found bugs, sent patches, spread the word, helped each other on the mailing-list and made this project possible. I hope the following (alphabetically sorted) list is complete. If you miss your name on that list (or want your name removed) please file a pull request. * acasajus * Adam R. Smith * Alexey Borzenkov * Alexis Daboville * Anton I. Sipos * Anton Kolechkin * apexi200sx * apheage * BillMa * Brad Greenlee * Brandon Gilmore * Branko Vukelic * Brian Sierakowski * Brian Wickman * Carl Scharenberg * Damien Degois * David Buxton * Duane Johnson * fcamel * Frank Murphy * Frederic Junod * goldfaber3012 * Greg Milby * gstein * Ian Davis * Itamar Nabriski * Iuri de Silvio * Jaimie Murdock * Jeff Nichols * Jeremy Kelley * joegester * Johannes Krampf * Jonas Haag * Joshua Roesslein * Judson Neer * Karl * Kevin Zuber * Kraken * Kyle Fritz * m35 * Marcos Neves * masklinn * Michael Labbe * Michael Soulier * `reddit `_ * Nicolas Vanhoren * Oz N Tiram * Robert Rollins * rogererens * rwxrwx * Santiago Gala * Sean M. Collins * Sebastian Wollrath * Seth * Sigurd Høgsbro * Stuart Rackham * Sun Ning * Tomás A. Schertel * Tristan Zajonc * voltron * Wieland Hoffmann * zombat * Thiago Avelino python-bottle-0.13.2/LICENSE000066400000000000000000000020521470367422500154230ustar00rootroot00000000000000Copyright (c) 2009-2024, Marcel Hellkamp. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. python-bottle-0.13.2/MANIFEST.in000066400000000000000000000001611470367422500161530ustar00rootroot00000000000000include bottle.py include setup.py include README.rst include LICENSE include test/views/*.tpl include test/*.py python-bottle-0.13.2/Makefile000066400000000000000000000040311470367422500160550ustar00rootroot00000000000000VERSION = $(shell python setup.py --version) ALLFILES = $(shell echo bottle.py test/*.py test/views/*.tpl) VENV = build/venv TESTBUILD = build/python .PHONY: venv release coverage install docs test clean release: clean test_all venv $(VENV)/bin/python3 setup.py --version | egrep -q -v '[a-zA-Z]' # Fail on dev/rc versions git commit -e -m "Release of $(VERSION)" # Fail on nothing to commit git tag -a -m "Release of $(VERSION)" $(VERSION) # Fail on existing tags git push origin HEAD # Fail on out-of-sync upstream git push origin tag $(VERSION) # Fail on dublicate tag $(VENV)/bin/python3 setup.py sdist bdist_wheel # Build project $(VENV)/bin/twine upload dist/$(VERSION)* # Release to pypi venv: $(VENV)/.installed $(VENV)/.installed: Makefile python3 -mvenv $(VENV) $(VENV)/bin/python3 -mensurepip $(VENV)/bin/pip install -U pip $(VENV)/bin/pip install -U setuptools wheel twine pytest coverage $(VENV)/bin/pip install -U sphinx sphinx-intl transifex-client touch $(VENV)/.installed coverage: venv $(VENV)/bin/coverage erase $(VENV)/bin/coverage run -m pytest $(VENV)/bin/coverage combine $(VENV)/bin/coverage report $(VENV)/bin/coverage html push: test_all git push origin HEAD install: python setup.py install docs: venv $(VENV)/bin/sphinx-build -b html -d build/docs/doctrees docs build/docs/html/; tx-pull: venv . $(VENV)/bin/activate; \ cd docs/_locale/ \ && tx pull -af tx-push: venv . $(VENV)/bin/activate; \ cd docs/_locale/ \ && sphinx-build -b gettext -E .. _pot \ && sphinx-intl update-txconfig-resources -p _pot -d . --transifex-project-name bottle \ && tx push -s tx: $(MAKE) tx-push $(MAKE) tx-pull test: venv . $(VENV)/bin/activate; pytest clean: rm -rf $(VENV) build/ dist/ MANIFEST .coverage .name htmlcov 2>/dev/null || true find . -name '__pycache__' -exec rm -rf {} + find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + find . -name '._*' -exec rm -f {} + python-bottle-0.13.2/README.rst000066400000000000000000000056161470367422500161160ustar00rootroot00000000000000.. image:: http://bottlepy.org/docs/dev/_static/logo_nav.png :target: http://bottlepy.org/ :alt: Bottle Logo :align: right .. image:: https://github.com/bottlepy/bottle/workflows/Tests/badge.svg :target: https://github.com/bottlepy/bottle/workflows/Tests :alt: Tests Status .. image:: https://img.shields.io/pypi/v/bottle.svg :target: https://pypi.python.org/pypi/bottle/ :alt: Latest Version .. image:: https://img.shields.io/pypi/l/bottle.svg :target: https://pypi.python.org/pypi/bottle/ :alt: License .. _mako: http://www.makotemplates.org/ .. _cheetah: http://www.cheetahtemplate.org/ .. _jinja2: http://jinja.pocoo.org/ .. _paste: https://pythonpaste.readthedocs.io/ .. _fapws3: https://github.com/william-os4y/fapws3 .. _bjoern: https://github.com/jonashaag/bjoern .. _cherrypy: https://docs.cherrypy.dev/ .. _WSGI: https://wsgi.readthedocs.io/ .. _Python: http://python.org/ ============================ Bottle: Python Web Framework ============================ Bottle is a fast, simple and lightweight WSGI_ micro web-framework for Python_. It is distributed as a single file module and has no dependencies other than the `Python Standard Library `_. * **Routing:** Requests to function-call mapping with support for clean and dynamic URLs. * **Templates:** Fast and pythonic `*built-in template engine* `_ and support for mako_, jinja2_ and cheetah_ templates. * **Utilities:** Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata. * **Server:** Built-in HTTP development server and support for paste_, fapws3_, bjoern_, `Google App Engine `_, cherrypy_ or any other WSGI_ capable HTTP server. Homepage and documentation: http://bottlepy.org Example: "Hello World" in a bottle ---------------------------------- .. code-block:: python from bottle import route, run, template @route('/hello/') def index(name): return template('Hello {{name}}!', name=name) run(host='localhost', port=8080) Run this script or paste it into a Python console, then point your browser to ``_. That's it. Download and Install -------------------- .. __: https://github.com/bottlepy/bottle/raw/master/bottle.py Install the latest stable release with ``pip install bottle`` or download `bottle.py`__ (unstable) into your project directory. There are no hard dependencies other than the Python standard library. License ------- .. __: https://github.com/bottlepy/bottle/raw/master/LICENSE Code and documentation are available according to the MIT License (see LICENSE__). The Bottle logo however is *NOT* covered by that license. It is allowed to use the logo as a link to the bottle homepage or in direct context with the unmodified library. In all other cases, please ask first. python-bottle-0.13.2/bottle.py000077500000000000000000005377221470367422500163050ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with URL parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies other than the Python Standard Library. Homepage and documentation: http://bottlepy.org/ Copyright (c) 2009-2024, Marcel Hellkamp. License: MIT (see LICENSE for details) """ from __future__ import print_function import sys __author__ = 'Marcel Hellkamp' __version__ = '0.13.2' __license__ = 'MIT' ############################################################################### # Command-line interface ###################################################### ############################################################################### # INFO: Some server adapters need to monkey-patch std-lib modules before they # are imported. This is why some of the command-line handling is done here, but # the actual call to _main() is at the end of the file. def _cli_parse(args): # pragma: no coverage from argparse import ArgumentParser parser = ArgumentParser(prog=args[0], usage="%(prog)s [options] package.module:app") opt = parser.add_argument opt("--version", action="store_true", help="show version number.") opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.") opt("-s", "--server", default='wsgiref', help="use SERVER as backend.") opt("-p", "--plugin", action="append", help="install additional plugin/s.") opt("-c", "--conf", action="append", metavar="FILE", help="load config values from FILE.") opt("-C", "--param", action="append", metavar="NAME=VALUE", help="override config values.") opt("--debug", action="store_true", help="start server in debug mode.") opt("--reload", action="store_true", help="auto-reload on file changes.") opt('app', help='WSGI app entry point.', nargs='?') cli_args = parser.parse_args(args[1:]) return cli_args, parser def _cli_patch(cli_args): # pragma: no coverage parsed_args, _ = _cli_parse(cli_args) opts = parsed_args if opts.server: if opts.server.startswith('gevent'): import gevent.monkey gevent.monkey.patch_all() elif opts.server.startswith('eventlet'): import eventlet eventlet.monkey_patch() if __name__ == '__main__': _cli_patch(sys.argv) ############################################################################### # Imports and Python 2/3 unification ########################################## ############################################################################### import base64, calendar, email.utils, functools, hmac, itertools,\ mimetypes, os, re, tempfile, threading, time, warnings, weakref, hashlib from types import FunctionType from datetime import date as datedate, datetime, timedelta from tempfile import NamedTemporaryFile from traceback import format_exc, print_exc from unicodedata import normalize try: from ujson import dumps as json_dumps, loads as json_lds except ImportError: from json import dumps as json_dumps, loads as json_lds py = sys.version_info py3k = py.major > 2 # Lots of stdlib and builtin differences. if py3k: import http.client as httplib import _thread as thread from urllib.parse import urljoin, SplitResult as UrlSplitResult from urllib.parse import urlencode, quote as urlquote, unquote as urlunquote urlunquote = functools.partial(urlunquote, encoding='latin1') from http.cookies import SimpleCookie, Morsel, CookieError from collections.abc import MutableMapping as DictMixin from types import ModuleType as new_module import pickle from io import BytesIO import configparser from datetime import timezone UTC = timezone.utc # getfullargspec was deprecated in 3.5 and un-deprecated in 3.6 # getargspec was deprecated in 3.0 and removed in 3.11 from inspect import getfullargspec def getargspec(func): spec = getfullargspec(func) kwargs = makelist(spec[0]) + makelist(spec.kwonlyargs) return kwargs, spec[1], spec[2], spec[3] basestring = str unicode = str json_loads = lambda s: json_lds(touni(s)) callable = lambda x: hasattr(x, '__call__') imap = map def _raise(*a): raise a[0](a[1]).with_traceback(a[2]) else: # 2.x warnings.warn("Python 2 support will be dropped in Bottle 0.14", DeprecationWarning) import httplib import thread from urlparse import urljoin, SplitResult as UrlSplitResult from urllib import urlencode, quote as urlquote, unquote as urlunquote from Cookie import SimpleCookie, Morsel, CookieError from itertools import imap import cPickle as pickle from imp import new_module from StringIO import StringIO as BytesIO import ConfigParser as configparser from collections import MutableMapping as DictMixin from inspect import getargspec from datetime import tzinfo class _UTC(tzinfo): def utcoffset(self, dt): return timedelta(0) def tzname(self, dt): return "UTC" def dst(self, dt): return timedelta(0) UTC = _UTC() unicode = unicode json_loads = json_lds exec(compile('def _raise(*a): raise a[0], a[1], a[2]', '', 'exec')) # Some helpers for string/byte handling def tob(s, enc='utf8'): if isinstance(s, unicode): return s.encode(enc) return b'' if s is None else bytes(s) def touni(s, enc='utf8', err='strict'): if isinstance(s, bytes): return s.decode(enc, err) return unicode("" if s is None else s) tonat = touni if py3k else tob def _stderr(*args): try: print(*args, file=sys.stderr) except (IOError, AttributeError): pass # Some environments do not allow printing (mod_wsgi) # A bug in functools causes it to break if the wrapper is an instance method def update_wrapper(wrapper, wrapped, *a, **ka): try: functools.update_wrapper(wrapper, wrapped, *a, **ka) except AttributeError: pass # These helpers are used at module level and need to be defined first. # And yes, I know PEP-8, but sometimes a lower-case classname makes more sense. def depr(major, minor, cause, fix, stacklevel=3): text = "Warning: Use of deprecated feature or API. (Deprecated in Bottle-%d.%d)\n"\ "Cause: %s\n"\ "Fix: %s\n" % (major, minor, cause, fix) if DEBUG == 'strict': raise DeprecationWarning(text) warnings.warn(text, DeprecationWarning, stacklevel=stacklevel) return DeprecationWarning(text) def makelist(data): # This is just too handy if isinstance(data, (tuple, list, set, dict)): return list(data) elif data: return [data] else: return [] class DictProperty(object): """ Property that maps to a key in a local dict-like attribute. """ def __init__(self, attr, key=None, read_only=False): self.attr, self.key, self.read_only = attr, key, read_only def __call__(self, func): functools.update_wrapper(self, func, updated=[]) self.getter, self.key = func, self.key or func.__name__ return self def __get__(self, obj, cls): if obj is None: return self key, storage = self.key, getattr(obj, self.attr) if key not in storage: storage[key] = self.getter(obj) return storage[key] def __set__(self, obj, value): if self.read_only: raise AttributeError("Read-Only property.") getattr(obj, self.attr)[self.key] = value def __delete__(self, obj): if self.read_only: raise AttributeError("Read-Only property.") del getattr(obj, self.attr)[self.key] class cached_property(object): """ A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. """ def __init__(self, func): update_wrapper(self, func) self.func = func def __get__(self, obj, cls): if obj is None: return self value = obj.__dict__[self.func.__name__] = self.func(obj) return value class lazy_attribute(object): """ A property that caches itself to the class object. """ def __init__(self, func): functools.update_wrapper(self, func, updated=[]) self.getter = func def __get__(self, obj, cls): value = self.getter(cls) setattr(cls, self.__name__, value) return value ############################################################################### # Exceptions and Events ####################################################### ############################################################################### class BottleException(Exception): """ A base class for exceptions used by bottle. """ pass ############################################################################### # Routing ###################################################################### ############################################################################### class RouteError(BottleException): """ This is a base class for all routing related exceptions """ class RouteReset(BottleException): """ If raised by a plugin or request handler, the route is reset and all plugins are re-applied. """ class RouterUnknownModeError(RouteError): pass class RouteSyntaxError(RouteError): """ The route parser found something not supported by this router. """ class RouteBuildError(RouteError): """ The route could not be built. """ def _re_flatten(p): """ Turn all capturing groups in a regular expression pattern into non-capturing groups. """ if '(' not in p: return p return re.sub(r'(\\*)(\(\?P<[^>]+>|\((?!\?))', lambda m: m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:', p) class Router(object): """ A Router is an ordered collection of route->target pairs. It is used to efficiently match WSGI requests against a number of routes and return the first target that satisfies the request. The target may be anything, usually a string, ID or callable object. A route consists of a path-rule and a HTTP method. The path-rule is either a static path (e.g. `/contact`) or a dynamic path that contains wildcards (e.g. `/wiki/`). The wildcard syntax and details on the matching order are described in docs:`routing`. """ default_pattern = '[^/]+' default_filter = 're' #: The current CPython regexp implementation does not allow more #: than 99 matching groups per regular expression. _MAX_GROUPS_PER_PATTERN = 99 def __init__(self, strict=False): self.rules = [] # All rules in order self._groups = {} # index of regexes to find them in dyna_routes self.builder = {} # Data structure for the url builder self.static = {} # Search structure for static routes self.dyna_routes = {} self.dyna_regexes = {} # Search structure for dynamic routes #: If true, static routes are no longer checked first. self.strict_order = strict self.filters = { 're': lambda conf: (_re_flatten(conf or self.default_pattern), None, None), 'int': lambda conf: (r'-?\d+', int, lambda x: str(int(x))), 'float': lambda conf: (r'-?[\d.]+', float, lambda x: str(float(x))), 'path': lambda conf: (r'.+?', None, None) } def add_filter(self, name, func): """ Add a filter. The provided function is called with the configuration string as parameter and must return a (regexp, to_python, to_url) tuple. The first element is a string, the last two are callables or None. """ self.filters[name] = func rule_syntax = re.compile('(\\\\*)' '(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)' '|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)' '(?::((?:\\\\.|[^\\\\>])+)?)?)?>))') def _itertokens(self, rule): offset, prefix = 0, '' for match in self.rule_syntax.finditer(rule): prefix += rule[offset:match.start()] g = match.groups() if g[2] is not None: depr(0, 13, "Use of old route syntax.", "Use instead of :name in routes.", stacklevel=4) if len(g[0]) % 2: # Escaped wildcard prefix += match.group(0)[len(g[0]):] offset = match.end() continue if prefix: yield prefix, None, None name, filtr, conf = g[4:7] if g[2] is None else g[1:4] yield name, filtr or 'default', conf or None offset, prefix = match.end(), '' if offset <= len(rule) or prefix: yield prefix + rule[offset:], None, None def add(self, rule, method, target, name=None): """ Add a new rule or replace the target for an existing rule. """ anons = 0 # Number of anonymous wildcards found keys = [] # Names of keys pattern = '' # Regular expression pattern with named groups filters = [] # Lists of wildcard input filters builder = [] # Data structure for the URL builder is_static = True for key, mode, conf in self._itertokens(rule): if mode: is_static = False if mode == 'default': mode = self.default_filter mask, in_filter, out_filter = self.filters[mode](conf) if not key: pattern += '(?:%s)' % mask key = 'anon%d' % anons anons += 1 else: pattern += '(?P<%s>%s)' % (key, mask) keys.append(key) if in_filter: filters.append((key, in_filter)) builder.append((key, out_filter or str)) elif key: pattern += re.escape(key) builder.append((None, key)) self.builder[rule] = builder if name: self.builder[name] = builder if is_static and not self.strict_order: self.static.setdefault(method, {}) self.static[method][self.build(rule)] = (target, None) return try: re_pattern = re.compile('^(%s)$' % pattern) re_match = re_pattern.match except re.error as e: raise RouteSyntaxError("Could not add Route: %s (%s)" % (rule, e)) if filters: def getargs(path): url_args = re_match(path).groupdict() for name, wildcard_filter in filters: try: url_args[name] = wildcard_filter(url_args[name]) except ValueError: raise HTTPError(400, 'Path has wrong format.') return url_args elif re_pattern.groupindex: def getargs(path): return re_match(path).groupdict() else: getargs = None flatpat = _re_flatten(pattern) whole_rule = (rule, flatpat, target, getargs) if (flatpat, method) in self._groups: if DEBUG: msg = 'Route <%s %s> overwrites a previously defined route' warnings.warn(msg % (method, rule), RuntimeWarning, stacklevel=3) self.dyna_routes[method][ self._groups[flatpat, method]] = whole_rule else: self.dyna_routes.setdefault(method, []).append(whole_rule) self._groups[flatpat, method] = len(self.dyna_routes[method]) - 1 self._compile(method) def _compile(self, method): all_rules = self.dyna_routes[method] comborules = self.dyna_regexes[method] = [] maxgroups = self._MAX_GROUPS_PER_PATTERN for x in range(0, len(all_rules), maxgroups): some = all_rules[x:x + maxgroups] combined = (flatpat for (_, flatpat, _, _) in some) combined = '|'.join('(^%s$)' % flatpat for flatpat in combined) combined = re.compile(combined).match rules = [(target, getargs) for (_, _, target, getargs) in some] comborules.append((combined, rules)) def build(self, _name, *anons, **query): """ Build an URL by filling the wildcards in a rule. """ builder = self.builder.get(_name) if not builder: raise RouteBuildError("No route with that name.", _name) try: for i, value in enumerate(anons): query['anon%d' % i] = value url = ''.join([f(query.pop(n)) if n else f for (n, f) in builder]) return url if not query else url + '?' + urlencode(query) except KeyError as E: raise RouteBuildError('Missing URL argument: %r' % E.args[0]) def match(self, environ): """ Return a (target, url_args) tuple or raise HTTPError(400/404/405). """ verb = environ['REQUEST_METHOD'].upper() path = environ['PATH_INFO'] or '/' methods = ('PROXY', 'HEAD', 'GET', 'ANY') if verb == 'HEAD' else ('PROXY', verb, 'ANY') for method in methods: if method in self.static and path in self.static[method]: target, getargs = self.static[method][path] return target, getargs(path) if getargs else {} elif method in self.dyna_regexes: for combined, rules in self.dyna_regexes[method]: match = combined(path) if match: target, getargs = rules[match.lastindex - 1] return target, getargs(path) if getargs else {} # No matching route found. Collect alternative methods for 405 response allowed = set([]) nocheck = set(methods) for method in set(self.static) - nocheck: if path in self.static[method]: allowed.add(method) for method in set(self.dyna_regexes) - allowed - nocheck: for combined, rules in self.dyna_regexes[method]: match = combined(path) if match: allowed.add(method) if allowed: allow_header = ",".join(sorted(allowed)) raise HTTPError(405, "Method not allowed.", Allow=allow_header) # No matching route and no alternative method found. We give up raise HTTPError(404, "Not found: " + repr(path)) class Route(object): """ This class wraps a route callback along with route specific metadata and configuration and applies Plugins on demand. It is also responsible for turning an URL path rule into a regular expression usable by the Router. """ def __init__(self, app, rule, method, callback, name=None, plugins=None, skiplist=None, **config): #: The application this route is installed to. self.app = app #: The path-rule string (e.g. ``/wiki/``). self.rule = rule #: The HTTP method as a string (e.g. ``GET``). self.method = method #: The original callback with no plugins applied. Useful for introspection. self.callback = callback #: The name of the route (if specified) or ``None``. self.name = name or None #: A list of route-specific plugins (see :meth:`Bottle.route`). self.plugins = plugins or [] #: A list of plugins to not apply to this route (see :meth:`Bottle.route`). self.skiplist = skiplist or [] #: Additional keyword arguments passed to the :meth:`Bottle.route` #: decorator are stored in this dictionary. Used for route-specific #: plugin configuration and meta-data. self.config = app.config._make_overlay() self.config.load_dict(config) @cached_property def call(self): """ The route callback with all plugins applied. This property is created on demand and then cached to speed up subsequent requests.""" return self._make_callback() def reset(self): """ Forget any cached values. The next time :attr:`call` is accessed, all plugins are re-applied. """ self.__dict__.pop('call', None) def prepare(self): """ Do all on-demand work immediately (useful for debugging).""" self.call def all_plugins(self): """ Yield all Plugins affecting this route. """ unique = set() for p in reversed(self.app.plugins + self.plugins): if True in self.skiplist: break name = getattr(p, 'name', False) if name and (name in self.skiplist or name in unique): continue if p in self.skiplist or type(p) in self.skiplist: continue if name: unique.add(name) yield p def _make_callback(self): callback = self.callback for plugin in self.all_plugins(): try: if hasattr(plugin, 'apply'): callback = plugin.apply(callback, self) else: callback = plugin(callback) except RouteReset: # Try again with changed configuration. return self._make_callback() if callback is not self.callback: update_wrapper(callback, self.callback) return callback def get_undecorated_callback(self): """ Return the callback. If the callback is a decorated function, try to recover the original function. """ func = self.callback func = getattr(func, '__func__' if py3k else 'im_func', func) closure_attr = '__closure__' if py3k else 'func_closure' while hasattr(func, closure_attr) and getattr(func, closure_attr): attributes = getattr(func, closure_attr) func = attributes[0].cell_contents # in case of decorators with multiple arguments if not isinstance(func, FunctionType): # pick first FunctionType instance from multiple arguments func = filter(lambda x: isinstance(x, FunctionType), map(lambda x: x.cell_contents, attributes)) func = list(func)[0] # py3 support return func def get_callback_args(self): """ Return a list of argument names the callback (most likely) accepts as keyword arguments. If the callback is a decorated function, try to recover the original function before inspection. """ return getargspec(self.get_undecorated_callback())[0] def get_config(self, key, default=None): """ Lookup a config field and return its value, first checking the route.config, then route.app.config.""" depr(0, 13, "Route.get_config() is deprecated.", "The Route.config property already includes values from the" " application config for missing keys. Access it directly.") return self.config.get(key, default) def __repr__(self): cb = self.get_undecorated_callback() return '<%s %s -> %s:%s>' % (self.method, self.rule, cb.__module__, cb.__name__) ############################################################################### # Application Object ########################################################### ############################################################################### class Bottle(object): """ 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 let debugging middleware handle exceptions. """ @lazy_attribute def _global_config(cls): cfg = ConfigDict() cfg.meta_set('catchall', 'validate', bool) return cfg def __init__(self, **kwargs): #: A :class:`ConfigDict` for app specific configuration. self.config = self._global_config._make_overlay() self.config._add_change_listener( functools.partial(self.trigger_hook, 'config')) self.config.update({ "catchall": True }) if kwargs.get('catchall') is False: depr(0, 13, "Bottle(catchall) keyword argument.", "The 'catchall' setting is now part of the app " "configuration. Fix: `app.config['catchall'] = False`") self.config['catchall'] = False if kwargs.get('autojson') is False: depr(0, 13, "Bottle(autojson) keyword argument.", "The 'autojson' setting is now part of the app " "configuration. Fix: `app.config['json.enable'] = False`") self.config['json.disable'] = True self._mounts = [] #: A :class:`ResourceManager` for application files self.resources = ResourceManager() self.routes = [] # List of installed :class:`Route` instances. self.router = Router() # Maps requests to :class:`Route` instances. self.error_handler = {} # Core plugins self.plugins = [] # List of installed plugins. self.install(JSONPlugin()) self.install(TemplatePlugin()) #: If true, most exceptions are caught and returned as :exc:`HTTPError` catchall = DictProperty('config', 'catchall') __hook_names = 'before_request', 'after_request', 'app_reset', 'config' __hook_reversed = {'after_request'} @cached_property def _hooks(self): return dict((name, []) for name in self.__hook_names) def add_hook(self, name, func): """ Attach a callback to a hook. Three hooks are currently implemented: before_request Executed once before each request. The request context is available, but no routing has happened yet. after_request Executed once after each request regardless of its outcome. app_reset Called whenever :meth:`Bottle.reset` is called. """ if name in self.__hook_reversed: self._hooks[name].insert(0, func) else: self._hooks[name].append(func) def remove_hook(self, name, func): """ Remove a callback from a hook. """ if name in self._hooks and func in self._hooks[name]: self._hooks[name].remove(func) return True def trigger_hook(self, __name, *args, **kwargs): """ Trigger a hook and return a list of results. """ return [hook(*args, **kwargs) for hook in self._hooks[__name][:]] def hook(self, name): """ Return a decorator that attaches a callback to a hook. See :meth:`add_hook` for details.""" def decorator(func): self.add_hook(name, func) return func return decorator def _mount_wsgi(self, prefix, app, **options): segments = [p for p in prefix.split('/') if p] if not segments: raise ValueError('WSGI applications cannot be mounted to "/".') path_depth = len(segments) def mountpoint_wrapper(): try: request.path_shift(path_depth) rs = HTTPResponse([]) def start_response(status, headerlist, exc_info=None): if exc_info: _raise(*exc_info) if py3k: # Errors here mean that the mounted WSGI app did not # follow PEP-3333 (which requires latin1) or used a # pre-encoding other than utf8 :/ status = status.encode('latin1').decode('utf8') headerlist = [(k, v.encode('latin1').decode('utf8')) for (k, v) in headerlist] rs.status = status for name, value in headerlist: rs.add_header(name, value) return rs.body.append body = app(request.environ, start_response) rs.body = itertools.chain(rs.body, body) if rs.body else body return rs finally: request.path_shift(-path_depth) options.setdefault('skip', True) options.setdefault('method', 'PROXY') options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) options['callback'] = mountpoint_wrapper self.route('/%s/<:re:.*>' % '/'.join(segments), **options) if not prefix.endswith('/'): self.route('/' + '/'.join(segments), **options) def _mount_app(self, prefix, app, **options): if app in self._mounts or '_mount.app' in app.config: depr(0, 13, "Application mounted multiple times. Falling back to WSGI mount.", "Clone application before mounting to a different location.") return self._mount_wsgi(prefix, app, **options) if options: depr(0, 13, "Unsupported mount options. Falling back to WSGI mount.", "Do not specify any route options when mounting bottle application.") return self._mount_wsgi(prefix, app, **options) if not prefix.endswith("/"): depr(0, 13, "Prefix must end in '/'. Falling back to WSGI mount.", "Consider adding an explicit redirect from '/prefix' to '/prefix/' in the parent application.") return self._mount_wsgi(prefix, app, **options) self._mounts.append(app) app.config['_mount.prefix'] = prefix app.config['_mount.app'] = self for route in app.routes: route.rule = prefix + route.rule.lstrip('/') self.add_route(route) def mount(self, prefix, app, **options): """ Mount an application (:class:`Bottle` or plain WSGI) to a specific URL prefix. Example:: parent_app.mount('/prefix/', child_app) :param prefix: path prefix or `mount-point`. :param app: an instance of :class:`Bottle` or a WSGI application. Plugins from the parent application are not applied to the routes of the mounted child application. If you need plugins in the child application, install them separately. While it is possible to use path wildcards within the prefix path (:class:`Bottle` childs only), it is highly discouraged. The prefix path must end with a slash. If you want to access the root of the child application via `/prefix` in addition to `/prefix/`, consider adding a route with a 307 redirect to the parent application. """ if not prefix.startswith('/'): raise ValueError("Prefix must start with '/'") if isinstance(app, Bottle): return self._mount_app(prefix, app, **options) else: return self._mount_wsgi(prefix, app, **options) def merge(self, routes): """ Merge the routes of another :class:`Bottle` application or a list of :class:`Route` objects into this application. The routes keep their 'owner', meaning that the :data:`Route.app` attribute is not changed. """ if isinstance(routes, Bottle): routes = routes.routes for route in routes: self.add_route(route) def install(self, plugin): """ Add a plugin to the list of plugins and prepare it for being applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API. """ if hasattr(plugin, 'setup'): plugin.setup(self) if not callable(plugin) and not hasattr(plugin, 'apply'): raise TypeError("Plugins must be callable or implement .apply()") self.plugins.append(plugin) self.reset() return plugin def uninstall(self, plugin): """ Uninstall plugins. Pass an instance to remove a specific plugin, a type object to remove all plugins that match that type, a string to remove all plugins with a matching ``name`` attribute or ``True`` to remove all plugins. Return the list of removed plugins. """ removed, remove = [], plugin for i, plugin in list(enumerate(self.plugins))[::-1]: if remove is True or remove is plugin or remove is type(plugin) \ or getattr(plugin, 'name', True) == remove: removed.append(plugin) del self.plugins[i] if hasattr(plugin, 'close'): plugin.close() if removed: self.reset() return removed def reset(self, route=None): """ Reset all routes (force plugins to be re-applied) and clear all caches. If an ID or route object is given, only that specific route is affected. """ if route is None: routes = self.routes elif isinstance(route, Route): routes = [route] else: routes = [self.routes[route]] for route in routes: route.reset() if DEBUG: for route in routes: route.prepare() self.trigger_hook('app_reset') def close(self): """ Close the application and all installed plugins. """ for plugin in self.plugins: if hasattr(plugin, 'close'): plugin.close() def run(self, **kwargs): """ Calls :func:`run` with the same parameters. """ run(self, **kwargs) def match(self, environ): """ Search for a matching route and return a (:class:`Route`, urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.""" return self.router.match(environ) def get_url(self, routename, **kargs): """ Return a string that matches a named route """ scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/' location = self.router.build(routename, **kargs).lstrip('/') return urljoin(urljoin('/', scriptname), location) def add_route(self, route): """ Add a route object, but do not change the :data:`Route.app` attribute.""" self.routes.append(route) self.router.add(route.rule, route.method, route, name=route.name) if DEBUG: route.prepare() def route(self, path=None, method='GET', callback=None, name=None, apply=None, skip=None, **config): """ A decorator to bind a function to a request URL. Example:: @app.route('/hello/') def hello(name): return 'Hello %s' % name The ```` part is a wildcard. See :class:`Router` for syntax details. :param path: Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function. :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. (default: `GET`) :param callback: An optional shortcut to avoid the decorator syntax. ``route(..., callback=func)`` equals ``route(...)(func)`` :param name: The name for this route. (default: None) :param apply: A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins. :param skip: A list of plugins, plugin classes or names. Matching plugins are not installed to this route. ``True`` skips all. Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see :meth:`Plugin.apply`). """ if callable(path): path, callback = None, path plugins = makelist(apply) skiplist = makelist(skip) def decorator(callback): if isinstance(callback, basestring): callback = load(callback) for rule in makelist(path) or yieldroutes(callback): for verb in makelist(method): verb = verb.upper() route = Route(self, rule, verb, callback, name=name, plugins=plugins, skiplist=skiplist, **config) self.add_route(route) return callback return decorator(callback) if callback else decorator def get(self, path=None, method='GET', **options): """ Equals :meth:`route`. """ return self.route(path, method, **options) def post(self, path=None, method='POST', **options): """ Equals :meth:`route` with a ``POST`` method parameter. """ return self.route(path, method, **options) def put(self, path=None, method='PUT', **options): """ Equals :meth:`route` with a ``PUT`` method parameter. """ return self.route(path, method, **options) def delete(self, path=None, method='DELETE', **options): """ Equals :meth:`route` with a ``DELETE`` method parameter. """ return self.route(path, method, **options) def patch(self, path=None, method='PATCH', **options): """ Equals :meth:`route` with a ``PATCH`` method parameter. """ return self.route(path, method, **options) def error(self, code=500, callback=None): """ Register an output handler for a HTTP error code. Can be used as a decorator or called directly :: def error_handler_500(error): return 'error_handler_500' app.error(code=500, callback=error_handler_500) @app.error(404) def error_handler_404(error): return 'error_handler_404' """ def decorator(callback): if isinstance(callback, basestring): callback = load(callback) self.error_handler[int(code)] = callback return callback return decorator(callback) if callback else decorator def default_error_handler(self, res): return tob(template(ERROR_PAGE_TEMPLATE, e=res, template_settings=dict(name='__ERROR_PAGE_TEMPLATE'))) def _handle(self, environ): path = environ['bottle.raw_path'] = environ['PATH_INFO'] if py3k: environ['PATH_INFO'] = path.encode('latin1').decode('utf8', 'ignore') environ['bottle.app'] = self request.bind(environ) response.bind() try: while True: # Remove in 0.14 together with RouteReset out = None try: self.trigger_hook('before_request') route, args = self.router.match(environ) environ['route.handle'] = route environ['bottle.route'] = route environ['route.url_args'] = args out = route.call(**args) break except HTTPResponse as E: out = E break except RouteReset: depr(0, 13, "RouteReset exception deprecated", "Call route.call() after route.reset() and " "return the result.") route.reset() continue finally: if isinstance(out, HTTPResponse): out.apply(response) try: self.trigger_hook('after_request') except HTTPResponse as E: out = E out.apply(response) except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception as E: if not self.catchall: raise stacktrace = format_exc() environ['wsgi.errors'].write(stacktrace) environ['wsgi.errors'].flush() environ['bottle.exc_info'] = sys.exc_info() out = HTTPError(500, "Internal Server Error", E, stacktrace) out.apply(response) return out def _cast(self, out, peek=None): """ Try to convert the parameter into something WSGI compatible and set correct HTTP headers when possible. Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like, iterable of strings and iterable of unicodes """ # Empty output is done here if not out: if 'Content-Length' not in response: response['Content-Length'] = 0 return [] # Join lists of byte or unicode strings. Mixed lists are NOT supported if isinstance(out, (tuple, list))\ and isinstance(out[0], (bytes, unicode)): out = out[0][0:0].join(out) # b'abc'[0:0] -> b'' # Encode unicode strings if isinstance(out, unicode): out = out.encode(response.charset) # Byte Strings are just returned if isinstance(out, bytes): if 'Content-Length' not in response: response['Content-Length'] = len(out) return [out] # HTTPError or HTTPException (recursive, because they may wrap anything) # TODO: Handle these explicitly in handle() or make them iterable. if isinstance(out, HTTPError): out.apply(response) out = self.error_handler.get(out.status_code, self.default_error_handler)(out) return self._cast(out) if isinstance(out, HTTPResponse): out.apply(response) return self._cast(out.body) # File-like objects. if hasattr(out, 'read'): if 'wsgi.file_wrapper' in request.environ: return request.environ['wsgi.file_wrapper'](out) elif hasattr(out, 'close') or not hasattr(out, '__iter__'): return WSGIFileWrapper(out) # Handle Iterables. We peek into them to detect their inner type. try: iout = iter(out) first = next(iout) while not first: first = next(iout) except StopIteration: return self._cast('') except HTTPResponse as E: first = E except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception as error: if not self.catchall: raise first = HTTPError(500, 'Unhandled exception', error, format_exc()) # These are the inner types allowed in iterator or generator objects. if isinstance(first, HTTPResponse): return self._cast(first) elif isinstance(first, bytes): new_iter = itertools.chain([first], iout) elif isinstance(first, unicode): encoder = lambda x: x.encode(response.charset) new_iter = imap(encoder, itertools.chain([first], iout)) else: msg = 'Unsupported response type: %s' % type(first) return self._cast(HTTPError(500, msg)) if hasattr(out, 'close'): new_iter = _closeiter(new_iter, out.close) return new_iter def wsgi(self, environ, start_response): """ The bottle WSGI-interface. """ try: out = self._cast(self._handle(environ)) # rfc2616 section 4.3 if response._status_code in (100, 101, 204, 304)\ or environ['REQUEST_METHOD'] == 'HEAD': if hasattr(out, 'close'): out.close() out = [] exc_info = environ.get('bottle.exc_info') if exc_info is not None: del environ['bottle.exc_info'] start_response(response._wsgi_status_line(), response.headerlist, exc_info) return out except (KeyboardInterrupt, SystemExit, MemoryError): raise except Exception as E: if not self.catchall: raise err = '

Critical error while processing request: %s

' \ % html_escape(environ.get('PATH_INFO', '/')) if DEBUG: err += '

Error:

\n
\n%s\n
\n' \ '

Traceback:

\n
\n%s\n
\n' \ % (html_escape(repr(E)), html_escape(format_exc())) environ['wsgi.errors'].write(err) environ['wsgi.errors'].flush() headers = [('Content-Type', 'text/html; charset=UTF-8')] start_response('500 INTERNAL SERVER ERROR', headers, sys.exc_info()) return [tob(err)] def __call__(self, environ, start_response): """ Each instance of :class:'Bottle' is a WSGI application. """ return self.wsgi(environ, start_response) def __enter__(self): """ Use this application as default for all module-level shortcuts. """ default_app.push(self) return self def __exit__(self, exc_type, exc_value, traceback): default_app.pop() def __setattr__(self, name, value): if name in self.__dict__: raise AttributeError("Attribute %s already defined. Plugin conflict?" % name) object.__setattr__(self, name, value) ############################################################################### # HTTP and WSGI Tools ########################################################## ############################################################################### class BaseRequest(object): """ A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only. Adding new attributes to a request actually adds them to the environ dictionary (as 'bottle.request.ext.'). This is the recommended way to store and access request-specific data. """ __slots__ = ('environ', ) #: Maximum size of memory buffer for :attr:`body` in bytes. MEMFILE_MAX = 102400 def __init__(self, environ=None): """ Wrap a WSGI environ dictionary. """ #: The wrapped WSGI environ dictionary. This is the only real attribute. #: All other attributes actually are read-only properties. self.environ = {} if environ is None else environ self.environ['bottle.request'] = self @DictProperty('environ', 'bottle.app', read_only=True) def app(self): """ Bottle application handling this request. """ raise RuntimeError('This request is not connected to an application.') @DictProperty('environ', 'bottle.route', read_only=True) def route(self): """ The bottle :class:`Route` object that matches this request. """ raise RuntimeError('This request is not connected to a route.') @DictProperty('environ', 'route.url_args', read_only=True) def url_args(self): """ The arguments extracted from the URL. """ raise RuntimeError('This request is not connected to a route.') @property def path(self): """ The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken clients and avoid the "empty path" edge case). """ return '/' + self.environ.get('PATH_INFO', '').lstrip('/') @property def method(self): """ The ``REQUEST_METHOD`` value as an uppercase string. """ return self.environ.get('REQUEST_METHOD', 'GET').upper() @DictProperty('environ', 'bottle.request.headers', read_only=True) def headers(self): """ A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP request headers. """ return WSGIHeaderDict(self.environ) def get_header(self, name, default=None): """ Return the value of a request header, or a given default value. """ return self.headers.get(name, default) @DictProperty('environ', 'bottle.request.cookies', read_only=True) def cookies(self): """ Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. Use :meth:`get_cookie` if you expect signed cookies. """ cookies = SimpleCookie(self.environ.get('HTTP_COOKIE', '')).values() return FormsDict((c.key, c.value) for c in cookies) def get_cookie(self, key, default=None, secret=None, digestmod=hashlib.sha256): """ Return the content of a cookie. To read a `Signed Cookie`, the `secret` must match the one used to create the cookie (see :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or wrong signature), return a default value. """ value = self.cookies.get(key) if secret: # See BaseResponse.set_cookie for details on signed cookies. if value and value.startswith('!') and '?' in value: sig, msg = map(tob, value[1:].split('?', 1)) hash = hmac.new(tob(secret), msg, digestmod=digestmod).digest() if _lscmp(sig, base64.b64encode(hash)): dst = pickle.loads(base64.b64decode(msg)) if dst and dst[0] == key: return dst[1] return default return value or default @DictProperty('environ', 'bottle.request.query', read_only=True) def query(self): """ The :attr:`query_string` parsed into a :class:`FormsDict`. These values are sometimes called "URL arguments" or "GET parameters", but not to be confused with "URL wildcards" as they are provided by the :class:`Router`. """ get = self.environ['bottle.get'] = FormsDict() pairs = _parse_qsl(self.environ.get('QUERY_STRING', '')) for key, value in pairs: get[key] = value return get @DictProperty('environ', 'bottle.request.forms', read_only=True) def forms(self): """ Form values parsed from an `url-encoded` or `multipart/form-data` encoded POST or PUT request body. The result is returned as a :class:`FormsDict`. All keys and values are strings. File uploads are stored separately in :attr:`files`. """ forms = FormsDict() forms.recode_unicode = self.POST.recode_unicode for name, item in self.POST.allitems(): if not isinstance(item, FileUpload): forms[name] = item return forms @DictProperty('environ', 'bottle.request.params', read_only=True) def params(self): """ A :class:`FormsDict` with the combined values of :attr:`query` and :attr:`forms`. File uploads are stored in :attr:`files`. """ params = FormsDict() for key, value in self.query.allitems(): params[key] = value for key, value in self.forms.allitems(): params[key] = value return params @DictProperty('environ', 'bottle.request.files', read_only=True) def files(self): """ File uploads parsed from `multipart/form-data` encoded POST or PUT request body. The values are instances of :class:`FileUpload`. """ files = FormsDict() files.recode_unicode = self.POST.recode_unicode for name, item in self.POST.allitems(): if isinstance(item, FileUpload): files[name] = item return files @DictProperty('environ', 'bottle.request.json', read_only=True) def json(self): """ If the ``Content-Type`` header is ``application/json`` or ``application/json-rpc``, this property holds the parsed content of the request body. Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory exhaustion. Invalid JSON raises a 400 error response. """ ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0] if ctype in ('application/json', 'application/json-rpc'): b = self._get_body_string(self.MEMFILE_MAX) if not b: return None try: return json_loads(b) except (ValueError, TypeError): raise HTTPError(400, 'Invalid JSON') return None def _iter_body(self, read, bufsize): maxread = max(0, self.content_length) while maxread: part = read(min(maxread, bufsize)) if not part: break yield part maxread -= len(part) @staticmethod def _iter_chunked(read, bufsize): err = HTTPError(400, 'Error while parsing chunked transfer body.') rn, sem, bs = tob('\r\n'), tob(';'), tob('') while True: header = read(1) while header[-2:] != rn: c = read(1) header += c if not c: raise err if len(header) > bufsize: raise err size, _, _ = header.partition(sem) try: maxread = int(tonat(size.strip()), 16) except ValueError: raise err if maxread == 0: break buff = bs while maxread > 0: if not buff: buff = read(min(maxread, bufsize)) part, buff = buff[:maxread], buff[maxread:] if not part: raise err yield part maxread -= len(part) if read(2) != rn: raise err @DictProperty('environ', 'bottle.request.body', read_only=True) def _body(self): try: read_func = self.environ['wsgi.input'].read except KeyError: self.environ['wsgi.input'] = BytesIO() return self.environ['wsgi.input'] body_iter = self._iter_chunked if self.chunked else self._iter_body body, body_size, is_temp_file = BytesIO(), 0, False for part in body_iter(read_func, self.MEMFILE_MAX): body.write(part) body_size += len(part) if not is_temp_file and body_size > self.MEMFILE_MAX: body, tmp = NamedTemporaryFile(mode='w+b'), body body.write(tmp.getvalue()) del tmp is_temp_file = True self.environ['wsgi.input'] = body body.seek(0) return body def _get_body_string(self, maxread): """ Read body into a string. Raise HTTPError(413) on requests that are too large. """ if self.content_length > maxread: raise HTTPError(413, 'Request entity too large') data = self.body.read(maxread + 1) if len(data) > maxread: raise HTTPError(413, 'Request entity too large') return data @property def body(self): """ The HTTP request body as a seek-able file-like object. Depending on :attr:`MEMFILE_MAX`, this is either a temporary file or a :class:`io.BytesIO` instance. Accessing this property for the first time reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses just do a `seek(0)` on the file object. """ self._body.seek(0) return self._body @property def chunked(self): """ True if Chunked transfer encoding was. """ return 'chunked' in self.environ.get( 'HTTP_TRANSFER_ENCODING', '').lower() #: An alias for :attr:`query`. GET = query @DictProperty('environ', 'bottle.request.post', read_only=True) def POST(self): """ The values of :attr:`forms` and :attr:`files` combined into a single :class:`FormsDict`. Values are either strings (form values) or instances of :class:`FileUpload`. """ post = FormsDict() content_type = self.environ.get('CONTENT_TYPE', '') content_type, options = _parse_http_header(content_type)[0] # We default to application/x-www-form-urlencoded for everything that # is not multipart and take the fast path (also: 3.1 workaround) if not content_type.startswith('multipart/'): body = tonat(self._get_body_string(self.MEMFILE_MAX), 'latin1') for key, value in _parse_qsl(body): post[key] = value return post post.recode_unicode = False charset = options.get("charset", "utf8") boundary = options.get("boundary") if not boundary: raise MultipartError("Invalid content type header, missing boundary") parser = _MultipartParser(self.body, boundary, self.content_length, mem_limit=self.MEMFILE_MAX, memfile_limit=self.MEMFILE_MAX, charset=charset) for part in parser.parse(): if not part.filename and part.is_buffered(): post[part.name] = tonat(part.value, 'utf8') else: post[part.name] = FileUpload(part.file, part.name, part.filename, part.headerlist) return post @property def url(self): """ The full request URI including hostname and scheme. If your app lives behind a reverse proxy or load balancer and you get confusing results, make sure that the ``X-Forwarded-Host`` header is set correctly. """ return self.urlparts.geturl() @DictProperty('environ', 'bottle.request.urlparts', read_only=True) def urlparts(self): """ The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple contains (scheme, host, path, query_string and fragment), but the fragment is always empty because it is not visible to the server. """ env = self.environ http = env.get('HTTP_X_FORWARDED_PROTO') \ or env.get('wsgi.url_scheme', 'http') host = env.get('HTTP_X_FORWARDED_HOST') or env.get('HTTP_HOST') if not host: # HTTP 1.1 requires a Host-header. This is for HTTP/1.0 clients. host = env.get('SERVER_NAME', '127.0.0.1') port = env.get('SERVER_PORT') if port and port != ('80' if http == 'http' else '443'): host += ':' + port path = urlquote(self.fullpath) return UrlSplitResult(http, host, path, env.get('QUERY_STRING'), '') @property def fullpath(self): """ Request path including :attr:`script_name` (if present). """ return urljoin(self.script_name, self.path.lstrip('/')) @property def query_string(self): """ The raw :attr:`query` part of the URL (everything in between ``?`` and ``#``) as a string. """ return self.environ.get('QUERY_STRING', '') @property def script_name(self): """ The initial portion of the URL's `path` that was removed by a higher level (server or routing middleware) before the application was called. This script path is returned with leading and tailing slashes. """ script_name = self.environ.get('SCRIPT_NAME', '').strip('/') return '/' + script_name + '/' if script_name else '/' def path_shift(self, shift=1): """ Shift path segments from :attr:`path` to :attr:`script_name` and vice versa. :param shift: The number of path segments to shift. May be negative to change the shift direction. (default: 1) """ script, path = path_shift(self.environ.get('SCRIPT_NAME', '/'), self.path, shift) self['SCRIPT_NAME'], self['PATH_INFO'] = script, path @property def content_length(self): """ The request body length as an integer. The client is responsible to set this header. Otherwise, the real length of the body is unknown and -1 is returned. In this case, :attr:`body` will be empty. """ return int(self.environ.get('CONTENT_LENGTH') or -1) @property def content_type(self): """ The Content-Type header as a lowercase-string (default: empty). """ return self.environ.get('CONTENT_TYPE', '').lower() @property def is_xhr(self): """ True if the request was triggered by a XMLHttpRequest. This only works with JavaScript libraries that support the `X-Requested-With` header (most of the popular libraries do). """ requested_with = self.environ.get('HTTP_X_REQUESTED_WITH', '') return requested_with.lower() == 'xmlhttprequest' @property def is_ajax(self): """ Alias for :attr:`is_xhr`. "Ajax" is not the right term. """ return self.is_xhr @property def auth(self): """ HTTP authentication data as a (user, password) tuple. This implementation currently supports basic (not digest) authentication only. If the authentication happened at a higher level (e.g. in the front web-server or a middleware), the password field is None, but the user field is looked up from the ``REMOTE_USER`` environ variable. On any errors, None is returned. """ basic = parse_auth(self.environ.get('HTTP_AUTHORIZATION', '')) if basic: return basic ruser = self.environ.get('REMOTE_USER') if ruser: return (ruser, None) return None @property def remote_route(self): """ A list of all IPs that were involved in this request, starting with the client IP and followed by zero or more proxies. This does only work if all proxies support the ```X-Forwarded-For`` header. Note that this information can be forged by malicious clients. """ proxy = self.environ.get('HTTP_X_FORWARDED_FOR') if proxy: return [ip.strip() for ip in proxy.split(',')] remote = self.environ.get('REMOTE_ADDR') return [remote] if remote else [] @property def remote_addr(self): """ The client IP as a string. Note that this information can be forged by malicious clients. """ route = self.remote_route return route[0] if route else None def copy(self): """ Return a new :class:`Request` with a shallow :attr:`environ` copy. """ return Request(self.environ.copy()) def get(self, value, default=None): return self.environ.get(value, default) def __getitem__(self, key): return self.environ[key] def __delitem__(self, key): self[key] = "" del (self.environ[key]) def __iter__(self): return iter(self.environ) def __len__(self): return len(self.environ) def keys(self): return self.environ.keys() def __setitem__(self, key, value): """ Change an environ value and clear all caches that depend on it. """ if self.environ.get('bottle.request.readonly'): raise KeyError('The environ dictionary is read-only.') self.environ[key] = value todelete = () if key == 'wsgi.input': todelete = ('body', 'forms', 'files', 'params', 'post', 'json') elif key == 'QUERY_STRING': todelete = ('query', 'params') elif key.startswith('HTTP_'): todelete = ('headers', 'cookies') for key in todelete: self.environ.pop('bottle.request.' + key, None) def __repr__(self): return '<%s: %s %s>' % (self.__class__.__name__, self.method, self.url) def __getattr__(self, name): """ Search in self.environ for additional user defined attributes. """ try: var = self.environ['bottle.request.ext.%s' % name] return var.__get__(self) if hasattr(var, '__get__') else var except KeyError: raise AttributeError('Attribute %r not defined.' % name) def __setattr__(self, name, value): """ Define new attributes that are local to the bound request environment. """ if name == 'environ': return object.__setattr__(self, name, value) key = 'bottle.request.ext.%s' % name if hasattr(self, name): raise AttributeError("Attribute already defined: %s" % name) self.environ[key] = value def __delattr__(self, name): try: del self.environ['bottle.request.ext.%s' % name] except KeyError: raise AttributeError("Attribute not defined: %s" % name) def _hkey(key): if '\n' in key or '\r' in key or '\0' in key: raise ValueError("Header names must not contain control characters: %r" % key) return key.title().replace('_', '-') def _hval(value): value = tonat(value) if '\n' in value or '\r' in value or '\0' in value: raise ValueError("Header value must not contain control characters: %r" % value) return value class HeaderProperty(object): def __init__(self, name, reader=None, writer=None, default=''): self.name, self.default = name, default self.reader, self.writer = reader, writer self.__doc__ = 'Current value of the %r header.' % name.title() def __get__(self, obj, _): if obj is None: return self value = obj.get_header(self.name, self.default) return self.reader(value) if self.reader else value def __set__(self, obj, value): obj[self.name] = self.writer(value) if self.writer else value def __delete__(self, obj): del obj[self.name] class BaseResponse(object): """ Storage class for a response body as well as headers and cookies. This class does support dict-like case-insensitive item-access to headers, but is NOT a dict. Most notably, iterating over a response yields parts of the body and not the headers. """ default_status = 200 default_content_type = 'text/html; charset=UTF-8' # Header denylist for specific response codes # (rfc2616 section 10.2.3 and 10.3.5) bad_headers = { 204: frozenset(('Content-Type', 'Content-Length')), 304: frozenset(('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-Range', 'Content-Type', 'Content-Md5', 'Last-Modified')) } def __init__(self, body='', status=None, headers=None, **more_headers): """ Create a new response object. :param body: The response body as one of the supported types. :param status: Either an HTTP status code (e.g. 200) or a status line including the reason phrase (e.g. '200 OK'). :param headers: A dictionary or a list of name-value pairs. Additional keyword arguments are added to the list of headers. Underscores in the header name are replaced with dashes. """ self._cookies = None self._headers = {} self.body = body self.status = status or self.default_status if headers: if isinstance(headers, dict): headers = headers.items() for name, value in headers: self.add_header(name, value) if more_headers: for name, value in more_headers.items(): self.add_header(name, value) def copy(self, cls=None): """ Returns a copy of self. """ cls = cls or BaseResponse assert issubclass(cls, BaseResponse) copy = cls() copy.status = self.status copy._headers = dict((k, v[:]) for (k, v) in self._headers.items()) if self._cookies: cookies = copy._cookies = SimpleCookie() for k,v in self._cookies.items(): cookies[k] = v.value cookies[k].update(v) # also copy cookie attributes return copy def __iter__(self): return iter(self.body) def close(self): if hasattr(self.body, 'close'): self.body.close() @property def status_line(self): """ The HTTP status line as a string (e.g. ``404 Not Found``).""" return self._status_line @property def status_code(self): """ The HTTP status code as an integer (e.g. 404).""" return self._status_code def _set_status(self, status): if isinstance(status, int): code, status = status, _HTTP_STATUS_LINES.get(status) elif ' ' in status: if '\n' in status or '\r' in status or '\0' in status: raise ValueError('Status line must not include control chars.') status = status.strip() code = int(status.split()[0]) else: raise ValueError('String status line without a reason phrase.') if not 100 <= code <= 999: raise ValueError('Status code out of range.') self._status_code = code self._status_line = str(status or ('%d Unknown' % code)) def _get_status(self): return self._status_line status = property( _get_status, _set_status, None, ''' A writeable property to change the HTTP response status. It accepts either a numeric code (100-999) or a string with a custom reason phrase (e.g. "404 Brain not found"). Both :data:`status_line` and :data:`status_code` are updated accordingly. The return value is always a status string. ''') del _get_status, _set_status @property def headers(self): """ An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the response headers. """ hdict = HeaderDict() hdict.dict = self._headers return hdict def __contains__(self, name): return _hkey(name) in self._headers def __delitem__(self, name): del self._headers[_hkey(name)] def __getitem__(self, name): return self._headers[_hkey(name)][-1] def __setitem__(self, name, value): self._headers[_hkey(name)] = [_hval(value)] def get_header(self, name, default=None): """ Return the value of a previously defined header. If there is no header with that name, return a default value. """ return self._headers.get(_hkey(name), [default])[-1] def set_header(self, name, value): """ Create a new response header, replacing any previously defined headers with the same name. """ self._headers[_hkey(name)] = [_hval(value)] def add_header(self, name, value): """ Add an additional response header, not removing duplicates. """ self._headers.setdefault(_hkey(name), []).append(_hval(value)) def iter_headers(self): """ Yield (header, value) tuples, skipping headers that are not allowed with the current response status code. """ return self.headerlist def _wsgi_status_line(self): """ WSGI conform status line (latin1-encodeable) """ if py3k: return self._status_line.encode('utf8').decode('latin1') return self._status_line @property def headerlist(self): """ WSGI conform list of (header, value) tuples. """ out = [] headers = list(self._headers.items()) if 'Content-Type' not in self._headers: headers.append(('Content-Type', [self.default_content_type])) if self._status_code in self.bad_headers: bad_headers = self.bad_headers[self._status_code] headers = [h for h in headers if h[0] not in bad_headers] out += [(name, val) for (name, vals) in headers for val in vals] if self._cookies: for c in self._cookies.values(): out.append(('Set-Cookie', _hval(c.OutputString()))) if py3k: out = [(k, v.encode('utf8').decode('latin1')) for (k, v) in out] return out content_type = HeaderProperty('Content-Type') content_length = HeaderProperty('Content-Length', reader=int, default=-1) expires = HeaderProperty( 'Expires', reader=lambda x: datetime.fromtimestamp(parse_date(x), UTC), writer=lambda x: http_date(x)) @property def charset(self, default='UTF-8'): """ Return the charset specified in the content-type header (default: utf8). """ if 'charset=' in self.content_type: return self.content_type.split('charset=')[-1].split(';')[0].strip() return default def set_cookie(self, name, value, secret=None, digestmod=hashlib.sha256, **options): """ Create a new cookie or replace an old one. If the `secret` parameter is set, create a `Signed Cookie` (described below). :param name: the name of the cookie. :param value: the value of the cookie. :param secret: a signature key required for signed cookies. Additionally, this method accepts all RFC 2109 attributes that are supported by :class:`cookie.Morsel`, including: :param maxage: maximum age in seconds. (default: None) :param expires: a datetime object or UNIX timestamp. (default: None) :param domain: the domain that is allowed to read the cookie. (default: current domain) :param path: limits the cookie to a given path (default: current path) :param secure: limit the cookie to HTTPS connections (default: off). :param httponly: prevents client-side javascript to read this cookie (default: off, requires Python 2.6 or newer). :param samesite: Control or disable third-party use for this cookie. Possible values: `lax`, `strict` or `none` (default). If neither `expires` nor `maxage` is set (default), the cookie will expire at the end of the browser session (as soon as the browser window is closed). Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers. Warning: Pickle is a potentially dangerous format. If an attacker gains access to the secret key, he could forge cookies that execute code on server side if unpickled. Using pickle is discouraged and support for it will be removed in later versions of bottle. Warning: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling save, not to store secret information at client side. """ if not self._cookies: self._cookies = SimpleCookie() # Monkey-patch Cookie lib to support 'SameSite' parameter # https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1 if py < (3, 8, 0): Morsel._reserved.setdefault('samesite', 'SameSite') if secret: if not isinstance(value, basestring): depr(0, 13, "Pickling of arbitrary objects into cookies is " "deprecated.", "Only store strings in cookies. " "JSON strings are fine, too.") encoded = base64.b64encode(pickle.dumps([name, value], -1)) sig = base64.b64encode(hmac.new(tob(secret), encoded, digestmod=digestmod).digest()) value = touni(tob('!') + sig + tob('?') + encoded) elif not isinstance(value, basestring): raise TypeError('Secret key required for non-string cookies.') # Cookie size plus options must not exceed 4kb. if len(name) + len(value) > 3800: raise ValueError('Content does not fit into a cookie.') self._cookies[name] = value for key, value in options.items(): if key in ('max_age', 'maxage'): # 'maxage' variant added in 0.13 key = 'max-age' if isinstance(value, timedelta): value = value.seconds + value.days * 24 * 3600 if key == 'expires': value = http_date(value) if key in ('same_site', 'samesite'): # 'samesite' variant added in 0.13 key, value = 'samesite', (value or "none").lower() if value not in ('lax', 'strict', 'none'): raise CookieError("Invalid value for SameSite") if key in ('secure', 'httponly') and not value: continue self._cookies[name][key] = value def delete_cookie(self, key, **kwargs): """ Delete a cookie. Be sure to use the same `domain` and `path` settings as used to create the cookie. """ kwargs['max_age'] = -1 kwargs['expires'] = 0 self.set_cookie(key, '', **kwargs) def __repr__(self): out = '' for name, value in self.headerlist: out += '%s: %s\n' % (name.title(), value.strip()) return out def _local_property(): ls = threading.local() def fget(_): try: return ls.var except AttributeError: raise RuntimeError("Request context not initialized.") def fset(_, value): ls.var = value def fdel(_): del ls.var return property(fget, fset, fdel, 'Thread-local property') class LocalRequest(BaseRequest): """ A thread-local subclass of :class:`BaseRequest` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`request`). If accessed during a request/response cycle, this instance always refers to the *current* request (even on a multithreaded server). """ bind = BaseRequest.__init__ environ = _local_property() class LocalResponse(BaseResponse): """ A thread-local subclass of :class:`BaseResponse` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`response`). Its attributes are used to build the HTTP response at the end of the request/response cycle. """ bind = BaseResponse.__init__ _status_line = _local_property() _status_code = _local_property() _cookies = _local_property() _headers = _local_property() body = _local_property() Request = BaseRequest Response = BaseResponse class HTTPResponse(Response, BottleException): """ A subclass of :class:`Response` that can be raised or returned from request handlers to short-curcuit request processing and override changes made to the global :data:`request` object. This bypasses error handlers, even if the status code indicates an error. Return or raise :class:`HTTPError` to trigger error handlers. """ def __init__(self, body='', status=None, headers=None, **more_headers): super(HTTPResponse, self).__init__(body, status, headers, **more_headers) def apply(self, other): """ Copy the state of this response to a different :class:`Response` object. """ other._status_code = self._status_code other._status_line = self._status_line other._headers = self._headers other._cookies = self._cookies other.body = self.body class HTTPError(HTTPResponse): """ A subclass of :class:`HTTPResponse` that triggers error handlers. """ default_status = 500 def __init__(self, status=None, body=None, exception=None, traceback=None, **more_headers): self.exception = exception self.traceback = traceback super(HTTPError, self).__init__(body, status, **more_headers) ############################################################################### # Plugins ###################################################################### ############################################################################### class PluginError(BottleException): pass class JSONPlugin(object): name = 'json' api = 2 def __init__(self, json_dumps=json_dumps): self.json_dumps = json_dumps def setup(self, app): app.config._define('json.enable', default=True, validate=bool, help="Enable or disable automatic dict->json filter.") app.config._define('json.ascii', default=False, validate=bool, help="Use only 7-bit ASCII characters in output.") app.config._define('json.indent', default=True, validate=bool, help="Add whitespace to make json more readable.") app.config._define('json.dump_func', default=None, help="If defined, use this function to transform" " dict into json. The other options no longer" " apply.") def apply(self, callback, route): dumps = self.json_dumps if not self.json_dumps: return callback @functools.wraps(callback) def wrapper(*a, **ka): try: rv = callback(*a, **ka) except HTTPResponse as resp: rv = resp if isinstance(rv, dict): #Attempt to serialize, raises exception on failure json_response = dumps(rv) #Set content type only if serialization successful response.content_type = 'application/json' return json_response elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict): rv.body = dumps(rv.body) rv.content_type = 'application/json' return rv return wrapper class TemplatePlugin(object): """ This plugin applies the :func:`view` decorator to all routes with a `template` config parameter. If the parameter is a tuple, the second element must be a dict with additional options (e.g. `template_engine`) or default variables for the template. """ name = 'template' api = 2 def setup(self, app): app.tpl = self def apply(self, callback, route): conf = route.config.get('template') if isinstance(conf, (tuple, list)) and len(conf) == 2: return view(conf[0], **conf[1])(callback) elif isinstance(conf, str): return view(conf)(callback) else: return callback #: Not a plugin, but part of the plugin API. TODO: Find a better place. class _ImportRedirect(object): def __init__(self, name, impmask): """ Create a virtual package that redirects imports (see PEP 302). """ self.name = name self.impmask = impmask self.module = sys.modules.setdefault(name, new_module(name)) self.module.__dict__.update({ '__file__': __file__, '__path__': [], '__all__': [], '__loader__': self }) sys.meta_path.append(self) def find_spec(self, fullname, path, target=None): if '.' not in fullname: return if fullname.rsplit('.', 1)[0] != self.name: return from importlib.util import spec_from_loader return spec_from_loader(fullname, self) def find_module(self, fullname, path=None): if '.' not in fullname: return if fullname.rsplit('.', 1)[0] != self.name: return return self def create_module(self, spec): return self.load_module(spec.name) def exec_module(self, module): pass # This probably breaks importlib.reload() :/ def load_module(self, fullname): if fullname in sys.modules: return sys.modules[fullname] modname = fullname.rsplit('.', 1)[1] realname = self.impmask % modname __import__(realname) module = sys.modules[fullname] = sys.modules[realname] setattr(self.module, modname, module) module.__loader__ = self return module ############################################################################### # Common Utilities ############################################################# ############################################################################### class MultiDict(DictMixin): """ This dict stores multiple values per key, but behaves exactly like a normal dict in that it returns only the newest value for any given key. There are special methods available to access the full list of values. """ def __init__(self, *a, **k): self.dict = dict((k, [v]) for (k, v) in dict(*a, **k).items()) def __len__(self): return len(self.dict) def __iter__(self): return iter(self.dict) def __contains__(self, key): return key in self.dict def __delitem__(self, key): del self.dict[key] def __getitem__(self, key): return self.dict[key][-1] def __setitem__(self, key, value): self.append(key, value) def keys(self): return self.dict.keys() if py3k: def values(self): return (v[-1] for v in self.dict.values()) def items(self): return ((k, v[-1]) for k, v in self.dict.items()) def allitems(self): return ((k, v) for k, vl in self.dict.items() for v in vl) iterkeys = keys itervalues = values iteritems = items iterallitems = allitems else: def values(self): return [v[-1] for v in self.dict.values()] def items(self): return [(k, v[-1]) for k, v in self.dict.items()] def iterkeys(self): return self.dict.iterkeys() def itervalues(self): return (v[-1] for v in self.dict.itervalues()) def iteritems(self): return ((k, v[-1]) for k, v in self.dict.iteritems()) def iterallitems(self): return ((k, v) for k, vl in self.dict.iteritems() for v in vl) def allitems(self): return [(k, v) for k, vl in self.dict.iteritems() for v in vl] def get(self, key, default=None, index=-1, type=None): """ Return the most recent value for a key. :param default: The default value to be returned if the key is not present or the type conversion fails. :param index: An index for the list of available values. :param type: If defined, this callable is used to cast the value into a specific type. Exception are suppressed and result in the default value to be returned. """ try: val = self.dict[key][index] return type(val) if type else val except Exception: pass return default def append(self, key, value): """ Add a new value to the list of values for this key. """ self.dict.setdefault(key, []).append(value) def replace(self, key, value): """ Replace the list of values with a single value. """ self.dict[key] = [value] def getall(self, key): """ Return a (possibly empty) list of values for a key. """ return self.dict.get(key) or [] #: Aliases for WTForms to mimic other multi-dict APIs (Django) getone = get getlist = getall class FormsDict(MultiDict): """ This :class:`MultiDict` subclass is used to store request form data. Additionally to the normal dict-like item access methods (which return unmodified data as native strings), this container also supports attribute-like access to its values. Attributes are automatically de- or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing attributes default to an empty string. """ #: Encoding used for attribute values. input_encoding = 'utf8' #: If true (default), unicode strings are first encoded with `latin1` #: and then decoded to match :attr:`input_encoding`. recode_unicode = True def _fix(self, s, encoding=None): if isinstance(s, unicode) and self.recode_unicode: # Python 3 WSGI return s.encode('latin1').decode(encoding or self.input_encoding) elif isinstance(s, bytes): # Python 2 WSGI return s.decode(encoding or self.input_encoding) else: return s def decode(self, encoding=None): """ Returns a copy with all keys and values de- or recoded to match :attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode dictionary. """ copy = FormsDict() enc = copy.input_encoding = encoding or self.input_encoding copy.recode_unicode = False for key, value in self.allitems(): copy.append(self._fix(key, enc), self._fix(value, enc)) return copy def getunicode(self, name, default=None, encoding=None): """ Return the value as a unicode string, or the default. """ try: return self._fix(self[name], encoding) except (UnicodeError, KeyError): return default def __getattr__(self, name, default=unicode()): # Without this guard, pickle generates a cryptic TypeError: if name.startswith('__') and name.endswith('__'): return super(FormsDict, self).__getattr__(name) return self.getunicode(name, default=default) class HeaderDict(MultiDict): """ A case-insensitive version of :class:`MultiDict` that defaults to replace the old value instead of appending it. """ def __init__(self, *a, **ka): self.dict = {} if a or ka: self.update(*a, **ka) def __contains__(self, key): return _hkey(key) in self.dict def __delitem__(self, key): del self.dict[_hkey(key)] def __getitem__(self, key): return self.dict[_hkey(key)][-1] def __setitem__(self, key, value): self.dict[_hkey(key)] = [_hval(value)] def append(self, key, value): self.dict.setdefault(_hkey(key), []).append(_hval(value)) def replace(self, key, value): self.dict[_hkey(key)] = [_hval(value)] def getall(self, key): return self.dict.get(_hkey(key)) or [] def get(self, key, default=None, index=-1): return MultiDict.get(self, _hkey(key), default, index) def filter(self, names): for name in (_hkey(n) for n in names): if name in self.dict: del self.dict[name] class WSGIHeaderDict(DictMixin): """ This dict-like class wraps a WSGI environ dict and provides convenient access to HTTP_* fields. Keys and values are native strings (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI environment contains non-native string values, these are de- or encoded using a lossless 'latin1' character set. The API will remain stable even on changes to the relevant PEPs. Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-native strings.) """ #: List of keys that do not have a ``HTTP_`` prefix. cgikeys = ('CONTENT_TYPE', 'CONTENT_LENGTH') def __init__(self, environ): self.environ = environ def _ekey(self, key): """ Translate header field name to CGI/WSGI environ key. """ key = key.replace('-', '_').upper() if key in self.cgikeys: return key return 'HTTP_' + key def raw(self, key, default=None): """ Return the header value as is (may be bytes or unicode). """ return self.environ.get(self._ekey(key), default) def __getitem__(self, key): val = self.environ[self._ekey(key)] if py3k: if isinstance(val, unicode): val = val.encode('latin1').decode('utf8') else: val = val.decode('utf8') return val def __setitem__(self, key, value): raise TypeError("%s is read-only." % self.__class__) def __delitem__(self, key): raise TypeError("%s is read-only." % self.__class__) def __iter__(self): for key in self.environ: if key[:5] == 'HTTP_': yield _hkey(key[5:]) elif key in self.cgikeys: yield _hkey(key) def keys(self): return [x for x in self] def __len__(self): return len(self.keys()) def __contains__(self, key): return self._ekey(key) in self.environ _UNSET = object() class ConfigDict(dict): """ A dict-like configuration storage with additional support for namespaces, validators, meta-data and overlays. This dict-like class is heavily optimized for read access. Read-only methods and item access should be as fast as a native dict. """ __slots__ = ('_meta', '_change_listener', '_overlays', '_virtual_keys', '_source', '__weakref__') def __init__(self): self._meta = {} self._change_listener = [] #: Weak references of overlays that need to be kept in sync. self._overlays = [] #: Config that is the source for this overlay. self._source = None #: Keys of values copied from the source (values we do not own) self._virtual_keys = set() def load_module(self, name, squash=True): """Load values from a Python module. Import a python module by name and add all upper-case module-level variables to this config dict. :param name: Module name to import and load. :param squash: If true (default), nested dicts are assumed to represent namespaces and flattened (see :meth:`load_dict`). """ config_obj = load(name) obj = {key: getattr(config_obj, key) for key in dir(config_obj) if key.isupper()} if squash: self.load_dict(obj) else: self.update(obj) return self def load_config(self, filename, **options): """ Load values from ``*.ini`` style config files using configparser. INI style sections (e.g. ``[section]``) are used as namespace for all keys within that section. Both section and key names may contain dots as namespace separators and are converted to lower-case. The special sections ``[bottle]`` and ``[ROOT]`` refer to the root namespace and the ``[DEFAULT]`` section defines default values for all other sections. :param filename: The path of a config file, or a list of paths. :param options: All keyword parameters are passed to the underlying :class:`python:configparser.ConfigParser` constructor call. """ options.setdefault('allow_no_value', True) if py3k: options.setdefault('interpolation', configparser.ExtendedInterpolation()) conf = configparser.ConfigParser(**options) conf.read(filename) for section in conf.sections(): for key in conf.options(section): value = conf.get(section, key) if section not in ('bottle', 'ROOT'): key = section + '.' + key self[key.lower()] = value return self def load_dict(self, source, namespace=''): """ Load values from a dictionary structure. Nesting can be used to represent namespaces. >>> c = ConfigDict() >>> c.load_dict({'some': {'namespace': {'key': 'value'} } }) {'some.namespace.key': 'value'} """ for key, value in source.items(): if isinstance(key, basestring): nskey = (namespace + '.' + key).strip('.') if isinstance(value, dict): self.load_dict(value, namespace=nskey) else: self[nskey] = value else: raise TypeError('Key has type %r (not a string)' % type(key)) return self def update(self, *a, **ka): """ If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update(). >>> c = ConfigDict() >>> c.update('some.namespace', key='value') """ prefix = '' if a and isinstance(a[0], basestring): prefix = a[0].strip('.') + '.' a = a[1:] for key, value in dict(*a, **ka).items(): self[prefix + key] = value def setdefault(self, key, value=None): if key not in self: self[key] = value return self[key] def __setitem__(self, key, value): if not isinstance(key, basestring): raise TypeError('Key has type %r (not a string)' % type(key)) self._virtual_keys.discard(key) value = self.meta_get(key, 'filter', lambda x: x)(value) if key in self and self[key] is value: return self._on_change(key, value) dict.__setitem__(self, key, value) for overlay in self._iter_overlays(): overlay._set_virtual(key, value) def __delitem__(self, key): if key not in self: raise KeyError(key) if key in self._virtual_keys: raise KeyError("Virtual keys cannot be deleted: %s" % key) if self._source and key in self._source: # Not virtual, but present in source -> Restore virtual value dict.__delitem__(self, key) self._set_virtual(key, self._source[key]) else: # not virtual, not present in source. This is OUR value self._on_change(key, None) dict.__delitem__(self, key) for overlay in self._iter_overlays(): overlay._delete_virtual(key) def _set_virtual(self, key, value): """ Recursively set or update virtual keys. """ if key in self and key not in self._virtual_keys: return # Do nothing for non-virtual keys. self._virtual_keys.add(key) if key in self and self[key] is not value: self._on_change(key, value) dict.__setitem__(self, key, value) for overlay in self._iter_overlays(): overlay._set_virtual(key, value) def _delete_virtual(self, key): """ Recursively delete virtual entry. """ if key not in self._virtual_keys: return # Do nothing for non-virtual keys. if key in self: self._on_change(key, None) dict.__delitem__(self, key) self._virtual_keys.discard(key) for overlay in self._iter_overlays(): overlay._delete_virtual(key) def _on_change(self, key, value): for cb in self._change_listener: if cb(self, key, value): return True def _add_change_listener(self, func): self._change_listener.append(func) return func def meta_get(self, key, metafield, default=None): """ Return the value of a meta field for a key. """ return self._meta.get(key, {}).get(metafield, default) def meta_set(self, key, metafield, value): """ Set the meta field for a key to a new value. Meta-fields are shared between all members of an overlay tree. """ self._meta.setdefault(key, {})[metafield] = value def meta_list(self, key): """ Return an iterable of meta field names defined for a key. """ return self._meta.get(key, {}).keys() def _define(self, key, default=_UNSET, help=_UNSET, validate=_UNSET): """ (Unstable) Shortcut for plugins to define own config parameters. """ if default is not _UNSET: self.setdefault(key, default) if help is not _UNSET: self.meta_set(key, 'help', help) if validate is not _UNSET: self.meta_set(key, 'validate', validate) def _iter_overlays(self): for ref in self._overlays: overlay = ref() if overlay is not None: yield overlay def _make_overlay(self): """ (Unstable) Create a new overlay that acts like a chained map: Values missing in the overlay are copied from the source map. Both maps share the same meta entries. Entries that were copied from the source are called 'virtual'. You can not delete virtual keys, but overwrite them, which turns them into non-virtual entries. Setting keys on an overlay never affects its source, but may affect any number of child overlays. Other than collections.ChainMap or most other implementations, this approach does not resolve missing keys on demand, but instead actively copies all values from the source to the overlay and keeps track of virtual and non-virtual keys internally. This removes any lookup-overhead. Read-access is as fast as a build-in dict for both virtual and non-virtual keys. Changes are propagated recursively and depth-first. A failing on-change handler in an overlay stops the propagation of virtual values and may result in an partly updated tree. Take extra care here and make sure that on-change handlers never fail. Used by Route.config """ # Cleanup dead references self._overlays[:] = [ref for ref in self._overlays if ref() is not None] overlay = ConfigDict() overlay._meta = self._meta overlay._source = self self._overlays.append(weakref.ref(overlay)) for key in self: overlay._set_virtual(key, self[key]) return overlay class AppStack(list): """ A stack-like list. Calling it returns the head of the stack. """ def __call__(self): """ Return the current default application. """ return self.default def push(self, value=None): """ Add a new :class:`Bottle` instance to the stack """ if not isinstance(value, Bottle): value = Bottle() self.append(value) return value new_app = push @property def default(self): try: return self[-1] except IndexError: return self.push() class WSGIFileWrapper(object): def __init__(self, fp, buffer_size=1024 * 64): self.fp, self.buffer_size = fp, buffer_size for attr in 'fileno', 'close', 'read', 'readlines', 'tell', 'seek': if hasattr(fp, attr): setattr(self, attr, getattr(fp, attr)) def __iter__(self): buff, read = self.buffer_size, self.read part = read(buff) while part: yield part part = read(buff) class _closeiter(object): """ This only exists to be able to attach a .close method to iterators that do not support attribute assignment (most of itertools). """ def __init__(self, iterator, close=None): self.iterator = iterator self.close_callbacks = makelist(close) def __iter__(self): return iter(self.iterator) def close(self): for func in self.close_callbacks: func() class ResourceManager(object): """ This class manages a list of search paths and helps to find and open application-bound resources (files). :param base: default value for :meth:`add_path` calls. :param opener: callable used to open resources. :param cachemode: controls which lookups are cached. One of 'all', 'found' or 'none'. """ def __init__(self, base='./', opener=open, cachemode='all'): self.opener = opener self.base = base self.cachemode = cachemode #: A list of search paths. See :meth:`add_path` for details. self.path = [] #: A cache for resolved paths. ``res.cache.clear()`` clears the cache. self.cache = {} def add_path(self, path, base=None, index=None, create=False): """ Add a new path to the list of search paths. Return False if the path does not exist. :param path: The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file (not ending in `/`), the filename is stripped off. :param base: Path used to absolutize relative search paths. Defaults to :attr:`base` which defaults to ``os.getcwd()``. :param index: Position within the list of search paths. Defaults to last index (appends to the list). The `base` parameter makes it easy to reference files installed along with a python module or package:: res.add_path('./resources/', __file__) """ base = os.path.abspath(os.path.dirname(base or self.base)) path = os.path.abspath(os.path.join(base, os.path.dirname(path))) path += os.sep if path in self.path: self.path.remove(path) if create and not os.path.isdir(path): os.makedirs(path) if index is None: self.path.append(path) else: self.path.insert(index, path) self.cache.clear() return os.path.exists(path) def __iter__(self): """ Iterate over all existing files in all registered paths. """ search = self.path[:] while search: path = search.pop() if not os.path.isdir(path): continue for name in os.listdir(path): full = os.path.join(path, name) if os.path.isdir(full): search.append(full) else: yield full def lookup(self, name): """ Search for a resource and return an absolute file path, or `None`. The :attr:`path` list is searched in order. The first match is returned. Symlinks are followed. The result is cached to speed up future lookups. """ if name not in self.cache or DEBUG: for path in self.path: fpath = os.path.join(path, name) if os.path.isfile(fpath): if self.cachemode in ('all', 'found'): self.cache[name] = fpath return fpath if self.cachemode == 'all': self.cache[name] = None return self.cache[name] def open(self, name, mode='r', *args, **kwargs): """ Find a resource and return a file object, or raise IOError. """ fname = self.lookup(name) if not fname: raise IOError("Resource %r not found." % name) return self.opener(fname, mode=mode, *args, **kwargs) class FileUpload(object): def __init__(self, fileobj, name, filename, headers=None): """ Wrapper for a single file uploaded via ``multipart/form-data``. """ #: Open file(-like) object (BytesIO buffer or temporary file) self.file = fileobj #: Name of the upload form field self.name = name #: Raw filename as sent by the client (may contain unsafe characters) self.raw_filename = filename #: A :class:`HeaderDict` with additional headers (e.g. content-type) self.headers = HeaderDict(headers) if headers else HeaderDict() content_type = HeaderProperty('Content-Type') content_length = HeaderProperty('Content-Length', reader=int, default=-1) def get_header(self, name, default=None): """ Return the value of a header within the multipart part. """ return self.headers.get(name, default) @cached_property def filename(self): """ Name of the file on the client file system, but normalized to ensure file system compatibility. An empty filename is returned as 'empty'. Only ASCII letters, digits, dashes, underscores and dots are allowed in the final filename. Accents are removed, if possible. Whitespace is replaced by a single dash. Leading or tailing dots or dashes are removed. The filename is limited to 255 characters. """ fname = self.raw_filename if not isinstance(fname, unicode): fname = fname.decode('utf8', 'ignore') fname = normalize('NFKD', fname) fname = fname.encode('ASCII', 'ignore').decode('ASCII') fname = os.path.basename(fname.replace('\\', os.path.sep)) fname = re.sub(r'[^a-zA-Z0-9-_.\s]', '', fname).strip() fname = re.sub(r'[-\s]+', '-', fname).strip('.-') return fname[:255] or 'empty' def _copy_file(self, fp, chunk_size=2 ** 16): read, write, offset = self.file.read, fp.write, self.file.tell() while 1: buf = read(chunk_size) if not buf: break write(buf) self.file.seek(offset) def save(self, destination, overwrite=False, chunk_size=2 ** 16): """ Save file to disk or copy its content to an open file(-like) object. If *destination* is a directory, :attr:`filename` is added to the path. Existing files are not overwritten by default (IOError). :param destination: File path, directory or file(-like) object. :param overwrite: If True, replace existing files. (default: False) :param chunk_size: Bytes to read at a time. (default: 64kb) """ if isinstance(destination, basestring): # Except file-likes here if os.path.isdir(destination): destination = os.path.join(destination, self.filename) if not overwrite and os.path.exists(destination): raise IOError('File exists.') with open(destination, 'wb') as fp: self._copy_file(fp, chunk_size) else: self._copy_file(destination, chunk_size) ############################################################################### # Application Helper ########################################################### ############################################################################### def abort(code=500, text='Unknown Error.'): """ Aborts execution and causes a HTTP error. """ raise HTTPError(code, text) def redirect(url, code=None): """ Aborts execution and causes a 303 or 302 redirect, depending on the HTTP protocol version. """ if not code: code = 303 if request.get('SERVER_PROTOCOL') == "HTTP/1.1" else 302 res = response.copy(cls=HTTPResponse) res.status = code res.body = "" res.set_header('Location', urljoin(request.url, url)) raise res def _rangeiter(fp, offset, limit, bufsize=1024 * 1024): """ Yield chunks from a range in a file. """ fp.seek(offset) while limit > 0: part = fp.read(min(limit, bufsize)) if not part: break limit -= len(part) yield part def static_file(filename, root, mimetype=True, download=False, charset='UTF-8', etag=None, headers=None): """ Open a file in a safe way and return an instance of :exc:`HTTPResponse` that can be sent back to the client. :param filename: Name or path of the file to send, relative to ``root``. :param root: Root path for file lookups. Should be an absolute directory path. :param mimetype: Provide the content-type header (default: guess from file extension) :param download: If True, ask the browser to open a `Save as...` dialog instead of opening the file with the associated program. You can specify a custom filename as a string. If not specified, the original filename is used (default: False). :param charset: The charset for files with a ``text/*`` mime-type. (default: UTF-8) :param etag: Provide a pre-computed ETag header. If set to ``False``, ETag handling is disabled. (default: auto-generate ETag header) :param headers: Additional headers dict to add to the response. While checking user input is always a good idea, this function provides additional protection against malicious ``filename`` parameters from breaking out of the ``root`` directory and leaking sensitive information to an attacker. Read-protected files or files outside of the ``root`` directory are answered with ``403 Access Denied``. Missing files result in a ``404 Not Found`` response. Conditional requests (``If-Modified-Since``, ``If-None-Match``) are answered with ``304 Not Modified`` whenever possible. ``HEAD`` and ``Range`` requests (used by download managers to check or continue partial downloads) are also handled automatically. """ root = os.path.join(os.path.abspath(root), '') filename = os.path.abspath(os.path.join(root, filename.strip('/\\'))) headers = headers.copy() if headers else {} getenv = request.environ.get if not filename.startswith(root): return HTTPError(403, "Access denied.") if not os.path.exists(filename) or not os.path.isfile(filename): return HTTPError(404, "File does not exist.") if not os.access(filename, os.R_OK): return HTTPError(403, "You do not have permission to access this file.") if mimetype is True: name = download if isinstance(download, str) else filename mimetype, encoding = mimetypes.guess_type(name) if encoding == 'gzip': mimetype = 'application/gzip' elif encoding: # e.g. bzip2 -> application/x-bzip2 mimetype = 'application/x-' + encoding if charset and mimetype and 'charset=' not in mimetype \ and (mimetype[:5] == 'text/' or mimetype == 'application/javascript'): mimetype += '; charset=%s' % charset if mimetype: headers['Content-Type'] = mimetype if download is True: download = os.path.basename(filename) if download: download = download.replace('"','') headers['Content-Disposition'] = 'attachment; filename="%s"' % download stats = os.stat(filename) headers['Content-Length'] = clen = stats.st_size headers['Last-Modified'] = email.utils.formatdate(stats.st_mtime, usegmt=True) headers['Date'] = email.utils.formatdate(time.time(), usegmt=True) if etag is None: etag = '%d:%d:%d:%d:%s' % (stats.st_dev, stats.st_ino, stats.st_mtime, clen, filename) etag = hashlib.sha1(tob(etag)).hexdigest() if etag: headers['ETag'] = etag check = getenv('HTTP_IF_NONE_MATCH') if check and check == etag: return HTTPResponse(status=304, **headers) ims = getenv('HTTP_IF_MODIFIED_SINCE') if ims: ims = parse_date(ims.split(";")[0].strip()) if ims is not None and ims >= int(stats.st_mtime): return HTTPResponse(status=304, **headers) body = '' if request.method == 'HEAD' else open(filename, 'rb') headers["Accept-Ranges"] = "bytes" range_header = getenv('HTTP_RANGE') if range_header: ranges = list(parse_range_header(range_header, clen)) if not ranges: return HTTPError(416, "Requested Range Not Satisfiable") offset, end = ranges[0] rlen = end - offset headers["Content-Range"] = "bytes %d-%d/%d" % (offset, end - 1, clen) headers["Content-Length"] = str(rlen) if body: body = _closeiter(_rangeiter(body, offset, rlen), body.close) return HTTPResponse(body, status=206, **headers) return HTTPResponse(body, **headers) ############################################################################### # HTTP Utilities and MISC (TODO) ############################################### ############################################################################### def debug(mode=True): """ Change the debug level. There is only one debug level supported at the moment.""" global DEBUG if mode: warnings.simplefilter('default') DEBUG = bool(mode) def http_date(value): if isinstance(value, basestring): return value if isinstance(value, datetime): # aware datetime.datetime is converted to UTC time # naive datetime.datetime is treated as UTC time value = value.utctimetuple() elif isinstance(value, datedate): # datetime.date is naive, and is treated as UTC time value = value.timetuple() if not isinstance(value, (int, float)): # convert struct_time in UTC to UNIX timestamp value = calendar.timegm(value) return email.utils.formatdate(value, usegmt=True) def parse_date(ims): """ Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. """ try: ts = email.utils.parsedate_tz(ims) return calendar.timegm(ts[:8] + (0, )) - (ts[9] or 0) except (TypeError, ValueError, IndexError, OverflowError): return None def parse_auth(header): """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" try: method, data = header.split(None, 1) if method.lower() == 'basic': user, pwd = touni(base64.b64decode(tob(data))).split(':', 1) return user, pwd except (KeyError, ValueError): return None def parse_range_header(header, maxlen=0): """ Yield (start, end) ranges parsed from a HTTP Range header. Skip unsatisfiable ranges. The end index is non-inclusive.""" if not header or header[:6] != 'bytes=': return ranges = [r.split('-', 1) for r in header[6:].split(',') if '-' in r] for start, end in ranges: try: if not start: # bytes=-100 -> last 100 bytes start, end = max(0, maxlen - int(end)), maxlen elif not end: # bytes=100- -> all but the first 99 bytes start, end = int(start), maxlen else: # bytes=100-200 -> bytes 100-200 (inclusive) start, end = int(start), min(int(end) + 1, maxlen) if 0 <= start < end <= maxlen: yield start, end except ValueError: pass #: Header tokenizer used by _parse_http_header() _hsplit = re.compile('(?:(?:"((?:[^"\\\\]|\\\\.)*)")|([^;,=]+))([;,=]?)').findall def _parse_http_header(h): """ Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values and parameters. For non-standard or broken input, this implementation may return partial results. :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``) :return: List of (value, params) tuples. The second element is a (possibly empty) dict. """ values = [] if '"' not in h: # INFO: Fast path without regexp (~2x faster) for value in h.split(','): parts = value.split(';') values.append((parts[0].strip(), {})) for attr in parts[1:]: name, value = attr.split('=', 1) values[-1][1][name.strip().lower()] = value.strip() else: lop, key, attrs = ',', None, {} for quoted, plain, tok in _hsplit(h): value = plain.strip() if plain else quoted.replace('\\"', '"') if lop == ',': attrs = {} values.append((value, attrs)) elif lop == ';': if tok == '=': key = value else: attrs[value.strip().lower()] = '' elif lop == '=' and key: attrs[key.strip().lower()] = value key = None lop = tok return values def _parse_qsl(qs): r = [] for pair in qs.split('&'): if not pair: continue nv = pair.split('=', 1) if len(nv) != 2: nv.append('') key = urlunquote(nv[0].replace('+', ' ')) value = urlunquote(nv[1].replace('+', ' ')) r.append((key, value)) return r def _lscmp(a, b): """ Compares two strings in a cryptographically safe way: Runtime is not affected by length of common prefix. """ return not sum(0 if x == y else 1 for x, y in zip(a, b)) and len(a) == len(b) def cookie_encode(data, key, digestmod=None): """ Encode and sign a pickle-able object. Return a (byte) string """ depr(0, 13, "cookie_encode() will be removed soon.", "Do not use this API directly.") digestmod = digestmod or hashlib.sha256 msg = base64.b64encode(pickle.dumps(data, -1)) sig = base64.b64encode(hmac.new(tob(key), msg, digestmod=digestmod).digest()) return tob('!') + sig + tob('?') + msg def cookie_decode(data, key, digestmod=None): """ Verify and decode an encoded string. Return an object or None.""" depr(0, 13, "cookie_decode() will be removed soon.", "Do not use this API directly.") data = tob(data) if cookie_is_encoded(data): sig, msg = data.split(tob('?'), 1) digestmod = digestmod or hashlib.sha256 hashed = hmac.new(tob(key), msg, digestmod=digestmod).digest() if _lscmp(sig[1:], base64.b64encode(hashed)): return pickle.loads(base64.b64decode(msg)) return None def cookie_is_encoded(data): """ Return True if the argument looks like a encoded cookie.""" depr(0, 13, "cookie_is_encoded() will be removed soon.", "Do not use this API directly.") return bool(data.startswith(tob('!')) and tob('?') in data) def html_escape(string): """ Escape HTML special characters ``&<>`` and quotes ``'"``. """ return string.replace('&', '&').replace('<', '<').replace('>', '>')\ .replace('"', '"').replace("'", ''') def html_quote(string): """ Escape and quote a string to be used as an HTTP attribute.""" return '"%s"' % html_escape(string).replace('\n', ' ')\ .replace('\r', ' ').replace('\t', ' ') def yieldroutes(func): """ Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example:: a() -> '/a' b(x, y) -> '/b//' c(x, y=5) -> '/c/' and '/c//' d(x=5, y=6) -> '/d' and '/d/' and '/d//' """ path = '/' + func.__name__.replace('__', '/').lstrip('/') spec = getargspec(func) argc = len(spec[0]) - len(spec[3] or []) path += ('/<%s>' * argc) % tuple(spec[0][:argc]) yield path for arg in spec[0][argc:]: path += '/<%s>' % arg yield path def path_shift(script_name, path_info, shift=1): """ Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa. :return: The modified paths. :param script_name: The SCRIPT_NAME path. :param script_name: The PATH_INFO path. :param shift: The number of path fragments to shift. May be negative to change the shift direction. (default: 1) """ if shift == 0: return script_name, path_info pathlist = path_info.strip('/').split('/') scriptlist = script_name.strip('/').split('/') if pathlist and pathlist[0] == '': pathlist = [] if scriptlist and scriptlist[0] == '': scriptlist = [] if 0 < shift <= len(pathlist): moved = pathlist[:shift] scriptlist = scriptlist + moved pathlist = pathlist[shift:] elif 0 > shift >= -len(scriptlist): moved = scriptlist[shift:] pathlist = moved + pathlist scriptlist = scriptlist[:shift] else: empty = 'SCRIPT_NAME' if shift < 0 else 'PATH_INFO' raise AssertionError("Cannot shift. Nothing left from %s" % empty) new_script_name = '/' + '/'.join(scriptlist) new_path_info = '/' + '/'.join(pathlist) if path_info.endswith('/') and pathlist: new_path_info += '/' return new_script_name, new_path_info def auth_basic(check, realm="private", text="Access denied"): """ Callback decorator to require HTTP auth (basic). TODO: Add route(check_auth=...) parameter. """ def decorator(func): @functools.wraps(func) def wrapper(*a, **ka): user, password = request.auth or (None, None) if user is None or not check(user, password): err = HTTPError(401, text) err.add_header('WWW-Authenticate', 'Basic realm="%s"' % realm) return err return func(*a, **ka) return wrapper return decorator # Shortcuts for common Bottle methods. # They all refer to the current default application. def make_default_app_wrapper(name): """ Return a callable that relays calls to the current default app. """ @functools.wraps(getattr(Bottle, name)) def wrapper(*a, **ka): return getattr(app(), name)(*a, **ka) return wrapper route = make_default_app_wrapper('route') get = make_default_app_wrapper('get') post = make_default_app_wrapper('post') put = make_default_app_wrapper('put') delete = make_default_app_wrapper('delete') patch = make_default_app_wrapper('patch') error = make_default_app_wrapper('error') mount = make_default_app_wrapper('mount') hook = make_default_app_wrapper('hook') install = make_default_app_wrapper('install') uninstall = make_default_app_wrapper('uninstall') url = make_default_app_wrapper('get_url') ############################################################################### # Multipart Handling ########################################################### ############################################################################### # cgi.FieldStorage was deprecated in Python 3.11 and removed in 3.13 # This implementation is based on https://github.com/defnull/multipart/ class MultipartError(HTTPError): def __init__(self, msg): HTTPError.__init__(self, 400, "MultipartError: " + msg) class _MultipartParser(object): def __init__( self, stream, boundary, content_length=-1, disk_limit=2 ** 30, mem_limit=2 ** 20, memfile_limit=2 ** 18, buffer_size=2 ** 16, charset="latin1", ): self.stream = stream self.boundary = boundary self.content_length = content_length self.disk_limit = disk_limit self.memfile_limit = memfile_limit self.mem_limit = min(mem_limit, self.disk_limit) self.buffer_size = min(buffer_size, self.mem_limit) self.charset = charset if not boundary: raise MultipartError("No boundary.") if self.buffer_size - 6 < len(boundary): # "--boundary--\r\n" raise MultipartError("Boundary does not fit into buffer_size.") def _lineiter(self): """ Iterate over a binary file-like object (crlf terminated) line by line. Each line is returned as a (line, crlf) tuple. Lines larger than buffer_size are split into chunks where all but the last chunk has an empty string instead of crlf. Maximum chunk size is twice the buffer size. """ read = self.stream.read maxread, maxbuf = self.content_length, self.buffer_size partial = b"" # Contains the last (partial) line while True: chunk = read(maxbuf if maxread < 0 else min(maxbuf, maxread)) maxread -= len(chunk) if not chunk: if partial: yield partial, b'' break if partial: chunk = partial + chunk scanpos = 0 while True: i = chunk.find(b'\r\n', scanpos) if i >= 0: yield chunk[scanpos:i], b'\r\n' scanpos = i + 2 else: # CRLF not found partial = chunk[scanpos:] if scanpos else chunk break if len(partial) > maxbuf: yield partial[:-1], b"" partial = partial[-1:] def parse(self): """ Return a MultiPart iterator. Can only be called once. """ lines, line = self._lineiter(), "" separator = b"--" + tob(self.boundary) terminator = separator + b"--" mem_used, disk_used = 0, 0 # Track used resources to prevent DoS is_tail = False # True if the last line was incomplete (cutted) # Consume first boundary. Ignore any preamble, as required by RFC # 2046, section 5.1.1. for line, nl in lines: if line in (separator, terminator): break else: raise MultipartError("Stream does not contain boundary") # First line is termainating boundary -> empty multipart stream if line == terminator: for _ in lines: raise MultipartError("Found data after empty multipart stream") return part_options = { "buffer_size": self.buffer_size, "memfile_limit": self.memfile_limit, "charset": self.charset, } part = _MultipartPart(**part_options) for line, nl in lines: if not is_tail and (line == separator or line == terminator): part.finish() if part.is_buffered(): mem_used += part.size else: disk_used += part.size yield part if line == terminator: break part = _MultipartPart(**part_options) else: is_tail = not nl # The next line continues this one try: part.feed(line, nl) if part.is_buffered(): if part.size + mem_used > self.mem_limit: raise MultipartError("Memory limit reached.") elif part.size + disk_used > self.disk_limit: raise MultipartError("Disk limit reached.") except MultipartError: part.close() raise else: part.close() if line != terminator: raise MultipartError("Unexpected end of multipart stream.") class _MultipartPart(object): def __init__(self, buffer_size=2 ** 16, memfile_limit=2 ** 18, charset="latin1"): self.headerlist = [] self.headers = None self.file = False self.size = 0 self._buf = b"" self.disposition = None self.name = None self.filename = None self.content_type = None self.charset = charset self.memfile_limit = memfile_limit self.buffer_size = buffer_size def feed(self, line, nl=""): if self.file: return self.write_body(line, nl) return self.write_header(line, nl) def write_header(self, line, nl): line = line.decode(self.charset) if not nl: raise MultipartError("Unexpected end of line in header.") if not line.strip(): # blank line -> end of header segment self.finish_header() elif line[0] in " \t" and self.headerlist: name, value = self.headerlist.pop() self.headerlist.append((name, value + line.strip())) else: if ":" not in line: raise MultipartError("Syntax error in header: No colon.") name, value = line.split(":", 1) self.headerlist.append((name.strip(), value.strip())) def write_body(self, line, nl): if not line and not nl: return # This does not even flush the buffer self.size += len(line) + len(self._buf) self.file.write(self._buf + line) self._buf = nl if self.content_length > 0 and self.size > self.content_length: raise MultipartError("Size of body exceeds Content-Length header.") if self.size > self.memfile_limit and isinstance(self.file, BytesIO): self.file, old = NamedTemporaryFile(mode="w+b"), self.file old.seek(0) copied, maxcopy, chunksize = 0, self.size, self.buffer_size read, write = old.read, self.file.write while copied < maxcopy: chunk = read(min(chunksize, maxcopy - copied)) write(chunk) copied += len(chunk) def finish_header(self): self.file = BytesIO() self.headers = HeaderDict(self.headerlist) content_disposition = self.headers.get("Content-Disposition") content_type = self.headers.get("Content-Type") if not content_disposition: raise MultipartError("Content-Disposition header is missing.") self.disposition, self.options = _parse_http_header(content_disposition)[0] self.name = self.options.get("name") if "filename" in self.options: self.filename = self.options.get("filename") if self.filename[1:3] == ":\\" or self.filename[:2] == "\\\\": self.filename = self.filename.split("\\")[-1] # ie6 bug self.content_type, options = _parse_http_header(content_type)[0] if content_type else (None, {}) self.charset = options.get("charset") or self.charset self.content_length = int(self.headers.get("Content-Length", "-1")) def finish(self): if not self.file: raise MultipartError("Incomplete part: Header section not closed.") self.file.seek(0) def is_buffered(self): """ Return true if the data is fully buffered in memory.""" return isinstance(self.file, BytesIO) @property def value(self): """ Data decoded with the specified charset """ return self.raw.decode(self.charset) @property def raw(self): """ Data without decoding """ pos = self.file.tell() self.file.seek(0) try: return self.file.read() finally: self.file.seek(pos) def close(self): if self.file: self.file.close() self.file = False ############################################################################### # Server Adapter ############################################################### ############################################################################### # Before you edit or add a server adapter, please read: # - https://github.com/bottlepy/bottle/pull/647#issuecomment-60152870 # - https://github.com/bottlepy/bottle/pull/865#issuecomment-242795341 class ServerAdapter(object): quiet = False def __init__(self, host='127.0.0.1', port=8080, **options): self.options = options self.host = host self.port = int(port) def run(self, handler): # pragma: no cover pass def __repr__(self): args = ', '.join('%s=%s' % (k, repr(v)) for k, v in self.options.items()) return "%s(%s)" % (self.__class__.__name__, args) class CGIServer(ServerAdapter): quiet = True def run(self, handler): # pragma: no cover from wsgiref.handlers import CGIHandler def fixed_environ(environ, start_response): environ.setdefault('PATH_INFO', '') return handler(environ, start_response) CGIHandler().run(fixed_environ) class FlupFCGIServer(ServerAdapter): def run(self, handler): # pragma: no cover import flup.server.fcgi self.options.setdefault('bindAddress', (self.host, self.port)) flup.server.fcgi.WSGIServer(handler, **self.options).run() class WSGIRefServer(ServerAdapter): def run(self, app): # pragma: no cover from wsgiref.simple_server import make_server from wsgiref.simple_server import WSGIRequestHandler, WSGIServer import socket class FixedHandler(WSGIRequestHandler): def address_string(self): # Prevent reverse DNS lookups please. return self.client_address[0] def log_request(*args, **kw): if not self.quiet: return WSGIRequestHandler.log_request(*args, **kw) handler_cls = self.options.get('handler_class', FixedHandler) server_cls = self.options.get('server_class', WSGIServer) if ':' in self.host: # Fix wsgiref for IPv6 addresses. if getattr(server_cls, 'address_family') == socket.AF_INET: class server_cls(server_cls): address_family = socket.AF_INET6 self.srv = make_server(self.host, self.port, app, server_cls, handler_cls) self.port = self.srv.server_port # update port actual port (0 means random) try: self.srv.serve_forever() except KeyboardInterrupt: self.srv.server_close() # Prevent ResourceWarning: unclosed socket raise class CherryPyServer(ServerAdapter): def run(self, handler): # pragma: no cover depr(0, 13, "The wsgi server part of cherrypy was split into a new " "project called 'cheroot'.", "Use the 'cheroot' server " "adapter instead of cherrypy.") from cherrypy import wsgiserver # This will fail for CherryPy >= 9 self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler certfile = self.options.get('certfile') if certfile: del self.options['certfile'] keyfile = self.options.get('keyfile') if keyfile: del self.options['keyfile'] server = wsgiserver.CherryPyWSGIServer(**self.options) if certfile: server.ssl_certificate = certfile if keyfile: server.ssl_private_key = keyfile try: server.start() finally: server.stop() class CherootServer(ServerAdapter): def run(self, handler): # pragma: no cover from cheroot import wsgi from cheroot.ssl import builtin self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler certfile = self.options.pop('certfile', None) keyfile = self.options.pop('keyfile', None) chainfile = self.options.pop('chainfile', None) server = wsgi.Server(**self.options) if certfile and keyfile: server.ssl_adapter = builtin.BuiltinSSLAdapter( certfile, keyfile, chainfile) try: server.start() finally: server.stop() class WaitressServer(ServerAdapter): def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options) class PasteServer(ServerAdapter): def run(self, handler): # pragma: no cover from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(handler, setup_console_handler=(not self.quiet)) httpserver.serve(handler, host=self.host, port=str(self.port), **self.options) class MeinheldServer(ServerAdapter): def run(self, handler): from meinheld import server server.listen((self.host, self.port)) server.run(handler) class FapwsServer(ServerAdapter): """ Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 """ def run(self, handler): # pragma: no cover depr(0, 13, "fapws3 is not maintained and support will be dropped.") import fapws._evwsgi as evwsgi from fapws import base, config port = self.port if float(config.SERVER_IDENT[-2:]) > 0.4: # fapws3 silently changed its API in 0.5 port = str(port) evwsgi.start(self.host, port) # fapws3 never releases the GIL. Complain upstream. I tried. No luck. if 'BOTTLE_CHILD' in os.environ and not self.quiet: _stderr("WARNING: Auto-reloading does not work with Fapws3.") _stderr(" (Fapws3 breaks python thread support)") evwsgi.set_base_module(base) def app(environ, start_response): environ['wsgi.multiprocess'] = False return handler(environ, start_response) evwsgi.wsgi_cb(('', app)) evwsgi.run() class TornadoServer(ServerAdapter): """ The super hyped asynchronous server by facebook. Untested. """ def run(self, handler): # pragma: no cover import tornado.wsgi, tornado.httpserver, tornado.ioloop container = tornado.wsgi.WSGIContainer(handler) server = tornado.httpserver.HTTPServer(container) server.listen(port=self.port, address=self.host) tornado.ioloop.IOLoop.instance().start() class AppEngineServer(ServerAdapter): """ Adapter for Google App Engine. """ quiet = True def run(self, handler): depr(0, 13, "AppEngineServer no longer required", "Configure your application directly in your app.yaml") from google.appengine.ext.webapp import util # A main() function in the handler script enables 'App Caching'. # Lets makes sure it is there. This _really_ improves performance. module = sys.modules.get('__main__') if module and not hasattr(module, 'main'): module.main = lambda: util.run_wsgi_app(handler) util.run_wsgi_app(handler) class TwistedServer(ServerAdapter): """ Untested. """ def run(self, handler): from twisted.web import server, wsgi from twisted.python.threadpool import ThreadPool from twisted.internet import reactor thread_pool = ThreadPool() thread_pool.start() reactor.addSystemEventTrigger('after', 'shutdown', thread_pool.stop) factory = server.Site(wsgi.WSGIResource(reactor, thread_pool, handler)) reactor.listenTCP(self.port, factory, interface=self.host) if not reactor.running: reactor.run() class DieselServer(ServerAdapter): """ Untested. """ def run(self, handler): depr(0, 13, "Diesel is not tested or supported and will be removed.") from diesel.protocols.wsgi import WSGIApplication app = WSGIApplication(handler, port=self.port) app.run() class GeventServer(ServerAdapter): """ Untested. Options: * See gevent.wsgi.WSGIServer() documentation for more options. """ def run(self, handler): from gevent import pywsgi, local if not isinstance(threading.local(), local.local): msg = "Bottle requires gevent.monkey.patch_all() (before import)" raise RuntimeError(msg) if self.quiet: self.options['log'] = None address = (self.host, self.port) server = pywsgi.WSGIServer(address, handler, **self.options) if 'BOTTLE_CHILD' in os.environ: import signal signal.signal(signal.SIGINT, lambda s, f: server.stop()) server.serve_forever() class GunicornServer(ServerAdapter): """ Untested. See http://gunicorn.org/configure.html for options. """ def run(self, handler): from gunicorn.app.base import BaseApplication if self.host.startswith("unix:"): config = {'bind': self.host} else: config = {'bind': "%s:%d" % (self.host, self.port)} config.update(self.options) class GunicornApplication(BaseApplication): def load_config(self): for key, value in config.items(): self.cfg.set(key, value) def load(self): return handler GunicornApplication().run() class EventletServer(ServerAdapter): """ Untested. Options: * `backlog` adjust the eventlet backlog parameter which is the maximum number of queued connections. Should be at least 1; the maximum value is system-dependent. * `family`: (default is 2) socket family, optional. See socket documentation for available families. """ def run(self, handler): from eventlet import wsgi, listen, patcher if not patcher.is_monkey_patched(os): msg = "Bottle requires eventlet.monkey_patch() (before import)" raise RuntimeError(msg) socket_args = {} for arg in ('backlog', 'family'): try: socket_args[arg] = self.options.pop(arg) except KeyError: pass address = (self.host, self.port) try: wsgi.server(listen(address, **socket_args), handler, log_output=(not self.quiet)) except TypeError: # Fallback, if we have old version of eventlet wsgi.server(listen(address), handler) class BjoernServer(ServerAdapter): """ Fast server written in C: https://github.com/jonashaag/bjoern """ def run(self, handler): from bjoern import run run(handler, self.host, self.port, reuse_port=True) class AsyncioServerAdapter(ServerAdapter): """ Extend ServerAdapter for adding custom event loop """ def get_event_loop(self): pass class AiohttpServer(AsyncioServerAdapter): """ Asynchronous HTTP client/server framework for asyncio https://pypi.python.org/pypi/aiohttp/ https://pypi.org/project/aiohttp-wsgi/ """ def get_event_loop(self): import asyncio return asyncio.new_event_loop() def run(self, handler): import asyncio from aiohttp_wsgi.wsgi import serve self.loop = self.get_event_loop() asyncio.set_event_loop(self.loop) if 'BOTTLE_CHILD' in os.environ: import signal signal.signal(signal.SIGINT, lambda s, f: self.loop.stop()) serve(handler, host=self.host, port=self.port) class AiohttpUVLoopServer(AiohttpServer): """uvloop https://github.com/MagicStack/uvloop """ def get_event_loop(self): import uvloop return uvloop.new_event_loop() class AutoServer(ServerAdapter): """ Untested. """ adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, CherootServer, WSGIRefServer] def run(self, handler): for sa in self.adapters: try: return sa(self.host, self.port, **self.options).run(handler) except ImportError: pass server_names = { 'cgi': CGIServer, 'flup': FlupFCGIServer, 'wsgiref': WSGIRefServer, 'waitress': WaitressServer, 'cherrypy': CherryPyServer, 'cheroot': CherootServer, 'paste': PasteServer, 'fapws3': FapwsServer, 'tornado': TornadoServer, 'gae': AppEngineServer, 'twisted': TwistedServer, 'diesel': DieselServer, 'meinheld': MeinheldServer, 'gunicorn': GunicornServer, 'eventlet': EventletServer, 'gevent': GeventServer, 'bjoern': BjoernServer, 'aiohttp': AiohttpServer, 'uvloop': AiohttpUVLoopServer, 'auto': AutoServer, } ############################################################################### # Application Control ########################################################## ############################################################################### def load(target, **namespace): """ Import a module or fetch an object from a module. * ``package.module`` returns `module` as a module object. * ``pack.mod:name`` returns the module variable `name` from `pack.mod`. * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result. The last form accepts not only function calls, but any type of expression. Keyword arguments passed to this function are available as local variables. Example: ``import_string('re:compile(x)', x='[a-z]')`` """ module, target = target.split(":", 1) if ':' in target else (target, None) if module not in sys.modules: __import__(module) if not target: return sys.modules[module] if target.isalnum(): return getattr(sys.modules[module], target) package_name = module.split('.')[0] namespace[package_name] = sys.modules[package_name] return eval('%s.%s' % (module, target), namespace) def load_app(target): """ Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter. """ global NORUN NORUN, nr_old = True, NORUN tmp = default_app.push() # Create a new "default application" try: rv = load(target) # Import the target module return rv if callable(rv) else tmp finally: default_app.remove(tmp) # Remove the temporary added default application NORUN = nr_old _debug = debug def run(app=None, server='wsgiref', host='127.0.0.1', port=8080, interval=1, reloader=False, quiet=False, plugins=None, debug=None, config=None, **kargs): """ Start a server instance. This method blocks until the server terminates. :param app: WSGI application or target string supported by :func:`load_app`. (default: :func:`default_app`) :param server: Server adapter to use. See :data:`server_names` keys for valid names or pass a :class:`ServerAdapter` subclass. (default: `wsgiref`) :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces including the external one. (default: 127.0.0.1) :param port: Server port to bind to. Values below 1024 require root privileges. (default: 8080) :param reloader: Start auto-reloading server? (default: False) :param interval: Auto-reloader interval in seconds (default: 1) :param quiet: Suppress output to stdout and stderr? (default: False) :param options: Options passed to the server adapter. """ if NORUN: return if reloader and not os.environ.get('BOTTLE_CHILD'): import subprocess fd, lockfile = tempfile.mkstemp(prefix='bottle.', suffix='.lock') environ = os.environ.copy() environ['BOTTLE_CHILD'] = 'true' environ['BOTTLE_LOCKFILE'] = lockfile args = [sys.executable] + sys.argv # If a package was loaded with `python -m`, then `sys.argv` needs to be # restored to the original value, or imports might break. See #1336 if getattr(sys.modules.get('__main__'), '__package__', None): args[1:1] = ["-m", sys.modules['__main__'].__package__] try: os.close(fd) # We never write to this file while os.path.exists(lockfile): p = subprocess.Popen(args, env=environ) while p.poll() is None: os.utime(lockfile, None) # Tell child we are still alive time.sleep(interval) if p.returncode == 3: # Child wants to be restarted continue sys.exit(p.returncode) except KeyboardInterrupt: pass finally: if os.path.exists(lockfile): os.unlink(lockfile) return try: if debug is not None: _debug(debug) app = app or default_app() if isinstance(app, basestring): app = load_app(app) if not callable(app): raise ValueError("Application is not callable: %r" % app) for plugin in plugins or []: if isinstance(plugin, basestring): plugin = load(plugin) app.install(plugin) if config: app.config.update(config) if server in server_names: server = server_names.get(server) if isinstance(server, basestring): server = load(server) if isinstance(server, type): server = server(host=host, port=port, **kargs) if not isinstance(server, ServerAdapter): raise ValueError("Unknown or unsupported server: %r" % server) server.quiet = server.quiet or quiet if not server.quiet: _stderr("Bottle v%s server starting up (using %s)..." % (__version__, repr(server))) if server.host.startswith("unix:"): _stderr("Listening on %s" % server.host) else: _stderr("Listening on http://%s:%d/" % (server.host, server.port)) _stderr("Hit Ctrl-C to quit.\n") if reloader: lockfile = os.environ.get('BOTTLE_LOCKFILE') bgcheck = FileCheckerThread(lockfile, interval) with bgcheck: server.run(app) if bgcheck.status == 'reload': sys.exit(3) else: server.run(app) except KeyboardInterrupt: pass except (SystemExit, MemoryError): raise except: if not reloader: raise if not getattr(server, 'quiet', quiet): print_exc() time.sleep(interval) sys.exit(3) class FileCheckerThread(threading.Thread): """ Interrupt main-thread as soon as a changed module file is detected, the lockfile gets deleted or gets too old. """ def __init__(self, lockfile, interval): threading.Thread.__init__(self) self.daemon = True self.lockfile, self.interval = lockfile, interval #: Is one of 'reload', 'error' or 'exit' self.status = None def run(self): exists = os.path.exists mtime = lambda p: os.stat(p).st_mtime files = dict() for module in list(sys.modules.values()): path = getattr(module, '__file__', '') or '' if path[-4:] in ('.pyo', '.pyc'): path = path[:-1] if path and exists(path): files[path] = mtime(path) while not self.status: if not exists(self.lockfile)\ or mtime(self.lockfile) < time.time() - self.interval - 5: self.status = 'error' thread.interrupt_main() for path, lmtime in list(files.items()): if not exists(path) or mtime(path) > lmtime: self.status = 'reload' thread.interrupt_main() break time.sleep(self.interval) def __enter__(self): self.start() def __exit__(self, exc_type, *_): if not self.status: self.status = 'exit' # silent exit self.join() return exc_type is not None and issubclass(exc_type, KeyboardInterrupt) ############################################################################### # Template Adapters ############################################################ ############################################################################### class TemplateError(BottleException): pass class BaseTemplate(object): """ Base class and minimal API for template adapters """ extensions = ['tpl', 'html', 'thtml', 'stpl'] settings = {} #used in prepare() defaults = {} #used in render() def __init__(self, source=None, name=None, lookup=None, encoding='utf8', **settings): """ Create a new template. If the source parameter (str or buffer) is missing, the name argument is used to guess a template filename. Subclasses can assume that self.source and/or self.filename are set. Both are strings. The lookup, encoding and settings parameters are stored as instance variables. The lookup parameter stores a list containing directory paths. The encoding parameter should be used to decode byte strings or files. The settings parameter contains a dict for engine-specific settings. """ self.name = name self.source = source.read() if hasattr(source, 'read') else source self.filename = source.filename if hasattr(source, 'filename') else None self.lookup = [os.path.abspath(x) for x in lookup] if lookup else [] self.encoding = encoding self.settings = self.settings.copy() # Copy from class variable self.settings.update(settings) # Apply if not self.source and self.name: self.filename = self.search(self.name, self.lookup) if not self.filename: raise TemplateError('Template %s not found.' % repr(name)) if not self.source and not self.filename: raise TemplateError('No template specified.') self.prepare(**self.settings) @classmethod def search(cls, name, lookup=None): """ Search name in all directories specified in lookup. First without, then with common extensions. Return first hit. """ if not lookup: raise depr(0, 12, "Empty template lookup path.", "Configure a template lookup path.") if os.path.isabs(name): raise depr(0, 12, "Use of absolute path for template name.", "Refer to templates with names or paths relative to the lookup path.") for spath in lookup: spath = os.path.abspath(spath) + os.sep fname = os.path.abspath(os.path.join(spath, name)) if not fname.startswith(spath): continue if os.path.isfile(fname): return fname for ext in cls.extensions: if os.path.isfile('%s.%s' % (fname, ext)): return '%s.%s' % (fname, ext) @classmethod def global_config(cls, key, *args): """ This reads or sets the global settings stored in class.settings. """ if args: cls.settings = cls.settings.copy() # Make settings local to class cls.settings[key] = args[0] else: return cls.settings[key] def prepare(self, **options): """ Run preparations (parsing, caching, ...). It should be possible to call this again to refresh a template or to update settings. """ raise NotImplementedError def render(self, *args, **kwargs): """ Render the template with the specified local variables and return a single byte or unicode string. If it is a byte string, the encoding must match self.encoding. This method must be thread-safe! Local variables may be provided in dictionaries (args) or directly, as keywords (kwargs). """ raise NotImplementedError class MakoTemplate(BaseTemplate): def prepare(self, **options): from mako.template import Template from mako.lookup import TemplateLookup options.update({'input_encoding': self.encoding}) options.setdefault('format_exceptions', bool(DEBUG)) lookup = TemplateLookup(directories=self.lookup, **options) if self.source: self.tpl = Template(self.source, lookup=lookup, **options) else: self.tpl = Template(uri=self.name, filename=self.filename, lookup=lookup, **options) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) _defaults = self.defaults.copy() _defaults.update(kwargs) return self.tpl.render(**_defaults) class CheetahTemplate(BaseTemplate): def prepare(self, **options): from Cheetah.Template import Template self.context = threading.local() self.context.vars = {} options['searchList'] = [self.context.vars] if self.source: self.tpl = Template(source=self.source, **options) else: self.tpl = Template(file=self.filename, **options) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) self.context.vars.update(self.defaults) self.context.vars.update(kwargs) out = str(self.tpl) self.context.vars.clear() return out class Jinja2Template(BaseTemplate): def prepare(self, filters=None, tests=None, globals={}, **kwargs): from jinja2 import Environment, FunctionLoader self.env = Environment(loader=FunctionLoader(self.loader), **kwargs) if filters: self.env.filters.update(filters) if tests: self.env.tests.update(tests) if globals: self.env.globals.update(globals) if self.source: self.tpl = self.env.from_string(self.source) else: self.tpl = self.env.get_template(self.name) def render(self, *args, **kwargs): for dictarg in args: kwargs.update(dictarg) _defaults = self.defaults.copy() _defaults.update(kwargs) return self.tpl.render(**_defaults) def loader(self, name): if name == self.filename: fname = name else: fname = self.search(name, self.lookup) if not fname: return with open(fname, "rb") as f: return (f.read().decode(self.encoding), fname, lambda: False) class SimpleTemplate(BaseTemplate): def prepare(self, escape_func=html_escape, noescape=False, syntax=None, **ka): self.cache = {} enc = self.encoding self._str = lambda x: touni(x, enc) self._escape = lambda x: escape_func(touni(x, enc)) self.syntax = syntax if noescape: self._str, self._escape = self._escape, self._str @cached_property def co(self): return compile(self.code, self.filename or '', 'exec') @cached_property def code(self): source = self.source if not source: with open(self.filename, 'rb') as f: source = f.read() try: source, encoding = touni(source), 'utf8' except UnicodeError: raise depr(0, 11, 'Unsupported template encodings.', 'Use utf-8 for templates.') parser = StplParser(source, encoding=encoding, syntax=self.syntax) code = parser.translate() self.encoding = parser.encoding return code def _rebase(self, _env, _name=None, **kwargs): _env['_rebase'] = (_name, kwargs) def _include(self, _env, _name=None, **kwargs): env = _env.copy() env.update(kwargs) if _name not in self.cache: self.cache[_name] = self.__class__(name=_name, lookup=self.lookup, syntax=self.syntax) return self.cache[_name].execute(env['_stdout'], env) def execute(self, _stdout, kwargs): env = self.defaults.copy() env.update(kwargs) env.update({ '_stdout': _stdout, '_printlist': _stdout.extend, 'include': functools.partial(self._include, env), 'rebase': functools.partial(self._rebase, env), '_rebase': None, '_str': self._str, '_escape': self._escape, 'get': env.get, 'setdefault': env.setdefault, 'defined': env.__contains__ }) exec(self.co, env) if env.get('_rebase'): subtpl, rargs = env.pop('_rebase') rargs['base'] = ''.join(_stdout) #copy stdout del _stdout[:] # clear stdout return self._include(env, subtpl, **rargs) return env def render(self, *args, **kwargs): """ Render the template using keyword arguments as local variables. """ env = {} stdout = [] for dictarg in args: env.update(dictarg) env.update(kwargs) self.execute(stdout, env) return ''.join(stdout) class StplSyntaxError(TemplateError): pass class StplParser(object): """ Parser for stpl templates. """ _re_cache = {} #: Cache for compiled re patterns # This huge pile of voodoo magic splits python code into 8 different tokens. # We use the verbose (?x) regex mode to make this more manageable _re_tok = r'''( [urbURB]* (?: ''(?!') |""(?!") |'{6} |"{6} |'(?:[^\\']|\\.)+?' |"(?:[^\\"]|\\.)+?" |'{3}(?:[^\\]|\\.|\n)+?'{3} |"{3}(?:[^\\]|\\.|\n)+?"{3} ) )''' _re_inl = _re_tok.replace(r'|\n', '') # We re-use this string pattern later _re_tok += r''' # 2: Comments (until end of line, but not the newline itself) |(\#.*) # 3: Open and close (4) grouping tokens |([\[\{\(]) |([\]\}\)]) # 5,6: Keywords that start or continue a python block (only start of line) |^([\ \t]*(?:if|for|while|with|try|def|class)\b) |^([\ \t]*(?:elif|else|except|finally)\b) # 7: Our special 'end' keyword (but only if it stands alone) |((?:^|;)[\ \t]*end[\ \t]*(?=(?:%(block_close)s[\ \t]*)?\r?$|;|\#)) # 8: A customizable end-of-code-block template token (only end of line) |(%(block_close)s[\ \t]*(?=\r?$)) # 9: And finally, a single newline. The 10th token is 'everything else' |(\r?\n) ''' # Match the start tokens of code areas in a template _re_split = r'''(?m)^[ \t]*(\\?)((%(line_start)s)|(%(block_start)s))''' # Match inline statements (may contain python strings) _re_inl = r'''%%(inline_start)s((?:%s|[^'"\n])*?)%%(inline_end)s''' % _re_inl # add the flag in front of the regexp to avoid Deprecation warning (see Issue #949) # verbose and dot-matches-newline mode _re_tok = '(?mx)' + _re_tok _re_inl = '(?mx)' + _re_inl default_syntax = '<% %> % {{ }}' def __init__(self, source, syntax=None, encoding='utf8'): self.source, self.encoding = touni(source, encoding), encoding self.set_syntax(syntax or self.default_syntax) self.code_buffer, self.text_buffer = [], [] self.lineno, self.offset = 1, 0 self.indent, self.indent_mod = 0, 0 self.paren_depth = 0 def get_syntax(self): """ Tokens as a space separated string (default: <% %> % {{ }}) """ return self._syntax def set_syntax(self, syntax): self._syntax = syntax self._tokens = syntax.split() if syntax not in self._re_cache: names = 'block_start block_close line_start inline_start inline_end' etokens = map(re.escape, self._tokens) pattern_vars = dict(zip(names.split(), etokens)) patterns = (self._re_split, self._re_tok, self._re_inl) patterns = [re.compile(p % pattern_vars) for p in patterns] self._re_cache[syntax] = patterns self.re_split, self.re_tok, self.re_inl = self._re_cache[syntax] syntax = property(get_syntax, set_syntax) def translate(self): if self.offset: raise RuntimeError('Parser is a one time instance.') while True: m = self.re_split.search(self.source, pos=self.offset) if m: text = self.source[self.offset:m.start()] self.text_buffer.append(text) self.offset = m.end() if m.group(1): # Escape syntax line, sep, _ = self.source[self.offset:].partition('\n') self.text_buffer.append(self.source[m.start():m.start(1)] + m.group(2) + line + sep) self.offset += len(line + sep) continue self.flush_text() self.offset += self.read_code(self.source[self.offset:], multiline=bool(m.group(4))) else: break self.text_buffer.append(self.source[self.offset:]) self.flush_text() return ''.join(self.code_buffer) def read_code(self, pysource, multiline): code_line, comment = '', '' offset = 0 while True: m = self.re_tok.search(pysource, pos=offset) if not m: code_line += pysource[offset:] offset = len(pysource) self.write_code(code_line.strip(), comment) break code_line += pysource[offset:m.start()] offset = m.end() _str, _com, _po, _pc, _blk1, _blk2, _end, _cend, _nl = m.groups() if self.paren_depth > 0 and (_blk1 or _blk2): # a if b else c code_line += _blk1 or _blk2 continue if _str: # Python string code_line += _str elif _com: # Python comment (up to EOL) comment = _com if multiline and _com.strip().endswith(self._tokens[1]): multiline = False # Allow end-of-block in comments elif _po: # open parenthesis self.paren_depth += 1 code_line += _po elif _pc: # close parenthesis if self.paren_depth > 0: # we could check for matching parentheses here, but it's # easier to leave that to python - just check counts self.paren_depth -= 1 code_line += _pc elif _blk1: # Start-block keyword (if/for/while/def/try/...) code_line = _blk1 self.indent += 1 self.indent_mod -= 1 elif _blk2: # Continue-block keyword (else/elif/except/...) code_line = _blk2 self.indent_mod -= 1 elif _cend: # The end-code-block template token (usually '%>') if multiline: multiline = False else: code_line += _cend elif _end: self.indent -= 1 self.indent_mod += 1 else: # \n self.write_code(code_line.strip(), comment) self.lineno += 1 code_line, comment, self.indent_mod = '', '', 0 if not multiline: break return offset def flush_text(self): text = ''.join(self.text_buffer) del self.text_buffer[:] if not text: return parts, pos, nl = [], 0, '\\\n' + ' ' * self.indent for m in self.re_inl.finditer(text): prefix, pos = text[pos:m.start()], m.end() if prefix: parts.append(nl.join(map(repr, prefix.splitlines(True)))) if prefix.endswith('\n'): parts[-1] += nl parts.append(self.process_inline(m.group(1).strip())) if pos < len(text): prefix = text[pos:] lines = prefix.splitlines(True) if lines[-1].endswith('\\\\\n'): lines[-1] = lines[-1][:-3] elif lines[-1].endswith('\\\\\r\n'): lines[-1] = lines[-1][:-4] parts.append(nl.join(map(repr, lines))) code = '_printlist((%s,))' % ', '.join(parts) self.lineno += code.count('\n') + 1 self.write_code(code) @staticmethod def process_inline(chunk): if chunk[0] == '!': return '_str(%s)' % chunk[1:] return '_escape(%s)' % chunk def write_code(self, line, comment=''): code = ' ' * (self.indent + self.indent_mod) code += line.lstrip() + comment + '\n' self.code_buffer.append(code) def template(*args, **kwargs): """ Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments). """ tpl = args[0] if args else None for dictarg in args[1:]: kwargs.update(dictarg) adapter = kwargs.pop('template_adapter', SimpleTemplate) lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) tplid = (id(lookup), tpl) if tplid not in TEMPLATES or DEBUG: settings = kwargs.pop('template_settings', {}) if isinstance(tpl, adapter): TEMPLATES[tplid] = tpl if settings: TEMPLATES[tplid].prepare(**settings) elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl: TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) else: TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) if not TEMPLATES[tplid]: abort(500, 'Template (%s) not found' % tpl) return TEMPLATES[tplid].render(kwargs) mako_template = functools.partial(template, template_adapter=MakoTemplate) cheetah_template = functools.partial(template, template_adapter=CheetahTemplate) jinja2_template = functools.partial(template, template_adapter=Jinja2Template) def view(tpl_name, **defaults): """ Decorator: renders a template for a handler. The handler can control its behavior like that: - return a dict of template vars to fill out the template - return something other than a dict and the view decorator will not process the template, but return the handler result as is. This includes returning a HTTPResponse(dict) to get, for instance, JSON with autojson or other castfilters. """ def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) if isinstance(result, (dict, DictMixin)): tplvars = defaults.copy() tplvars.update(result) return template(tpl_name, **tplvars) elif result is None: return template(tpl_name, **defaults) return result return wrapper return decorator mako_view = functools.partial(view, template_adapter=MakoTemplate) cheetah_view = functools.partial(view, template_adapter=CheetahTemplate) jinja2_view = functools.partial(view, template_adapter=Jinja2Template) ############################################################################### # Constants and Globals ######################################################## ############################################################################### TEMPLATE_PATH = ['./', './views/'] TEMPLATES = {} DEBUG = False NORUN = False # If set, run() does nothing. Used by load_app() #: A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found') HTTP_CODES = httplib.responses.copy() HTTP_CODES[418] = "I'm a teapot" # RFC 2324 HTTP_CODES[428] = "Precondition Required" HTTP_CODES[429] = "Too Many Requests" HTTP_CODES[431] = "Request Header Fields Too Large" HTTP_CODES[451] = "Unavailable For Legal Reasons" # RFC 7725 HTTP_CODES[511] = "Network Authentication Required" _HTTP_STATUS_LINES = dict((k, '%d %s' % (k, v)) for (k, v) in HTTP_CODES.items()) #: The default template used for error pages. Override with @error() ERROR_PAGE_TEMPLATE = """ %%try: %%from %s import DEBUG, request Error: {{e.status}}

Error: {{e.status}}

Sorry, the requested URL {{repr(request.url)}} caused an error:

{{e.body}}
%%if DEBUG and e.exception:

Exception:

%%try: %%exc = repr(e.exception) %%except: %%exc = '' %% type(e.exception).__name__ %%end
{{exc}}
%%end %%if DEBUG and e.traceback:

Traceback:

{{e.traceback}}
%%end %%except ImportError: ImportError: Could not generate the error page. Please add bottle to the import path. %%end """ % __name__ #: A thread-safe instance of :class:`LocalRequest`. If accessed from within a #: request callback, this instance always refers to the *current* request #: (even on a multi-threaded server). request = LocalRequest() #: A thread-safe instance of :class:`LocalResponse`. It is used to change the #: HTTP response for the *current* request. response = LocalResponse() #: A thread-safe namespace. Not used by Bottle. local = threading.local() # Initialize app stack (create first empty Bottle app now deferred until needed) # BC: 0.6.4 and needed for run() apps = app = default_app = AppStack() #: A virtual package that redirects import statements. #: Example: ``import bottle.ext.sqlite`` actually imports `bottle_sqlite`. ext = _ImportRedirect('bottle.ext' if __name__ == '__main__' else __name__ + ".ext", 'bottle_%s').module def _main(argv): # pragma: no coverage args, parser = _cli_parse(argv) def _cli_error(cli_msg): parser.print_help() _stderr('\nError: %s\n' % cli_msg) sys.exit(1) if args.version: print('Bottle %s' % __version__) sys.exit(0) if not args.app: _cli_error("No application entry point specified.") sys.path.insert(0, '.') sys.modules.setdefault('bottle', sys.modules['__main__']) host, port = (args.bind or 'localhost'), 8080 if ':' in host and host.rfind(']') < host.rfind(':'): host, port = host.rsplit(':', 1) host = host.strip('[]') config = ConfigDict() for cfile in args.conf or []: try: if cfile.endswith('.json'): with open(cfile, 'rb') as fp: config.load_dict(json_loads(fp.read())) else: config.load_config(cfile) except configparser.Error as parse_error: _cli_error(parse_error) except IOError: _cli_error("Unable to read config file %r" % cfile) except (UnicodeError, TypeError, ValueError) as error: _cli_error("Unable to parse config file %r: %s" % (cfile, error)) for cval in args.param or []: if '=' in cval: config.update((cval.split('=', 1),)) else: config[cval] = True run(args.app, host=host, port=int(port), server=args.server, reloader=args.reload, plugins=args.plugin, debug=args.debug, config=config) def main(): _main(sys.argv) if __name__ == '__main__': # pragma: no coverage main() python-bottle-0.13.2/docs/000077500000000000000000000000001470367422500153475ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/000077500000000000000000000000001470367422500167455ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/.tx/000077500000000000000000000000001470367422500174565ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/.tx/config000066400000000000000000000037301470367422500206510ustar00rootroot00000000000000[main] host = https://www.transifex.com type = PO [bottle.development] file_filter = /LC_MESSAGES/development.po source_file = _pot/development.pot source_lang = en type = PO [bottle.index] file_filter = /LC_MESSAGES/index.po source_file = _pot/index.pot source_lang = en type = PO [bottle.configuration] file_filter = /LC_MESSAGES/configuration.po source_file = _pot/configuration.pot source_lang = en type = PO [bottle.changelog] file_filter = /LC_MESSAGES/changelog.po source_file = _pot/changelog.pot source_lang = en type = PO [bottle.stpl] file_filter = /LC_MESSAGES/stpl.po source_file = _pot/stpl.pot source_lang = en type = PO [bottle.async] file_filter = /LC_MESSAGES/async.po source_file = _pot/async.pot source_lang = en type = PO [bottle.recipes] file_filter = /LC_MESSAGES/recipes.po source_file = _pot/recipes.pot source_lang = en type = PO [bottle.tutorial] file_filter = /LC_MESSAGES/tutorial.po source_file = _pot/tutorial.pot source_lang = en type = PO [bottle.deployment] file_filter = /LC_MESSAGES/deployment.po source_file = _pot/deployment.pot source_lang = en type = PO [bottle.routing] file_filter = /LC_MESSAGES/routing.po source_file = _pot/routing.pot source_lang = en type = PO [bottle.api] file_filter = /LC_MESSAGES/api.po source_file = _pot/api.pot source_lang = en type = PO [bottle.tutorial_app] file_filter = /LC_MESSAGES/tutorial_app.po source_file = _pot/tutorial_app.pot source_lang = en type = PO [bottle.plugins] file_filter = /LC_MESSAGES/plugins.po source_file = _pot/plugins.pot source_lang = en type = PO [bottle.contact] file_filter = /LC_MESSAGES/contact.po source_file = _pot/contact.pot source_lang = en type = PO [bottle.faq] file_filter = /LC_MESSAGES/faq.po source_file = _pot/faq.pot source_lang = en type = PO [bottle.plugins--index] file_filter = /LC_MESSAGES/plugins/index.po source_file = _pot/plugins/index.pot source_lang = en type = PO python-bottle-0.13.2/docs/_locale/README.txt000066400000000000000000000006251470367422500204460ustar00rootroot00000000000000Translation Workflow ==================== If documentation changed, run `make push` to push new messages to transiflex (manager account required). To update the local translation files, call `make pull` and commit the changes from time to time (manager account required). Go to https://www.transifex.com/bottle for actually translating stuff. You can du that with a normal user account at transiflex. python-bottle-0.13.2/docs/_locale/_pot/000077500000000000000000000000001470367422500177065ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/_pot/api.pot000066400000000000000000001376401470367422500212160ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "This is a mostly auto-generated API. If you are new to bottle, you might find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.py:docstring of bottle.debug:1 msgid "Change the debug level. There is only one debug level supported at the moment." msgstr "" #: ../../../bottle.py:docstring of bottle.run:1 msgid "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.py:docstring of bottle.run:0 #: ../../../bottle.py:docstring of bottle.path_shift:0 #: ../../../bottle.py:docstring of bottle.MultiDict.get:0 #: ../../../bottle.py:docstring of bottle.HeaderDict.get:0 #: ../../../bottle.py:docstring of bottle.ResourceManager:0 #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.py:docstring of bottle.FileUpload.save:0 #: ../../../bottle.py:docstring of bottle.Bottle:0 #: ../../../bottle.py:docstring of bottle.Bottle.mount:0 #: ../../../bottle.py:docstring of bottle.Bottle.route:0 #: ../../../bottle.py:docstring of bottle.BaseRequest.path_shift:0 #: ../../../bottle.py:docstring of bottle.BaseResponse:0 #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:0 #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.py:docstring of bottle.run:3 msgid "WSGI application or target string supported by :func:`load_app`. (default: :func:`default_app`)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:5 msgid "Server adapter to use. See :data:`server_names` keys for valid names or pass a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:8 msgid "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:10 msgid "Server port to bind to. Values below 1024 require root privileges. (default: 8080)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.py:docstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.py:docstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.py:docstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.py:docstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.py:docstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.py:docstring of bottle.load:7 msgid "The last form accepts not only function calls, but any type of expression. Keyword arguments passed to this function are available as local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.py:docstring of bottle.load_app:1 msgid "Load a bottle application from a module and make sure that the import does not affect the current default application, but returns a separate application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.py:docstring of bottle.request:1 #: ../../../bottle.py:docstring of bottle.request:1 msgid "A thread-safe instance of :class:`LocalRequest`. If accessed from within a request callback, this instance always refers to the *current* request (even on a multi-threaded server)." msgstr "" #: ../../../bottle.py:docstring of bottle.response:1 msgid "A thread-safe instance of :class:`LocalResponse`. It is used to change the HTTP response for the *current* request." msgstr "" #: ../../../bottle.py:docstring of bottle.HTTP_CODES:1 msgid "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "Return the current :ref:`default-app`. Actually, these are callable instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and :class:`AppStack`) and uses the top of the stack as a *default application* for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "Decorator to install a route to the current default application. See :meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "Decorator to install an error handler to the current default application. See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.py:docstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.py:docstring of bottle.parse_auth:1 msgid "Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None" msgstr "" #: ../../../bottle.py:docstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.py:docstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.py:docstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.py:docstring of bottle.yieldroutes:1 msgid "Return a generator for routes that match the signature (name, args) of the func parameter. This may yield more than one route if the function takes optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.py:docstring of bottle.path_shift:6 msgid "The number of path fragments to shift. May be negative to change the shift direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict:1 msgid "This dict stores multiple values per key, but behaves exactly like a normal dict in that it returns only the newest value for any given key. There are special methods available to access the full list of values." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.get:1 #: ../../../bottle.py:docstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.get:3 #: ../../../bottle.py:docstring of bottle.HeaderDict.get:3 msgid "The default value to be returned if the key is not present or the type conversion fails." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.get:5 #: ../../../bottle.py:docstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.get:6 #: ../../../bottle.py:docstring of bottle.HeaderDict.get:6 msgid "If defined, this callable is used to cast the value into a specific type. Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.append:1 #: ../../../bottle.py:docstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.replace:1 #: ../../../bottle.py:docstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.getall:1 #: ../../../bottle.py:docstring of bottle.MultiDict.getall:1 #: ../../../bottle.py:docstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.py:docstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.py:docstring of bottle.HeaderDict:1 msgid "A case-insensitive version of :class:`MultiDict` that defaults to replace the old value instead of appending it." msgstr "" #: ../../../bottle.py:docstring of bottle.FormsDict:1 msgid "This :class:`MultiDict` subclass is used to store request form data. Additionally to the normal dict-like item access methods (which return unmodified data as native strings), this container also supports attribute-like access to its values. Attributes are automatically de- or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing attributes default to an empty string." msgstr "" #: ../../../bottle.py:docstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.py:docstring of bottle.FormsDict.recode_unicode:1 msgid "If true (default), unicode strings are first encoded with `latin1` and then decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.py:docstring of bottle.FormsDict.decode:1 msgid "Returns a copy with all keys and values de- or recoded to match :attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode dictionary." msgstr "" #: ../../../bottle.py:docstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.py:docstring of bottle.WSGIHeaderDict:1 msgid "This dict-like class wraps a WSGI environ dict and provides convenient access to HTTP_* fields. Keys and values are native strings (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI environment contains non-native string values, these are de- or encoded using a lossless 'latin1' character set." msgstr "" #: ../../../bottle.py:docstring of bottle.WSGIHeaderDict:7 msgid "The API will remain stable even on changes to the relevant PEPs. Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-native strings.)" msgstr "" #: ../../../bottle.py:docstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.py:docstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.py:docstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.py:docstring of bottle.AppStack.push:1 #: ../../../bottle.py:docstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager:1 msgid "This class manages a list of search paths and helps to find and open application-bound resources (files)." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:1 msgid "Add a new path to the list of search paths. Return False if the path does not exist." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:4 msgid "The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file (not ending in `/`), the filename is stripped off." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:7 msgid "Path used to absolutize relative search paths. Defaults to :attr:`base` which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:9 msgid "Position within the list of search paths. Defaults to last index (appends to the list)." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.add_path:12 msgid "The `base` parameter makes it easy to reference files installed along with a python module or package::" msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.lookup:3 msgid "The :attr:`path` list is searched in order. The first match is returned. Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.py:docstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.content_type:1 #: ../../../bottle.py:docstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.content_length:1 #: ../../../bottle.py:docstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.filename:1 msgid "Name of the file on the client file system, but normalized to ensure file system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.filename:4 msgid "Only ASCII letters, digits, dashes, underscores and dots are allowed in the final filename. Accents are removed, if possible. Whitespace is replaced by a single dash. Leading or tailing dots or dashes are removed. The filename is limited to 255 characters." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.save:1 msgid "Save file to disk or copy its content to an open file(-like) object. If *destination* is a directory, :attr:`filename` is added to the path. Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.py:docstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.py:docstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle:1 msgid "Each Bottle object represents a single, distinct web application and consists of routes, callbacks, plugins, resources and configuration. Instances are callable WSGI applications." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle:5 msgid "If true (default), handle all exceptions. Turn off to let debugging middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:4 msgid "Executed once before each request. The request context is available, but no routing has happened yet." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.hook:1 msgid "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` for details." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:1 msgid "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL prefix. Example::" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:9 msgid "Plugins from the parent application are not applied to the routes of the mounted child application. If you need plugins in the child application, install them separately." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:13 msgid "While it is possible to use path wildcards within the prefix path (:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.mount:16 msgid "The prefix path must end with a slash. If you want to access the root of the child application via `/prefix` in addition to `/prefix/`, consider adding a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.merge:1 msgid "Merge the routes of another :class:`Bottle` application or a list of :class:`Route` objects into this application. The routes keep their 'owner', meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.install:1 msgid "Add a plugin to the list of plugins and prepare it for being applied to all routes of this application. A plugin may be a simple decorator or an object that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.uninstall:1 msgid "Uninstall plugins. Pass an instance to remove a specific plugin, a type object to remove all plugins that match that type, a string to remove all plugins with a matching ``name`` attribute or ``True`` to remove all plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.reset:1 msgid "Reset all routes (force plugins to be re-applied) and clear all caches. If an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.match:1 msgid "Search for a matching route and return a (:class:`Route`, urlargs) tuple. The second value is a dictionary with parameters extracted from the URL. Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:7 msgid "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:10 msgid "Request path or a list of paths to listen to. If no path is specified, it is automatically generated from the signature of the function." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:13 msgid "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. (default: `GET`)" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:15 msgid "An optional shortcut to avoid the decorator syntax. ``route(..., callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:18 msgid "A decorator or plugin or a list of plugins. These are applied to the route callback in addition to installed plugins." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:20 msgid "A list of plugins, plugin classes or names. Matching plugins are not installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.route:23 msgid "Any additional keyword arguments are stored as route-specific configuration and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.error:1 msgid "Register an output handler for a HTTP error code. Can be used as a decorator or called directly ::" msgstr "" #: ../../../bottle.py:docstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.py:docstring of bottle.Route:1 msgid "This class wraps a route callback along with route specific metadata and configuration and applies Plugins on demand. It is also responsible for turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "Additional keyword arguments passed to the :meth:`Bottle.route` decorator are stored in this dictionary. Used for route-specific plugin configuration and meta-data." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.call:1 msgid "The route callback with all plugins applied. This property is created on demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.reset:1 msgid "Forget any cached values. The next time :attr:`call` is accessed, all plugins are re-applied." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.get_undecorated_callback:1 msgid "Return the callback. If the callback is a decorated function, try to recover the original function." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.get_callback_args:1 msgid "Return a list of argument names the callback (most likely) accepts as keyword arguments. If the callback is a decorated function, try to recover the original function before inspection." msgstr "" #: ../../../bottle.py:docstring of bottle.Route.get_config:1 msgid "Lookup a config field and return its value, first checking the route.config, then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "The :class:`Request` class wraps a WSGI environment and provides helpful methods to parse and access form data, cookies, file uploads and other metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest:1 msgid "A wrapper for WSGI environment dictionaries that adds a lot of convenient access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest:4 msgid "Adding new attributes to a request actually adds them to the environ dictionary (as 'bottle.request.ext.'). This is the recommended way to store and access request-specific data." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.environ:1 msgid "The wrapped WSGI environ dictionary. This is the only real attribute. All other attributes actually are read-only properties." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.path:1 msgid "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.headers:1 msgid "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP request headers." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.cookies:1 msgid "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.get_cookie:1 msgid "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must match the one used to create the cookie (see :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or wrong signature), return a default value." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.query:1 msgid "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are sometimes called \"URL arguments\" or \"GET parameters\", but not to be confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.forms:1 msgid "Form values parsed from an `url-encoded` or `multipart/form-data` encoded POST or PUT request body. The result is returned as a :class:`FormsDict`. All keys and values are strings. File uploads are stored separately in :attr:`files`." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.params:1 msgid "A :class:`FormsDict` with the combined values of :attr:`query` and :attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.files:1 msgid "File uploads parsed from `multipart/form-data` encoded POST or PUT request body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.json:1 msgid "If the ``Content-Type`` header is ``application/json`` or ``application/json-rpc``, this property holds the parsed content of the request body. Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.body:1 msgid "The HTTP request body as a seek-able file-like object. Depending on :attr:`MEMFILE_MAX`, this is either a temporary file or a :class:`io.BytesIO` instance. Accessing this property for the first time reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.POST:1 msgid "The values of :attr:`forms` and :attr:`files` combined into a single :class:`FormsDict`. Values are either strings (form values) or instances of :class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.url:1 msgid "The full request URI including hostname and scheme. If your app lives behind a reverse proxy or load balancer and you get confusing results, make sure that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.urlparts:1 msgid "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple contains (scheme, host, path, query_string and fragment), but the fragment is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.query_string:1 msgid "The raw :attr:`query` part of the URL (everything in between ``?`` and ``#``) as a string." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.script_name:1 msgid "The initial portion of the URL's `path` that was removed by a higher level (server or routing middleware) before the application was called. This script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.path_shift:4 msgid "The number of path segments to shift. May be negative to change the shift direction. (default: 1)" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.content_length:1 msgid "The request body length as an integer. The client is responsible to set this header. Otherwise, the real length of the body is unknown and -1 is returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.is_xhr:1 msgid "True if the request was triggered by a XMLHttpRequest. This only works with JavaScript libraries that support the `X-Requested-With` header (most of the popular libraries do)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.auth:1 msgid "HTTP authentication data as a (user, password) tuple. This implementation currently supports basic (not digest) authentication only. If the authentication happened at a higher level (e.g. in the front web-server or a middleware), the password field is None, but the user field is looked up from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.remote_route:1 msgid "A list of all IPs that were involved in this request, starting with the client IP and followed by zero or more proxies. This does only work if all proxies support the ```X-Forwarded-For`` header. Note that this information can be forged by malicious clients." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.remote_addr:1 msgid "The client IP as a string. Note that this information can be forged by malicious clients." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "The module-level :data:`bottle.request` is a proxy object (implemented in :class:`LocalRequest`) and always refers to the `current` request, or in other words, the request that is currently processed by the request handler in the current thread. This `thread locality` ensures that you can safely use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.py:docstring of bottle.LocalRequest:1 msgid "A thread-local subclass of :class:`BaseRequest` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`request`). If accessed during a request/response cycle, this instance always refers to the *current* request (even on a multithreaded server)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "The :class:`Response` class stores the HTTP status code as well as headers and cookies that are to be sent to the client. Similar to :data:`bottle.request` there is a thread-local :data:`bottle.response` instance that can be used to adjust the `current` response. Moreover, you can instantiate :class:`Response` and return it from your request handler. In this case, the custom instance overrules the headers and cookies defined in the global one." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:3 msgid "This class does support dict-like case-insensitive item-access to headers, but is NOT a dict. Most notably, iterating over a response yields parts of the body and not the headers." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:8 msgid "Either an HTTP status code (e.g. 200) or a status line including the reason phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse:12 msgid "Additional keyword arguments are added to the list of headers. Underscores in the header name are replaced with dashes." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.status:1 msgid "A writeable property to change the HTTP response status. It accepts either a numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 Brain not found\"). Both :data:`status_line` and :data:`status_code` are updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.headers:1 msgid "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the response headers." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.get_header:1 msgid "Return the value of a previously defined header. If there is no header with that name, return a default value." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_header:1 msgid "Create a new response header, replacing any previously defined headers with the same name." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.iter_headers:1 msgid "Yield (header, value) tuples, skipping headers that are not allowed with the current response status code." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.charset:1 msgid "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:1 msgid "Create a new cookie or replace an old one. If the `secret` parameter is set, create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:8 msgid "Additionally, this method accepts all RFC 2109 attributes that are supported by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:13 msgid "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:17 msgid "prevents client-side javascript to read this cookie (default: off, requires Python 2.6 or newer)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:19 msgid "Control or disable third-party use for this cookie. Possible values: `lax`, `strict` or `none` (default)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:22 msgid "If neither `expires` nor `maxage` is set (default), the cookie will expire at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:26 msgid "Signed cookies may store any pickle-able object and are cryptographically signed to prevent manipulation. Keep in mind that cookies are limited to 4kb in most browsers." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:30 msgid "Warning: Pickle is a potentially dangerous format. If an attacker gains access to the secret key, he could forge cookies that execute code on server side if unpickled. Using pickle is discouraged and support for it will be removed in later versions of bottle." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.set_cookie:35 msgid "Warning: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling save, not to store secret information at client side." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.delete_cookie:1 msgid "Delete a cookie. Be sure to use the same `domain` and `path` settings as used to create the cookie." msgstr "" #: ../../../bottle.py:docstring of bottle.LocalResponse:1 msgid "A thread-local subclass of :class:`BaseResponse` with a different set of attributes for each thread. There is usually only one global instance of this class (:data:`response`). Its attributes are used to build the HTTP response at the end of the request/response cycle." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.py:docstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "The following two classes can be raised as an exception. The most noticeable difference is that bottle invokes error handlers for :class:`HTTPError`, but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "All template engines supported by :mod:`bottle` implement the :class:`BaseTemplate` API. This way it is possible to switch and mix template engines without changing the application code at all." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate.__init__:1 msgid "Create a new template. If the source parameter (str or buffer) is missing, the name argument is used to guess a template filename. Subclasses can assume that self.source and/or self.filename are set. Both are strings. The lookup, encoding and settings parameters are stored as instance variables. The lookup parameter stores a list containing directory paths. The encoding parameter should be used to decode byte strings or files. The settings parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate.search:1 msgid "Search name in all directories specified in lookup. First without, then with common extensions. Return first hit." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate.prepare:1 msgid "Run preparations (parsing, caching, ...). It should be possible to call this again to refresh a template or to update settings." msgstr "" #: ../../../bottle.py:docstring of bottle.BaseTemplate.render:1 msgid "Render the template with the specified local variables and return a single byte or unicode string. If it is a byte string, the encoding must match self.encoding. This method must be thread-safe! Local variables may be provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.py:docstring of bottle.view:1 msgid "Decorator: renders a template for a handler. The handler can control its behavior like that:" msgstr "" #: ../../../bottle.py:docstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.py:docstring of bottle.view:5 msgid "return something other than a dict and the view decorator will not process the template, but return the handler result as is. This includes returning a HTTPResponse(dict) to get, for instance, JSON with autojson or other castfilters." msgstr "" #: ../../../bottle.py:docstring of bottle.template:1 msgid "Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "You can write your own adapter for your favourite template engine or use one of the predefined adapters. Currently there are four fully supported template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "To use :class:`MakoTemplate` as your default template engine, just import its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/async.pot000066400000000000000000000172241470367422500215550ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "Asynchronous design patterns don't mix well with the synchronous nature of `WSGI `_. This is why most asynchronous frameworks (tornado, twisted, ...) implement a specialized API to expose their asynchronous features. Bottle is a WSGI framework and shares the synchronous nature of WSGI, but thanks to the awesome `gevent project `_, it is still possible to write asynchronous applications with bottle. This article documents the usage of Bottle with Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "Briefly worded, the `WSGI specification (pep 3333) `_ defines a request/response circle as follows: The application callable is invoked once for each request and must return a body iterator. The server then iterates over the body and writes each chunk to the socket. As soon as the body iterator is exhausted, the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "Simple enough, but there is a snag: All this happens synchronously. If your application needs to wait for data (IO, sockets, databases, ...), it must either yield empty strings (busy wait) or block the current thread. Both solutions occupy the handling thread and prevent it from answering new requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "Most servers limit the number of threads to avoid their relatively high overhead. Pools of 20 or less threads are common. As soon as all threads are occupied, any new connection is stalled. The server is effectively dead for everyone else. If you want to implement a chat that uses long-polling ajax requests to get real-time updates, you'd reach the limited at 20 concurrent connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "Most servers limit the size of their worker pools to a relatively low number of concurrent threads, due to the high overhead involved in switching between and creating new threads. While threads are cheap compared to processes (forks), they are still expensive to create for each new connection." msgstr "" #: ../../async.rst:20 msgid "The `gevent `_ module adds *greenlets* to the mix. Greenlets behave similar to traditional threads, but are very cheap to create. A gevent-based server can spawn thousands of greenlets (one for each connection) with almost no overhead. Blocking individual greenlets has no impact on the servers ability to accept new requests. The number of concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "This makes creating asynchronous applications incredibly easy, because they look and feel like synchronous applications. A gevent-based server is actually not asynchronous, but massively multi-threaded. Here is an example::" msgstr "" #: ../../async.rst:39 msgid "The first line is important. It causes gevent to monkey-patch most of Python's blocking APIs to not block the current thread, but pass the CPU to the next greenlet instead. It actually replaces Python's threading with gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` which would normally block the whole thread. If you don't feel comfortable with monkey-patching python built-ins, you can use the corresponding gevent functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "If you run this script and point your browser to ``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and `END` show up one by one (rather than waiting 8 seconds to see them all at once). It works exactly as with normal threads, but now your server can handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "Some browsers buffer a certain amount of data before they start rendering a page. You might need to yield more than a few bytes to see an effect in these browsers. Additionally, many browsers have a limit of one concurrent connection per URL. If this is the case, you can use a second browser or a benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "A very common design pattern in asynchronous frameworks (including tornado, twisted, node.js and friends) is to use non-blocking APIs and bind callbacks to asynchronous events. The socket object is kept open until it is closed explicitly to allow callbacks to write to the socket at a later point. Here is an example based on the `tornado library `_::" msgstr "" #: ../../async.rst:63 msgid "The main benefit is that the request handler terminates early. The handling thread can move on and accept new requests while the callbacks continue to write to sockets of previous requests. This is how these frameworks manage to process a lot of concurrent requests with only a small number of OS threads." msgstr "" #: ../../async.rst:65 msgid "With Gevent+WSGI, things are different: First, terminating early has no benefit because we have an unlimited pool of (pseudo)threads to accept new connections. Second, we cannot terminate early because that would close the socket (as required by WSGI). Third, we must return an iterable to conform to WSGI." msgstr "" #: ../../async.rst:67 msgid "In order to conform to the WSGI standard, all we have to do is to return a body iterable that we can write to asynchronously. With the help of `gevent.queue `_, we can *simulate* a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "From the server perspective, the queue object is iterable. It blocks if empty and stops as soon as it reaches ``StopIteration``. This conforms to WSGI. On the application side, the queue object behaves like a non-blocking socket. You can write to it at any time, pass it around and even start a new (pseudo)thread that writes to it asynchronously. This is how long-polling is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "Lets forget about the low-level details for a while and speak about WebSockets. Since you are reading this article, you probably know what WebSockets are: A bidirectional communication channel between a browser (client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple WebSocket endpoint that receives messages and just sends them back to the client::" msgstr "" #: ../../async.rst:111 msgid "The while-loop runs until the client closes the connection. You get the idea :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/changelog.pot000066400000000000000000000560151470367422500223700ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "Keeping up support for ancient Python versions hinders adaptation of new features and serves no real purpose. If you need support for older Python versions, you can stay on bottle-0.12. The updated list of tested and supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go a step further and also remove support for 2.6 and 3.1 to 3.5 even if it was never deprecated explicitly in bottle. This means that this release is *not* backwards compatible in Python <2.7.3 or <3.6 environments. Maintainers for distributions or systems that still use these old python versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "The documented API of the :class:`ConfigDict` class is now considered stable and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "The old route syntax (``/hello/:name``) is deprecated in favor of the more readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about parameters that are not compatible with the new mounting behavior. The old behavior (mount applications as WSGI callable) still works and is used as a fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "The server adapter for google app engine is not useful anymore and marked as deprecated." msgstr "" #: ../../changelog.rst:43 msgid "Bottle uses pickle to store arbitrary objects into signed cookies. This is safe, as long as the signature key remains a secret. Unfortunately, people tend to push code with signature keys to github all the time, so we decided to remove pickle-support from bottle. Signed cookies will now issue a deprecation warning if the value is not a string, and support for non-string values will be removed in 0.14. The global :func:`cookie_encode`, :func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated. If you are using this feature, think about using json to serialize your objects before storing them into cookies, or switch to a session system that stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "Plugins with the old API (``api=1`` or no api attribute) will no longer work." msgstr "" #: ../../changelog.rst:47 msgid "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "The :class:`ConfigDict` class was introduced in 0.11 and changed during 0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "Attribute access and assignment was removed due to high overhead and limited usability." msgstr "" #: ../../changelog.rst:51 msgid "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid ":class:`ConfigDict` instances are no longer callable. This was a shortcut for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid ":class:`ConfigDict` constructor no longer accepts any parameters. Use the `load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "Bottle 0.12 changed some aspects of the Simple Template Engine. These changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "In STPL Templates, the 'rebase' and 'include' keywords were replaced with functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "PEP-263 encoding strings are no longer recognized. Templates are always utf-8." msgstr "" #: ../../changelog.rst:61 msgid "The 'geventSocketIO' server adapter was removed without notice. It did not work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "Signed cookies now use a stronger HMAC algorithm by default. This will result in old cookies to appear invalid after the update. Pass an explicit ``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and :meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "Bottle() instances are now context managers. If used in a with-statement, the default application changes to the specific instance and the shortcuts for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "Added `aiohttp `_ and `uvloop `_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "The :attr:`Request.json` property now accepts ``application/json-rpc`` requests." msgstr "" #: ../../changelog.rst:75 msgid ":func:`static_file` gained support for ``ETag`` headers. It will generate ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "The keywords `include` and `rebase` are functions now and can accept variable template names." msgstr "" #: ../../changelog.rst:89 msgid "The new :attr:`BaseRequest.route` property returns the :class:`Route` that originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in CPythons dict() implementation was fixed over a year ago. If you are still using Python 2.5 in production, consider upgrading or at least make sure that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "More information can be found in this `development blog post `_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "The new :class:`ResourceManager` interface helps locating files bundled with an application." msgstr "" #: ../../changelog.rst:102 msgid "Added a server adapter for `waitress `_." msgstr "" #: ../../changelog.rst:103 msgid "New :meth:`Bottle.merge` method to install all routes from one application into another." msgstr "" #: ../../changelog.rst:104 msgid "New :attr:`BaseRequest.app` property to get the application object that handles a request." msgstr "" #: ../../changelog.rst:105 msgid "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid ":attr:`Response.status` is a read-write property that can be assigned either a numeric status code or a status string with a reason phrase (``200 OK``). The return value is now a string to better match existing APIs (WebOb, werkzeug). To be absolutely clear, you can use the read-only properties :attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context dictionary as second parameter. The new object offers some additional information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "Plugin names are considered unique now. The topmost plugin with a given name on a given route is installed, all other plugins with the same name are silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, :attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and :attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` attributes. In future releases, :attr:`BaseResponse.status` will return a string (e.g. ``200 OK``) instead of an integer to match the API of other common frameworks. To make the transition as smooth as possible, you should use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many places. The new dict implementation allows attribute access and handles unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "Added three new functions to the SimpleTemplate default namespace that handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and :func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "The default escape function for SimpleTemplate now additionally escapes single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "A new route syntax (e.g. ``/object/``) and support for route wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "Introduced a :class:`ConfigDict` that makes accessing configuration a lot easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid ":meth:`Bottle.route` now accpets an import string for the ``callback`` parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "Finally dropped support for type filters. Replace with a custom plugin of needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "The :func:`route` decorator got a lot of new features. See :meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "New server adapters for `gevent `_, `meinheld `_ and `bjoern `_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "The :class:`Router` now special-cases ``wsgi.run_once`` environments to speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "Reduced module load time by ~30% and optimized template parser. See `8ccb2d `_, `f72a7c `_ and `b14b9a `_ for details." msgstr "" #: ../../changelog.rst:170 msgid "Support for \"App Caching\" on Google App Engine. See `af93ec `_." msgstr "" #: ../../changelog.rst:171 msgid "Some of the rarely used or deprecated features are now plugins that avoid overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 #: ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "This release is mostly backward compatible, but some APIs are marked deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "The ``static`` route parameter is deprecated. You can escape wild-cards with a backslash." msgstr "" #: ../../changelog.rst:178 msgid "Type-based output filters are deprecated. They can easily be replaced with plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "The built-in Key/Value database is not available anymore. It is marked deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "Regular expressions must be encapsulated with ``#``. In 0.6 all non-alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "Regular expressions not part of a route wildcard are escaped automatically. You don't have to escape dots or other regular control characters anymore. In 0.6 the whole URL was interpreted as a regular expression. You can use anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar behaviour." msgstr "" #: ../../changelog.rst:194 msgid "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "The :class:`SimpleTemplate` engine escapes HTML special characters in ``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "The :class:`SimpleTemplate` engine returns unicode strings instead of lists of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "The :class:`Request` object got new properties: :attr:`Request.body`, :attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, :attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are now able to encode and decode python objects. This is called a *secure cookie* because the encoded values are signed and protected from changes on client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "The new :class:`Router` class drastically improves performance for setups with lots of dynamic routes and supports named routes (named route + dict = URL string)." msgstr "" #: ../../changelog.rst:215 msgid "It is now possible (and recommended) to return :exc:`HTTPError` and :exc:`HTTPResponse` instances or other exception objects instead of raising them." msgstr "" #: ../../changelog.rst:216 msgid "The new function :func:`static_file` equals :func:`send_file` but returns a :exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. :func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "Thanks to all the people who found bugs, sent patches, spread the word, helped each other on the mailing-list and made this project possible. I hope the following (alphabetically sorted) list is complete. If you miss your name on that list (or want your name removed) please :doc:`tell me ` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/configuration.pot000066400000000000000000000234461470367422500233120ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "This is a draft for a new API. `Tell us `_ what you think." msgstr "" #: ../../configuration.rst:10 msgid "Bottle applications can store their configuration in :attr:`Bottle.config`, a dict-like object and central place for application specific settings. This dictionary controls many aspects of the framework, tells (newer) plugins what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. All the common dict methods work as expected. Let us start with some examples::" msgstr "" #: ../../configuration.rst:44 msgid "The app object is not always available, but as long as you are within a request context, you can use the `request` object to get the current application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "To make life easier, plugins and applications should follow some simple rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "All keys should be lowercase strings and follow the rules for python identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "Namespaces are separated by dots (e.g. ``namespace.field`` or ``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "Bottle uses the root namespace for its own configuration. Plugins should store all their variables in their own namespace (e.g. ``sqlite.db`` or ``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "Configuration files are useful if you want to enable non-programmers to configure your application, or just don't want to hack python module files just to change the database port. A very common syntax for configuration files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style configuration files from disk and import their values into your existing configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "Loading configuration from a Python module is a common pattern for Python programs and frameworks. Bottle assumes that configuration keys are all upper case:" msgstr "" #: ../../configuration.rst:98 msgid "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "Note the second parameter to disable loading as namespaced items as in :meth:`ConfigDict.load_dict`. By default, loading from a Python module will call this method, unless you specifically call this method with `False` as the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an entire structure of nested dictionaries and turns it into a flat list of keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "The ``config`` hook on the application object is triggered each time a value in :attr:`Bottle.config` is changed. This hook can be used to react on configuration changes at runtime, for example reconnect to a new database, change the debug settings on a background service or resize worker thread pools. The hook callback receives two arguments (key, new_value) and is called before the value is actually changed in the dictionary. Raising an exception from a hook callback cancels the change and the old value is preserved." msgstr "" #: ../../configuration.rst:148 msgid "The hook callbacks cannot *change* the value that is to be stored to the dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid ":class:`ConfigDict` allows you to store meta data along with configuration keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "A help or description string. May be used by debugging, introspection or admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "A callable that accepts and returns a single value. If a filter is defined for a key, any new value stored to that key is first passed through the filter callback. The filter can be used to cast the value to a different type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "This feature is most useful for plugins. They can validate their config parameters or trigger side effects using filters and document their configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict:1 msgid "A dict-like configuration storage with additional support for namespaces, validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict:4 msgid "This dict-like class is heavily optimized for read access. All read-only methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_module:17 msgid "If true (default), dictionary values are assumed to represent namespaces (see :meth:`load_dict`)." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:3 msgid "A configuration file consists of sections, each led by a ``[section]`` header, followed by key/value entries separated by either ``=`` or ``:``. Section names and keys are case-insensitive. Leading and trailing whitespace is removed from keys and values. Values can be omitted, in which case the key/value delimiter may also be left out. Values can also span multiple lines, as long as they are indented deeper than the first line of the value. Commands are prefixed by ``#`` or ``;`` and may only appear on their own on an otherwise empty line." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:13 msgid "Both section and key names may contain dots (``.``) as namespace separators. The actual configuration parameter name is constructed by joining section name and key name together and converting to lower case." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:18 msgid "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_config:25 msgid "All keyword parameters are passed to the underlying :class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.load_dict:1 msgid "Load values from a dictionary structure. Nesting can be used to represent namespaces." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.update:1 msgid "If the first parameter is a string, all keys are prefixed with this namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.py:docstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/contact.pot000066400000000000000000000044531470367422500220730ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy behind this website. I'm 27 years old and studying computer science at the Georg-August-University in Göttingen, Germany. Python is my favorite language, but I also code in ruby and JavaScript a lot. Watch me on `twitter `_ or visit my profile at `GitHub `_ to get in contact. A `mailinglist `_ is open for Bottle related questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "" #: ../../contact.rst:11 msgid "This is my first open source project so far. It started and a small experiment but soon got so much positive feedback I decided to make something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "(This is required by `German law `_)" msgstr "" #: ../../contact.rst:17 msgid "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/deployment.pot000066400000000000000000000247301470367422500226200ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "The bottle :func:`run` function, when called without any parameters, starts a local development server on port 8080. You can access and test your application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "To get your application available to the outside world, specify the IP the server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The listening port can be changed in a similar way, but you need root or admin rights to choose a port below 1024. Port 80 is the standard for HTTP servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "The built-in default server is based on `wsgiref WSGIServer `_. This non-threading HTTP server is perfectly fine for development, but may become a performance bottleneck when server load increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "Use a different server that is either multi-threaded or supports asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "**Multi-threaded** servers are the 'classic' way to do it. They are very robust, reasonably fast and easy to manage. As a drawback, they can only handle a limited number of connections at the same time and utilize only one CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python runtime. This does not hurt most applications, they are waiting for network IO most of the time anyway, but may slow down CPU intensive tasks (e.g. image processing)." msgstr "" #: ../../deployment.rst:47 msgid "**Asynchronous IO** servers are very fast, can handle a virtually unlimited number of concurrent connections and are easy to manage. To take full advantage of their potential, you need to design your application accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "**Multi-processing** (forking) servers are not limited by the GIL and utilize more than one CPU core, but make communication between server instances more expensive. You need a database or external message query to share state between processes, or design your application so that it does not need any shared state. The setup is also a bit more complicated, but there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "The easiest way to increase performance is to install a multi-threaded server library like paste_ or cherrypy_ and tell Bottle to use that instead of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "Bottle ships with a lot of ready-to-use adapters for the most common WSGI servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 #: ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "If there is no adapter for your favorite server or if you need more control over the server setup, you may want to start the server manually. Refer to the server documentation on how to run WSGI applications. Here is an example for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "Instead of running your own HTTP server from within Bottle, you can attach Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "All you need is an ``app.wsgi`` file that provides an ``application`` object. This object is used by mod_wsgi to start your application and should be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "uWSGI_ is a modern alternative to FastCGI and the recommended deployment option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project provides an application server that runs your application, and defines a protocol that frontend webservers can speak to. Have a look at the excellent `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "New App Engine applications using the Python 2.7 runtime environment support any WSGI application and should be configured to use the Bottle application object directly. For example suppose your application's main module is ``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object like so::" msgstr "" #: ../../deployment.rst:158 msgid "It is always a good idea to let GAE serve static files directly. Here is example for a working ``app.yaml`` (using the legacy Python 2.5 runtime environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "A single Python process can utilize only one CPU at a time, even if there are more CPU cores available. The trick is to balance the load between multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "Instead of a single Bottle application server, you start one instance for each CPU core available using different local port (localhost:8080, 8081, 8082, ...). You can choose any server adapter you want, even asynchronous ones. Then a high performance load balancer acts as a reverse proxy and forwards each new requests to a random port, spreading the load between all available back-ends. This way you can use all of your CPU cores and even spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "One of the fastest load balancers available is Pound_ but most common web servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "A CGI server starts a new process for each request. This adds a lot of overhead but is sometimes the only option, especially on cheap hosting packages. The `cgi` server adapter does not actually start a CGI server, but transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/development.pot000066400000000000000000000331741470367422500227640ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "This document is intended for developers and package maintainers interested in the bottle development and release workflow. If you want to contribute, you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "There are several ways to join the community and stay up to date. Here are some of them:" msgstr "" #: ../../development.rst:12 msgid "**Mailing list**: Join our mailing list by sending an email to `bottlepy+subscribe@googlegroups.com `_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "**Twitter**: `Follow us on Twitter `_ or search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "**IRC**: Join `#bottlepy on irc.freenode.net `_ or use the `web chat interface `_." msgstr "" #: ../../development.rst:15 msgid "**Google plus**: We sometimes `blog about Bottle, releases and technical stuff `_ on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "The bottle `development repository `_ and the `issue tracker `_ are both hosted at `github `_. If you plan to contribute, it is a good idea to create an account there and fork the main repository. This way your changes and ideas are visible to other developers and can be discussed openly. Even without an account, you can clone the repository or just download the latest development version as a source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "**Download:** Development branch as `tar archive `_ or `zip file `_." msgstr "" #: ../../development.rst:26 msgid "**Translations:** `transifex.com/projects/p/bottle `_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "" #: ../../development.rst:32 msgid "Bottle is released at irregular intervals and distributed through `PyPI `_. Release candidates and bugfix-revisions of outdated releases are only available from the git repository mentioned above. Some Linux distributions may offer packages for outdated releases, though." msgstr "" #: ../../development.rst:34 msgid "The Bottle version number splits into three parts (**major.minor.revision**). These are *not* used to promote new features but to indicate important bug-fixes and/or API changes. Critical bugs are fixed in at least the two latest minor releases and announced in all available channels (mailinglist, twitter, github). Non-critical bugs or features are not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "The major release number is increased on important milestones or updates that completely break backward compatibility. You probably have to work over your entire application to use a new release. These releases are very rare, through." msgstr "" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "The minor release number is increased on updates that change the API or behaviour in some way. You might get some depreciation warnings any may have to tweak some configuration settings to restore the old behaviour, but in most cases these changes are designed to be backward compatible for at least one minor release. You should update to stay up do date, but don't have to. An exception is 0.8, which *will* break backward compatibility hard. (This is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "The revision number is increased on bug-fixes and other patches that do not change the API or behaviour. You can safely update without editing your application code. In fact, you really should as soon as possible, because important security fixes are released this way." msgstr "" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "Release candidates are marked by an ``rc`` in their revision number. These are API stable most of the time and open for testing, but not officially released yet. You should not use these for production." msgstr "" #: ../../development.rst:50 msgid "Repository Structure" msgstr "" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "This is the integration, testing and development branch. All changes that are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "As soon as the master branch is (almost) ready for a new release, it is branched into a new release branch. This \"release candidate\" is feature-frozen but may receive bug-fixes and last-minute changes until it is considered production ready and officially released. From that point on it is called a \"support branch\" and still receives bug-fixes, but only important ones. The revision number is increased on each push to these branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "All other branches are feature branches. These are based on the master branch and only live as long as they are still active and not merged back into ``master``." msgstr "" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:66 msgid "If you want to add a feature, create a new branch from ``master``. If you want to fix a bug, branch ``release-x.y`` for each affected release. Please use a separate branch for each feature or bug to make integration as easy as possible. Thats all. There are git workflow examples at the bottom of this page." msgstr "" #: ../../development.rst:68 msgid "Oh, and never ever change the release number. We'll do that on integration. You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:73 msgid "Watch the tags (and the mailing list) for bug-fixes and new releases. If you want to fetch a specific release from the git repository, trust the tags, not the branches. A branch may contain changes that are not released yet, but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "" #: ../../development.rst:79 msgid "The best way to get your changes integrated into the main development branch is to fork the main repository at github, create a new feature-branch, apply your changes and send a pull-request. Further down this page is a small collection of git workflow examples that may guide you. Submitting git-compatible patches to the mailing list is fine too. In any case, please follow some basic rules:" msgstr "" #: ../../development.rst:81 msgid "**Documentation:** Tell us what your patch does. Comment your code. If you introduced a new feature, add to the documentation so others can learn about it." msgstr "" #: ../../development.rst:82 msgid "**Test:** Write tests to prove that your code works as expected and does not break anything. If you fixed a bug, write at least one test-case that triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:83 msgid "**One patch at a time:** Only fix one bug or add one feature at a time. Design your patches so that they can be applyed as a whole. Keep your patches clean, small and focused." msgstr "" #: ../../development.rst:84 msgid "**Sync with upstream:** If the ``upstream/master`` branch changed while you were working on your patch, rebase or pull to make sure that your patch still applies without conflicts." msgstr "" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "" #: ../../development.rst:90 msgid "You need a recent version of Sphinx to build the documentation. The recommended way is to install :command:`virtualenv` using your distribution package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:123 msgid "The following examples assume that you have an (free) `github account `_. This is not mandatory, but makes things a lot easier." msgstr "" #: ../../development.rst:125 msgid "First of all you need to create a fork (a personal clone) of the official repository. To do this, you simply click the \"fork\" button on the `bottle project page `_. When the fork is done, you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:127 msgid "The fork you just created is hosted at github and read-able by everyone, but write-able only by you. Now you need to clone the fork locally to actually make changes to it. Make sure you use the private (read-write) URL and *not* the public (read-only) one::" msgstr "" #: ../../development.rst:131 msgid "Once the clone is complete your repository will have a remote named \"origin\" that points to your fork on github. Don’t let the name confuse you, this does not point to the original bottle repository, but to your own fork. To keep track of the official repository, add another remote named \"upstream\"::" msgstr "" #: ../../development.rst:137 msgid "Note that \"upstream\" is a public clone URL, which is read-only. You cannot push changes directly to it. Instead, we will pull from your public repository. This is described later." msgstr "" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "" #: ../../development.rst:141 msgid "New features are developed in separate feature-branches to make integration easy. Because they are going to be integrated into the ``master`` branch, they must be based on ``upstream/master``. To create a new feature-branch, type the following::" msgstr "" #: ../../development.rst:145 msgid "Now implement your feature, write tests, update the documentation, make sure that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:149 msgid "If the ``upstream/master`` branch changed in the meantime, there may be conflicts with your changes. To solve these, 'rebase' your feature-branch onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:154 msgid "This is equivalent to undoing all your changes, updating your branch to the latest version and reapplying all your patches again. If you released your branch already (see next step), this is not an option because it rewrites your history. You can do a normal pull instead. Resolve any conflicts, run the tests again and commit." msgstr "" #: ../../development.rst:156 msgid "Now you are almost ready to send a pull request. But first you need to make your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:160 msgid "After you’ve pushed your commit(s) you need to inform us about the new feature. One way is to send a pull-request using github. Another way would be to start a thread in the mailing-list, which is recommended. It allows other developers to see and discuss your patches and you get some feedback for free :)" msgstr "" #: ../../development.rst:162 msgid "If we accept your patch, we will integrate it into the official development branch and make it part of the next release." msgstr "" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "" #: ../../development.rst:166 msgid "The workflow for bug-fixes is very similar to the one for features, but there are some differences:" msgstr "" #: ../../development.rst:168 msgid "Branch off of the affected release branches instead of just the development branch." msgstr "" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:170 msgid "Do this for each affected branch including ``upstream/master`` if it is affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:171 msgid "Name your branch after the release it is based on to avoid confusion. Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/faq.pot000066400000000000000000000054001470367422500212000ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "Bottle is a *micro* framework designed for prototyping and building small web applications and services. It stays out of your way and allows you to get things done fast, but misses some advanced features and ready-to-use solutions found in other frameworks (MVC, ORM, form validation, scaffolding, XML-RPC). Although it *is* possible to add these features and build complex applications with Bottle, you should consider using a full-stack Web framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ or mod_wsgi_ environment, the working directory (``./``) depends on your Apache settings. You should add an absolute path to the template search path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "In :ref:`dynamic route syntax `, a placeholder token (````) matches everything up to the next slash. This equals to ``[^/]+`` in regular expression syntax. To accept slashes too, you have to add a custom regular pattern to the placeholder. An example: ``/images/`` would match ``/images/icons/error.png`` but ``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "Redirects and url-building only works if bottle knows the public address and location of your application. If you run bottle locally behind a reverse proxy or load balancer, some information might get lost along the way. For example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect the local request by your proxy, not the real request by the client. Here is a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/index.pot000066400000000000000000000066421470367422500215510ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:22 msgid "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for Python_. It is distributed as a single file module and has no dependencies other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:25 msgid "**Routing:** Requests to function-call mapping with support for clean and dynamic URLs." msgstr "" #: ../../index.rst:26 msgid "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:27 msgid "**Utilities:** Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:28 msgid "**Server:** Built-in HTTP development server and support for paste_, bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "" #: ../../index.rst:42 msgid "Run this script or paste it into a Python console, then point your browser to ``_. That's it." msgstr "" #: ../../index.rst:45 msgid "Download and Install" msgstr "" #: ../../index.rst:48 msgid "Install the latest stable release with ``pip install bottle`` or download `bottle.py`__ (unstable) into your project directory. There are no hard [1]_ dependencies other than the Python standard library. Bottle supports **Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "" #: ../../index.rst:56 msgid "Start here if you want to learn how to use the bottle framework for web development. If you have any questions not answered here, feel free to ask the `mailing list `_." msgstr "" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "" #: ../../index.rst:86 msgid "These chapters are intended for developers interested in the bottle development and release workflow." msgstr "" #: ../../index.rst:103 msgid "License" msgstr "" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "" #: ../../index.rst:110 msgid "The Bottle logo however is *NOT* covered by that license. It is allowed to use the logo as a link to the bottle homepage or in direct context with the unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:115 msgid "Footnotes" msgstr "" #: ../../index.rst:116 msgid "Usage of the template or server adapter classes requires the corresponding template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/plugindev.pot000066400000000000000000000304171470367422500224340ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "This guide explains the plugin API and how to write custom plugins. I suggest reading :ref:`plugins` first if you have not done that already. You might also want to have a look at the :doc:`/plugins/index` for some practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "This is a draft. If you see any errors or find that a specific part is not explained clear enough, please tell the `mailing-list `_ or file a `bug report `_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "The plugin API builds on the concept of `decorators `_. To put it briefly, a plugin is a decorator applied to every single route callback of an application." msgstr "" #: ../../plugindev.rst:20 msgid "This is just a simplification. Plugins can do a lot more than just decorating route callbacks, but it is a good starting point. Lets have a look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "This plugin measures the execution time for each request and adds an appropriate ``X-Exec-Time`` header to the response. As you can see, the plugin returns a wrapper and the wrapper calls the original callback recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "The last line tells Bottle to install the plugin to the default application. This causes the plugin to be automatically applied to all routes of that application. In other words, ``stopwatch()`` is called once for each route callback and the return value is used as a replacement for the original callback." msgstr "" #: ../../plugindev.rst:40 msgid "Plugins are applied on demand, that is, as soon as a route is requested for the first time. For this to work properly in multi-threaded environments, the plugin should be thread-safe. This is not a problem most of the time, but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "Once all plugins are applied to a route, the wrapped callback is cached and subsequent requests are handled by the cached version directly. This means that a plugin is usually applied only once to a specific route. That cache, however, is cleared every time the list of installed plugins changes. Your plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "The decorator API is quite limited, though. You don't know anything about the route being decorated or the associated application object and have no way to efficiently store data that is shared among all routes. But fear not! Plugins are not limited to just decorator functions. Bottle accepts anything as a plugin as long as it is callable or implements an extended API. This API is described below and gives you a lot of control over the whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid ":class:`Plugin` is not a real class (you cannot import it from :mod:`bottle`) but an interface that plugins are expected to implement. Bottle accepts any object of any type as a plugin, as long as it conforms to the following API." msgstr "" #: ../../plugindev.rst:54 msgid "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is defined, it is always preferred over calling the plugin directly. All other methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "Both :meth:`Bottle.uninstall` and the `skip` parameter of :meth:`Bottle.route()` accept a name string to refer to a plugin or plugin type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "The Plugin API is still evolving. This integer attribute tells bottle which version to use. If it is missing, bottle defaults to the first version. The current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "Called as soon as the plugin is installed to an application (see :meth:`Bottle.install`). The only parameter is the associated application object." msgstr "" #: ../../plugindev.rst:70 msgid "As long as :meth:`apply` is not defined, the plugin itself is used as a decorator and applied directly to each route callback. The only parameter is the callback to decorate. Whatever is returned by this method replaces the original callback. If there is no need to wrap or replace a given callback, just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "If defined, this method is used in favor of :meth:`__call__` to decorate route callbacks. The additional `route` parameter is an instance of :class:`Route` and provides a lot of meta-information and context for that route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "Called immediately before the plugin is uninstalled or the application is closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for plugins that are applied directly to a route via the :meth:`Bottle.route()` decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "The Plugin API is still evolving and changed with Bottle 0.10 to address certain issues with the route context dictionary. To ensure backwards compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` attribute to tell bottle which API to use. The API differences are summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "The `context` parameter of the :meth:`Plugin.apply` method is now an instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed informations about the associated route. The most important attributes are summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "A list of route-specific plugins. These are applied in addition to application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "A list of plugins to not apply to this route (again, see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "Additional keyword arguments passed to the :meth:`Bottle.route` decorator are stored in this dictionary. Used for route-specific configuration and meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "For your plugin, :attr:`Route.config` is probably the most important attribute. Keep in mind that this dictionary is local to the route, but shared between all plugins. It is always a good idea to add a unique prefix or, if your plugin needs a lot of configuration, store it in a separate namespace within the `config` dictionary. This helps to avoid naming collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "While some :class:`Route` attributes are mutable, changes may have unwanted effects on other plugins. It is most likely a bad idea to monkey-patch a broken route instead of providing a helpful error message and let the user fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "In some rare cases, however, it might be justifiable to break this rule. After you made your changes to the :class:`Route` instance, raise :exc:`RouteReset` as an exception. This removes the current route from the cache and causes all plugins to be re-applied. The router is not updated, however. Changes to `rule` or `method` values have no effect on the router, but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "Once all plugins are applied to a route, the wrapped route callback is cached to speed up subsequent requests. If the behavior of your plugin depends on configuration, and you want to be able to change that configuration at runtime, you need to read the configuration on each request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "For performance reasons, however, it might be worthwhile to choose a different wrapper based on current needs, work with closures, or enable or disable a plugin at runtime. Let's take the built-in HooksPlugin as an example: If no hooks are installed, the plugin removes itself from all affected routes and has virtually no overhead. As soon as you install the first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "To achieve this, you need control over the callback cache: :meth:`Route.reset` clears the cache for a single route and :meth:`Bottle.reset` clears all caches for all routes of an application at once. On the next request, all plugins are re-applied to the route as if it were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "Both methods won't affect the current request if called from within a route callback, of cause. To force a restart of the current request, raise :exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "This plugin provides an sqlite3 database connection handle as an additional keyword argument to wrapped callbacks, but only if the callback expects it. If not, the route is ignored and no overhead is added. The wrapper does not affect the return value, but handles plugin-related exceptions properly. :meth:`Plugin.setup` is used to inspect the application and search for conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "This plugin is actually useful and very similar to the version bundled with Bottle. Not bad for less than 60 lines of code, don't you think? Here is a usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "The first route needs a database connection and tells the plugin to create a handle by requesting a ``db`` keyword argument. The second route does not need a database and is therefore ignored by the plugin. The third route does expect a 'db' keyword argument, but explicitly skips the sqlite plugin. This way the argument is not overruled by the plugin and still contains the value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/plugins/000077500000000000000000000000001470367422500213675ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/_pot/plugins/index.pot000066400000000000000000000142151470367422500232250ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "This is a list of third-party plugins that add extend Bottles core functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "Have a look at :ref:`plugins` for general questions about plugins (installation, usage). If you plan to develop a new plugin, the :doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "Cork provides a simple set of methods to implement Authentication and Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "Cors-plugin is the easiest way to implement cors on your bottle web application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "Integrates the `werkzeug` library (alternative request and response objects, advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:63 msgid "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "Plugins listed here are not part of Bottle or the Bottle project, but developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/recipes.pot000066400000000000000000000215401470367422500220660ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "There is no built-in support for sessions because there is no *right* way to do it (in a micro framework). Depending on requirements and environment you could use beaker_ middleware with a fitting backend or implement it yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent requests modify the same session at the same time, one of the updates might get lost. For this reason, sessions should only be populated once and treated as a read-only store after that. If you find yourself updating sessions regularly, and don't want to risk losing any updates, think about using a real database instead or seek alternative session middleware libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "Bottle catches all Exceptions raised in your app code to prevent your WSGI server from crashing. If the built-in :func:`debug` mode is not enough and you need exceptions to propagate to a debugging middleware, you can turn off this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "Now, bottle only catches its own exceptions (:exc:`HTTPError`, :exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "The werkzeug_ and paste_ libraries both ship with very powerful debugging WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for paste_. They both allow you do inspect the stack and even execute python code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "Unit-testing is usually performed against methods defined in your web application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 #: ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "In the example the Bottle route() method is never executed - only index() is tested." msgstr "" #: ../../recipes.rst:89 msgid "If the code being tested requires access to ``bottle.request`` you can mock it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "Any HTTP-based testing system can be used with a running WSGI server, but some testing frameworks work more intimately with WSGI, and provide the ability the call WSGI applications in a controlled environment, with tracebacks and full use of debugging tools. `Testing tools for WSGI `_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "Example using `WebTest `_ and `Nose `_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "This is not the recommend way (you should use a middleware in front of bottle to do this) but you can call other WSGI applications from within your bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "Again, this is not the recommend way to implement subprojects. It is only here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "Several \"push\" mechanisms like XHR multipart need the ability to write response data without closing the connection in conjunction with the response header \"Connection: keep-alive\". WSGI does not easily lend itself to this behavior, but it is still possible to do so in Bottle by using the gevent_ async framework. Here is a sample that works with either the gevent_ HTTP server or the paste_ HTTP server (it may work with others, but I have not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "If you browse to ``http://localhost:8080/stream``, you should see 'START', 'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "A common feature request is for Bottle to support Gzip compression, which speeds up sites by compressing static resources (like CSS and JS files) during a request." msgstr "" #: ../../recipes.rst:220 msgid "Supporting Gzip compression is not a straightforward proposition, due to a number of corner cases that crop up frequently. A proper Gzip implementation must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "Do not cache small files because a disk seek would take longer than on-the-fly compression." msgstr "" #: ../../recipes.rst:232 msgid "Because of these requirements, it is the recommendation of the Bottle project that Gzip compression is best handled by the WSGI server Bottle runs on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "For example, if you want to allow Cross-Origin Resource Sharing for the content returned by all of your URL, you can use the hook decorator and setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "You can also use the ``before_request`` to take an action before every function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "Heroku_, a popular cloud application platform now provides support for running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "This recipe is based upon the `Heroku Quickstart `_, with Bottle specific code replacing the `Write Your App `_ section of the `Getting Started with Python on Heroku/Cedar `_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "Heroku's app stack passes the port that the application needs to listen on for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/routing.pot000066400000000000000000000134311470367422500221230ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "Bottle uses a powerful routing engine to find the right callback for each request. The :ref:`tutorial ` shows you the basics. This document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "The :class:`Router` distinguishes between two basic types of routes: **static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. ``/hello/``). A route that contains one or more *wildcards* it is considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "The simplest form of a wildcard consists of a name enclosed in angle brackets (e.g. ````). The name should be unique for a given route and form a valid python identifier (alphanumeric, starting with a letter). This is because wildcards are used as keyword arguments for the request callback later." msgstr "" #: ../../routing.rst:16 msgid "Each wildcard matches one or more characters, but stops at the first slash (``/``). This equals a regular expression of ``[^/]+`` and ensures that only one path segment is matched and routes with more than one wildcard stay unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 #: ../../routing.rst:25 #: ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "Is it possible to escape characters like colon ``:`` with a backslash ``\\``. This will prevent to trigger the old syntax in case you need to use ``:``. For example: the rule ``//item:`` triggers the old syntax, (see below) but ``/action/item\\:`` works as intended with the new syntax." msgstr "" #: ../../routing.rst:33 msgid "You can change the exact behaviour in many ways using filters. This is described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "Filters are used to define more specific wildcards, and/or transform the matched part of the URL before it is passed to the callback. A filtered wildcard is declared as ```` or ````. The syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "**:path** matches all characters including the slash character in a non-greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "**:re[:exp]** allows you to specify a custom regular expression in the config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "You can add your own filters to the router. All you need is a function that returns three elements: A regular expression string, a callable to convert the URL fragment to a python value, and a callable that does the opposite. The filter function is called with the configuration string as the only parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "The new rule syntax was introduce in **Bottle 0.10** to simplify some common use cases, but the old syntax still works and you can find lot code examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "Try to avoid the old syntax in future projects if you can. It is not currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "Route decorator can also be directly called as method. This way provides flexibility in complex setups, allowing you to directly control, when and how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "Here is a basic example of explicit routing configuration for default bottle application::" msgstr "" #: ../../routing.rst:105 msgid "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/_pot/stpl.pot000066400000000000000000000206201470367422500214140ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "Bottle comes with a fast, powerful and easy to learn built-in template engine called *SimpleTemplate* or *stpl* for short. It is the default engine used by the :func:`view` and :func:`template` helpers but can be used as a stand-alone general purpose template engine too. This document explains the template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "In this document we use the :func:`template` helper in examples for the sake of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "Just keep in mind that compiling and rendering templates are two different actions, even if the :func:`template` helper hides this fact. Templates are usually compiled only once and cached internally, but rendered many times with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "Python is a very powerful language but its whitespace-aware syntax makes it difficult to use as a template language. SimpleTemplate removes some of these restrictions and allows you to write clean, readable and maintainable templates while preserving full access to the features, libraries and speed of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and is executed on each :meth:`SimpleTemplate.render` call. Do not render untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "You already learned the use of the ``{{...}}`` syntax from the \"Hello World!\" example above, but there is more: any python expression is allowed within the curly brackets as long as it evaluates to a string or something that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "The contained python expression is executed at render-time and has access to all keyword arguments passed to the :meth:`SimpleTemplate.render` method. HTML special characters are escaped automatically to prevent `XSS `_ attacks. You can start the expression with an exclamation mark to disable escaping for that expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "The template engine allows you to embed lines or blocks of python code within your template. Code lines start with ``%`` and code blocks are surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "Embedded python code follows regular python syntax, but with two additional syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "**Indentation is ignored.** You can put as much whitespace in front of statements as you want. This allows you to align your code with the surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "Blocks that are normally indented now have to be closed explicitly with an ``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "Both the ``%`` and the ``<%`` tokens are only recognized if they are the first non-whitespace characters in a line. You don't have to escape them if they appear mid-text in your template markup. Only if a line of text starts with one of these tokens, you have to escape it with a backslash. In the rare case where the backslash + token combination appears in your markup at the beginning of a line, you can always help yourself with a string literal in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "If you find yourself needing to escape a lot, consider using :ref:`custom tokens `." msgstr "" #: ../../stpl.rst:98 msgid "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is only a convenient way to type less and avoid clutter for longer code segments. This means that in ``<% %>`` blocks, all indented code must be terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "Code blocks and code lines always span the whole line. Whitespace in front of after a code segment is stripped away. You won't see empty lines or dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "But embedding code still requires you to start a new line, which may not what you want to see in your rendered template. To skip the newline in front of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "This only works directly in front of code segments. In all other places you can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "Each template is preloaded with a bunch of functions that help with the most common use cases. These functions are always available. You don't have to import or provide them yourself. For everything not covered here there are probably good python libraries available. Remember that you can ``import`` anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "Prior to this release, :func:`include` and :func:`rebase` were syntax keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "Render a sub-template with the specified variables and insert the resulting text into the current template. The function returns a dictionary containing the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "Mark the current template to be later included into a different template. After the current template is rendered, its resulting text is stored in a variable named ``base`` and passed to the base-template, which is then rendered. This can be used to `wrap` a template with surrounding text, or simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "Accessing undefined variables in a template raises :exc:`NameError` and stops rendering immediately. This is standard python behavior and nothing new, but vanilla python lacks an easy way to check the availability of a variable. This quickly gets annoying if you want to support flexible inputs or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "Return True if the variable is defined in the current template namespace, False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "If the variable is not defined, create it with the given default value. Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "Here is an example that uses all three functions to implement optional template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.py:docstring of bottle.SimpleTemplate.prepare:1 msgid "Run preparations (parsing, caching, ...). It should be possible to call this again to refresh a template or to update settings." msgstr "" #: ../../../bottle.py:docstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/tutorial.pot000066400000000000000000001352571470367422500223120ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "" #: ../../tutorial.rst:26 msgid "This tutorial introduces you to the concepts and features of the Bottle web framework and covers basic and advanced topics alike. You can read it from start to end, or use it as a reference later on. The automatically generated :doc:`api` may be interesting for you, too. It covers more details, but explains less than this tutorial. Solutions for the most common questions can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If you need any help, join our `mailing list `_ or visit us in our `IRC channel `_." msgstr "" #: ../../tutorial.rst:31 msgid "Installation" msgstr "" #: ../../tutorial.rst:33 msgid "Bottle does not depend on any external libraries. You can just download `bottle.py `_ into your project directory and start coding:" msgstr "" #: ../../tutorial.rst:39 msgid "This will get you the latest development snapshot that includes all the new features. If you prefer a more stable environment, you should stick with the stable releases. These are available on `PyPI `_ and can be installed via :command:`pip` (recommended), :command:`easy_install` or your package manager:" msgstr "" #: ../../tutorial.rst:47 msgid "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle applications. If you do not have permissions to install packages system-wide or simply don't want to, create a `virtualenv `_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "This tutorial assumes you have Bottle either :ref:`installed ` or copied into your project directory. Let's start with a very basic \"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "This is it. Run this script, visit http://localhost:8080/hello and you will see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "The :func:`route` decorator binds a piece of code to an URL path. In this case, we link the ``/hello`` path to the ``hello()`` function. This is called a `route` (hence the decorator name) and is the most important concept of this framework. You can define as many routes as you want. Whenever a browser requests a URL, the associated function is called and the return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "The :func:`run` call in the last line starts a built-in development server. It runs on ``localhost`` port ``8080`` and serves requests until you hit :kbd:`Control-c`. You can switch the server backend later, but for now a development server is all we need. It requires no setup at all and is an incredibly painless way to get your application up and running for local tests." msgstr "" #: ../../tutorial.rst:85 msgid "The :ref:`tutorial-debugging` is very helpful during early development, but should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "This is just a demonstration of the basic concept of how applications are built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "For the sake of simplicity, most examples in this tutorial use a module-level :func:`route` decorator to define routes. This adds routes to a global \"default application\", an instance of :class:`Bottle` that is automatically created the first time you call :func:`route`. Several other module-level decorators and functions relate to this default application, but if you prefer a more object oriented approach and don't mind the extra typing, you can create a separate application object and use that instead of the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "The object-oriented approach is further described in the :ref:`default-app` section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "In the last chapter we built a very simple web application with only a single route. Here is the routing part of the \"Hello World\" example again::" msgstr "" #: ../../tutorial.rst:122 msgid "The :func:`route` decorator links an URL path to a callback function, and adds a new route to the :ref:`default application `. An application with just one route is kind of boring, though. Let's add some more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "This example demonstrates two things: You can bind more than one route to a single callback, and you can add wildcards to URLs and access them via keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "Routes that contain wildcards are called `dynamic routes` (as opposed to `static routes`) and match more than one URL at the same time. A simple wildcard consists of a name enclosed in angle brackets (e.g. ````) and accepts one or more characters up to the next slash (``/``). For example, the route ``/hello/`` accepts requests for ``/hello/alice`` as well as ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "Each wildcard passes the covered part of the URL as a keyword argument to the request callback. You can use them right away and implement RESTful, nice-looking and meaningful URLs with ease. Here are some other examples along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "Filters can be used to define more specific wildcards, and/or transform the covered part of the URL before it is passed to the callback. A filtered wildcard is declared as ```` or ````. The syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "**:path** matches all characters including the slash character in a non-greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "**:re** allows you to specify a custom regular expression in the config field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "The HTTP protocol defines several `request methods`__ (sometimes referred to as \"verbs\") for different tasks. GET is the default for all routes with no other method specified. These routes will match GET requests only. To handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` keyword argument to the :func:`route` decorator or use one of the five alternative decorators: :func:`get`, :func:`post`, :func:`put`, :func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "The POST method is commonly used for HTML form submission. This example shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "In this example the ``/login`` URL is linked to two distinct callbacks, one for GET requests and another for POST requests. The first one displays a HTML form to the user. The second callback is invoked on a form submission and checks the login credentials the user entered into the form. The use of :attr:`Request.forms` is further described in the :ref:`tutorial-request` section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "The HEAD method is used to ask for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information about a resource without having to download the entire document. Bottle handles these requests automatically by falling back to the corresponding GET route and cutting off the request body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "Additionally, the non-standard ANY method works as a low priority fallback: Routes that listen to ANY will match requests regardless of their HTTP method but only if no other more specific route is defined. This is helpful for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "To sum it up: HEAD requests fall back to GET routes and all requests fall back to ANY routes, but only if there is no matching route for the original request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "Static files such as images or CSS files are not served automatically. You have to add a route and a callback to control which files get served and where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "The :func:`static_file` function is a helper to serve files in a safe and convenient way (see :ref:`tutorial-static-files`). This example is limited to files directly within the ``/path/to/your/static/files`` directory because the ```` wildcard won't match a path with a slash in it. To serve files in subdirectories, change the wildcard to use the `path` filter::" msgstr "" #: ../../tutorial.rst:234 msgid "Be careful when specifying a relative root-path such as ``root='./static/files'``. The working directory (``./``) and the project directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "If anything goes wrong, Bottle displays an informative but fairly plain error page. You can override the default for a specific HTTP status code with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "From now on, `404 File not Found` errors will display a custom error page to the user. The only parameter passed to the error-handler is an instance of :exc:`HTTPError`. Apart from that, an error-handler is quite similar to a regular request callback. You can read from :data:`request`, write to :data:`response` and return any supported data-type except for :exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "Error handlers are used only if your application returns or raises an :exc:`HTTPError` exception (:func:`abort` does just that). Changing :attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "In pure WSGI, the range of types you may return from your application is very limited. Applications must return an iterable yielding byte strings. You may return a string (because strings are iterable) but this causes most servers to transmit your content char by char. Unicode strings are not allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "Bottle is much more flexible and supports a wide range of types. It even adds a ``Content-Length`` header if possible and encodes unicode automatically, so you don't have to. What follows is a list of data types you may return from your application callbacks and a short description of how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "As mentioned above, Python dictionaries (or subclasses thereof) are automatically transformed into JSON strings and returned to the browser with the ``Content-Type`` header set to ``application/json``. This makes it easy to implement json-based APIs. Data formats other than json are supported too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings (or iterables yielding unicode strings) are automatically encoded with the codec specified in the ``Content-Type`` header (utf8 by default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "Bottle returns strings as a whole (instead of iterating over each char) and adds a ``Content-Length`` header based on the string length. Lists of byte strings are joined first. Other iterables yielding byte strings are not joined because they may grow too big to fit into memory. The ``Content-Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "Returning these has the same effect as when raising them as an exception. In case of an :exc:`HTTPError`, the error handler is applied. See :ref:`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "Everything that has a ``.read()`` method is treated as a file or file-like object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI server framework. Some WSGI server implementations can make use of optimized system calls (sendfile) to transmit files more efficiently. In other cases this just iterates over chunks that fit into memory. Optional headers such as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use :func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "You are allowed to use ``yield`` within your callbacks or return an iterable, as long as the iterable yields byte strings, unicode strings, :exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not supported, sorry. Please note that the HTTP status code and the headers are sent to the browser as soon as the iterable yields its first non-empty value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "The ordering of this list is significant. You may for example return a subclass of :class:`str` with a ``read()`` method. It is still treated as a string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide how to encode unicode strings. This header defaults to ``text/html; charset=UTF8`` and can be changed using the :attr:`Response.content_type` attribute or by setting the :attr:`Response.charset` attribute directly. (The :class:`Response` object is described in the section :ref:`tutorial-response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "In some rare cases the Python encoding names differ from the names supported by the HTTP specification. Then, you have to do both: first set the :attr:`Response.content_type` header (which is sent to the client unchanged) and then set the :attr:`Response.charset` attribute (which is used to encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "You can directly return file objects, but :func:`static_file` is the recommended way to serve static files. It automatically guesses a mime-type, adds a ``Last-Modified`` header, restricts paths to a ``root`` directory for security reasons and generates appropriate error responses (403 on permission errors, 404 on missing files). It even supports the ``If-Modified-Since`` header and eventually generates a ``304 Not Modified`` response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "You can raise the return value of :func:`static_file` as an exception if you really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "Most browsers try to open downloaded files if the MIME type is known and assigned to an application (e.g. PDF files). If this is not what you want, you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "If the ``download`` parameter is just ``True``, the original filename is used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "To redirect a client to a different URL, you can send a ``303 See Other`` response with the ``Location`` header set to the new URL. :func:`redirect` does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "Both functions will interrupt your callback code by raising an :exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:369 msgid "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will result in a ``500 Internal Server Error`` response, so they won't crash your WSGI server. You can turn off this behavior to handle exceptions in your middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "Response metadata such as the HTTP status code, response headers and cookies are stored in an object called :data:`response` up to the point where they are transmitted to the browser. You can manipulate these metadata directly or use the predefined helper methods to do so. The full API and feature list is described in the API section (see :class:`Response`), but the most common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "The `HTTP status code `_ controls the behavior of the browser and defaults to ``200 OK``. In most scenarios you won't need to set the :attr:`Response.status` attribute manually, but use the :func:`abort` helper or return an :exc:`HTTPResponse` instance with the appropriate status code. Any integer is allowed, but codes other than the ones defined by the `HTTP specification `_ will only confuse the browser and break standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "Response headers such as ``Cache-Control`` or ``Location`` are defined via :meth:`Response.set_header`. This method takes two parameters, a header name and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "Most headers are unique, meaning that only one header per name is send to the client. Some special headers however are allowed to appear more than once in a response. To add an additional header, use :meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "Please note that this is just an example. If you want to work with cookies, read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 #: ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "A cookie is a named piece of text stored in the user's browser profile. You can access previously defined cookies via :meth:`Request.get_cookie` and set new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "The :meth:`Response.set_cookie` method accepts a number of additional keyword arguments that control the cookies lifetime and behavior. Some of the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "**domain:** The domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "**httponly:** Prevent client-side javascript to read this cookie (default: off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "**same_site:** Disables third-party use for a cookie. Allowed attributes: `lax` and `strict`. In strict mode the cookie will never be sent. In lax mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "If neither `expires` nor `max_age` is set, the cookie expires at the end of the browser session or as soon as the browser window is closed. There are some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "Some users configure their browsers to not accept cookies at all. Most search engines ignore cookies too. Make sure that your application still works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "Cookies are stored at client side and are not encrypted in any way. Whatever you store in a cookie, the user can read it. Worse than that, an attacker might be able to steal a user's cookies through `XSS `_ vulnerabilities on your side. Some viruses are known to read the browser cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "As mentioned above, cookies are easily forged by malicious clients. Bottle can cryptographically sign your cookies to prevent this kind of manipulation. All you have to do is to provide a signature key via the `secret` keyword argument whenever you read or set a cookie and keep that key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "In addition, Bottle automatically pickles and unpickles any data stored to signed cookies. This allows you to store any pickle-able object (not only strings) to cookies, as long as the pickled data does not exceed the 4 KB limit." msgstr "" #: ../../tutorial.rst:458 msgid "Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling safe and prevent manipulation, not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "Cookies, HTTP header, HTML ``
`` fields and other request data is available through the global :data:`request` object. This special object always refers to the *current* request, even in multi-threaded environments where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "The :data:`request` object is a subclass of :class:`BaseRequest` and has a very rich API to access data. We only cover the most commonly used features here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "Bottle uses a special type of dictionary to store form data and cookies. :class:`FormsDict` behaves like a normal dictionary, but has some additional features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "**Attribute access**: All values in the dictionary are also accessible as attributes. These virtual attributes return unicode strings, even if the value is missing or unicode decoding fails. In that case, the string is empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "**Multiple values per key:** :class:`FormsDict` is a subclass of :class:`MultiDict` and can store more than one value per key. The standard dictionary access methods will only return a single value, but the :meth:`~MultiDict.getall` method returns a (possibly empty) list of all values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "**WTForms support:** Some libraries (e.g. `WTForms `_) want all-unicode dictionaries as input. :meth:`FormsDict.decode` does that for you. It decodes all values and returns a copy of itself, while preserving multiple values per key and all the other features." msgstr "" #: ../../tutorial.rst:515 msgid "In **Python 2** all keys and values are byte-strings. If you need unicode, you can call :meth:`FormsDict.getunicode` or fetch values via attribute access. Both methods try to decode the string (default: utf8) and return an empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "In **Python 3** all strings are unicode, but HTTP is a byte-based wire protocol. The server has to decode the byte strings somehow before they are passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 (aka latin1), a reversible single-byte codec that can be re-encoded with a different encoding later. Bottle does that for :meth:`FormsDict.getunicode` and attribute access, but not for the dict-access methods. These return the unchanged values as provided by the server implementation, which is probably not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "If you need the whole dictionary with correctly decoded values (e.g. for WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "Cookies are small pieces of text stored in the clients browser and sent back to the server with each request. They are useful to keep some state around for more than one request (HTTP itself is stateless), but should not be used for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "All cookies sent by the client are available through :attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "The :meth:`BaseRequest.get_cookie` method is a different way do access cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or ``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict` is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit a small number of key/value pairs to the server. You can use the :attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these values and the :attr:`BaseRequest.query_string` attribute to get the whole string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "Let us start from the beginning. In HTML, a typical ```` looks something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "The ``action`` attribute specifies the URL that will receive the form data. ``method`` defines the HTTP method to use (``GET`` or ``POST``). With ``method=\"get\"`` the form values are appended to the URL and available through :attr:`BaseRequest.query` as described above. This is considered insecure and has other limitations, so we use ``method=\"post\"`` here. If in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms` as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "There are several other attributes used to access form data. Some of them combine values from different sources for easier access. The following table should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 #: ../../tutorial.rst:622 #: ../../tutorial.rst:623 #: ../../tutorial.rst:624 #: ../../tutorial.rst:624 #: ../../tutorial.rst:625 #: ../../tutorial.rst:626 #: ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 #: ../../tutorial.rst:621 #: ../../tutorial.rst:622 #: ../../tutorial.rst:622 #: ../../tutorial.rst:623 #: ../../tutorial.rst:623 #: ../../tutorial.rst:624 #: ../../tutorial.rst:625 #: ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "To support file uploads, we have to change the ```` tag a bit. First, we tell the browser to encode the form data in a different way by adding an ``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, we add ```` tags to allow the user to select a file. Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "Bottle stores file uploads in :attr:`BaseRequest.files` as :class:`FileUpload` instances, along with some metadata about the upload. Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid ":attr:`FileUpload.filename` contains the name of the file on the clients file system, but is cleaned up and normalized to prevent bugs caused by unsupported characters or path segments in the filename. If you need the unmodified name as sent by the client, have a look at :attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "The :attr:`FileUpload.save` method is highly recommended if you want to store the file to disk. It prevents some common errors (e.g. it does not overwrite existing files unless you tell it to) and stores the file in a memory efficient way. You can access the file object directly via :attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "Some JavaScript or REST clients send ``application/json`` content to the server. The :attr:`BaseRequest.json` attribute contains the parsed data structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "You can access the raw body data as a file-like object via :attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` setting. In both cases the body is completely buffered before you can access the attribute. If you expect huge amounts of data and want to get direct unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The original is stored in :attr:`BaseRequest.environ`, but the request object itself behaves like a dictionary, too. Most of the interesting data is exposed through special methods or attributes, but if you want to access `WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "Bottle comes with a fast and powerful built-in template engine called :doc:`stpl`. To render a template you can use the :func:`template` function or the :func:`view` decorator. All you have to do is to provide the name of the template and the variables you want to pass to the template as keyword arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "This will load the template file ``hello_template.tpl`` and render it with the ``name`` variable set. Bottle will look for templates in the ``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` list." msgstr "" #: ../../tutorial.rst:707 msgid "The :func:`view` decorator allows you to return a dictionary with the template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "The template syntax is a very thin layer around the Python language. Its main purpose is to ensure correct indentation of blocks, so you can format your template without worrying about indentation. Follow the link for a full syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "Templates are cached in memory after compilation. Modifications made to the template files will have no affect until you clear the template cache. Call ``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "Bottle's core features cover most common use-cases, but as a micro-framework it has its limits. This is where \"Plugins\" come into play. Plugins add missing functionality to the framework, integrate third party libraries, or just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "We have a growing :doc:`/plugins/index` and most plugins are designed to be portable and re-usable across applications. The chances are high that your problem has already been solved and a ready-to-use plugin exists. If not, the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "The effects and APIs of plugins are manifold and depend on the specific plugin. The ``SQLitePlugin`` plugin for example detects callbacks that require a ``db`` keyword argument and creates a fresh database connection object every time the callback is called. This makes it very convenient to use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "Other plugin may populate the thread-safe :data:`local` object, change details of the :data:`request` object, filter the data returned by the callback or bypass the callback completely. An \"auth\" plugin for example could check for a valid session and return a login page instead of calling the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "Plugins can be installed application-wide or just to some specific routes that need additional functionality. Most plugins can safely be installed to all routes and are smart enough to not add overhead to callbacks that do not need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "Let us take the ``SQLitePlugin`` plugin for example. It only affects route callbacks that need a database connection. Other routes are left alone. Because of this, we can install the plugin application-wide with no additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "To install a plugin, just call :func:`install` with the plugin as first argument::" msgstr "" #: ../../tutorial.rst:786 msgid "The plugin is not applied to the route callbacks yet. This is delayed to make sure no routes are missed. You can install plugins first and add routes later, if you want to. The order of installed plugins is significant, though. If a plugin requires a database connection, you need to install the database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "You can use a name, class or instance to :func:`uninstall` a previously installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "Plugins can be installed and removed at any time, even at runtime while serving requests. This enables some neat tricks (installing slow debugging or profiling plugins only when needed) but should not be overused. Each time the list of plugins changes, the route cache is flushed and all plugins are re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "The module-level :func:`install` and :func:`uninstall` functions affect the :ref:`default-app`. To manage plugins for a specific application, use the corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "The ``apply`` parameter of the :func:`route` decorator comes in handy if you want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "You may want to explicitly disable a plugin for a number of routes. The :func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "The ``skip`` parameter accepts a single value or a list of values. You can use a name, class or instance to identify the plugin that is to be skipped. Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "Most plugins are specific to the application they were installed to. Consequently, they should not affect sub-applications mounted with :meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "Whenever you mount an application, Bottle creates a proxy-route on the main-application that forwards all requests to the sub-application. Plugins are disabled for this kind of proxy-route by default. As a result, our (fictional) `WTForms` plugin affects the ``/contact`` route, but does not affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "This behavior is intended as a sane default, but can be overridden. The following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "But there is a snag: The plugin sees the whole sub-application as a single route, namely the proxy-route mentioned above. In order to affect each individual route of the sub-application, you have to install the plugin to the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "So you have learned the basics and want to write your own application? Here are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "Bottle maintains a global stack of :class:`Bottle` instances and uses the top of the stack as a default for some of the module-level functions and decorators. The :func:`route` decorator, for example, is a shortcut for calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "This is very convenient for small applications and saves you some typing, but also means that, as soon as your module is imported, routes are installed to the global default application. To avoid this kind of import side-effects, Bottle offers a second, more explicit way to build applications::" msgstr "" #: ../../tutorial.rst:899 msgid "Separating the application object improves re-usability a lot, too. Other developers can safely import the ``app`` object from your module and use :meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "Starting with bottle-0.13 you can use :class:`Bottle` instances as context managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "In this mode, Bottle is much more verbose and provides helpful debugging information whenever an error occurs. It also disables some optimisations that might get in your way and adds some checks that warn you about possible misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "During development, you have to restart the server a lot to test your recent changes. The auto reloader can do this for you. Every time you edit a module file, the reloader restarts the server process and loads the newest version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "How it works: the main process will not start a server, but spawn a new child process using the same command line arguments used to start the main process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` and start as a normal non-reloading app server. As soon as any of the loaded modules changes, the child process is terminated and re-spawned by the main process. Changes in template files will not trigger a reload. Please use debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "The reloading depends on the ability to stop the child process. If you are running on Windows or any other operating system not supporting ``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), ``signal.SIGTERM`` is used to kill the child. Note that exit handlers and finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to ``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "Both plugins and applications are specified via import expressions. These consist of an import path (e.g. ``package.module``) and an expression to be evaluated in the namespace of that module, separated by a colon. See :func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1034 msgid "Bottle runs on the built-in `wsgiref WSGIServer `_ by default. This non-threading HTTP server is perfectly fine for development, but may become a performance bottleneck when server load increases." msgstr "" #: ../../tutorial.rst:1036 msgid "The easiest way to increase performance is to install a multi-threaded server library like paste_ or cherrypy_ and tell Bottle to use that instead of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "This, and many other deployment options are described in a separate article: :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "Programmer code that is to be called when some external action happens. In the context of web frameworks, the mapping between URL paths and application code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "A function returning another function, usually applied as a function transformation using the ``@decorator`` syntax. See `python documentation for function definition `_ for more about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "A structure where information about all documents under the root is saved, and used for cross-referencing. The environment is pickled after the parsing stage, so that successive runs only need to read and parse new and changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "A function to handle some specific event or situation. In a web framework, the application is developed by attaching a handler function as callback for each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "The directory which, including its subdirectories, contains all source files for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/_pot/tutorial_app.pot000066400000000000000000000724421470367422500231460ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "This tutorial is a work in progress and written by `noisefloor `_." msgstr "" #: ../../tutorial_app.rst:26 msgid "This tutorial should give a brief introduction to the Bottle_ WSGI Framework. The main goal is to be able, after reading through this tutorial, to create a project using Bottle. Within this document, not all abilities will be shown, but at least the main and important ones like routing, utilizing the Bottle template abilities to format output and handling GET / POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "To understand the content here, it is not necessary to have a basic knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. You should have a fair understanding of the Python_ programming language. Furthermore, the example used in the tutorial retrieves and stores data in a SQL database, so a basic idea about SQL helps, but is not a must to understand the concepts of Bottle. Right here, SQLite_ is used. The output of Bottle sent to the browser is formatted in some examples by the help of HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "For the sake of introducing Bottle, the Python code \"in between\" is kept short, in order to keep the focus. Also all code within the tutorial is working fine, but you may not necessarily use it \"in the wild\", e.g. on a public web server. In order to do so, you may add e.g. more error handling, protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "At the end of this tutorial, we will have a simple, web-based ToDo list. The list contains a text (with max 100 characters) and a status (0 for closed, 1 for open) for each item. Through the web-based user interface, open items can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "During development, all pages will be available on ``localhost`` only, but later on it will be shown how to adapt the application for a \"real\" server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "Bottle will do the routing and format the output, with the help of templates. The items of the list will be stored inside a SQLite database. Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "We will end up with an application with the following pages and functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "Assuming that you have a fairly new installation of Python (version 2.5 or higher), you only need to install Bottle in addition to that. Bottle has no other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "You can either manually install Bottle or use Python's easy_install: ``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "As we use SQLite3 as a database, make sure it is installed. On Linux systems, most distributions have SQLite3 installed by default. SQLite is available for Windows and MacOS X as well and the `sqlite3` module is part of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "First, we need to create the database we use later on. To do so, save the following script in your project directory and run it with python. You can use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "This generates a database-file `todo.db` with tables called ``todo`` and three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for each row, which is used later on to reference the rows. The column ``task`` holds the text which describes the task, it can be max 100 characters long. Finally, the column ``status`` is used to mark a task as open (value 1) or closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "Now it is time to introduce Bottle in order to create a web-based application. But first, we need to look into a basic concept of Bottle: routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "Basically, each page visible in the browser is dynamically generated when the page address is called. Thus, there is no static content. That is exactly what is called a \"route\" within Bottle: a certain address on the server. So, for example, when the page ``http://localhost:8080/todo`` is called from the browser, Bottle \"grabs\" the call and checks if there is any (Python) function defined for the route \"todo\". If so, Bottle will execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "So, after understanding the concept of routes, let's create the first one. The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "Save the code a ``todo.py``, preferably in the same directory as the file ``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the ``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "Let's have a look what we just did: We imported the necessary module ``sqlite3`` to access to SQLite database and from Bottle we imported ``route`` and ``run``. The ``run()`` statement simply starts the web server included in Bottle. By default, the web server serves the pages on localhost and port 8080. Furthermore, we imported ``route``, which is the function responsible for Bottle's routing. As you can see, we defined one function, ``todo_list()``, with a few lines of code reading from the database. The important point is the `decorator statement`_ ``@route('/todo')`` right before the ``def todo_list()`` statement. By doing this, we bind this function to the route ``/todo``, so every time the browsers calls ``http://localhost:8080/todo``, Bottle returns the result of the function ``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "Actually you can bind more than one route to a function. So the following code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "will work fine, too. What will not work is to bind one route to more than one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "What you will see in the browser is what is returned, thus the value given by the ``return`` statement. In this example, we need to convert ``result`` in to a string by ``str()``, as Bottle expects a string or a list of strings from the return statement. But here, the result of the database query is a list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "Now, after understanding the little script above, it is time to execute it and watch the result yourself. Remember that on Linux- / Unix-based systems the file ``todo.py`` needs to be executable first. Then, just run ``python todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. In case you made no mistake writing the script, the output should look like this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "If so - congratulations! You are now a successful user of Bottle. In case it did not work and you need to make some changes to the script, remember to stop Bottle serving the page, otherwise the revised version will not be loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "Actually, the output is not really exciting nor nice to read. It is the raw result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "So, in the next step we format the output in a nicer way. But before we do that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "Maybe you already noticed that Bottle sends a short error message to the browser in case something within the script is wrong, e.g. the connection to the database is not working. For debugging purposes it is quite helpful to get more details. This can be easily achieved by adding the following statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "By enabling \"debug\", you will get a full stacktrace of the Python interpreter, which usually contains useful information for finding bugs. Furthermore, templates (see below) are not cached, thus changes to templates will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "That ``debug(True)`` is supposed to be used for development only, it should *not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "Another quite nice feature is auto-reloading, which is enabled by modifying the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "This will automatically detect changes to the script and reload the new version once it is called again, without the need to stop and start the server." msgstr "" #: ../../tutorial_app.rst:160 msgid "Again, the feature is mainly supposed to be used while developing, not on production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "Now let's have a look at casting the output of the script into a proper format." msgstr "" #: ../../tutorial_app.rst:167 msgid "Actually Bottle expects to receive a string or a list of strings from a function and returns them by the help of the built-in server to the browser. Bottle does not bother about the content of the string itself, so it can be text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "Bottle brings its own easy-to-use template engine with it. Templates are stored as separate files having a ``.tpl`` extension. The template can be called then from within a function. Templates can contain any type of text (which will be most likely HTML-markup mixed with Python statements). Furthermore, templates can take arguments, e.g. the result set of a database query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "Right here, we are going to cast the result of our query showing the open ToDo items into a simple table with two columns: the first column will contain the ID of the item, the second column the text. The result set is, as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "So we do here two things: first, we import ``template`` from Bottle in order to be able to use templates. Second, we assign the output of the template ``make_table`` to the variable ``output``, which is then returned. In addition to calling the template, we assign ``result``, which we received from the database query, to the variable ``rows``, which is later on used within the template. If necessary, you can assign more than one variable / value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "Templates always return a list of strings, thus there is no need to convert anything. We can save one line of code by writing ``return template('make_table', rows=result)``, which gives exactly the same result as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "Let's have a look at the code: every line starting with % is interpreted as Python code. Because it is effectively Python, only valid Python statements are allowed. The template will raise exceptions, just as any other Python code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "As you can see, we use Python's ``for`` statement two times, in order to go through ``rows``. As seen above, ``rows`` is a variable which holds the result of the database query, so it is a list of tuples. The first ``for`` statement accesses the tuples within the list, the second one the items within the tuple, which are put each into a cell of the table. It is important that you close all ``for``, ``if``, ``while`` etc. statements with ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "If you need to access a variable within a non-Python code line inside the template, you need to put it into double curly braces. This tells the template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "Run the script again and look at the output. Still not really nice, but at least more readable than the list of tuples. You can spice-up the very simple HTML markup above, e.g. by using in-line styles to get a better looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "As we can review all open items properly, we move to the next step, which is adding new items to the ToDo list. The new item should be received from a regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "To do so, we first add a new route to our script and tell the route that it should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "To access GET (or POST) data, we need to import ``request`` from Bottle. To assign the actual data to a variable, we use the statement ``request.GET.task.strip()`` statement, where ``task`` is the name of the GET data we want to access. That's all. If your GET data has more than one variable, multiple ``request.GET.get()`` statements can be used and assigned to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "The rest of this piece of code is just processing of the gained data: writing to the database, retrieve the corresponding id from the database and generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "But where do we get the GET data from? Well, we can use a static HTML page holding the form. Or, what we do right now, is to use a template which is output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "By the way, if you prefer to use POST data: this works exactly the same way, just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "By using only the routes we know so far it is possible, but may be quite tricky. But Bottle knows something called \"dynamic routes\", which makes this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "This tells Bottle to accept for ```` any string up to the next slash. Furthermore, the value of ``something`` will be passed to the function assigned to that route, so the data can be processed within the function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "It is basically pretty much the same what we already did above when adding new items, like using ``GET`` data etc. The main addition here is using the dynamic route ````, which here passes the number to the corresponding function. As you can see, ``no`` is integer ID and used within the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "Again, this template is a mix of Python statements and HTML, as already explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "A last word on dynamic routes: you can even use a regular expression for a dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "Using dynamic routes is fine, but for many cases it makes sense to validate the dynamic part of the route. For example, we expect an integer number in our route for editing above. But if a float, characters or so are received, the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "For those cases, Bottle offers the ```` wildcard filter, which matches (signed) digits and converts the value to integer. In order to apply the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "Save the code and call the page again using incorrect value for ````, e.g. a float. You will receive not an exception, but a \"404 Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "Bottle can also handle dynamic routes, where the \"dynamic part\" of the route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "So, just to demonstrate that, let's assume that all single items in our ToDo list should be accessible by their plain number, by a term like e.g. \"item1\". For obvious reasons, you do not want to create a route for every item. Furthermore, the simple dynamic routes do not work either, as part of the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "The line ``@route(/item)`` starts like a normal route, but the third part of the wildcard is interpreted as a regular expression, which is the dynamic part of the route. So in this case, we want to match any digit between 0 and 9. The following function \"show_item\" just checks whether the given item is present in the database or not. In case it is present, the corresponding text of the task is returned. As you can see, only the regular expression part of the route is passed forward. Furthermore, it is always forwarded as a string, even if it is a plain integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "Sometimes it may become necessary to associate a route not to a Python function, but just return a static file. So if you have for example a help page for your application, you may want to return this page as plain HTML. This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "At first, we need to import the ``static_file`` function from Bottle. As you can see, the ``return static_file`` statement replaces the ``return`` statement. It takes at least two arguments: the name of the file to be returned and the path to the file. Even if the file is in the same directory as your application, the path needs to be stated. But in this case, you can use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file automatically, but in case you like to state it explicitly, add a third argument to ``static_file``, which would be here ``mimetype='text/html'``. ``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "There may be cases where you do not want your application to generate the output directly, but return data to be processed further on, e.g. by JavaScript. For those cases, Bottle offers the possibility to return JSON objects, which is sort of standard for exchanging data between web applications. Furthermore, JSON can be processed by many programming languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "So, let's assume we want to return the data generated in the regular expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "As you can, that is fairly simple: just return a regular Python dictionary and Bottle will convert it automatically into a JSON object prior to sending. So if you e.g. call \"http://localhost/json1\" Bottle should in this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "The next step may is to catch the error with Bottle itself, to keep away any type of error message from the user of your application. To do that, Bottle has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "So, at first we need to import ``error`` from Bottle and define a route by ``error(403)``, which catches all \"403 forbidden\" errors. The function \"mistake\" is assigned to that. Please note that ``error()`` always passes the error-code to the function - even if you do not need it. Thus, the function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "Again, you can assign more than one error-route to a function, or catch various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "After going through all the sections above, you should have a brief understanding how the Bottle WSGI framework works. Furthermore you have all the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "The following chapter give a short introduction how to adapt Bottle for larger projects. Furthermore, we will show how to operate Bottle with web servers which perform better on a higher load / more web traffic than the one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "So far, we used the standard server used by Bottle, which is the `WSGI reference Server`_ shipped along with Python. Although this server is perfectly suitable for development purposes, it is not really suitable for larger applications. But before we have a look at the alternatives, let's have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known as ``localhost``, and on port ``8080``. To modify the setting is pretty simple, as additional parameters can be passed to Bottle's ``run()`` function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "To change the port, just add ``port=portnumber`` to the run command. So, for example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "The ``port`` and ``host`` parameter can also be applied when Bottle is running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "As said above, the standard server is perfectly suitable for development, personal use or a small group of people only using your application based on Bottle. For larger tasks, the standard server may become a bottleneck, as it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "But Bottle has already various adapters to multi-threaded servers on board, which perform better on higher load. Bottle supports Cherrypy_, Flup_ and Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "If you want to run for example Bottle with the Paste server, use the following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and ``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "Maybe you already have an Apache_ or you want to run a Bottle-based application large scale - then it is time to think about Apache with mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "We assume that your Apache server is up and running and mod_wsgi is working fine as well. On a lot of Linux distributions, mod_wsgi can be easily installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "Bottle brings an adapter for mod_wsgi with it, so serving your application is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "In the following example, we assume that you want to make your application \"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your code, templates and SQLite database are stored in the path ``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "When you run your application via mod_wsgi, it is imperative to remove the ``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "After that, create a file called ``adapter.wsgi`` with the following content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "and save it in the same path, ``/var/www/todo``. Actually the name of the file can be anything, as long as the extension is ``.wsgi``. The name is only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "Finally, we need to add a virtual host to the Apache configuration, which looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "After restarting the server, your ToDo list should be accessible at ``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "Now we are at the end of this introduction and tutorial to Bottle. We learned about the basic concepts of Bottle and wrote a first application using the Bottle framework. In addition to that, we saw how to adapt Bottle for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "As said in the introduction, this tutorial is not showing all shades and possibilities of Bottle. What we skipped here is e.g. receiving file objects and streams and how to handle authentication data. Furthermore, we did not show how templates can be called from within another template. For an introduction into those points, please refer to the full `Bottle documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "As the ToDo list example was developed piece by piece, here is the complete listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/000077500000000000000000000000001470367422500177055ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/000077500000000000000000000000001470367422500214725ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/api.po000066400000000000000000001416621470367422500226150ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # defnull , 2015 # defnull , 2015 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../api.rst:3 msgid "API Reference" msgstr "API Referenz" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "Diese API wurde größtenteils automatisch generiert. Wenn Bottle für dich neu ist, bietet :doc:`tutorial` einen guten Einstieg." #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/async.po000066400000000000000000000177751470367422500231700ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2017-08-03 11:49+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/changelog.po000066400000000000000000000572151470367422500237730ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/configuration.po000066400000000000000000000241421470367422500247040ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/contact.po000066400000000000000000000050011470367422500234610ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Charles LeMagne, 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "Über Bottle" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "Dies ist soweit mein erstes Open Source Projekt." #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/deployment.po000066400000000000000000000254211470367422500242160ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/development.po000066400000000000000000000631451470367422500243650ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Charles LeMagne, 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: Charles LeMagne\n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "Entwicklernotizen" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "Dieses Dokument ist für Entwickler und Paketbetreuer gedacht die Interesse an der Entwicklung und dem Veröffentlichungsworkflow von bottle haben.\nWenn du etwas beitragen möchtest, dann bist du genau richtig!" #: ../../development.rst:8 msgid "Get involved" msgstr "Beteiligen" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "Es gibt einige Wege der Community beizutreten und auf dem neuesten Stand zu bleiben. Hier sind ein paar davon:" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "**Mailing list**: Tritt unserer Mailingliste bei indem du eine e-Mail an `bottlepy+subscribe@googlegroups.com ` sendest. (Ein Google Account wird nicht benötigt)" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "**Twitter**: `Folge uns auf Twitter `_ oder suche nach dem `#bottlepy `_ tag." #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "**IRC**: Tritt `#bottlepy auf irc.freenode.net bei `_ oder nutze die `Webchat Oberfläche `_." #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "**Google plus**: Ab und an `blogen wir über Bottle, Veröffentlichungen und technischen Kram `_ auf unserer Google+ Seite." #: ../../development.rst:19 msgid "Get the Sources" msgstr "Die Quelldateien holen" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "Das bottle `Entwicklungs-repository `_ und der `Issue-tracker `_ sind beide auf `github `_ zu finden." #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "**git:** ``git clone git://github.com/bottlepy/bottle.git``" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "**Download:** Entwicklungs branch als `tar Archiv `_ oder `zip Datei `_." #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "**Übersetzungen:** `transifex.com/projects/p/bottle `_" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "Veröffentlichungen und Updates" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "Bottle wird in unregelmäßigen Abständen veröffentlicht und über `PyPI `_ verteilt. Veröffentlichungskandidaten und bugfix-Revisionen von veralteten Veröffentlichungen sind nur über das oben genannte Git-Repository verfügbar. Einige Linux-Distributionen bieten jedoch möglicherweise Paket aus veralteten Veröffentlichungen an." #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "Die Bottle Versionsnummer ist in drei Teile unterteilt (**major.minor.revision**). Diese werden *nicht* dazu genutzt um neue Funktionen zu bewerben, sondern um wichtige bug-fixes und/oder Änderungen an der API zu indizieren. Kritische Fehler werden in den letzten zwei stabilen Veröffentlichungen behoben und über alle Kanäle mitgeteilt (Mailinglisten, Twitter, Github). Nicht kritische Fehler oder Features werden garantiert zurückgestellt. Dies wird sich eventuell in der Zukunft ändern. " #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "Major Release (x.0)" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "Die major release Nummer vergrößert sich bei wichtigen Meilensteinen oder Aktualisierungen die die Abwärtskompatibilität vollständig unterbrechen. Du musst wahrscheinlich deine komplette Anwendung überarbeiten um mit einer neuen Veröffentlichung zu arbeiten. Diese Veröffentlichungen sind allerdings sehr selten." #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "Minor Release (x.y)" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "Die minor release Nummer vergrößert sich bei Aktualisierungen welche die API oder das Verhalten in irgendeiner Weise beeinflussen. Es kann zu deprecation Warnungen kommen und eventuell musst du einige Einstellungen anpassen um das alte Verhalten wiederherzustellen, in den meisten Fällen sind diese Änderungen jedoch so entwickelt dass mindestens zum letzten minor release abwärtskompatibel sind. Du solltest updaten, um up-to-date zu bleiben, musst allerdings nicht. Eine Ausnahme stellt 0.8 dar, welches hart mit der Abwärtskompatibilität brechen *wird*. (Dies ist der Grund warum 0.7 übersprungen wurde.) Das tut mir Leid." #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "Revision (x.y.z)" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "Die Revisionsnummer erhöht sich bei Fehlerbehebungen und anderen Patches welche das API-Verhalten nicht beeinflussen. Du kannst sicher updaten ohne den Code deiner Applikation bearbeiten zu müssen. In der Tat solltest du dies auch so schnell wie möglich tun, da auf diese Art wichtige Sicherheitsfixes veröffentlicht werden." #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "Pre-Release Versionen" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "Veröffentlichungskandidaten sind durch ein ``rc`` in ihrer Versionsnummer gekennzeichnet. Diese sind meistens API stabil und offen zur Prüfung, jedoch noch nicht offiziell veröffentlicht. Du solltest sie nicht in einer Produktivumgebung einsetzen." #: ../../development.rst:50 msgid "Repository Structure" msgstr "Repositorystruktur" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "Die Struktur des Quellrepositorys ist wie folgt:" #: ../../development.rst:55 msgid "``master`` branch" msgstr "``master`` Branch" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "Dies ist der Integrations-, Test und Entwicklungsbranch. Alle Änderungen die planmäßig Teil der nächsten Veröffentlichung werden, werden hier zusammengeführt und getestet." #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "``release-x.y`` Branches" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "Sobald ein Master Branch (fast) bereit zur Veröffentlichung ist wird er in einen neuen Veröffentlichungs Branch verzweigt. Dieser \"Veröffentlichungskandidat\" ist feature-frozen, erfährt allerdings möglicherweise noch Fehlerbehebungen und Änderungen in letzter Minute bevor er als Produktionsreif angesehen und offiziell veröffentlicht wird. Von diesem Punkt an wird er \"support branch\" genannt und erhält immer noch Fehlerbehebungen, allerdings nur wichtige. Die Revisionsnummer wird mit jedem push in diesem Branch erhöht, sodass du mit wichtigen Änderungen mithalten kannst." #: ../../development.rst:62 msgid "Feature branches" msgstr "Feature Branches" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "Alle anderen Branches sind Feature Branches. Diese basieren auf dem Master Branch und leben nur solange sie noch aktiv sind und nicht wieder mit ``master`` zusammengeführt wurden." #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "Was bedeutet dies für den Entwickler?" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "Wenn du ein Feature hinzufügen willst, erstelle einen neuen Branch aus ``master``. Wenn du einen Fehler beheben möchtest, branche `release-x.y`` für jede betroffene Veröffentlichung. Bitte nutze einen separaten Branch für jedes Feature und jeden Fehler um die Integration so einfach wie möglich zu halten. Das ist alles. Es gibt git-workflow am Ende dieser Seite." #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "Oh, und ändere niemals die Releasenummer. Wir machen dies während der Integration. Du weißt eh nie in welcher Reihenfolge wir die ausstehenden Anfragen einbeziehen :)" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "Was bedeutet dies für den Betreuer?" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "Behalte die Tags (und die Mailingliste) im Auge um Fehlerkorrekturen und neue Veröffentlichungen mitzubekommen. Wenn du eine bestimmte Version aus dem git-Repository holen willst vertraue den Tags, nicht den branches. Ein Branch enthält möglicherweise Änderungen die noch nicht veröffentlicht sind, Tags hingegen indizieren das exakte Commit welches die Versionsnummer geändert hat." #: ../../development.rst:77 msgid "Submitting Patches" msgstr "Patches Einreichen" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "Der beste Weg um deine Änderungen in den Hauptentwicklungsbranch zu integrieren ist, das Hauptrepository zu forken, einen neuen Feature Branch zu erstellen, deine Änderungen vorzunehmen und ein pull-request zu senden. Weiter unten auf dieser Seite befindet sich eine kleine Sammlung von git workflow Beispielislen die dir behilflich sein können. Git-kompatible patches über die Mailingliste einzurichen ist auch gut. In jedem Fall beachte bitte folgende Regeln:" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "**Dukomentation:** Sag uns was dein patch macht. Kommentiere deinen Code. Wenn du ein neues Feature vorstellst, füge es der Dokumentation hinzu, sodass Anderes etwas darüber lernen können." #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "**Test:** Schreibe Tests um nachzuweisen dass dein Code wie geplant funktioniert und nichts kaputt macht. Wenn du einen Fehler behoben hast, schreibe mindestens einen Testfall, welcher den Fehler auslöst. Stelle sicher dass alle Tests durchlaufen bevor du ein Patch einreichst." #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "**Ein Patch zur selben Zeit:** Behebe nur einen Fehler oder füge nur ein Feature zur selben Zeit hinzu. Entwickle deine Patches so, dass sie als Ganzes angewendet werden können. Halte deine Patches sauber, klein und fokussiert." #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "**Synchronisere mit upstream:** Wenn sich der ``upstream/master`` Branch geändert hat während du an deinem Patch gearbeitet hast, führe ein rebase oder pull durch um sicherzustellen dass dein Patch noch zu dem Konflikt passt." #: ../../development.rst:88 msgid "Building the Documentation" msgstr "Die Dokumentation erstellen" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "Du brauchst eine aktuelle Version von Sphinx um die Dokumentation zu erstellen. Der empfohlene Ablauf ist ` :command:`virtualenv` aus deinem Distributionspackage Repository und Sphinx manuell zu installieren um eine aktuelle Version zu erhalten." #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "GIT Workflow Beispiele" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "Die folgenden Beispiele nehmen an dass du einen (kostnelosen) `Github Account `_ besitzt. Dies ist nicht notwendig, erleichtert die Dinge jedoch sehr." #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "Als Erstes musst du eine Fork (ein persönlicher Klon) des offiziellen Repositorys erstellen. Um dies zu tun klicke einfach auf den \"fork\" Button auf der `bottle Projektseite `_. Wenn das Forken erledigt ist, wirst du eine kurze Einführung in dein neues Repository präsentiert bekommen. " #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "Die Fork die du erstellt hast ist auf github gehostet und lesbar für jeden, schreibbar jedoch nur für dich. Jetzt musst du die Fork lokal klonen um tatsächlich Änderungen daran vorzunehmen. Stelle sicher dass du die private (lesen-schreiben) URL und *nicht* die öffentliche (nur lesen) nutzt::" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "Sobald dein Klon vollständig ist wird dein Repository eine remote namens \"origin\" haben die auf deine Fork auf github zeigt. Lass dich nicht von den Namen irritieren, sie zeigt nicht auf das originale bottle Repository, sondern auf deine eigene Fork. Um mit Änderungen an dem offiziellen repository auf dem Laufenden zu bleiben füge eine weitere remote namens \"upstream\" hinzu::" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "Bedenke dass \"upstream\" eine öffentliche Klon-URL ist und nur lesbar. Du kannst keine Änderungen direkt dorthin pushen. Stattdessen werden wir von deinem öffentlichen Repository pullen. Dies wird später beschrieben." #: ../../development.rst:140 msgid "Submit a Feature" msgstr "Ein Feature einreichen" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "Neue Features werden in separaten Feature-Branches entwickelt um deren Integration zu vereinfachen. Da sie in den ``master`` Branch integriert werden müssen sie auf ``upstream/master`` basieren. Um einen neuen Feature-Branch zu erstellen, gib das Folgende ein:" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "Jetzt implementiere dein Feature, schreibe Tests, aktualisiere die Dokumentation, stelle sicher dass alle Tests durchlaufen und committe deine Änderungen." #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "Wenn sich ``upstream/master`` zwischenzeitlich geändert hat können Konflikte mit deinen Änderungen entstehen. Um diese zu lösen 'rebase' deinen Feature-Branch auf den aktualisieren ``upstream/master`` Branch::" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "Dies ist gleichbedeutend mit der Rückgängigmachung all deiner Änderungen, deinen Branch upzudaten und deine Patches erneut anzuwenden. Wenn du deinen Branch bereits veröffentlicht hast (siehe nächster Schritt) ist dies keine Option, da es deinen Verlauf neu schreibt. Du kannst stattdessen einen normalen Pull machen. Löse alle Konflikte, führe die Tests durch und committe erneut." #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "Jetzt bist du beinahe bereit ein pull-request zu senden. Aber als ersten muss du deinen Feature-Branch öffentlich machen indem du ihn in deine Github-Fork pushst. " #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "Nachdem du deinen commit gepusht hast musst du uns über das neue Feature informieren. Eine Möglichkeit ist, ein pull-request über Github zu senden. Eine Andere wäre, einen neuen Thread in der Mailingliste zu starten, was empfohlen wird. Es erlaubt anderen Entwicklern deine Patches zu sehen und zu diskutieren und du bekommst gratis Feedback :)" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "Wenn wir dein Patch akzeptieren werden wir es in den offiziellen Entwickungs Branch integrieren und es wird Teil der nächsten Veröffentlichung." #: ../../development.rst:165 msgid "Fix a Bug" msgstr "Einen Fehler beheben" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "Der Workflow für Fehlerbehebungen ist dem für Features sehr ähnlich, jedoch gibt es ein paar Unterschiede:" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "Branche von dem betroffenen Release-Branch anstelle des Entwicklungs-Branches." #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "Schreibe mindestens einen Testfall der den Fehler auslöst." #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "Tue dies für jeden betroffenen Branch, eingeschlossen ``upstream/master`` sofern dieser betroffen ist. ``git cherry-pick`` kann dir eventuell helfen sich wiederholende Arbeitsschritte zu minimieren." #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "Benenne deinen Branch nach der Veröffentlichung auf der er basiert um Verwechslungen zu vermeiden. \nBeispiele: ``my_bugfix-x.y`` oder ``my_bugfix-dev``." python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/faq.po000066400000000000000000000107641470367422500226110ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Charles LeMagne, 2017 # Charles LeMagne, 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "Häufig gestellte Fragen" #: ../../faq.rst:13 msgid "About Bottle" msgstr "Über Bottle" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "Ist Bottle für komplexe Anwendungen geeignet?" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "Bottle ist ein *micro*-Framework, entworfen für Prototyping und kleine Webanwendungen und -services.\nEs hält sich im Hintergrund und erlaubt es dir die Dinge schnell erledigt zu bekommen, ihm fehlen allerdings einige fortgeschnittenere Eigenschaften und ready-to-use Lösungen wie sie in anderen Frameworks zu finden sind (MVC, ORM, Formularvalidierung, Scaffolding, CML-RPC). Auch *wenn* es möglich ist diese hinzuzufügen und komplexere Anwendungen mit Bottle zu entwickeln, solltest du in Betracht ziehen ein vollwertiges Web-Framework wie pylons oder paste zu benutzen." #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "Häufige Probleme und Fallstricke" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "\"Template nicht gefunden\" in mod_wsgi/mod_python" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "Bottle sucht in ``./`` und ``./views/`` nach Templates. In einer mod_python_ oder mod_wsgi_ Umgebung hängt das Arbeitsverzeichnis (``./``) von deinen Apache Einstellungen ab. Du solltest dem Templatepfad einen absoluten Pfad hinzufügen" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "damit Bottle den richtigen Pfad nutzt." #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "Dynamische Routen und Schrägstriche" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "Probleme mit Reverse-Proxies" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "Umleitungen und URL-building funktioniert nur wenn Bottle die öffentliche Adresse und den Ort deiner Anwendung kennt. Nutzt du Bottle lokal hinter einem Reverse-Proxie oder einem Load-Balancer können auf dem Weg Informationen verloren gehen.\nZum Beispiel könnte der ``wsgi.url_scheme``-Wert oder der ``Host``-Header die lokale Anfrage deines Proxys widerspiegeln und nicht die echte Anfrage des Clients.\nHier ist eine kleines WSGI-Middleware Snipptes welches dir hilft diese Werte zu korrigieren:" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/index.po000066400000000000000000000071021470367422500231410ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "" #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "" #: ../../index.rst:45 msgid "Download and Install" msgstr "" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "" #: ../../index.rst:103 msgid "License" msgstr "" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:115 msgid "Footnotes" msgstr "" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/plugindev.po000066400000000000000000000313741470367422500240370ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500231535ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/plugins/index.po000066400000000000000000000144111470367422500246230ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/recipes.po000066400000000000000000000222421470367422500234660ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/routing.po000066400000000000000000000137571470367422500235360ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/stpl.po000066400000000000000000000213501470367422500230150ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/tutorial.po000066400000000000000000001455321470367422500237070ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Charles LeMagne, 2017 # Charles LeMagne, 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "Tutorial" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "Dieses Tutorial führt dich in die Konzepte und Eigenschaften des Bottle Web-Frameworks ein und deckt grundlegende und fortgeschnittene Themenbereiche ab. Du kannst es dir von Anfang bis Ende durchlesen oder später als Referenz nutzen. Die automatisch generierte :doc:`api` könnte dich ebenfalls interessieren. Sie deckt mehr Details ab, erklärt im Gegensatz zu diesem Tutorial aber weniger. Lösungen für die meistgestellten Fragen sind in der :doc:`recipes` Sammlung oder der :doc:`faq` Seite zu finden. Wenn du Hilfe brauchst, tritt unserem Mailverteiler `_ bei oder besuche unsere IRC-Kanal `_." #: ../../tutorial.rst:31 msgid "Installation" msgstr "Installation" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "Bottle hängt von keinerlei externen Bibliotheken ab. Du kannst einfach `bottle.py `_ in dein Projektverzeichnis herunterladen und anfangen zu coden." #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "So bekommst du den aktuellsten Entwicklungsschnappschuss, welcher alle neuen Features enthält . Wenn du eine stabilere Umgebung bevorzugst solltest du bei den stabilen Veröffentlichungen bleiben. Diese sind auf `PyPI `_ verfügbar und können einfach via :command:`pip` (empfohlen), :command:`easy_install` oder deinem Paketmanager installiert werden." #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "Oder wenn virtualenv nicht auf deinem System installiert ist:" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "Schnellstart: \"Hallo Welt\"" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "Dieses Tutorial setzt voraus dass du entweder :ref:`installiert ` oder in dein Projektverzeichnis kopiert hast.\nLass uns mit einem sehr grundlegenden \"Hallo Welt\" Beispiel starten::" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "Das ist es. Starte dieses Skript, besuche visit http://localhost:8080/hello und du wirst \"Hello World!\" in deinem Browser sehen. Und so funktioniert es:" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "Der :func:`route` Dekorator bindet ein stück Code anneinen URL-Pfad.\nIn diesem Fall verlinken wir den ``/hello``-Pfad mit der ``hello()``-Funktion.\nDies wird `route` genannt (daher auch der Dekoratorname) und ist das wichtigste Konzept dieses Frameworks.\nDu kannst so viele Routen definieren wie du willst.\nWann immer ein Browser eine URL anfragt wird die damit verbundene Funktion aufgerufen und die Rückgabe an den Browser gesendet. So einfach ist das." #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "Der :func:`run` Aufruf in der letzten Zeile startet einen eingebauten Entwicklungsserver. Er läuft auf ``localhost``, Port ``8080`` und bedient Anfragen, bist du :kbd:`Control-c` drückst. Du kannst das Server-Backend später ändern, doch im Augenblick ist dieser Entwicklungsserver alles was wir brauchen. Er benötigt kein Setup und ist ein sehr schmerzfreier Weg um deine Anwendung zum lokalen Testen ans Laufen zu bringen." #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/de_DE/LC_MESSAGES/tutorial_app.po000066400000000000000000000745221470367422500245470ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: German (Germany) (http://www.transifex.com/bottle/bottle/language/de_DE/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: de_DE\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/000077500000000000000000000000001470367422500173545ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/000077500000000000000000000000001470367422500211415ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/api.po000066400000000000000000001413221470367422500222550ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/async.po000066400000000000000000000177551470367422500226350ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2015-01-22 19:17+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/changelog.po000066400000000000000000000571741470367422500234460ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/configuration.po000066400000000000000000000241211470367422500243500ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/contact.po000066400000000000000000000072761470367422500231500ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Ibrahim DERRAZ , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../contact.rst:3 msgid "Contact" msgstr "Contact" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "Bonjour, je suis *Marcel Hellkamp* (alias *defnull*), développeur de Bottle, et la personne derrière ce site. J'ans 27 ans et j’étudie l’informatique à l’université Georg-August-University à Göttingen en Allemagne. Python est mon langage préféré, mais je code aussi en Ruby et JavaScript. Suivez moi sur `twitter `_ ou visitez mon profil sur `GitHub `_ . Une `mailinglist `_ est disponible pour toutes les questions liés à Bottle" #: ../../contact.rst:10 msgid "About Bottle" msgstr "À propos de Bottle" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "Il s'agit de mon premier projet open-source. Il s’agissait d'un projet d'expérimentation, mais grâce à tout vos retours positifs, j'ai décidé d'en faire un projet sérieux. Et le voilà." #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "Impressum und Kontaktdaten" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "(Requis par la `loi Allemande `_)" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist ausdrücklich untersagt." #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "**Betreiber**: Marcel Hellkamp" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "**Ort**: D - 37075 Göttingen" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "**Strasse**: Theodor-Heuss Strasse 13" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "**Telefon**: +49 (0) 551 20005915" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "**E-Mail**: marc at gsites dot de" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/deployment.po000066400000000000000000000254701470367422500236710ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Ibrahim DERRAZ , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "Déploiement " #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/development.po000066400000000000000000000342051470367422500240270ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:50 msgid "Repository Structure" msgstr "" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/faq.po000066400000000000000000000056261470367422500222610ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "À propos de Bottle" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/index.po000066400000000000000000000076451470367422500226240ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Ibrahim DERRAZ , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "" #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "Exemple: \"Hello World\" dans une bottle" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "Executez ce script ou coller le dans une console Python, puis rendez vous sur ``_ dans votre navigateur. Et voilà." #: ../../index.rst:45 msgid "Download and Install" msgstr "Téléchargement et installation" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "Guide de l'utilisateur" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "" #: ../../index.rst:103 msgid "License" msgstr "Licence" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "Le code et la documentation sont disponibles conformément à la licence MIT:" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:115 msgid "Footnotes" msgstr "" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/plugindev.po000066400000000000000000000313531470367422500235030ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500226225ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/plugins/index.po000066400000000000000000000143701470367422500242760ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/recipes.po000066400000000000000000000222211470367422500231320ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/routing.po000066400000000000000000000137361470367422500232020ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/stpl.po000066400000000000000000000213271470367422500224700ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/tutorial.po000066400000000000000000001404111470367422500233450ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "" #: ../../tutorial.rst:31 msgid "Installation" msgstr "" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "Déploiement " #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/fr/LC_MESSAGES/tutorial_app.po000066400000000000000000000745011470367422500242130ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: French (http://www.transifex.com/bottle/bottle/language/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/000077500000000000000000000000001470367422500177305ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/000077500000000000000000000000001470367422500215155ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/api.po000066400000000000000000001413341470367422500226340ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/async.po000066400000000000000000000177671470367422500232140ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2015-01-22 19:17+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/changelog.po000066400000000000000000000572061470367422500240160ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/configuration.po000066400000000000000000000241331470367422500247270ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/contact.po000066400000000000000000000046461470367422500235220ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/deployment.po000066400000000000000000000254121470367422500242410ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/development.po000066400000000000000000000342171470367422500244060ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:50 msgid "Repository Structure" msgstr "" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/faq.po000066400000000000000000000056151470367422500226330ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/index.po000066400000000000000000000130221470367422500231620ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Manabu Shimohira , 2017 # taisa007 , 2016 # taisa007 , 2016 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "Bottle: Python Webフレームワーク" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "BottleはPython製の早くてシンプルでライトウェイトなWSGIマイクロWebフレームワークです。Bottleは1つのファイルで構成されていて、Pythonの標準ライブラリには依存していません。" #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "**ルーティング:** リクエストをファンクションとマッピングします。また、ダイナミックURLもサポートしています。" #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "**テンプレート:** Pythonのビルドインテンプレートやmako、jinja2、cheetahテンプレートをサポートしています。" #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "ファイルアップロートやクッキー、ヘッダー、その他HTTPに関連するデータに簡単にアクセスすることが可能です。" #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "例: Bottleによる \"Hello World\"" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "このスクリプトを実行するかPythonコンソールに貼り付けて実行し、ブラウザに次のURLを入力してください。``" #: ../../index.rst:45 msgid "Download and Install" msgstr "ダウンロードとインストール" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "ユーザーズガイド" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "Bottleの使い方はここから調べることができます。ここで分からないことについてはメーリングリスト``_で質問してください。" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "ナレッジベース" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "Bottleに関する記事や使い方のノウハウ集です。" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "コントリビューション" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "このチャプターはBottleの開発やリリースワークフローに興味のある人向けのコンテンツです。" #: ../../index.rst:103 msgid "License" msgstr "ライセンス" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "コードとドキュメントはMITライセンスに応じてご利用いただけます" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "Bottleロゴの利用はライセンスによって制限されていない為、Bottleのホームページへのリンクなどにご利用いただけます。" #: ../../index.rst:115 msgid "Footnotes" msgstr "脚注" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "テンプレートやサーバーアダプタークラスの使用方法は、対応するテンプレートやサーバーモジュールが必要です。" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/plugindev.po000066400000000000000000000313651470367422500240620ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500231765ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/plugins/index.po000066400000000000000000000144021470367422500246460ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/recipes.po000066400000000000000000000222411470367422500235100ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "脚注" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/routing.po000066400000000000000000000137501470367422500235520ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/stpl.po000066400000000000000000000213411470367422500230400ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/tutorial.po000066400000000000000000001435601470367422500237310ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Manabu Shimohira , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "チュートリアル" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "このチュートリアルでは、Bottle Webフレームワークの概念と機能を、基礎から上級までカバーして紹介します。最初から最後まで読み通すのもいいでしょうし、リファレンスとしてあとで参照するのも良いでしょう。自動的に生成される :doc: 'api' も興味を引くことでしょう。そこには詳細について述べられていますが、このチュートリアルよりも説明は多くは述べられていません。一般的に共通した質問についての答えは :doc:`recipes` コレクションか :doc:`faq` ページで見つけることができます。なんらかの助けが必要な場合には `_ のメーリングリストに参加するか、`_のIRCチャネルを訪問してください。" #: ../../tutorial.rst:31 msgid "Installation" msgstr "インストール" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "Bottleはどの外部ライブラリーにも依存していません。 `bottle.py `_ をコンピューターにダウンロードすればコーディングを始めることができます。" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "これにより全ての新機能が含まれた最新の開発スナップショットを入手することが可能になります。より安定した環境を希望する場合には、安定リリースを選択してください。これらは :command:`pip` (推奨), :command:`easy_install` を実行することで`PyPI `_やその他のパッケージ管理ツールから入手することができます。" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/ja_JP/LC_MESSAGES/tutorial_app.po000066400000000000000000000745131470367422500245720ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Japanese (Japan) (http://www.transifex.com/bottle/bottle/language/ja_JP/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ja_JP\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/000077500000000000000000000000001470367422500177535ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/000077500000000000000000000000001470367422500215405ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/000077500000000000000000000000001470367422500225015ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/api.po000066400000000000000000001330111470367422500236110ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getlist:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getone:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returend. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "" "path prefix or `mount-point`. If it ends in a slash, that slash is " "mandatory." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:8 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:10 msgid "All other parameters are passed to the underlying :meth:`route` call." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route` , urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ``:name`` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "Decorator: Register an output handler for a HTTP error code" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turing an URL path rule into a regular expression usable by the Router." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json``, this property holds " "the parsed content of the request body. Only requests smaller than " ":attr:`MEMFILE_MAX` are processed to avoid memory exhaustion." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.GET:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest.bind:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest.environ:1 #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.7 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:20 msgid "" "If neither `expires` nor `max_age` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:24 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:28 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/async.po000066400000000000000000000173621470367422500241670ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/changelog.po000066400000000000000000000412371470367422500247770ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:13 msgid "Added :func:`patch` shortcut for `route(..., method='PATCH')`" msgstr "" #: ../../changelog.rst:17 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:19 msgid "" "New SimpleTemplate parser implementation * Support for multi-line code " "blocks (`<% ... %>`). * The keywords `include` and `rebase` are functions " "now and can accept variable template names." msgstr "" #: ../../changelog.rst:22 msgid "" "The new :meth:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:23 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:24 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:26 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:30 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:32 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:33 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:34 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:35 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:36 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:37 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:38 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:39 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:42 msgid "API Changes" msgstr "" #: ../../changelog.rst:43 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:46 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:47 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:50 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:52 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:54 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:55 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:56 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:58 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:60 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:61 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:62 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:64 msgid "Templates" msgstr "" #: ../../changelog.rst:66 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:67 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:69 msgid "Routing" msgstr "" #: ../../changelog.rst:71 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:72 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:74 msgid "Other changes" msgstr "" #: ../../changelog.rst:76 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:77 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:78 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:79 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:80 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:81 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:82 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:83 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:87 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:90 msgid "Whats new?" msgstr "" #: ../../changelog.rst:91 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:92 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:93 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:94 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:95 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:96 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:97 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:100 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:101 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:102 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:103 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:104 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:107 ../../changelog.rst:118 msgid "API changes" msgstr "" #: ../../changelog.rst:108 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:110 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:111 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:115 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:119 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:121 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:122 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:124 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:125 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:127 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:128 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:129 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:130 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:131 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:133 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:134 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:135 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:137 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:138 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:142 msgid "New features" msgstr "" #: ../../changelog.rst:143 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:145 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:146 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:147 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:148 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:149 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:150 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:151 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:152 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:158 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:52 msgid "rogererens" msgstr "" #: ../../../AUTHORS:53 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:54 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:55 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:56 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:57 msgid "Seth" msgstr "" #: ../../../AUTHORS:58 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:59 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:60 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:61 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:62 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:63 msgid "voltron" msgstr "" #: ../../../AUTHORS:64 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:65 msgid "zombat" msgstr "" #: ../../../AUTHORS:66 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/configuration.po000066400000000000000000000154451470367422500257210ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:84 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:88 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:109 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:113 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:122 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:128 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:132 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:136 msgid "help" msgstr "" #: ../../configuration.rst:135 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:139 msgid "filter" msgstr "" #: ../../configuration.rst:139 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:141 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:163 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, on_change listeners and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "If the config file contains sections, their names are used as namespaces for" " the values within. The two special sections ``DEFAULT`` and ``bottle`` " "refer to the root namespace (no prefix)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update(). " "Example: ``update('some.namespace', key='value')``" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "" "Set the meta field for a key to a new value. This triggers the on-change " "handler for existing keys." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/contact.po000066400000000000000000000042411470367422500244750ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Autor" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/deployment.po000066400000000000000000000252131470367422500252240ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP of " "the interface the server should listen to (e.g. ``run(host='192.168.0.1')``)" " or let the server listen to all interfaces at once (e.g. " "``run(host='0.0.0.0')``). The listening port can be changed in a similar " "way, but you need root or admin rights to choose a port below 1024. Port 80 " "is the standard for HTTP servers::" msgstr "" #: ../../deployment.rst:36 msgid "Server Options" msgstr "" #: ../../deployment.rst:38 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development and early production, but may become a performance " "bottleneck when server load increases. There are three ways to eliminate " "this bottleneck:" msgstr "" #: ../../deployment.rst:40 msgid "Use a different server that is either multi-threaded or asynchronous." msgstr "" #: ../../deployment.rst:41 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:42 msgid "Do both." msgstr "" #: ../../deployment.rst:44 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:46 msgid "" "**Asynchronous** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:48 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:51 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:53 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:57 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:60 msgid "Name" msgstr "" #: ../../deployment.rst:60 msgid "Homepage" msgstr "" #: ../../deployment.rst:60 msgid "Description" msgstr "" #: ../../deployment.rst:62 msgid "cgi" msgstr "" #: ../../deployment.rst:62 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:63 msgid "flup" msgstr "" #: ../../deployment.rst:63 msgid "flup_" msgstr "" #: ../../deployment.rst:63 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:64 msgid "gae" msgstr "" #: ../../deployment.rst:64 msgid "gae_" msgstr "" #: ../../deployment.rst:64 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:65 msgid "wsgiref" msgstr "" #: ../../deployment.rst:65 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:65 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:66 msgid "cherrypy" msgstr "" #: ../../deployment.rst:66 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:66 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:67 msgid "paste" msgstr "" #: ../../deployment.rst:67 msgid "paste_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "fapws3" msgstr "" #: ../../deployment.rst:74 msgid "fapws3_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous (network side only), written in C" msgstr "" #: ../../deployment.rst:75 msgid "tornado" msgstr "" #: ../../deployment.rst:75 msgid "tornado_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:76 msgid "twisted" msgstr "" #: ../../deployment.rst:76 msgid "twisted_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:77 msgid "meinheld" msgstr "" #: ../../deployment.rst:77 msgid "meinheld_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:78 msgid "bjoern" msgstr "" #: ../../deployment.rst:78 msgid "bjoern_" msgstr "" #: ../../deployment.rst:78 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:79 msgid "auto" msgstr "" #: ../../deployment.rst:79 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:82 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:84 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:93 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:95 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:97 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:99 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:109 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:128 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:132 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:142 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:153 msgid "" "Bottle also provides a ``gae`` server adapter for legacy App Engine " "applications using the Python 2.5 runtime environment. It works similar to " "the ``cgi`` adapter in that it does not start a new HTTP server, but " "prepares and optimizes your application for Google App Engine and makes sure" " it conforms to their API::" msgstr "" #: ../../deployment.rst:157 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:173 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:175 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:177 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:179 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:181 msgid "Pound example::" msgstr "" #: ../../deployment.rst:199 msgid "Apache example::" msgstr "" #: ../../deployment.rst:207 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:219 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:221 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/development.po000066400000000000000000000340661470367422500253740ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:29 msgid "Releases and Updates" msgstr "" #: ../../development.rst:31 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:33 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:36 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:36 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:39 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:39 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:42 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:42 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:46 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:45 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:49 msgid "Repository Structure" msgstr "" #: ../../development.rst:51 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:54 msgid "``master`` branch" msgstr "" #: ../../development.rst:54 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:57 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:57 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:60 msgid "``bugfix_name-x.y`` branches" msgstr "" #: ../../development.rst:60 msgid "" "These branches are only temporary and used to develop and share non-trivial " "bug-fixes for existing releases. They are merged into the corresponding " "release branch and deleted soon after that." msgstr "" #: ../../development.rst:64 msgid "Feature branches" msgstr "" #: ../../development.rst:63 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:67 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:68 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:70 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:74 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:75 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:79 msgid "Submitting Patches" msgstr "" #: ../../development.rst:81 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:83 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:84 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:85 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:86 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:90 msgid "Building the Documentation" msgstr "" #: ../../development.rst:92 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:123 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:125 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:127 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:129 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:133 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:139 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:142 msgid "Submit a Feature" msgstr "" #: ../../development.rst:143 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:147 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:151 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:156 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:158 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:162 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:164 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:167 msgid "Fix a Bug" msgstr "" #: ../../development.rst:168 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:170 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:171 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:172 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:173 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/faq.po000066400000000000000000000052051470367422500236120ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (``:name``) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/:filepath#.*#`` would match ``/images/icons/error.png`` but " "``/images/:filename`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/index.po000066400000000000000000000063741470367422500241620ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../index.rst:21 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:23 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:26 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "" #: ../../index.rst:27 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:28 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:29 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "fapws3_, bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:32 msgid "Example: \"Hello World\" in a bottle" msgstr "" #: ../../index.rst:43 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "" #: ../../index.rst:46 msgid "Download and Install" msgstr "" #: ../../index.rst:49 msgid "" "Install the latest stable release with ``pip install bottle``, " "``easy_install -U bottle`` or download `bottle.py`__ (unstable) into your " "project directory. There are no hard [1]_ dependencies other than the Python" " standard library. Bottle runs with **Python 2.5+ and 3.x**." msgstr "" #: ../../index.rst:52 msgid "User's Guide" msgstr "" #: ../../index.rst:53 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "" #: ../../index.rst:68 msgid "Knowledge Base" msgstr "" #: ../../index.rst:69 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:81 msgid "Development and Contribution" msgstr "" #: ../../index.rst:83 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "" #: ../../index.rst:100 msgid "License" msgstr "" #: ../../index.rst:102 msgid "Code and documentation are available according to the MIT License:" msgstr "" #: ../../index.rst:107 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:112 msgid "Footnotes" msgstr "" #: ../../index.rst:113 msgid "" "Usage of the template or server adapter classes of course requires the " "corresponding template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/plugindev.po000066400000000000000000000307731470367422500250500ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "Of course, this is just a simplification. Plugins can do a lot more than " "just decorating route callbacks, but it is a good starting point. Lets have " "a look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/:page``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtaully no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/plugins/000077500000000000000000000000001470367422500241625ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/plugins/index.po000066400000000000000000000101471470367422500256340ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:18 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:21 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:24 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:27 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:27 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:30 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:33 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:36 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:42 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:45 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:48 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:51 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:54 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:56 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/recipes.po000066400000000000000000000201371470367422500244760ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:46 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:48 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:56 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:58 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:62 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:64 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:66 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:77 msgid "Test script::" msgstr "" #: ../../recipes.rst:84 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:88 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:90 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:92 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:112 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:114 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:130 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:134 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:136 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:142 msgid "or add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:156 msgid "Footnotes" msgstr "" #: ../../recipes.rst:157 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:161 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:165 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:167 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:184 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:187 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:190 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:192 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:194 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:196 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:197 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:198 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:199 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:200 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:201 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:202 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:203 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:204 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:206 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:210 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:212 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:230 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:235 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:237 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:240 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:256 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/routing.po000066400000000000000000000125731470367422500245400ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:32 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:36 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:38 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:40 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:41 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:42 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:43 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:45 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:71 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:75 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:78 msgid "Old Syntax" msgstr "" #: ../../routing.rst:78 msgid "New Syntax" msgstr "" #: ../../routing.rst:80 msgid "``:name``" msgstr "" #: ../../routing.rst:80 msgid "````" msgstr "" #: ../../routing.rst:81 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:81 msgid "````" msgstr "" #: ../../routing.rst:82 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:82 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:83 msgid "``:##``" msgstr "" #: ../../routing.rst:83 msgid "``<:re>``" msgstr "" #: ../../routing.rst:86 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:91 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:93 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:95 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:101 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/stpl.po000066400000000000000000000176611470367422500240360ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself to escape a lot, consider using :ref:`custom tokens " "`." msgstr "" #: ../../stpl.rst:99 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:101 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:109 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:115 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:123 msgid "THis time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:127 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:130 msgid "Template Functions" msgstr "" #: ../../stpl.rst:132 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:136 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:141 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:149 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:154 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:166 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:174 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:179 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:183 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:186 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:200 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/tutorial.po000066400000000000000000001414461470367422500247160ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "" #: ../../tutorial.rst:31 msgid "Installation" msgstr "" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.5 or newer (including 3.x) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "Of course this is a very simple example, but it shows the basic concept of " "how applications are built with Bottle. Continue reading and you'll see what" " else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:152 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:154 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:156 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:157 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:158 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:159 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:161 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:175 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:179 msgid "" "The new rule syntax was introduced in **Bottle 0.10** to simplify some " "common use cases, but the old syntax still works and you can find a lot of " "code examples still using it. The differences are best described by example:" msgstr "" #: ../../tutorial.rst:182 msgid "Old Syntax" msgstr "" #: ../../tutorial.rst:182 msgid "New Syntax" msgstr "" #: ../../tutorial.rst:184 msgid "``:name``" msgstr "" #: ../../tutorial.rst:184 msgid "````" msgstr "" #: ../../tutorial.rst:185 msgid "``:name#regexp#``" msgstr "" #: ../../tutorial.rst:185 msgid "````" msgstr "" #: ../../tutorial.rst:186 msgid "``:#regexp#``" msgstr "" #: ../../tutorial.rst:186 msgid "``<:re:regexp>``" msgstr "" #: ../../tutorial.rst:187 msgid "``:##``" msgstr "" #: ../../tutorial.rst:187 msgid "``<:re>``" msgstr "" #: ../../tutorial.rst:190 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../tutorial.rst:194 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:198 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the four " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:200 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:223 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:226 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:227 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:229 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:231 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:236 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:238 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:245 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:251 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:259 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:261 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:268 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:270 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:280 msgid "Generating content" msgstr "" #: ../../tutorial.rst:282 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:284 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:287 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:287 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:290 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:290 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:293 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:293 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:296 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:296 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:299 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:299 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:302 msgid "File objects" msgstr "" #: ../../tutorial.rst:302 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:305 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:305 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:307 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:310 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:311 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:326 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:331 msgid "Static Files" msgstr "" #: ../../tutorial.rst:333 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:346 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:349 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:350 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:356 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:361 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:363 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:372 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:379 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:382 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPError` exception." msgstr "" #: ../../tutorial.rst:385 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:386 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:392 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:394 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:397 msgid "Status Code" msgstr "" #: ../../tutorial.rst:398 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:401 msgid "Response Header" msgstr "" #: ../../tutorial.rst:402 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:409 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:414 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:420 ../../tutorial.rst:549 msgid "Cookies" msgstr "" #: ../../tutorial.rst:422 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:432 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:434 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:435 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:436 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:437 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:438 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:439 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:441 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:443 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:444 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:445 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:446 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:451 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:452 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:472 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:474 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:487 msgid "Request Data" msgstr "" #: ../../tutorial.rst:489 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:498 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:503 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:505 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:507 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:522 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:527 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:531 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:538 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:545 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:551 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:553 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:563 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:566 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:568 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:580 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:582 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:595 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:597 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:607 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:609 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:632 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:635 msgid "Attribute" msgstr "" #: ../../tutorial.rst:635 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:635 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:635 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:637 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:637 ../../tutorial.rst:638 ../../tutorial.rst:639 #: ../../tutorial.rst:640 ../../tutorial.rst:640 ../../tutorial.rst:641 #: ../../tutorial.rst:642 ../../tutorial.rst:642 msgid "yes" msgstr "" #: ../../tutorial.rst:637 ../../tutorial.rst:637 ../../tutorial.rst:638 #: ../../tutorial.rst:638 ../../tutorial.rst:639 ../../tutorial.rst:639 #: ../../tutorial.rst:640 ../../tutorial.rst:641 ../../tutorial.rst:641 #: ../../tutorial.rst:642 msgid "no" msgstr "" #: ../../tutorial.rst:638 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:639 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:640 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:641 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:642 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:647 msgid "File uploads" msgstr "" #: ../../tutorial.rst:649 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:659 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:673 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:675 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:679 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:681 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:685 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:687 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:692 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:694 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:712 msgid "Templates" msgstr "" #: ../../tutorial.rst:714 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:721 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:723 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:732 msgid "Syntax" msgstr "" #: ../../tutorial.rst:735 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:737 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:748 msgid "Caching" msgstr "" #: ../../tutorial.rst:749 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:759 msgid "Plugins" msgstr "" #: ../../tutorial.rst:763 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:765 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:767 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:787 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:791 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:793 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:795 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:797 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:802 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:806 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:807 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:817 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:820 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:824 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:826 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:836 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:838 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:860 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:863 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:865 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:876 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:878 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:882 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:887 msgid "Development" msgstr "" #: ../../tutorial.rst:889 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you beeing more productive." msgstr "" #: ../../tutorial.rst:895 msgid "Default Application" msgstr "" #: ../../tutorial.rst:897 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:905 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:915 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:920 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:945 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:947 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:955 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:957 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:959 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:960 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:961 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:963 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:966 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:968 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:978 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:983 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:989 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:997 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:1001 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1021 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1023 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1044 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1046 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development and early production, but may become a performance bottleneck " "when server load increases." msgstr "" #: ../../tutorial.rst:1048 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1052 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1060 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1063 msgid "callback" msgstr "" #: ../../tutorial.rst:1065 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1069 msgid "decorator" msgstr "" #: ../../tutorial.rst:1071 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1072 msgid "environ" msgstr "" #: ../../tutorial.rst:1074 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1078 msgid "handler function" msgstr "" #: ../../tutorial.rst:1080 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1083 msgid "source directory" msgstr "" #: ../../tutorial.rst:1085 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/_pot/tutorial_app.po000066400000000000000000000757501470367422500255620ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial_app.rst:20 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:24 msgid "" "This tutorial is a work in progess and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:27 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:29 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL databse, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:31 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:0 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:36 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:38 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:40 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:42 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:44 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:46 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:47 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:48 msgid "page for editing items: ``http://localhost:8080/edit/:no``" msgstr "" #: ../../tutorial_app.rst:49 msgid "" "validating data assigned by dynamic routes with the @validate decorator" msgstr "" #: ../../tutorial_app.rst:50 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:53 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:57 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:58 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:60 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:64 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:65 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:68 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:69 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:80 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:83 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:85 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:89 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:90 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:94 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:95 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:114 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:121 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:125 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:129 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:133 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:137 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:138 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:146 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:150 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:154 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:160 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:162 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:166 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:173 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:175 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:185 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. Of course, we can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:189 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Please note that, of course, only valid Python statements are " "allowed, otherwise the template will raise an exception, just as any other " "Python code. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:211 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. Of course, you can spice-up the" " very simple HTML markup above, e.g. by using in-line styles to get a better" " looking output." msgstr "" #: ../../tutorial_app.rst:215 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:216 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:218 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:241 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.get('task','').strip()`` statement, where ``task`` is the name" " of the GET data we want to access. That's all. If your GET data has more " "than one variable, multiple ``request.GET.get()`` statements can be used and" " assigned to other variables." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:245 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:247 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:270 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:278 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:280 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:282 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:286 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:287 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:289 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:291 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:295 msgid "" "The key point here is the colon. This tells Bottle to accept for " "``:something`` any string up to the next slash. Furthermore, the value of " "``something`` will be passed to the function assigned to that route, so the " "data can be processed within the function." msgstr "" #: ../../tutorial_app.rst:297 msgid "" "For our ToDo list, we will create a route ``@route('/edit/:no)``, where " "``no`` is the id of the item to edit." msgstr "" #: ../../tutorial_app.rst:299 msgid "The code looks like this::" msgstr "" #: ../../tutorial_app.rst:327 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ``:no``, which here passes the number to the corresponding " "function. As you can see, ``no`` is used within the function to access the " "right row of data within the database." msgstr "" #: ../../tutorial_app.rst:329 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:344 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:346 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:350 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:351 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:353 msgid "" "For those cases, Bottle offers the ``@validate`` decorator, which validates " "the \"input\" prior to passing it to the function. In order to apply the " "validator, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:362 msgid "" "At first, we imported ``validate`` from the Bottle framework, than we apply " "the @validate-decorator. Right here, we validate if ``no`` is an integer. " "Basically, the validation works with all types of data like floats, lists " "etc." msgstr "" #: ../../tutorial_app.rst:364 msgid "" "Save the code and call the page again using a \"403 forbidden\" value for " "``:no``, e.g. a float. You will receive not an exception, but a \"403 - " "Forbidden\" error, saying that an integer was expected." msgstr "" #: ../../tutorial_app.rst:367 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:368 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:370 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:372 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:386 msgid "" "Of course, this example is somehow artificially constructed - it would be " "easier to use a plain dynamic route only combined with a validation. " "Nevertheless, we want to see how regular expression routes work: the line " "``@route(/item:item_#[0-9]+#)`` starts like a normal route, but the part " "surrounded by # is interpreted as a regular expression, which is the dynamic" " part of the route. So in this case, we want to match any digit between 0 " "and 9. The following function \"show_item\" just checks whether the given " "item is present in the database or not. In case it is present, the " "corresponding text of the task is returned. As you can see, only the regular" " expression part of the route is passed forward. Furthermore, it is always " "forwarded as a string, even if it is a plain integer number, like in this " "case." msgstr "" #: ../../tutorial_app.rst:390 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:391 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:399 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:403 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:404 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:406 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"Task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:426 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:427 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:429 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:437 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:439 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:446 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:458 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:459 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:461 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:464 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:466 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:470 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:471 msgid "" "As standard, Bottle serves the pages on the IP adress 127.0.0.1, also known " "as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:473 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:477 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:479 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:483 msgid "Of course, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:487 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:491 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:492 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:494 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Fapws3_, " "Flup_ and Paste_." msgstr "" #: ../../tutorial_app.rst:496 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:502 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:506 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:507 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:513 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:515 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:517 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:528 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:530 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:546 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:549 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:551 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:553 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:556 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:558 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:560 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/api.po000066400000000000000000001415371470367422500226640ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Igor P. Leroy , 2015 # john snow , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../api.rst:3 msgid "API Reference" msgstr "API Referências" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "Conteúdo dos Módulos" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/async.po000066400000000000000000000200001470367422500232050ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2015-01-22 19:17+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/changelog.po000066400000000000000000000572171470367422500240430ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/configuration.po000066400000000000000000000241441470367422500247540ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/contact.po000066400000000000000000000046751470367422500235470ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "Sobre o Bottle" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/deployment.po000066400000000000000000000254231470367422500242660ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/development.po000066400000000000000000000342301470367422500244240ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:50 msgid "Repository Structure" msgstr "" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/faq.po000066400000000000000000000057711470367422500226610ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Claudio Rogerio Carvalho Filho , 2017 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "Perguntas Frequentes" #: ../../faq.rst:13 msgid "About Bottle" msgstr "Sobre o Bottle" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/index.po000066400000000000000000000127421470367422500232150ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # alephmelo , 2015 # Igor P. Leroy , 2015 # Igor P. Leroy , 2015 # Thiago Avelino , 2015 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "Bottle: Python Web Framework" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "Bottle é um simples, rápido, e leve WSGI_ micro web-framework para Python_. Ele é distribuído como um único arquivo (módulo) e não tem dependências que além `Biblioteca padrão do Python `_." #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "**Rotas:** Solicitações de chamada de função de mapeamento com suporte para URLs limpas e dinâmicos." #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "**Templates:**Rápido e pythonico :ref:`mecanismo de templates interno ` e suporte para mako_, jinja2_ and cheetah_ templates." #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "**Utilitários:** Conveniente acesso a dados de formulários, upload de arquivos, cookies, cabeçalhos e outros metadados relacionados ao HTTP." #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "Exemplo: \"Olá Mundo\" em bottle" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "Execute este script ou cole em um console de Python, em seguida, acesse em seu navegador o ``_. Feito!" #: ../../index.rst:45 msgid "Download and Install" msgstr "Download e Instalar" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "Guia do usuário" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "Comece por aqui se você quer aprender como usar o bottle framework para desenvolvimento web. Se você tiver quaisquer perguntas não respondidas aqui, sinta-se livre para pedir ajuda a `lista de discussão `_." #: ../../index.rst:71 msgid "Knowledge Base" msgstr "Base de conhecimento" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "Uma coleção de artigos, guias e COMO FAZER." #: ../../index.rst:84 msgid "Development and Contribution" msgstr "Desenvolvimento e contribuição" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "Esses capítulos são destinados a desenvolvedores interessados no desenvolvimento do bottle e entender o fluxo de contribuição." #: ../../index.rst:103 msgid "License" msgstr "Licença" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "Código e documentação estão disponíveis sobre a licença MIT:" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "O logotipo do bottle no entanto *NÃO é* abrangido pela licença (MIT). É permitido usar o logotipo como um link para a home page do bottle ou em contexto direto com a biblioteca não modificado. Nos outros casos, por favor, pergunte primeiro." #: ../../index.rst:115 msgid "Footnotes" msgstr "Notas de rodapé" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "Uso das classes adaptadoras de templates ou de servidores requerem os módulos do template ou servidor correspondentes." python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/plugindev.po000066400000000000000000000313761470367422500241070ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500232215ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/plugins/index.po000066400000000000000000000210021470367422500246630ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Igor P. Leroy , 2015 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: Igor P. Leroy \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "Lista de Plugins disponíveis" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "Essa é uma lista de plugins terceiros que estendem funcionalidades de core do Bottle ou integra com outras bibliotecas com o framework Bottle." #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "Dê uma olhada nos :ref:`plugins` para perguntas gerais sobre plugins (instalação, utilização). Se você pretende desenvolver um novo plugin, a página de :doc:`/plugindev` pode ajudá-lo." #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "`Bottle-Beaker `_" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "Beaker para sessões e biblioteca de cache com Middleware WSGI" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "`Bottle-Cork `_" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "Cork fornece um simples conjunto de métodos para implementar Autenticação e Autorização em aplicações web baseadas em Bottle." #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "`Bottle-Extras `_" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "Meta pacotes para instalar a coleção de plugins do Bottle." #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "`Bottle-Flash `_" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "plugin flash para bottle" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "`Bottle-Hotqueue `_" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "Fila FIFO para Bottle escrita sobre Redis." #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "`Macaron `_" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "Macaron é um mapeamento objeto-relacional (ORM) para SQLite." #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "`Bottle-Memcache `_" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "Integração com Memcache para Bottle." #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "`Bottle-Mongo `_" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "Integração com MongoDB para Bottle" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "`Bottle-Redis `_" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "Integração com Redis para Bottle." #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "`Bottle-Renderer `_" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "Renderer plugin para bottle" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "`Bottle-Servefiles `_" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "App reutilizável que serve arquivos estáticos para aplicações bottle" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "`Bottle-Sqlalchemy `_" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "Integração com SQLAlchemy para Bottle." #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "`Bottle-Sqlite `_" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "Integração com bancos de dados SQLite3 para Bottle." #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "`Bottle-Web2pydal `_" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "Integração com Web2py Dal para Bottle." #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "`Bottle-Werkzeug `_" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "Integra a biblioteca `werkzeug` (request alternativo and objetos de response, middleware de debugging avançados e etc)." #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "Plugins listados aqui não são parte do Bottle ou do projeto Bottle, mas desenvolvidos e mantidos por terceiros." python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/recipes.po000066400000000000000000000222641470367422500235400ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "Notas de rodapé" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/routing.po000066400000000000000000000137611470367422500235770ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/stpl.po000066400000000000000000000213521470367422500230650ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/tutorial.po000066400000000000000000001437251470367422500237570ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # alephmelo , 2015 # Igor P. Leroy , 2015 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "Tutorial" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "Este tutorial apresenta os conceitos e funcionalidades do framework web Bottle e aborda tópicos básicos e avançados semelhantes. Você pode lê-lo do início ao fim, ou usá-lo como uma referência mais tarde. A :doc:`api` gerada automaticamente também pode ser interessante pra você. Abrange mais detalhes, mas explica menos que este tutorial. Soluções para as perguntas mais comuns podem ser encontradas em nossa coleção de :doc:`recipes` ou na página de :doc:`faq`. Se você precisar de alguma ajuda, se junte à nossa `lista de discussão `_ ou visite-nos em nosso `canal no IRC `_." #: ../../tutorial.rst:31 msgid "Installation" msgstr "Instalação" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "Bottle não depende de nenhuma biblioteca externa. Você pode apenas baixar `bottle.py `_ em seu diretório do projeto e começar a programar:" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "Isso vai te dar o último snapshot de desenvolvimento que inclui todos os novos recursos. Se você prefere um ambiente mais estável, você deve ficar com as versões estáveis. Estas informações estão disponíveis no `PyPI `_ e pode ser instalado via :command:`pip` (recomendado), :command:`easy_install` ou seu gerenciador de pacotes:" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "Ou, se virtualenv não estiver instalado no seu sistema:" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "Início rápido: \"Olá Mundo\"" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "Esse tutorial assume que você tem o Bottle :ref:`instalado ` ou copiado para o diretório do projeto. Vamos começar com um exemplo muito básico \"Olá Mundo\"::" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "É isso. Execute este script, visite http://localhost:8080/hello e você vai ver \"Olá mundo!\" no seu browser. Aqui vemos como funciona:" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "A Aplicação Padrão" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/pt_BR/LC_MESSAGES/tutorial_app.po000066400000000000000000000745241470367422500246170ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/bottle/bottle/language/pt_BR/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pt_BR\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/requirements.txt000066400000000000000000000000441470367422500222270ustar00rootroot00000000000000sphinx sphinx-intl transifex-client python-bottle-0.13.2/docs/_locale/ru_RU/000077500000000000000000000000001470367422500200015ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/000077500000000000000000000000001470367422500215665ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/api.po000066400000000000000000001415551470367422500227120ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/async.po000066400000000000000000000202071470367422500232440ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2017-08-03 11:49+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/changelog.po000066400000000000000000000574271470367422500240740ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/configuration.po000066400000000000000000000243541470367422500250050ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/contact.po000066400000000000000000000050671470367422500235710ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/deployment.po000066400000000000000000000256331470367422500243170ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:43 msgid "Do both." msgstr "" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:61 msgid "Name" msgstr "" #: ../../deployment.rst:61 msgid "Homepage" msgstr "" #: ../../deployment.rst:61 msgid "Description" msgstr "" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/development.po000066400000000000000000000344401470367422500244550ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:50 msgid "Repository Structure" msgstr "" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/faq.po000066400000000000000000000060361470367422500227020ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/index.po000066400000000000000000000073141470367422500232420ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "" #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "" #: ../../index.rst:45 msgid "Download and Install" msgstr "" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "" #: ../../index.rst:103 msgid "License" msgstr "" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:115 msgid "Footnotes" msgstr "" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/plugindev.po000066400000000000000000000316061470367422500241310ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500232475ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/plugins/index.po000066400000000000000000000146231470367422500247240ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/recipes.po000066400000000000000000000224541470367422500235670ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/routing.po000066400000000000000000000141711470367422500236210ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "" #: ../../routing.rst:82 msgid "New Syntax" msgstr "" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/stpl.po000066400000000000000000000215621470367422500231160ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/tutorial.po000066400000000000000000001450741470367422500240040ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Aleksandra Ikonnikova, 2019 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "Руководство" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "Данное руководство являет собой описание принципов и функций веб-фреймворка Bottle и рассматривает как общие, так и более углубленные темы. Руководство можно читать сразу целиком либо использовать как справочный материал по мере надобности. Интерес может также представить автоматически герерируемый :doc:`api`, в котором включено больше технических подробностей, но меньше объяснений, чем в данном руководстве. Решения на наиболее часто задаваемые вопросы можно найти в нашей подборке :doc:`recipes` либо на странице :doc:`faq`. Если вам требуется какая-либо помощь или поддержка, подписывайтесь на нашу рассылку `mailing list `_ либо заходите на наш канал `IRC channel `_." #: ../../tutorial.rst:31 msgid "Installation" msgstr "Установка" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "Bottle не зависит от внешних библиотек. `bottle.py `_ можно скачать в ваш каталог с проектом и начать писать код:" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "Или, если virtualenv не установлено на вашей системе:" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "Это - всего лишь пример основных принципов, по которым с помощью Bottle строятся приложения. Читайте дальше, чтобы узнать больше о возможностях Bottle." #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "Объектно-ориентированный подход описывается более подробно в разделе :ref:`default-app`. Помните, что выбор за вами." #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "Рассмотрим некоторые практические примеры::" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "Прочие исключения" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:732 msgid "Caching" msgstr "" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:871 msgid "Development" msgstr "" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "Глоссарий" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/ru_RU/LC_MESSAGES/tutorial_app.po000066400000000000000000000747341470367422500246500ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Russian (Russia) (http://www.transifex.com/bottle/bottle/language/ru_RU/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ru_RU\n" "Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/000077500000000000000000000000001470367422500177465ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/000077500000000000000000000000001470367422500215335ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/000077500000000000000000000000001470367422500224745ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/api.po000066400000000000000000001330111470367422500236040ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../api.rst:3 msgid "API Reference" msgstr "" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "" #: ../../api.rst:17 msgid "Module Contents" msgstr "" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getlist:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getone:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returend. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "" "path prefix or `mount-point`. If it ends in a slash, that slash is " "mandatory." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:8 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:10 msgid "All other parameters are passed to the underlying :meth:`route` call." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route` , urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ``:name`` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "Decorator: Register an output handler for a HTTP error code" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turing an URL path rule into a regular expression usable by the Router." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json``, this property holds " "the parsed content of the request body. Only requests smaller than " ":attr:`MEMFILE_MAX` are processed to avoid memory exhaustion." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.GET:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest.bind:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest.environ:1 #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr "" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.7 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:20 msgid "" "If neither `expires` nor `max_age` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:24 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:28 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/async.po000066400000000000000000000173621470367422500241620ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/changelog.po000066400000000000000000000412371470367422500247720ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:13 msgid "Added :func:`patch` shortcut for `route(..., method='PATCH')`" msgstr "" #: ../../changelog.rst:17 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:19 msgid "" "New SimpleTemplate parser implementation * Support for multi-line code " "blocks (`<% ... %>`). * The keywords `include` and `rebase` are functions " "now and can accept variable template names." msgstr "" #: ../../changelog.rst:22 msgid "" "The new :meth:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:23 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:24 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:26 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:30 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:32 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:33 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:34 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:35 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:36 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:37 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:38 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:39 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:42 msgid "API Changes" msgstr "" #: ../../changelog.rst:43 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:46 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:47 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:50 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:52 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:54 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:55 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:56 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:58 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:60 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:61 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:62 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:64 msgid "Templates" msgstr "" #: ../../changelog.rst:66 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:67 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:69 msgid "Routing" msgstr "" #: ../../changelog.rst:71 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:72 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:74 msgid "Other changes" msgstr "" #: ../../changelog.rst:76 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:77 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:78 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:79 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:80 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:81 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:82 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:83 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:87 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:90 msgid "Whats new?" msgstr "" #: ../../changelog.rst:91 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:92 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:93 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:94 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:95 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:96 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:97 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:100 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:101 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:102 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:103 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:104 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:107 ../../changelog.rst:118 msgid "API changes" msgstr "" #: ../../changelog.rst:108 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:110 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:111 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:115 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:119 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:121 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:122 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:124 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:125 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:127 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:128 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:129 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:130 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:131 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:133 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:134 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:135 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:137 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:138 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:142 msgid "New features" msgstr "" #: ../../changelog.rst:143 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:145 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:146 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:147 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:148 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:149 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:150 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:151 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:152 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:158 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:52 msgid "rogererens" msgstr "" #: ../../../AUTHORS:53 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:54 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:55 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:56 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:57 msgid "Seth" msgstr "" #: ../../../AUTHORS:58 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:59 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:60 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:61 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:62 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:63 msgid "voltron" msgstr "" #: ../../../AUTHORS:64 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:65 msgid "zombat" msgstr "" #: ../../../AUTHORS:66 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/configuration.po000066400000000000000000000154451470367422500257140ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr "" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "" #: ../../configuration.rst:84 msgid "Loading Configuration from a nested :class:`dict`" msgstr "" #: ../../configuration.rst:88 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "" #: ../../configuration.rst:109 msgid "Listening to configuration changes" msgstr "" #: ../../configuration.rst:113 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "" #: ../../configuration.rst:122 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "" #: ../../configuration.rst:128 msgid "Filters and other Meta Data" msgstr "" #: ../../configuration.rst:132 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr "" #: ../../configuration.rst:136 msgid "help" msgstr "" #: ../../configuration.rst:135 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "" #: ../../configuration.rst:139 msgid "filter" msgstr "" #: ../../configuration.rst:139 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "" #: ../../configuration.rst:141 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "" #: ../../configuration.rst:163 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, on_change listeners and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "If the config file contains sections, their names are used as namespaces for" " the values within. The two special sections ``DEFAULT`` and ``bottle`` " "refer to the root namespace (no prefix)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update(). " "Example: ``update('some.namespace', key='value')``" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "" "Set the meta field for a key to a new value. This triggers the on-change " "handler for existing keys." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/contact.po000066400000000000000000000042411470367422500244700ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Autor" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/deployment.po000066400000000000000000000252131470367422500252170ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP of " "the interface the server should listen to (e.g. ``run(host='192.168.0.1')``)" " or let the server listen to all interfaces at once (e.g. " "``run(host='0.0.0.0')``). The listening port can be changed in a similar " "way, but you need root or admin rights to choose a port below 1024. Port 80 " "is the standard for HTTP servers::" msgstr "" #: ../../deployment.rst:36 msgid "Server Options" msgstr "" #: ../../deployment.rst:38 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development and early production, but may become a performance " "bottleneck when server load increases. There are three ways to eliminate " "this bottleneck:" msgstr "" #: ../../deployment.rst:40 msgid "Use a different server that is either multi-threaded or asynchronous." msgstr "" #: ../../deployment.rst:41 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "" #: ../../deployment.rst:42 msgid "Do both." msgstr "" #: ../../deployment.rst:44 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:46 msgid "" "**Asynchronous** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:48 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "" #: ../../deployment.rst:51 msgid "Switching the Server Backend" msgstr "" #: ../../deployment.rst:53 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:57 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "" #: ../../deployment.rst:60 msgid "Name" msgstr "" #: ../../deployment.rst:60 msgid "Homepage" msgstr "" #: ../../deployment.rst:60 msgid "Description" msgstr "" #: ../../deployment.rst:62 msgid "cgi" msgstr "" #: ../../deployment.rst:62 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:63 msgid "flup" msgstr "" #: ../../deployment.rst:63 msgid "flup_" msgstr "" #: ../../deployment.rst:63 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:64 msgid "gae" msgstr "" #: ../../deployment.rst:64 msgid "gae_" msgstr "" #: ../../deployment.rst:64 msgid "Helper for Google App Engine deployments" msgstr "" #: ../../deployment.rst:65 msgid "wsgiref" msgstr "" #: ../../deployment.rst:65 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:65 msgid "Single-threaded default server" msgstr "" #: ../../deployment.rst:66 msgid "cherrypy" msgstr "" #: ../../deployment.rst:66 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:66 msgid "Multi-threaded and very stable" msgstr "" #: ../../deployment.rst:67 msgid "paste" msgstr "" #: ../../deployment.rst:67 msgid "paste_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded, stable, tried and tested" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded" msgstr "" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "fapws3" msgstr "" #: ../../deployment.rst:74 msgid "fapws3_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous (network side only), written in C" msgstr "" #: ../../deployment.rst:75 msgid "tornado" msgstr "" #: ../../deployment.rst:75 msgid "tornado_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, powers some parts of Facebook" msgstr "" #: ../../deployment.rst:76 msgid "twisted" msgstr "" #: ../../deployment.rst:76 msgid "twisted_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, well tested but... twisted" msgstr "" #: ../../deployment.rst:77 msgid "meinheld" msgstr "" #: ../../deployment.rst:77 msgid "meinheld_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, partly written in C" msgstr "" #: ../../deployment.rst:78 msgid "bjoern" msgstr "" #: ../../deployment.rst:78 msgid "bjoern_" msgstr "" #: ../../deployment.rst:78 msgid "Asynchronous, very fast and written in C" msgstr "" #: ../../deployment.rst:79 msgid "auto" msgstr "" #: ../../deployment.rst:79 msgid "Automatically selects an available server adapter" msgstr "" #: ../../deployment.rst:82 msgid "The full list is available through :data:`server_names`." msgstr "" #: ../../deployment.rst:84 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "" #: ../../deployment.rst:93 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:95 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "" #: ../../deployment.rst:97 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "" #: ../../deployment.rst:99 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr "" #: ../../deployment.rst:109 msgid "The Apache configuration may look like this::" msgstr "" #: ../../deployment.rst:128 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:132 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:142 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:153 msgid "" "Bottle also provides a ``gae`` server adapter for legacy App Engine " "applications using the Python 2.5 runtime environment. It works similar to " "the ``cgi`` adapter in that it does not start a new HTTP server, but " "prepares and optimizes your application for Google App Engine and makes sure" " it conforms to their API::" msgstr "" #: ../../deployment.rst:157 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:173 msgid "Load Balancer (Manual Setup)" msgstr "" #: ../../deployment.rst:175 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "" #: ../../deployment.rst:177 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "" #: ../../deployment.rst:179 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr "" #: ../../deployment.rst:181 msgid "Pound example::" msgstr "" #: ../../deployment.rst:199 msgid "Apache example::" msgstr "" #: ../../deployment.rst:207 msgid "Lighttpd example::" msgstr "" #: ../../deployment.rst:219 msgid "Good old CGI" msgstr "" #: ../../deployment.rst:221 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/development.po000066400000000000000000000340661470367422500253670ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "" #: ../../development.rst:8 msgid "Get involved" msgstr "" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "" #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "" #: ../../development.rst:19 msgid "Get the Sources" msgstr "" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "" #: ../../development.rst:29 msgid "Releases and Updates" msgstr "" #: ../../development.rst:31 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:33 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "" #: ../../development.rst:36 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:36 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "" #: ../../development.rst:39 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:39 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "" #: ../../development.rst:42 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:42 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "" #: ../../development.rst:46 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:45 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "" #: ../../development.rst:49 msgid "Repository Structure" msgstr "" #: ../../development.rst:51 msgid "The source repository is structured as follows:" msgstr "" #: ../../development.rst:54 msgid "``master`` branch" msgstr "" #: ../../development.rst:54 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "" #: ../../development.rst:57 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:57 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "" #: ../../development.rst:60 msgid "``bugfix_name-x.y`` branches" msgstr "" #: ../../development.rst:60 msgid "" "These branches are only temporary and used to develop and share non-trivial " "bug-fixes for existing releases. They are merged into the corresponding " "release branch and deleted soon after that." msgstr "" #: ../../development.rst:64 msgid "Feature branches" msgstr "" #: ../../development.rst:63 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "" #: ../../development.rst:67 msgid "What does this mean for a developer?" msgstr "" #: ../../development.rst:68 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "" #: ../../development.rst:70 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "" #: ../../development.rst:74 msgid "What does this mean for a maintainer ?" msgstr "" #: ../../development.rst:75 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "" #: ../../development.rst:79 msgid "Submitting Patches" msgstr "" #: ../../development.rst:81 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "" #: ../../development.rst:83 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "" #: ../../development.rst:84 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "" #: ../../development.rst:85 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "" #: ../../development.rst:86 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "" #: ../../development.rst:90 msgid "Building the Documentation" msgstr "" #: ../../development.rst:92 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "" #: ../../development.rst:123 msgid "GIT Workflow Examples" msgstr "" #: ../../development.rst:125 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "" #: ../../development.rst:127 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "" #: ../../development.rst:129 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "" #: ../../development.rst:133 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "" #: ../../development.rst:139 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "" #: ../../development.rst:142 msgid "Submit a Feature" msgstr "" #: ../../development.rst:143 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "" #: ../../development.rst:147 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "" #: ../../development.rst:151 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "" #: ../../development.rst:156 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "" #: ../../development.rst:158 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "" #: ../../development.rst:162 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "" #: ../../development.rst:164 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "" #: ../../development.rst:167 msgid "Fix a Bug" msgstr "" #: ../../development.rst:168 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "" #: ../../development.rst:170 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "" #: ../../development.rst:171 msgid "Write at least one test-case that triggers the bug." msgstr "" #: ../../development.rst:172 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "" #: ../../development.rst:173 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/faq.po000066400000000000000000000052051470367422500236050ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "" #: ../../faq.rst:13 msgid "About Bottle" msgstr "" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (``:name``) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/:filepath#.*#`` would match ``/images/icons/error.png`` but " "``/images/:filename`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/index.po000066400000000000000000000063741470367422500241550ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../index.rst:21 msgid "Bottle: Python Web Framework" msgstr "" #: ../../index.rst:23 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "" #: ../../index.rst:26 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "" #: ../../index.rst:27 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "" #: ../../index.rst:28 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "" #: ../../index.rst:29 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "fapws3_, bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:32 msgid "Example: \"Hello World\" in a bottle" msgstr "" #: ../../index.rst:43 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "" #: ../../index.rst:46 msgid "Download and Install" msgstr "" #: ../../index.rst:49 msgid "" "Install the latest stable release with ``pip install bottle``, " "``easy_install -U bottle`` or download `bottle.py`__ (unstable) into your " "project directory. There are no hard [1]_ dependencies other than the Python" " standard library. Bottle runs with **Python 2.5+ and 3.x**." msgstr "" #: ../../index.rst:52 msgid "User's Guide" msgstr "" #: ../../index.rst:53 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "" #: ../../index.rst:68 msgid "Knowledge Base" msgstr "" #: ../../index.rst:69 msgid "A collection of articles, guides and HOWTOs." msgstr "" #: ../../index.rst:81 msgid "Development and Contribution" msgstr "" #: ../../index.rst:83 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "" #: ../../index.rst:100 msgid "License" msgstr "" #: ../../index.rst:102 msgid "Code and documentation are available according to the MIT License:" msgstr "" #: ../../index.rst:107 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "" #: ../../index.rst:112 msgid "Footnotes" msgstr "" #: ../../index.rst:113 msgid "" "Usage of the template or server adapter classes of course requires the " "corresponding template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/plugindev.po000066400000000000000000000307731470367422500250430ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "" #: ../../plugindev.rst:20 msgid "" "Of course, this is just a simplification. Plugins can do a lot more than " "just decorating route callbacks, but it is a good starting point. Lets have " "a look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr "" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr "" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr "" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr "" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "" #: ../../plugindev.rst:108 msgid "Description" msgstr "" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/:page``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr "" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtaully no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/plugins/000077500000000000000000000000001470367422500241555ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/plugins/index.po000066400000000000000000000101471470367422500256270ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "" #: ../../plugins/index.rst:18 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:18 msgid "Meta package to install the bottle plugin collection." msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:21 msgid "flash plugin for bottle" msgstr "" #: ../../plugins/index.rst:24 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:24 msgid "FIFO Queue for Bottle built upon redis" msgstr "" #: ../../plugins/index.rst:27 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:27 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "" #: ../../plugins/index.rst:30 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Memcache integration for Bottle." msgstr "" #: ../../plugins/index.rst:33 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:33 msgid "MongoDB integration for Bottle" msgstr "" #: ../../plugins/index.rst:36 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:36 msgid "Redis integration for Bottle." msgstr "" #: ../../plugins/index.rst:39 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Renderer plugin for bottle" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:42 msgid "A reusable app that serves static files for bottle apps" msgstr "" #: ../../plugins/index.rst:45 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:45 msgid "SQLAlchemy integration for Bottle." msgstr "" #: ../../plugins/index.rst:48 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:48 msgid "SQLite3 database integration for Bottle." msgstr "" #: ../../plugins/index.rst:51 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:51 msgid "Web2py Dal integration for Bottle." msgstr "" #: ../../plugins/index.rst:54 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:54 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "" #: ../../plugins/index.rst:56 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/recipes.po000066400000000000000000000201371470367422500244710ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "" #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "" #: ../../recipes.rst:46 msgid "Debugging with Style: Debugging Middleware" msgstr "" #: ../../recipes.rst:48 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "" #: ../../recipes.rst:56 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "" #: ../../recipes.rst:58 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "" #: ../../recipes.rst:62 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:64 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "" #: ../../recipes.rst:66 msgid "A simple example using `Nose `_::" msgstr "" #: ../../recipes.rst:77 msgid "Test script::" msgstr "" #: ../../recipes.rst:84 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "" #: ../../recipes.rst:88 msgid "Functional Testing Bottle Applications" msgstr "" #: ../../recipes.rst:90 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "" #: ../../recipes.rst:92 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "" #: ../../recipes.rst:112 msgid "Embedding other WSGI Apps" msgstr "" #: ../../recipes.rst:114 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "" #: ../../recipes.rst:130 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "" #: ../../recipes.rst:134 msgid "Ignore trailing slashes" msgstr "" #: ../../recipes.rst:136 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "" #: ../../recipes.rst:142 msgid "or add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:156 msgid "Footnotes" msgstr "" #: ../../recipes.rst:157 msgid "Because they are. See " msgstr "" #: ../../recipes.rst:161 msgid "Keep-alive requests" msgstr "" #: ../../recipes.rst:165 msgid "For a more detailed explanation, see :doc:`async`." msgstr "" #: ../../recipes.rst:167 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "" #: ../../recipes.rst:184 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "" #: ../../recipes.rst:187 msgid "Gzip Compression in Bottle" msgstr "" #: ../../recipes.rst:190 msgid "For a detailed discussion, see compression_" msgstr "" #: ../../recipes.rst:192 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "" #: ../../recipes.rst:194 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "" #: ../../recipes.rst:196 msgid "Compress on the fly and be fast doing so." msgstr "" #: ../../recipes.rst:197 msgid "Do not compress for browsers that don't support it." msgstr "" #: ../../recipes.rst:198 msgid "Do not compress files that are compressed already (images, videos)." msgstr "" #: ../../recipes.rst:199 msgid "Do not compress dynamic files." msgstr "" #: ../../recipes.rst:200 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "" #: ../../recipes.rst:201 msgid "Cache compressed files that don't change often." msgstr "" #: ../../recipes.rst:202 msgid "De-validate the cache if one of the files changed anyway." msgstr "" #: ../../recipes.rst:203 msgid "Make sure the cache does not get to big." msgstr "" #: ../../recipes.rst:204 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "" #: ../../recipes.rst:206 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "" #: ../../recipes.rst:210 msgid "Using the hooks plugin" msgstr "" #: ../../recipes.rst:212 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "" #: ../../recipes.rst:230 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "" #: ../../recipes.rst:235 msgid "Using Bottle with Heroku" msgstr "" #: ../../recipes.rst:237 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "" #: ../../recipes.rst:240 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "" #: ../../recipes.rst:256 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/routing.po000066400000000000000000000125731470367422500245330ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr "" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "" #: ../../routing.rst:21 msgid "Path" msgstr "" #: ../../routing.rst:21 msgid "Result" msgstr "" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "" #: ../../routing.rst:32 msgid "Wildcard Filters" msgstr "" #: ../../routing.rst:36 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../routing.rst:38 msgid "The following standard filters are implemented:" msgstr "" #: ../../routing.rst:40 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "" #: ../../routing.rst:41 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../routing.rst:42 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "" #: ../../routing.rst:43 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "" #: ../../routing.rst:45 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "" #: ../../routing.rst:71 msgid "Legacy Syntax" msgstr "" #: ../../routing.rst:75 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "" #: ../../routing.rst:78 msgid "Old Syntax" msgstr "" #: ../../routing.rst:78 msgid "New Syntax" msgstr "" #: ../../routing.rst:80 msgid "``:name``" msgstr "" #: ../../routing.rst:80 msgid "````" msgstr "" #: ../../routing.rst:81 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:81 msgid "````" msgstr "" #: ../../routing.rst:82 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:82 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:83 msgid "``:##``" msgstr "" #: ../../routing.rst:83 msgid "``<:re>``" msgstr "" #: ../../routing.rst:86 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../routing.rst:91 msgid "Explicit routing configuration" msgstr "" #: ../../routing.rst:93 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "" #: ../../routing.rst:95 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "" #: ../../routing.rst:101 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/stpl.po000066400000000000000000000176611470367422500240310ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr "" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr "" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr "" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself to escape a lot, consider using :ref:`custom tokens " "`." msgstr "" #: ../../stpl.rst:99 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:101 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:109 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:115 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:123 msgid "THis time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:127 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:130 msgid "Template Functions" msgstr "" #: ../../stpl.rst:132 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:136 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:141 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:149 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:154 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:166 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:174 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "" #: ../../stpl.rst:179 msgid "Return the variable, or a default value." msgstr "" #: ../../stpl.rst:183 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "" #: ../../stpl.rst:186 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "" #: ../../stpl.rst:200 msgid ":class:`SimpleTemplate` API" msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/tutorial.po000066400000000000000000001414461470367422500247110ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "" #: ../../tutorial.rst:31 msgid "Installation" msgstr "" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.5 or newer (including 3.x) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr "" #: ../../tutorial.rst:87 msgid "" "Of course this is a very simple example, but it shows the basic concept of " "how applications are built with Bottle. Continue reading and you'll see what" " else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "" #: ../../tutorial.rst:152 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:154 msgid "" "The following filters are implemented by default and more may be added:" msgstr "" #: ../../tutorial.rst:156 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "" #: ../../tutorial.rst:157 msgid "**:float** similar to :int but for decimal numbers." msgstr "" #: ../../tutorial.rst:158 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "" #: ../../tutorial.rst:159 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "" #: ../../tutorial.rst:161 msgid "Let's have a look at some practical examples::" msgstr "" #: ../../tutorial.rst:175 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:179 msgid "" "The new rule syntax was introduced in **Bottle 0.10** to simplify some " "common use cases, but the old syntax still works and you can find a lot of " "code examples still using it. The differences are best described by example:" msgstr "" #: ../../tutorial.rst:182 msgid "Old Syntax" msgstr "" #: ../../tutorial.rst:182 msgid "New Syntax" msgstr "" #: ../../tutorial.rst:184 msgid "``:name``" msgstr "" #: ../../tutorial.rst:184 msgid "````" msgstr "" #: ../../tutorial.rst:185 msgid "``:name#regexp#``" msgstr "" #: ../../tutorial.rst:185 msgid "````" msgstr "" #: ../../tutorial.rst:186 msgid "``:#regexp#``" msgstr "" #: ../../tutorial.rst:186 msgid "``<:re:regexp>``" msgstr "" #: ../../tutorial.rst:187 msgid "``:##``" msgstr "" #: ../../tutorial.rst:187 msgid "``<:re>``" msgstr "" #: ../../tutorial.rst:190 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "" #: ../../tutorial.rst:194 msgid "HTTP Request Methods" msgstr "" #: ../../tutorial.rst:198 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the four " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:200 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "" #: ../../tutorial.rst:223 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "" #: ../../tutorial.rst:226 msgid "Special Methods: HEAD and ANY" msgstr "" #: ../../tutorial.rst:227 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "" #: ../../tutorial.rst:229 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "" #: ../../tutorial.rst:231 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "" #: ../../tutorial.rst:236 msgid "Routing Static Files" msgstr "" #: ../../tutorial.rst:238 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "" #: ../../tutorial.rst:245 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr "" #: ../../tutorial.rst:251 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "" #: ../../tutorial.rst:259 msgid "Error Pages" msgstr "" #: ../../tutorial.rst:261 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "" #: ../../tutorial.rst:268 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "" #: ../../tutorial.rst:270 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "" #: ../../tutorial.rst:280 msgid "Generating content" msgstr "" #: ../../tutorial.rst:282 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "" #: ../../tutorial.rst:284 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "" #: ../../tutorial.rst:287 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:287 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "" #: ../../tutorial.rst:290 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:290 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "" #: ../../tutorial.rst:293 msgid "Unicode strings" msgstr "" #: ../../tutorial.rst:293 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "" #: ../../tutorial.rst:296 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:296 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "" #: ../../tutorial.rst:299 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:299 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "" #: ../../tutorial.rst:302 msgid "File objects" msgstr "" #: ../../tutorial.rst:302 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "" #: ../../tutorial.rst:305 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:305 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "" #: ../../tutorial.rst:307 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "" #: ../../tutorial.rst:310 msgid "Changing the Default Encoding" msgstr "" #: ../../tutorial.rst:311 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "" #: ../../tutorial.rst:326 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "" #: ../../tutorial.rst:331 msgid "Static Files" msgstr "" #: ../../tutorial.rst:333 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:346 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "" #: ../../tutorial.rst:349 msgid "Forced Download" msgstr "" #: ../../tutorial.rst:350 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "" #: ../../tutorial.rst:356 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "" #: ../../tutorial.rst:361 msgid "HTTP Errors and Redirects" msgstr "" #: ../../tutorial.rst:363 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr "" #: ../../tutorial.rst:372 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "" #: ../../tutorial.rst:379 msgid "You may provide a different HTTP status code as a second parameter." msgstr "" #: ../../tutorial.rst:382 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPError` exception." msgstr "" #: ../../tutorial.rst:385 msgid "Other Exceptions" msgstr "" #: ../../tutorial.rst:386 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "" #: ../../tutorial.rst:392 msgid "The :class:`Response` Object" msgstr "" #: ../../tutorial.rst:394 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "" #: ../../tutorial.rst:397 msgid "Status Code" msgstr "" #: ../../tutorial.rst:398 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "" #: ../../tutorial.rst:401 msgid "Response Header" msgstr "" #: ../../tutorial.rst:402 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "" #: ../../tutorial.rst:409 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "" #: ../../tutorial.rst:414 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "" #: ../../tutorial.rst:420 ../../tutorial.rst:549 msgid "Cookies" msgstr "" #: ../../tutorial.rst:422 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "" #: ../../tutorial.rst:432 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr "" #: ../../tutorial.rst:434 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "" #: ../../tutorial.rst:435 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "" #: ../../tutorial.rst:436 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "" #: ../../tutorial.rst:437 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "" #: ../../tutorial.rst:438 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../tutorial.rst:439 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:441 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "" #: ../../tutorial.rst:443 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "" #: ../../tutorial.rst:444 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "" #: ../../tutorial.rst:445 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "" #: ../../tutorial.rst:446 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "" #: ../../tutorial.rst:451 msgid "Signed Cookies" msgstr "" #: ../../tutorial.rst:452 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "" #: ../../tutorial.rst:472 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "" #: ../../tutorial.rst:474 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "" #: ../../tutorial.rst:487 msgid "Request Data" msgstr "" #: ../../tutorial.rst:489 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "" #: ../../tutorial.rst:498 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr "" #: ../../tutorial.rst:503 msgid "Introducing :class:`FormsDict`" msgstr "" #: ../../tutorial.rst:505 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "" #: ../../tutorial.rst:507 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "" #: ../../tutorial.rst:522 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "" #: ../../tutorial.rst:527 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "" #: ../../tutorial.rst:531 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "" #: ../../tutorial.rst:538 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "" #: ../../tutorial.rst:545 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "" #: ../../tutorial.rst:551 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "" #: ../../tutorial.rst:553 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "" #: ../../tutorial.rst:563 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr "" #: ../../tutorial.rst:566 msgid "HTTP Headers" msgstr "" #: ../../tutorial.rst:568 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "" #: ../../tutorial.rst:580 msgid "Query Variables" msgstr "" #: ../../tutorial.rst:582 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "" #: ../../tutorial.rst:595 msgid "HTML `` Handling" msgstr "" #: ../../tutorial.rst:597 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "" #: ../../tutorial.rst:607 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "" #: ../../tutorial.rst:609 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "" #: ../../tutorial.rst:632 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "" #: ../../tutorial.rst:635 msgid "Attribute" msgstr "" #: ../../tutorial.rst:635 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:635 msgid "POST Form fields" msgstr "" #: ../../tutorial.rst:635 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:637 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:637 ../../tutorial.rst:638 ../../tutorial.rst:639 #: ../../tutorial.rst:640 ../../tutorial.rst:640 ../../tutorial.rst:641 #: ../../tutorial.rst:642 ../../tutorial.rst:642 msgid "yes" msgstr "" #: ../../tutorial.rst:637 ../../tutorial.rst:637 ../../tutorial.rst:638 #: ../../tutorial.rst:638 ../../tutorial.rst:639 ../../tutorial.rst:639 #: ../../tutorial.rst:640 ../../tutorial.rst:641 ../../tutorial.rst:641 #: ../../tutorial.rst:642 msgid "no" msgstr "" #: ../../tutorial.rst:638 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:639 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:640 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:641 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:642 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:647 msgid "File uploads" msgstr "" #: ../../tutorial.rst:649 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "" #: ../../tutorial.rst:659 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "" #: ../../tutorial.rst:673 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr "" #: ../../tutorial.rst:675 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "" #: ../../tutorial.rst:679 msgid "JSON Content" msgstr "" #: ../../tutorial.rst:681 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "" #: ../../tutorial.rst:685 msgid "The raw request body" msgstr "" #: ../../tutorial.rst:687 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "" #: ../../tutorial.rst:692 msgid "WSGI Environment" msgstr "" #: ../../tutorial.rst:694 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:712 msgid "Templates" msgstr "" #: ../../tutorial.rst:714 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "" #: ../../tutorial.rst:721 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "" #: ../../tutorial.rst:723 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr "" #: ../../tutorial.rst:732 msgid "Syntax" msgstr "" #: ../../tutorial.rst:735 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "" #: ../../tutorial.rst:737 msgid "Here is an example template::" msgstr "" #: ../../tutorial.rst:748 msgid "Caching" msgstr "" #: ../../tutorial.rst:749 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "" #: ../../tutorial.rst:759 msgid "Plugins" msgstr "" #: ../../tutorial.rst:763 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "" #: ../../tutorial.rst:765 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "" #: ../../tutorial.rst:767 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "" #: ../../tutorial.rst:787 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "" #: ../../tutorial.rst:791 msgid "Application-wide Installation" msgstr "" #: ../../tutorial.rst:793 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "" #: ../../tutorial.rst:795 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "" #: ../../tutorial.rst:797 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "" #: ../../tutorial.rst:802 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "" #: ../../tutorial.rst:806 msgid "Uninstall Plugins" msgstr "" #: ../../tutorial.rst:807 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "" #: ../../tutorial.rst:817 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "" #: ../../tutorial.rst:820 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "" #: ../../tutorial.rst:824 msgid "Route-specific Installation" msgstr "" #: ../../tutorial.rst:826 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr "" #: ../../tutorial.rst:836 msgid "Blacklisting Plugins" msgstr "" #: ../../tutorial.rst:838 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "" #: ../../tutorial.rst:860 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "" #: ../../tutorial.rst:863 msgid "Plugins and Sub-Applications" msgstr "" #: ../../tutorial.rst:865 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "" #: ../../tutorial.rst:876 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "" #: ../../tutorial.rst:878 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "" #: ../../tutorial.rst:882 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "" #: ../../tutorial.rst:887 msgid "Development" msgstr "" #: ../../tutorial.rst:889 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you beeing more productive." msgstr "" #: ../../tutorial.rst:895 msgid "Default Application" msgstr "" #: ../../tutorial.rst:897 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "" #: ../../tutorial.rst:905 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:915 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "" #: ../../tutorial.rst:920 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:945 msgid "Debug Mode" msgstr "" #: ../../tutorial.rst:947 msgid "During early development, the debug mode can be very helpful." msgstr "" #: ../../tutorial.rst:955 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "" #: ../../tutorial.rst:957 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "" #: ../../tutorial.rst:959 msgid "The default error page shows a traceback." msgstr "" #: ../../tutorial.rst:960 msgid "Templates are not cached." msgstr "" #: ../../tutorial.rst:961 msgid "Plugins are applied immediately." msgstr "" #: ../../tutorial.rst:963 msgid "Just make sure not to use the debug mode on a production server." msgstr "" #: ../../tutorial.rst:966 msgid "Auto Reloading" msgstr "" #: ../../tutorial.rst:968 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "" #: ../../tutorial.rst:978 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "" #: ../../tutorial.rst:983 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "" #: ../../tutorial.rst:989 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "" #: ../../tutorial.rst:997 msgid "Command Line Interface" msgstr "" #: ../../tutorial.rst:1001 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "" #: ../../tutorial.rst:1021 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "" #: ../../tutorial.rst:1023 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "" #: ../../tutorial.rst:1044 msgid "Deployment" msgstr "" #: ../../tutorial.rst:1046 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development and early production, but may become a performance bottleneck " "when server load increases." msgstr "" #: ../../tutorial.rst:1048 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "" #: ../../tutorial.rst:1052 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "" #: ../../tutorial.rst:1060 msgid "Glossary" msgstr "" #: ../../tutorial.rst:1063 msgid "callback" msgstr "" #: ../../tutorial.rst:1065 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1069 msgid "decorator" msgstr "" #: ../../tutorial.rst:1071 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1072 msgid "environ" msgstr "" #: ../../tutorial.rst:1074 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1078 msgid "handler function" msgstr "" #: ../../tutorial.rst:1080 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1083 msgid "source directory" msgstr "" #: ../../tutorial.rst:1085 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/_pot/tutorial_app.po000066400000000000000000000757501470367422500255550ustar00rootroot00000000000000# msgid "" msgstr "" "Project-Id-Version: Bottle 0.13-dev\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2015-01-22 16:45-0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../../tutorial_app.rst:20 msgid "Tutorial: Todo-List Application" msgstr "" #: ../../tutorial_app.rst:24 msgid "" "This tutorial is a work in progess and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:27 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "" #: ../../tutorial_app.rst:29 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL databse, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:31 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "" #: ../../tutorial_app.rst:0 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:36 msgid "Goals" msgstr "" #: ../../tutorial_app.rst:38 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "" #: ../../tutorial_app.rst:40 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "" #: ../../tutorial_app.rst:42 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "" #: ../../tutorial_app.rst:44 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "" #: ../../tutorial_app.rst:46 msgid "start page ``http://localhost:8080/todo``" msgstr "" #: ../../tutorial_app.rst:47 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "" #: ../../tutorial_app.rst:48 msgid "page for editing items: ``http://localhost:8080/edit/:no``" msgstr "" #: ../../tutorial_app.rst:49 msgid "" "validating data assigned by dynamic routes with the @validate decorator" msgstr "" #: ../../tutorial_app.rst:50 msgid "catching errors" msgstr "" #: ../../tutorial_app.rst:53 msgid "Before We Start..." msgstr "" #: ../../tutorial_app.rst:57 msgid "Install Bottle" msgstr "" #: ../../tutorial_app.rst:58 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "" #: ../../tutorial_app.rst:60 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "" #: ../../tutorial_app.rst:64 msgid "Further Software Necessities" msgstr "" #: ../../tutorial_app.rst:65 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "" #: ../../tutorial_app.rst:68 msgid "Create An SQL Database" msgstr "" #: ../../tutorial_app.rst:69 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "" #: ../../tutorial_app.rst:80 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "" #: ../../tutorial_app.rst:83 msgid "Using Bottle for a Web-Based ToDo List" msgstr "" #: ../../tutorial_app.rst:85 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "" #: ../../tutorial_app.rst:89 msgid "Understanding routes" msgstr "" #: ../../tutorial_app.rst:90 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "" #: ../../tutorial_app.rst:94 msgid "First Step - Showing All Open Items" msgstr "" #: ../../tutorial_app.rst:95 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "" #: ../../tutorial_app.rst:110 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "" #: ../../tutorial_app.rst:112 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "" #: ../../tutorial_app.rst:114 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "" #: ../../tutorial_app.rst:121 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "" #: ../../tutorial_app.rst:123 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "" #: ../../tutorial_app.rst:125 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "" #: ../../tutorial_app.rst:129 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "" #: ../../tutorial_app.rst:131 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "" #: ../../tutorial_app.rst:133 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "" #: ../../tutorial_app.rst:137 msgid "Debugging and Auto-Reload" msgstr "" #: ../../tutorial_app.rst:138 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "" #: ../../tutorial_app.rst:146 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "" #: ../../tutorial_app.rst:150 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "" #: ../../tutorial_app.rst:154 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "" #: ../../tutorial_app.rst:160 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "" #: ../../tutorial_app.rst:162 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "" #: ../../tutorial_app.rst:166 msgid "Bottle Template To Format The Output" msgstr "" #: ../../tutorial_app.rst:167 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "" #: ../../tutorial_app.rst:169 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "" #: ../../tutorial_app.rst:171 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "" #: ../../tutorial_app.rst:173 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "" #: ../../tutorial_app.rst:175 msgid "To include the template in our example, just add the following lines::" msgstr "" #: ../../tutorial_app.rst:185 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. Of course, we can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:189 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "" #: ../../tutorial_app.rst:203 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Please note that, of course, only valid Python statements are " "allowed, otherwise the template will raise an exception, just as any other " "Python code. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:207 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "" #: ../../tutorial_app.rst:209 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "" #: ../../tutorial_app.rst:211 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. Of course, you can spice-up the" " very simple HTML markup above, e.g. by using in-line styles to get a better" " looking output." msgstr "" #: ../../tutorial_app.rst:215 msgid "Using GET and POST Values" msgstr "" #: ../../tutorial_app.rst:216 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "" #: ../../tutorial_app.rst:218 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "" #: ../../tutorial_app.rst:241 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.get('task','').strip()`` statement, where ``task`` is the name" " of the GET data we want to access. That's all. If your GET data has more " "than one variable, multiple ``request.GET.get()`` statements can be used and" " assigned to other variables." msgstr "" #: ../../tutorial_app.rst:243 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "" #: ../../tutorial_app.rst:245 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "" #: ../../tutorial_app.rst:247 msgid "The code needs to be extended to::" msgstr "" #: ../../tutorial_app.rst:270 msgid "``new_task.tpl`` looks like this::" msgstr "" #: ../../tutorial_app.rst:278 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "" #: ../../tutorial_app.rst:280 msgid "Now we are able to extend our to do list." msgstr "" #: ../../tutorial_app.rst:282 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "" #: ../../tutorial_app.rst:286 msgid "Editing Existing Items" msgstr "" #: ../../tutorial_app.rst:287 msgid "The last point to do is to enable editing of existing items." msgstr "" #: ../../tutorial_app.rst:289 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "" #: ../../tutorial_app.rst:291 msgid "The basic statement for a dynamic route looks like this::" msgstr "" #: ../../tutorial_app.rst:295 msgid "" "The key point here is the colon. This tells Bottle to accept for " "``:something`` any string up to the next slash. Furthermore, the value of " "``something`` will be passed to the function assigned to that route, so the " "data can be processed within the function." msgstr "" #: ../../tutorial_app.rst:297 msgid "" "For our ToDo list, we will create a route ``@route('/edit/:no)``, where " "``no`` is the id of the item to edit." msgstr "" #: ../../tutorial_app.rst:299 msgid "The code looks like this::" msgstr "" #: ../../tutorial_app.rst:327 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ``:no``, which here passes the number to the corresponding " "function. As you can see, ``no`` is used within the function to access the " "right row of data within the database." msgstr "" #: ../../tutorial_app.rst:329 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "" #: ../../tutorial_app.rst:344 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "" #: ../../tutorial_app.rst:346 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "" #: ../../tutorial_app.rst:350 msgid "Validating Dynamic Routes" msgstr "" #: ../../tutorial_app.rst:351 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "" #: ../../tutorial_app.rst:353 msgid "" "For those cases, Bottle offers the ``@validate`` decorator, which validates " "the \"input\" prior to passing it to the function. In order to apply the " "validator, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:362 msgid "" "At first, we imported ``validate`` from the Bottle framework, than we apply " "the @validate-decorator. Right here, we validate if ``no`` is an integer. " "Basically, the validation works with all types of data like floats, lists " "etc." msgstr "" #: ../../tutorial_app.rst:364 msgid "" "Save the code and call the page again using a \"403 forbidden\" value for " "``:no``, e.g. a float. You will receive not an exception, but a \"403 - " "Forbidden\" error, saying that an integer was expected." msgstr "" #: ../../tutorial_app.rst:367 msgid "Dynamic Routes Using Regular Expressions" msgstr "" #: ../../tutorial_app.rst:368 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "" #: ../../tutorial_app.rst:370 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "" #: ../../tutorial_app.rst:372 msgid "As said above, the solution is a regular expression::" msgstr "" #: ../../tutorial_app.rst:386 msgid "" "Of course, this example is somehow artificially constructed - it would be " "easier to use a plain dynamic route only combined with a validation. " "Nevertheless, we want to see how regular expression routes work: the line " "``@route(/item:item_#[0-9]+#)`` starts like a normal route, but the part " "surrounded by # is interpreted as a regular expression, which is the dynamic" " part of the route. So in this case, we want to match any digit between 0 " "and 9. The following function \"show_item\" just checks whether the given " "item is present in the database or not. In case it is present, the " "corresponding text of the task is returned. As you can see, only the regular" " expression part of the route is passed forward. Furthermore, it is always " "forwarded as a string, even if it is a plain integer number, like in this " "case." msgstr "" #: ../../tutorial_app.rst:390 msgid "Returning Static Files" msgstr "" #: ../../tutorial_app.rst:391 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "" #: ../../tutorial_app.rst:399 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "" #: ../../tutorial_app.rst:403 msgid "Returning JSON Data" msgstr "" #: ../../tutorial_app.rst:404 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "" #: ../../tutorial_app.rst:406 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "" #: ../../tutorial_app.rst:421 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"Task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:426 msgid "Catching Errors" msgstr "" #: ../../tutorial_app.rst:427 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "" #: ../../tutorial_app.rst:429 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "" #: ../../tutorial_app.rst:437 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "" #: ../../tutorial_app.rst:439 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "" #: ../../tutorial_app.rst:446 msgid "works fine, the following one as well::" msgstr "" #: ../../tutorial_app.rst:458 msgid "Summary" msgstr "" #: ../../tutorial_app.rst:459 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "" #: ../../tutorial_app.rst:461 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "" #: ../../tutorial_app.rst:464 msgid "Server Setup" msgstr "" #: ../../tutorial_app.rst:466 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "" #: ../../tutorial_app.rst:470 msgid "Running Bottle on a different port and IP" msgstr "" #: ../../tutorial_app.rst:471 msgid "" "As standard, Bottle serves the pages on the IP adress 127.0.0.1, also known " "as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:473 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "" #: ../../tutorial_app.rst:477 msgid "would make Bottle listen to port 80." msgstr "" #: ../../tutorial_app.rst:479 msgid "To change the IP address where Bottle is listening::" msgstr "" #: ../../tutorial_app.rst:483 msgid "Of course, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:487 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "" #: ../../tutorial_app.rst:491 msgid "Running Bottle with a different server" msgstr "" #: ../../tutorial_app.rst:492 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "" #: ../../tutorial_app.rst:494 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Fapws3_, " "Flup_ and Paste_." msgstr "" #: ../../tutorial_app.rst:496 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "" #: ../../tutorial_app.rst:502 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "" #: ../../tutorial_app.rst:506 msgid "Running Bottle on Apache with mod_wsgi" msgstr "" #: ../../tutorial_app.rst:507 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "" #: ../../tutorial_app.rst:509 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "" #: ../../tutorial_app.rst:511 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "" #: ../../tutorial_app.rst:513 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "" #: ../../tutorial_app.rst:515 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "" #: ../../tutorial_app.rst:517 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "" #: ../../tutorial_app.rst:528 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "" #: ../../tutorial_app.rst:530 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "" #: ../../tutorial_app.rst:546 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "" #: ../../tutorial_app.rst:549 msgid "Final Words" msgstr "" #: ../../tutorial_app.rst:551 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "" #: ../../tutorial_app.rst:553 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "" #: ../../tutorial_app.rst:556 msgid "Complete Example Listing" msgstr "" #: ../../tutorial_app.rst:558 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "" #: ../../tutorial_app.rst:560 msgid "Main code for the application ``todo.py``::" msgstr "" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr "" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/api.po000066400000000000000000001420601470367422500226470ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # jluzhu , 2019 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../api.rst:3 msgid "API Reference" msgstr "API参考" #: ../../api.rst:10 msgid "" "This is a mostly auto-generated API. If you are new to bottle, you might " "find the narrative :doc:`tutorial` more helpful." msgstr "这份文档几乎是全自动生成的。如果你刚接触bottle,也许 :doc:`tutorial` 会更有帮助。" #: ../../api.rst:17 msgid "Module Contents" msgstr "模块目录" #: ../../api.rst:19 msgid "The module defines several functions, constants, and an exception." msgstr "" #: ../../../bottle.pydocstring of bottle.debug:1 msgid "" "Change the debug level. There is only one debug level supported at the " "moment." msgstr "" #: ../../../bottle.pydocstring of bottle.run:1 msgid "" "Start a server instance. This method blocks until the server terminates." msgstr "" #: ../../../bottle.pydocstring of bottle.run:0 ../../../bottle.pydocstring of #: bottle.path_shift:0 ../../../bottle.pydocstring of bottle.MultiDict.get:0 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:0 #: ../../../bottle.pydocstring of bottle.ResourceManager:0 #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:0 #: ../../../bottle.pydocstring of bottle.FileUpload.save:0 #: ../../../bottle.pydocstring of bottle.Bottle:0 ../../../bottle.pydocstring #: of bottle.Bottle.mount:0 ../../../bottle.pydocstring of #: bottle.Bottle.route:0 ../../../bottle.pydocstring of #: bottle.BaseRequest.path_shift:0 ../../../bottle.pydocstring of #: bottle.BaseResponse:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 ../../../bottle.pydocstring of #: bottle.BaseResponse.set_cookie:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.run:3 msgid "" "WSGI application or target string supported by :func:`load_app`. (default: " ":func:`default_app`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:5 msgid "" "Server adapter to use. See :data:`server_names` keys for valid names or pass" " a :class:`ServerAdapter` subclass. (default: `wsgiref`)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:8 msgid "" "Server address to bind to. Pass ``0.0.0.0`` to listens on all interfaces " "including the external one. (default: 127.0.0.1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:10 msgid "" "Server port to bind to. Values below 1024 require root privileges. (default:" " 8080)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:12 msgid "Start auto-reloading server? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:13 msgid "Auto-reloader interval in seconds (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:14 msgid "Suppress output to stdout and stderr? (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.run:15 msgid "Options passed to the server adapter." msgstr "" #: ../../../bottle.pydocstring of bottle.load:1 msgid "Import a module or fetch an object from a module." msgstr "" #: ../../../bottle.pydocstring of bottle.load:3 msgid "``package.module`` returns `module` as a module object." msgstr "" #: ../../../bottle.pydocstring of bottle.load:4 msgid "``pack.mod:name`` returns the module variable `name` from `pack.mod`." msgstr "" #: ../../../bottle.pydocstring of bottle.load:5 msgid "``pack.mod:func()`` calls `pack.mod.func()` and returns the result." msgstr "" #: ../../../bottle.pydocstring of bottle.load:7 msgid "" "The last form accepts not only function calls, but any type of expression. " "Keyword arguments passed to this function are available as local variables. " "Example: ``import_string('re:compile(x)', x='[a-z]')``" msgstr "" #: ../../../bottle.pydocstring of bottle.load_app:1 msgid "" "Load a bottle application from a module and make sure that the import does " "not affect the current default application, but returns a separate " "application object. See :func:`load` for the target parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.request:1 ../../../bottle.pydocstring #: of bottle.request:1 msgid "" "A thread-safe instance of :class:`LocalRequest`. If accessed from within a " "request callback, this instance always refers to the *current* request (even" " on a multi-threaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.response:1 msgid "" "A thread-safe instance of :class:`LocalResponse`. It is used to change the " "HTTP response for the *current* request." msgstr "" #: ../../../bottle.pydocstring of bottle.HTTP_CODES:1 msgid "" "A dict to map HTTP status codes (e.g. 404) to phrases (e.g. 'Not Found')" msgstr "" #: ../../api.rst:38 msgid "" "Return the current :ref:`default-app`. Actually, these are callable " "instances of :class:`AppStack` and implement a stack-like API." msgstr "" #: ../../api.rst:42 msgid "Routing" msgstr "" #: ../../api.rst:44 msgid "" "Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and " ":class:`AppStack`) and uses the top of the stack as a *default application* " "for some of the module-level functions and decorators." msgstr "" #: ../../api.rst:54 msgid "" "Decorator to install a route to the current default application. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../api.rst:59 msgid "" "Decorator to install an error handler to the current default application. " "See :meth:`Bottle.error` for details." msgstr "" #: ../../api.rst:63 msgid "WSGI and HTTP Utilities" msgstr "" #: ../../../bottle.pydocstring of bottle.parse_date:1 msgid "Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch." msgstr "" #: ../../../bottle.pydocstring of bottle.parse_auth:1 msgid "" "Parse rfc2617 HTTP authentication header string (basic) and return " "(user,pass) tuple or None" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_encode:1 msgid "Encode and sign a pickle-able object. Return a (byte) string" msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_decode:1 msgid "Verify and decode an encoded string. Return an object or None." msgstr "" #: ../../../bottle.pydocstring of bottle.cookie_is_encoded:1 msgid "Return True if the argument looks like a encoded cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.yieldroutes:1 msgid "" "Return a generator for routes that match the signature (name, args) of the " "func parameter. This may yield more than one route if the function takes " "optional keyword arguments. The output is best described by example::" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:1 msgid "Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:0 msgid "Returns" msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:3 msgid "The modified paths." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:4 msgid "The SCRIPT_NAME path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:5 msgid "The PATH_INFO path." msgstr "" #: ../../../bottle.pydocstring of bottle.path_shift:6 msgid "" "The number of path fragments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../api.rst:81 msgid "Data Structures" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict:1 msgid "" "This dict stores multiple values per key, but behaves exactly like a normal " "dict in that it returns only the newest value for any given key. There are " "special methods available to access the full list of values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.keys:1 msgid "D.keys() -> a set-like object providing a view on D's keys" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.values:1 msgid "D.values() -> an object providing a view on D's values" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.items:1 msgid "D.items() -> a set-like object providing a view on D's items" msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:1 msgid "Return the most recent value for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:3 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:3 msgid "" "The default value to be returned if the key is not present or the type " "conversion fails." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:5 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:5 msgid "An index for the list of available values." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:6 #: ../../../bottle.pydocstring of bottle.HeaderDict.get:6 msgid "" "If defined, this callable is used to cast the value into a specific type. " "Exception are suppressed and result in the default value to be returned." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.append:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.append:1 msgid "Add a new value to the list of values for this key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.replace:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.replace:1 msgid "Replace the list of values with a single value." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.MultiDict.getall:1 #: ../../../bottle.pydocstring of bottle.HeaderDict.getall:1 msgid "Return a (possibly empty) list of values for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.MultiDict.get:1 msgid "Aliases for WTForms to mimic other multi-dict APIs (Django)" msgstr "" #: ../../../bottle.pydocstring of bottle.HeaderDict:1 msgid "" "A case-insensitive version of :class:`MultiDict` that defaults to replace " "the old value instead of appending it." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict:1 msgid "" "This :class:`MultiDict` subclass is used to store request form data. " "Additionally to the normal dict-like item access methods (which return " "unmodified data as native strings), this container also supports attribute-" "like access to its values. Attributes are automatically de- or recoded to " "match :attr:`input_encoding` (default: 'utf8'). Missing attributes default " "to an empty string." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.input_encoding:1 msgid "Encoding used for attribute values." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.recode_unicode:1 msgid "" "If true (default), unicode strings are first encoded with `latin1` and then " "decoded to match :attr:`input_encoding`." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.decode:1 msgid "" "Returns a copy with all keys and values de- or recoded to match " ":attr:`input_encoding`. Some libraries (e.g. WTForms) want a unicode " "dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.FormsDict.getunicode:1 msgid "Return the value as a unicode string, or the default." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:1 msgid "" "This dict-like class wraps a WSGI environ dict and provides convenient " "access to HTTP_* fields. Keys and values are native strings (2.x bytes or " "3.x unicode) and keys are case-insensitive. If the WSGI environment contains" " non-native string values, these are de- or encoded using a lossless " "'latin1' character set." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict:7 msgid "" "The API will remain stable even on changes to the relevant PEPs. Currently " "PEP 333, 444 and 3333 are supported. (PEP 444 is the only one that uses non-" "native strings.)" msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.cgikeys:1 msgid "List of keys that do not have a ``HTTP_`` prefix." msgstr "" #: ../../../bottle.pydocstring of bottle.WSGIHeaderDict.raw:1 msgid "Return the header value as is (may be bytes or unicode)." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack:1 msgid "A stack-like list. Calling it returns the head of the stack." msgstr "" #: ../../api.rst:100 msgid "Return the current default application and remove it from the stack." msgstr "" #: ../../../bottle.pydocstring of bottle.AppStack.push:1 #: ../../../bottle.pydocstring of bottle.AppStack.push:1 msgid "Add a new :class:`Bottle` instance to the stack" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:1 msgid "" "This class manages a list of search paths and helps to find and open " "application-bound resources (files)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:4 msgid "default value for :meth:`add_path` calls." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:5 msgid "callable used to open resources." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager:6 msgid "controls which lookups are cached. One of 'all', 'found' or 'none'." msgstr "" #: ../docstring of bottle.ResourceManager.path:1 msgid "A list of search paths. See :meth:`add_path` for details." msgstr "" #: ../docstring of bottle.ResourceManager.cache:1 msgid "A cache for resolved paths. ``res.cache.clear()`` clears the cache." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:1 msgid "" "Add a new path to the list of search paths. Return False if the path does " "not exist." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:4 msgid "" "The new search path. Relative paths are turned into an absolute and " "normalized form. If the path looks like a file (not ending in `/`), the " "filename is stripped off." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:7 msgid "" "Path used to absolutize relative search paths. Defaults to :attr:`base` " "which defaults to ``os.getcwd()``." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:9 msgid "" "Position within the list of search paths. Defaults to last index (appends to" " the list)." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.add_path:12 msgid "" "The `base` parameter makes it easy to reference files installed along with a" " python module or package::" msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:1 msgid "Search for a resource and return an absolute file path, or `None`." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.lookup:3 msgid "" "The :attr:`path` list is searched in order. The first match is returned. " "Symlinks are followed. The result is cached to speed up future lookups." msgstr "" #: ../../../bottle.pydocstring of bottle.ResourceManager.open:1 msgid "Find a resource and return a file object, or raise IOError." msgstr "" #: ../docstring of bottle.FileUpload.file:1 msgid "Open file(-like) object (BytesIO buffer or temporary file)" msgstr "" #: ../docstring of bottle.FileUpload.name:1 msgid "Name of the upload form field" msgstr "" #: ../docstring of bottle.FileUpload.raw_filename:1 msgid "Raw filename as sent by the client (may contain unsafe characters)" msgstr "" #: ../docstring of bottle.FileUpload.headers:1 msgid "A :class:`HeaderDict` with additional headers (e.g. content-type)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_type:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_type:1 msgid "Current value of the 'Content-Type' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.content_length:1 #: ../../../bottle.pydocstring of bottle.BaseResponse.content_length:1 msgid "Current value of the 'Content-Length' header." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.get_header:1 msgid "Return the value of a header within the mulripart part." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:1 msgid "" "Name of the file on the client file system, but normalized to ensure file " "system compatibility. An empty filename is returned as 'empty'." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.filename:4 msgid "" "Only ASCII letters, digits, dashes, underscores and dots are allowed in the " "final filename. Accents are removed, if possible. Whitespace is replaced by " "a single dash. Leading or tailing dots or dashes are removed. The filename " "is limited to 255 characters." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:1 msgid "" "Save file to disk or copy its content to an open file(-like) object. If " "*destination* is a directory, :attr:`filename` is added to the path. " "Existing files are not overwritten by default (IOError)." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:5 msgid "File path, directory or file(-like) object." msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:6 msgid "If True, replace existing files. (default: False)" msgstr "" #: ../../../bottle.pydocstring of bottle.FileUpload.save:7 msgid "Bytes to read at a time. (default: 64kb)" msgstr "" #: ../../api.rst:109 msgid "Exceptions" msgstr "" #: ../../../bottle.pydocstring of bottle.BottleException:1 msgid "A base class for exceptions used by bottle." msgstr "" #: ../../api.rst:117 msgid "The :class:`Bottle` Class" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:1 msgid "" "Each Bottle object represents a single, distinct web application and " "consists of routes, callbacks, plugins, resources and configuration. " "Instances are callable WSGI applications." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle:5 msgid "" "If true (default), handle all exceptions. Turn off to let debugging " "middleware handle exceptions." msgstr "" #: ../docstring of bottle.Bottle.config:1 msgid "A :class:`ConfigDict` for app specific configuration." msgstr "" #: ../docstring of bottle.Bottle.resources:1 msgid "A :class:`ResourceManager` for application files" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.catchall:1 msgid "If true, most exceptions are caught and returned as :exc:`HTTPError`" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:1 msgid "Attach a callback to a hook. Three hooks are currently implemented:" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "before_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:4 msgid "" "Executed once before each request. The request context is available, but no " "routing has happened yet." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:6 msgid "after_request" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:7 msgid "Executed once after each request regardless of its outcome." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:8 msgid "app_reset" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_hook:9 msgid "Called whenever :meth:`Bottle.reset` is called." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.remove_hook:1 msgid "Remove a callback from a hook." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.trigger_hook:1 msgid "Trigger a hook and return a list of results." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.hook:1 msgid "" "Return a decorator that attaches a callback to a hook. See :meth:`add_hook` " "for details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:1 msgid "" "Mount an application (:class:`Bottle` or plain WSGI) to a specific URL " "prefix. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:6 msgid "path prefix or `mount-point`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:7 msgid "an instance of :class:`Bottle` or a WSGI application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:9 msgid "" "Plugins from the parent application are not applied to the routes of the " "mounted child application. If you need plugins in the child application, " "install them separately." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:13 msgid "" "While it is possible to use path wildcards within the prefix path " "(:class:`Bottle` childs only), it is highly discouraged." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.mount:16 msgid "" "The prefix path must end with a slash. If you want to access the root of the" " child application via `/prefix` in addition to `/prefix/`, consider adding " "a route with a 307 redirect to the parent application." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.merge:1 msgid "" "Merge the routes of another :class:`Bottle` application or a list of " ":class:`Route` objects into this application. The routes keep their 'owner'," " meaning that the :data:`Route.app` attribute is not changed." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.install:1 msgid "" "Add a plugin to the list of plugins and prepare it for being applied to all " "routes of this application. A plugin may be a simple decorator or an object " "that implements the :class:`Plugin` API." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.uninstall:1 msgid "" "Uninstall plugins. Pass an instance to remove a specific plugin, a type " "object to remove all plugins that match that type, a string to remove all " "plugins with a matching ``name`` attribute or ``True`` to remove all " "plugins. Return the list of removed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.reset:1 msgid "" "Reset all routes (force plugins to be re-applied) and clear all caches. If " "an ID or route object is given, only that specific route is affected." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.close:1 msgid "Close the application and all installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.run:1 msgid "Calls :func:`run` with the same parameters." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.match:1 msgid "" "Search for a matching route and return a (:class:`Route`, urlargs) tuple. " "The second value is a dictionary with parameters extracted from the URL. " "Raise :exc:`HTTPError` (404/405) on a non-match." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get_url:1 msgid "Return a string that matches a named route" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.add_route:1 msgid "Add a route object, but do not change the :data:`Route.app` attribute." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:1 msgid "A decorator to bind a function to a request URL. Example::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:7 msgid "" "The ```` part is a wildcard. See :class:`Router` for syntax details." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:10 msgid "" "Request path or a list of paths to listen to. If no path is specified, it is" " automatically generated from the signature of the function." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:13 msgid "" "HTTP method (`GET`, `POST`, `PUT`, ...) or a list of methods to listen to. " "(default: `GET`)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:15 msgid "" "An optional shortcut to avoid the decorator syntax. ``route(..., " "callback=func)`` equals ``route(...)(func)``" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:17 msgid "The name for this route. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:18 msgid "" "A decorator or plugin or a list of plugins. These are applied to the route " "callback in addition to installed plugins." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:20 msgid "" "A list of plugins, plugin classes or names. Matching plugins are not " "installed to this route. ``True`` skips all." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.route:23 msgid "" "Any additional keyword arguments are stored as route-specific configuration " "and passed to plugins (see :meth:`Plugin.apply`)." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.get:1 msgid "Equals :meth:`route`." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.post:1 msgid "Equals :meth:`route` with a ``POST`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.put:1 msgid "Equals :meth:`route` with a ``PUT`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.delete:1 msgid "Equals :meth:`route` with a ``DELETE`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.patch:1 msgid "Equals :meth:`route` with a ``PATCH`` method parameter." msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.error:1 msgid "" "Register an output handler for a HTTP error code. Can be used as a decorator" " or called directly ::" msgstr "" #: ../../../bottle.pydocstring of bottle.Bottle.wsgi:1 msgid "The bottle WSGI-interface." msgstr "" #: ../../../bottle.pydocstring of bottle.Route:1 msgid "" "This class wraps a route callback along with route specific metadata and " "configuration and applies Plugins on demand. It is also responsible for " "turning an URL path rule into a regular expression usable by the Router." msgstr "" #: ../docstring of bottle.Route.app:1 msgid "The application this route is installed to." msgstr "" #: ../docstring of bottle.Route.rule:1 msgid "The path-rule string (e.g. ``/wiki/``)." msgstr "" #: ../docstring of bottle.Route.method:1 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "HTTP方法的字符串(例如: ``GET``)" #: ../docstring of bottle.Route.callback:1 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "未应用任何插件的原始回调函数,用于内省。" #: ../docstring of bottle.Route.name:1 msgid "The name of the route (if specified) or ``None``." msgstr "route的名字,如未指定则为 ``None``" #: ../docstring of bottle.Route.plugins:1 msgid "A list of route-specific plugins (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.skiplist:1 msgid "" "A list of plugins to not apply to this route (see :meth:`Bottle.route`)." msgstr "" #: ../docstring of bottle.Route.config:1 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific plugin configuration " "and meta-data." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.call:1 msgid "" "The route callback with all plugins applied. This property is created on " "demand and then cached to speed up subsequent requests." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.reset:1 msgid "" "Forget any cached values. The next time :attr:`call` is accessed, all " "plugins are re-applied." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.prepare:1 msgid "Do all on-demand work immediately (useful for debugging)." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.all_plugins:1 msgid "Yield all Plugins affecting this route." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_undecorated_callback:1 msgid "" "Return the callback. If the callback is a decorated function, try to recover" " the original function." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_callback_args:1 msgid "" "Return a list of argument names the callback (most likely) accepts as " "keyword arguments. If the callback is a decorated function, try to recover " "the original function before inspection." msgstr "" #: ../../../bottle.pydocstring of bottle.Route.get_config:1 msgid "" "Lookup a config field and return its value, first checking the route.config," " then route.app.config." msgstr "" #: ../../api.rst:127 msgid "The :class:`Request` Object" msgstr "" #: ../../api.rst:129 msgid "" "The :class:`Request` class wraps a WSGI environment and provides helpful " "methods to parse and access form data, cookies, file uploads and other " "metadata. Most of the attributes are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:1 msgid "" "A wrapper for WSGI environment dictionaries that adds a lot of convenient " "access methods and properties. Most of them are read-only." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest:4 msgid "" "Adding new attributes to a request actually adds them to the environ " "dictionary (as 'bottle.request.ext.'). This is the recommended way to " "store and access request-specific data." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.MEMFILE_MAX:1 msgid "Maximum size of memory buffer for :attr:`body` in bytes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.environ:1 msgid "" "The wrapped WSGI environ dictionary. This is the only real attribute. All " "other attributes actually are read-only properties." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.app:1 msgid "Bottle application handling this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.route:1 msgid "The bottle :class:`Route` object that matches this request." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url_args:1 msgid "The arguments extracted from the URL." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path:1 msgid "" "The value of ``PATH_INFO`` with exactly one prefixed slash (to fix broken " "clients and avoid the \"empty path\" edge case)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.method:1 msgid "The ``REQUEST_METHOD`` value as an uppercase string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.headers:1 msgid "" "A :class:`WSGIHeaderDict` that provides case-insensitive access to HTTP " "request headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_header:1 msgid "Return the value of a request header, or a given default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.cookies:1 msgid "" "Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT decoded. " "Use :meth:`get_cookie` if you expect signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.get_cookie:1 msgid "" "Return the content of a cookie. To read a `Signed Cookie`, the `secret` must" " match the one used to create the cookie (see " ":meth:`BaseResponse.set_cookie`). If anything goes wrong (missing cookie or " "wrong signature), return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "" "The :attr:`query_string` parsed into a :class:`FormsDict`. These values are " "sometimes called \"URL arguments\" or \"GET parameters\", but not to be " "confused with \"URL wildcards\" as they are provided by the :class:`Router`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.forms:1 msgid "" "Form values parsed from an `url-encoded` or `multipart/form-data` encoded " "POST or PUT request body. The result is returned as a :class:`FormsDict`. " "All keys and values are strings. File uploads are stored separately in " ":attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.params:1 msgid "" "A :class:`FormsDict` with the combined values of :attr:`query` and " ":attr:`forms`. File uploads are stored in :attr:`files`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.files:1 msgid "" "File uploads parsed from `multipart/form-data` encoded POST or PUT request " "body. The values are instances of :class:`FileUpload`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.json:1 msgid "" "If the ``Content-Type`` header is ``application/json`` or ``application" "/json-rpc``, this property holds the parsed content of the request body. " "Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory" " exhaustion. Invalid JSON raises a 400 error response." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.body:1 msgid "" "The HTTP request body as a seek-able file-like object. Depending on " ":attr:`MEMFILE_MAX`, this is either a temporary file or a " ":class:`io.BytesIO` instance. Accessing this property for the first time " "reads and replaces the ``wsgi.input`` environ variable. Subsequent accesses " "just do a `seek(0)` on the file object." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.chunked:1 msgid "True if Chunked transfer encoding was." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query:1 msgid "An alias for :attr:`query`." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.POST:1 msgid "" "The values of :attr:`forms` and :attr:`files` combined into a single " ":class:`FormsDict`. Values are either strings (form values) or instances of " ":class:`cgi.FieldStorage` (file uploads)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.url:1 msgid "" "The full request URI including hostname and scheme. If your app lives behind" " a reverse proxy or load balancer and you get confusing results, make sure " "that the ``X-Forwarded-Host`` header is set correctly." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.urlparts:1 msgid "" "The :attr:`url` string as an :class:`urlparse.SplitResult` tuple. The tuple " "contains (scheme, host, path, query_string and fragment), but the fragment " "is always empty because it is not visible to the server." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.fullpath:1 msgid "Request path including :attr:`script_name` (if present)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.query_string:1 msgid "" "The raw :attr:`query` part of the URL (everything in between ``?`` and " "``#``) as a string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.script_name:1 msgid "" "The initial portion of the URL's `path` that was removed by a higher level " "(server or routing middleware) before the application was called. This " "script path is returned with leading and tailing slashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "Shift path segments from :attr:`path` to :attr:`script_name` and" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:2 msgid "vice versa." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.path_shift:4 msgid "" "The number of path segments to shift. May be negative to change the shift " "direction. (default: 1)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_length:1 msgid "" "The request body length as an integer. The client is responsible to set this" " header. Otherwise, the real length of the body is unknown and -1 is " "returned. In this case, :attr:`body` will be empty." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.content_type:1 msgid "The Content-Type header as a lowercase-string (default: empty)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_xhr:1 msgid "" "True if the request was triggered by a XMLHttpRequest. This only works with " "JavaScript libraries that support the `X-Requested-With` header (most of the" " popular libraries do)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.is_ajax:1 msgid "Alias for :attr:`is_xhr`. \"Ajax\" is not the right term." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.auth:1 msgid "" "HTTP authentication data as a (user, password) tuple. This implementation " "currently supports basic (not digest) authentication only. If the " "authentication happened at a higher level (e.g. in the front web-server or a" " middleware), the password field is None, but the user field is looked up " "from the ``REMOTE_USER`` environ variable. On any errors, None is returned." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_route:1 msgid "" "A list of all IPs that were involved in this request, starting with the " "client IP and followed by zero or more proxies. This does only work if all " "proxies support the ```X-Forwarded-For`` header. Note that this information " "can be forged by malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.remote_addr:1 msgid "" "The client IP as a string. Note that this information can be forged by " "malicious clients." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.copy:1 msgid "Return a new :class:`Request` with a shallow :attr:`environ` copy." msgstr "" #: ../../api.rst:137 msgid "" "The module-level :data:`bottle.request` is a proxy object (implemented in " ":class:`LocalRequest`) and always refers to the `current` request, or in " "other words, the request that is currently processed by the request handler " "in the current thread. This `thread locality` ensures that you can safely " "use a global instance in a multi-threaded environment." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalRequest:1 msgid "" "A thread-local subclass of :class:`BaseRequest` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`request`). If accessed during a request/response cycle, " "this instance always refers to the *current* request (even on a " "multithreaded server)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseRequest.__init__:1 msgid "Wrap a WSGI environ dictionary." msgstr "" #: ../../api.rst:146 msgid "The :class:`Response` Object" msgstr ":class:`Response` 对象" #: ../../api.rst:148 msgid "" "The :class:`Response` class stores the HTTP status code as well as headers " "and cookies that are to be sent to the client. Similar to " ":data:`bottle.request` there is a thread-local :data:`bottle.response` " "instance that can be used to adjust the `current` response. Moreover, you " "can instantiate :class:`Response` and return it from your request handler. " "In this case, the custom instance overrules the headers and cookies defined " "in the global one." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:1 msgid "Storage class for a response body as well as headers and cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:3 msgid "" "This class does support dict-like case-insensitive item-access to headers, " "but is NOT a dict. Most notably, iterating over a response yields parts of " "the body and not the headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:7 msgid "The response body as one of the supported types." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:8 msgid "" "Either an HTTP status code (e.g. 200) or a status line including the reason " "phrase (e.g. '200 OK')." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:10 msgid "A dictionary or a list of name-value pairs." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse:12 msgid "" "Additional keyword arguments are added to the list of headers. Underscores " "in the header name are replaced with dashes." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.copy:1 msgid "Returns a copy of self." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_line:1 msgid "The HTTP status line as a string (e.g. ``404 Not Found``)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status_code:1 msgid "The HTTP status code as an integer (e.g. 404)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.status:1 msgid "" "A writeable property to change the HTTP response status. It accepts either a" " numeric code (100-999) or a string with a custom reason phrase (e.g. \"404 " "Brain not found\"). Both :data:`status_line` and :data:`status_code` are " "updated accordingly. The return value is always a status string." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headers:1 msgid "" "An instance of :class:`HeaderDict`, a case-insensitive dict-like view on the" " response headers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.get_header:1 msgid "" "Return the value of a previously defined header. If there is no header with " "that name, return a default value." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_header:1 msgid "" "Create a new response header, replacing any previously defined headers with " "the same name." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.add_header:1 msgid "Add an additional response header, not removing duplicates." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.iter_headers:1 msgid "" "Yield (header, value) tuples, skipping headers that are not allowed with the" " current response status code." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.headerlist:1 msgid "WSGI conform list of (header, value) tuples." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.expires:1 msgid "Current value of the 'Expires' header." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.charset:1 msgid "" "Return the charset specified in the content-type header (default: utf8)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:1 msgid "" "Create a new cookie or replace an old one. If the `secret` parameter is set," " create a `Signed Cookie` (described below)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:4 msgid "the name of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:5 msgid "the value of the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:6 msgid "a signature key required for signed cookies." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:8 msgid "" "Additionally, this method accepts all RFC 2109 attributes that are supported" " by :class:`cookie.Morsel`, including:" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:11 msgid "maximum age in seconds. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:12 msgid "a datetime object or UNIX timestamp. (default: None)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:13 msgid "" "the domain that is allowed to read the cookie. (default: current domain)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:15 msgid "limits the cookie to a given path (default: current path)" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:16 msgid "limit the cookie to HTTPS connections (default: off)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:17 msgid "" "prevents client-side javascript to read this cookie (default: off, requires " "Python 2.6 or newer)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:19 msgid "" "Control or disable third-party use for this cookie. Possible values: `lax`, " "`strict` or `none` (default)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:22 msgid "" "If neither `expires` nor `maxage` is set (default), the cookie will expire " "at the end of the browser session (as soon as the browser window is closed)." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:26 msgid "" "Signed cookies may store any pickle-able object and are cryptographically " "signed to prevent manipulation. Keep in mind that cookies are limited to 4kb" " in most browsers." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:30 msgid "" "Warning: Pickle is a potentially dangerous format. If an attacker gains " "access to the secret key, he could forge cookies that execute code on server" " side if unpickled. Using pickle is discouraged and support for it will be " "removed in later versions of bottle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.set_cookie:35 msgid "" "Warning: Signed cookies are not encrypted (the client can still see the " "content) and not copy-protected (the client can restore an old cookie). The " "main intention is to make pickling and unpickling save, not to store secret " "information at client side." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.delete_cookie:1 msgid "" "Delete a cookie. Be sure to use the same `domain` and `path` settings as " "used to create the cookie." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse:1 msgid "" "A thread-local subclass of :class:`BaseResponse` with a different set of " "attributes for each thread. There is usually only one global instance of " "this class (:data:`response`). Its attributes are used to build the HTTP " "response at the end of the request/response cycle." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseResponse.__init__:1 msgid "Initialize self. See help(type(self)) for accurate signature." msgstr "" #: ../../../bottle.pydocstring of bottle.LocalResponse.body:1 msgid "Thread-local property" msgstr "" #: ../../api.rst:160 msgid "" "The following two classes can be raised as an exception. The most noticeable" " difference is that bottle invokes error handlers for :class:`HTTPError`, " "but not for :class:`HTTPResponse` or other response types." msgstr "" #: ../../api.rst:172 msgid "Templates" msgstr "模板" #: ../../api.rst:174 msgid "" "All template engines supported by :mod:`bottle` implement the " ":class:`BaseTemplate` API. This way it is possible to switch and mix " "template engines without changing the application code at all." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate:1 msgid "Base class and minimal API for template adapters" msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.__init__:1 msgid "" "Create a new template. If the source parameter (str or buffer) is missing, " "the name argument is used to guess a template filename. Subclasses can " "assume that self.source and/or self.filename are set. Both are strings. The " "lookup, encoding and settings parameters are stored as instance variables. " "The lookup parameter stores a list containing directory paths. The encoding " "parameter should be used to decode byte strings or files. The settings " "parameter contains a dict for engine-specific settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.search:1 msgid "" "Search name in all directories specified in lookup. First without, then with" " common extensions. Return first hit." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.global_config:1 msgid "This reads or sets the global settings stored in class.settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.BaseTemplate.render:1 msgid "" "Render the template with the specified local variables and return a single " "byte or unicode string. If it is a byte string, the encoding must match " "self.encoding. This method must be thread-safe! Local variables may be " "provided in dictionaries (args) or directly, as keywords (kwargs)." msgstr "" #: ../../../bottle.pydocstring of bottle.view:1 msgid "" "Decorator: renders a template for a handler. The handler can control its " "behavior like that:" msgstr "" #: ../../../bottle.pydocstring of bottle.view:4 msgid "return a dict of template vars to fill out the template" msgstr "" #: ../../../bottle.pydocstring of bottle.view:5 msgid "" "return something other than a dict and the view decorator will not process " "the template, but return the handler result as is. This includes returning a" " HTTPResponse(dict) to get, for instance, JSON with autojson or other " "castfilters." msgstr "" #: ../../../bottle.pydocstring of bottle.template:1 msgid "" "Get a rendered template as a string iterator. You can use a name, a filename" " or a template string as first parameter. Template rendering arguments can " "be passed as dictionaries or directly (as keyword arguments)." msgstr "" #: ../../api.rst:185 msgid "" "You can write your own adapter for your favourite template engine or use one" " of the predefined adapters. Currently there are four fully supported " "template engines:" msgstr "" #: ../../api.rst:188 msgid "Class" msgstr "" #: ../../api.rst:188 msgid "URL" msgstr "" #: ../../api.rst:188 msgid "Decorator" msgstr "" #: ../../api.rst:188 msgid "Render function" msgstr "" #: ../../api.rst:190 msgid ":class:`SimpleTemplate`" msgstr "" #: ../../api.rst:190 msgid ":doc:`stpl`" msgstr "" #: ../../api.rst:190 msgid ":func:`view`" msgstr "" #: ../../api.rst:190 msgid ":func:`template`" msgstr "" #: ../../api.rst:191 msgid ":class:`MakoTemplate`" msgstr "" #: ../../api.rst:191 msgid "http://www.makotemplates.org" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_view`" msgstr "" #: ../../api.rst:191 msgid ":func:`mako_template`" msgstr "" #: ../../api.rst:192 msgid ":class:`CheetahTemplate`" msgstr "" #: ../../api.rst:192 msgid "http://www.cheetahtemplate.org/" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_view`" msgstr "" #: ../../api.rst:192 msgid ":func:`cheetah_template`" msgstr "" #: ../../api.rst:193 msgid ":class:`Jinja2Template`" msgstr "" #: ../../api.rst:193 msgid "http://jinja.pocoo.org/" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_view`" msgstr "" #: ../../api.rst:193 msgid ":func:`jinja2_template`" msgstr "" #: ../../api.rst:196 msgid "" "To use :class:`MakoTemplate` as your default template engine, just import " "its specialised decorator and render function::" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/async.po000066400000000000000000000330751470367422500232200ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2017-09-21 22:57+0000\n" "Last-Translator: Thiago Avelino \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../async.rst:2 msgid "Primer to Asynchronous Applications" msgstr "异步应用入门" #: ../../async.rst:4 msgid "" "Asynchronous design patterns don't mix well with the synchronous nature of " "`WSGI `_. This is why most " "asynchronous frameworks (tornado, twisted, ...) implement a specialized API " "to expose their asynchronous features. Bottle is a WSGI framework and shares" " the synchronous nature of WSGI, but thanks to the awesome `gevent project " "`_, it is still possible to write asynchronous " "applications with bottle. This article documents the usage of Bottle with " "Asynchronous WSGI." msgstr "异步设计模式和 `WSGI `_ 的同步本质并不能很好地兼容。这就是为什么大部分的异步框架(tornado, twisted, ...)都实现了专有的API来暴露它们的异步特征。Bottle是一个WSGI框架,也继承了WSGI的同步本质,但是谢谢优秀的 `gevent项目 `_ ,我们可以使用Bottle来编写异步应用。这份文档介绍了在Bottle中如何使用异步WSGI。" #: ../../async.rst:7 msgid "The Limits of Synchronous WSGI" msgstr "同步WSGI的限制" #: ../../async.rst:9 msgid "" "Briefly worded, the `WSGI specification (pep 3333) " "`_ defines a request/response " "circle as follows: The application callable is invoked once for each request" " and must return a body iterator. The server then iterates over the body and" " writes each chunk to the socket. As soon as the body iterator is exhausted," " the client connection is closed." msgstr "简单来说, `WSGI标准 (pep 3333) `_ 定义了下面这一个request/response的循环:每次请求到达的时候,应用中的callable会被调用一次,返回一个主体iterator。接着服务器会遍历该主体,分块写入socket。遍历完整个主体,就关闭客户端的连接。" #: ../../async.rst:11 msgid "" "Simple enough, but there is a snag: All this happens synchronously. If your " "application needs to wait for data (IO, sockets, databases, ...), it must " "either yield empty strings (busy wait) or block the current thread. Both " "solutions occupy the handling thread and prevent it from answering new " "requests. There is consequently only one ongoing request per thread." msgstr "足够简单,但是存在一个小问题:所有这些都是同步的。如果你的应用需要等待数据(IO, socket, 数据库, ...),除了返回一个空字符串(忙等),就只能阻塞当前线程。两种办法都会占用当前线程,导致线程不能处理新的请求,只能处理当前的一个请求。" #: ../../async.rst:13 msgid "" "Most servers limit the number of threads to avoid their relatively high " "overhead. Pools of 20 or less threads are common. As soon as all threads are" " occupied, any new connection is stalled. The server is effectively dead for" " everyone else. If you want to implement a chat that uses long-polling ajax " "requests to get real-time updates, you'd reach the limited at 20 concurrent " "connections. That's a pretty small chat." msgstr "大部分服务器都限制了线程的数量,避免伴随它们而来的资源消耗。常见的是一个线程池,内有20个或更少数量的线程。一旦所有的线程都被占用了,任何新的请求都会阻塞。事实上,对于其他人来说,服务器已经宕机了。如果你想实现一个聊天程序,使用ajax轮询来获取实时消息,很快你就会受到线程数量的限制。这样能同时服务的用户就太少了。" #: ../../async.rst:16 msgid "Greenlets to the rescue" msgstr "救星,Greenlet" #: ../../async.rst:18 msgid "" "Most servers limit the size of their worker pools to a relatively low number" " of concurrent threads, due to the high overhead involved in switching " "between and creating new threads. While threads are cheap compared to " "processes (forks), they are still expensive to create for each new " "connection." msgstr "大多数服务器的线程池都限制了线程池中线程的数量,避免创建和切换线程的代价。尽管和创建进程(fork)的代价比起来,线程还是挺便宜的。但是也没便宜到可以接受为每一个请求创建一个线程。" #: ../../async.rst:20 msgid "" "The `gevent `_ module adds *greenlets* to the mix. " "Greenlets behave similar to traditional threads, but are very cheap to " "create. A gevent-based server can spawn thousands of greenlets (one for each" " connection) with almost no overhead. Blocking individual greenlets has no " "impact on the servers ability to accept new requests. The number of " "concurrent connections is virtually unlimited." msgstr "`gevent `_ 模块添加了 *greenlet* 的支持。greenlet和传统的线程类似,但其创建只需消耗很少的资源。基于gevent的服务器可以生成成千上万的greenlet,为每个连接分配一个greenlet也毫无压力。阻塞greenlet,也不会影响到服务器接受新的请求。同时处理的连接数理论上是没有限制的。" #: ../../async.rst:22 msgid "" "This makes creating asynchronous applications incredibly easy, because they " "look and feel like synchronous applications. A gevent-based server is " "actually not asynchronous, but massively multi-threaded. Here is an " "example::" msgstr "这令创建异步应用难以置信的简单,因为它们看起来很想同步程序。基于gevent服务器实际上不是异步的,是大规模多线程。下面是一个例子。" #: ../../async.rst:39 msgid "" "The first line is important. It causes gevent to monkey-patch most of " "Python's blocking APIs to not block the current thread, but pass the CPU to " "the next greenlet instead. It actually replaces Python's threading with " "gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` " "which would normally block the whole thread. If you don't feel comfortable " "with monkey-patching python built-ins, you can use the corresponding gevent " "functions (``gevent.sleep()`` in this case)." msgstr "第一行很重要。它让gevent monkey-patch了大部分Python的阻塞API,让它们不阻塞当前线程,将CPU让给下一个greenlet。它实际上用基于gevent的伪线程替换了Python的线程。这就是你依然可以使用 ``time.sleep()`` 这个照常来说会阻塞线程的函数。如果这种monkey-patch的方式感令你感到不舒服,你依然可以使用gevent中相应的函数 ``gevent.sleep()`` 。" #: ../../async.rst:41 msgid "" "If you run this script and point your browser to " "``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and " "`END` show up one by one (rather than waiting 8 seconds to see them all at " "once). It works exactly as with normal threads, but now your server can " "handle thousands of concurrent requests without any problems." msgstr "如果你运行了上面的代码,接着访问 ``http://localhost:8080/stream`` ,你可看到 `START`, `MIDDLE`, 和 `END` 这几个字样依次出现(用时大约8秒)。它像普通的线程一样工作,但是现在你的服务器能同时处理成千上万的连接了。" #: ../../async.rst:45 msgid "" "Some browsers buffer a certain amount of data before they start rendering a " "page. You might need to yield more than a few bytes to see an effect in " "these browsers. Additionally, many browsers have a limit of one concurrent " "connection per URL. If this is the case, you can use a second browser or a " "benchmark tool (e.g. `ab` or `httperf`) to measure performance." msgstr "一些浏览器在开始渲染一个页面之前,会缓存确定容量的数据。在这些浏览器上,你需要返回更多的数据才能看到效果。另外,很多浏览器限制一个URL只使用一个连接。在这种情况下,你可以使用另外的浏览器,或性能测试工具(例如: `ab` 或 `httperf` )来测试性能。" #: ../../async.rst:52 msgid "Event Callbacks" msgstr "事件回调函数" #: ../../async.rst:54 msgid "" "A very common design pattern in asynchronous frameworks (including tornado, " "twisted, node.js and friends) is to use non-blocking APIs and bind callbacks" " to asynchronous events. The socket object is kept open until it is closed " "explicitly to allow callbacks to write to the socket at a later point. Here " "is an example based on the `tornado library " "`_::" msgstr "异步框架的常见设计模式(包括 tornado, twisted, node.js 和 friends),是使用非阻塞的API,绑定回调函数到异步事件上面。在显式地关闭之前,socket会保持打开,以便稍后回调函数往socket里面写东西。下面是一个基于 `tornado `_ 的例子。" #: ../../async.rst:63 msgid "" "The main benefit is that the request handler terminates early. The handling " "thread can move on and accept new requests while the callbacks continue to " "write to sockets of previous requests. This is how these frameworks manage " "to process a lot of concurrent requests with only a small number of OS " "threads." msgstr "主要的好处就是MainHandler能早早结束,在回调函数继续写socket来响应之前的请求的时候,当前线程能继续接受新的请求。这样就是为什么这类框架能同时处理很多请求,只使用很少的操作系统线程。" #: ../../async.rst:65 msgid "" "With Gevent+WSGI, things are different: First, terminating early has no " "benefit because we have an unlimited pool of (pseudo)threads to accept new " "connections. Second, we cannot terminate early because that would close the " "socket (as required by WSGI). Third, we must return an iterable to conform " "to WSGI." msgstr "对于Gevent和WSGI来说,情况就不一样了:首先,早早结束没有好处,因为我们的(伪)线程池已经没有限制了。第二,我们不能早早结束,因为这样会关闭socket(WSGI要求如此)。第三,我们必须返回一个iterator,以遵守WSGI的约定。" #: ../../async.rst:67 msgid "" "In order to conform to the WSGI standard, all we have to do is to return a " "body iterable that we can write to asynchronously. With the help of " "`gevent.queue `_, we can *simulate*" " a detached socket and rewrite the previous example as follows::" msgstr "为了遵循WSGI规范,我们只需返回一个iterable的实体,异步地将其写回客户端。在 `gevent.queue `_ 的帮助下,我们可以 *模拟* 一个脱管的socket,上面的例子可写成这样。" #: ../../async.rst:78 msgid "" "From the server perspective, the queue object is iterable. It blocks if " "empty and stops as soon as it reaches ``StopIteration``. This conforms to " "WSGI. On the application side, the queue object behaves like a non-blocking " "socket. You can write to it at any time, pass it around and even start a new" " (pseudo)thread that writes to it asynchronously. This is how long-polling " "is implemented most of the time." msgstr "从服务器的角度来看,queue对象是iterable的。如果为空,则阻塞,一旦遇到 ``StopIteration`` 则停止。这符合WSGI规范。从应用的角度来看,queue对象表现的像一个不会阻塞socket。你可以在任何时刻写入数据,pass it around,甚至启动一个新的(伪)线程,异步写入。这是在大部分情况下,实现长轮询。" #: ../../async.rst:82 msgid "Finally: WebSockets" msgstr "最后: WebSockets" #: ../../async.rst:84 msgid "" "Lets forget about the low-level details for a while and speak about " "WebSockets. Since you are reading this article, you probably know what " "WebSockets are: A bidirectional communication channel between a browser " "(client) and a web application (server)." msgstr "让我们暂时忘记底层的细节,来谈谈WebSocket。既然你正在阅读这篇文章,你有可能已经知道什么是WebSocket了,一个在浏览器(客户端)和Web应用(服务端)的双向的交流通道。" #: ../../async.rst:86 msgid "" "Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple " "WebSocket endpoint that receives messages and just sends them back to the " "client::" msgstr "感谢 `gevent-websocket `_ 包帮我们做的工作。下面是一个WebSocket的简单例子,接受消息然后将其发回客户端。" #: ../../async.rst:111 msgid "" "The while-loop runs until the client closes the connection. You get the idea" " :)" msgstr "while循环直到客户端关闭连接的时候才会终止。You get the idea :)" #: ../../async.rst:113 msgid "The client-site JavaScript API is really straight forward, too::" msgstr "客户端的JavaScript API也十分简洁明了::" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/changelog.po000066400000000000000000000572561470367422500240410ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../changelog.rst:6 msgid "Release Notes and Changelog" msgstr "发布摘要和更改历史(不译)" #: ../../changelog.rst:9 msgid "Release 0.13" msgstr "" #: ../../changelog.rst:11 msgid "Not released yet." msgstr "" #: ../../changelog.rst:14 msgid "Dropped support for Python versions that reached their end-of-life." msgstr "" #: ../../changelog.rst:15 msgid "" "Keeping up support for ancient Python versions hinders adaptation of new " "features and serves no real purpose. If you need support for older Python " "versions, you can stay on bottle-0.12. The updated list of tested and " "supported python releases is as follows:" msgstr "" #: ../../changelog.rst:20 msgid "Python 2.7 (>= 2.7.3)" msgstr "" #: ../../changelog.rst:21 msgid "Python 3.6" msgstr "" #: ../../changelog.rst:22 msgid "Python 3.7" msgstr "" #: ../../changelog.rst:23 msgid "Python 3.8" msgstr "" #: ../../changelog.rst:24 msgid "Python 3.9" msgstr "" #: ../../changelog.rst:25 msgid "PyPy 2.7" msgstr "" #: ../../changelog.rst:26 msgid "PyPy 3.6" msgstr "" #: ../../changelog.rst:27 msgid "PyPy 3.7" msgstr "" #: ../../changelog.rst:29 msgid "" "Support for Python 2.5 was marked as deprecated since 0.12. We decided to go" " a step further and also remove support for 2.6 and 3.1 to 3.5 even if it " "was never deprecated explicitly in bottle. This means that this release is " "*not* backwards compatible in Python <2.7.3 or <3.6 environments. " "Maintainers for distributions or systems that still use these old python " "versions should not update to Bottle 0.13 and stick with 0.12 instead." msgstr "" #: ../../changelog.rst:35 msgid "Stabilized APIs" msgstr "" #: ../../changelog.rst:36 msgid "" "The documented API of the :class:`ConfigDict` class is now considered stable" " and ready to use." msgstr "" #: ../../changelog.rst:38 msgid "Deprecated APIs" msgstr "" #: ../../changelog.rst:39 msgid "" "The old route syntax (``/hello/:name``) is deprecated in favor of the more " "readable and flexible ``/hello/`` syntax." msgstr "" #: ../../changelog.rst:40 msgid "" ":meth:`Bottle.mount` now recognizes Bottle instance and will warn about " "parameters that are not compatible with the new mounting behavior. The old " "behavior (mount applications as WSGI callable) still works and is used as a " "fallback automatically." msgstr "" #: ../../changelog.rst:41 msgid "The undocumented :func:`local_property` helper is now deprecated." msgstr "" #: ../../changelog.rst:42 msgid "" "The server adapter for google app engine is not useful anymore and marked as" " deprecated." msgstr "" #: ../../changelog.rst:43 msgid "" "Bottle uses pickle to store arbitrary objects into signed cookies. This is " "safe, as long as the signature key remains a secret. Unfortunately, people " "tend to push code with signature keys to github all the time, so we decided " "to remove pickle-support from bottle. Signed cookies will now issue a " "deprecation warning if the value is not a string, and support for non-string" " values will be removed in 0.14. The global :func:`cookie_encode`, " ":func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated." " If you are using this feature, think about using json to serialize your " "objects before storing them into cookies, or switch to a session system that" " stores data server-side instead of client-side." msgstr "" #: ../../changelog.rst:45 msgid "Removed APIs (deprecated since 0.12)" msgstr "" #: ../../changelog.rst:46 msgid "" "Plugins with the old API (``api=1`` or no api attribute) will no longer " "work." msgstr "" #: ../../changelog.rst:47 msgid "" "Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will " "now result in an error instead of a warning." msgstr "" #: ../../changelog.rst:48 msgid "" "The :class:`ConfigDict` class was introduced in 0.11 and changed during " "0.12. These changes are now final." msgstr "" #: ../../changelog.rst:50 msgid "" "Attribute access and assignment was removed due to high overhead and limited" " usability." msgstr "" #: ../../changelog.rst:51 msgid "" "Namespaced sub-instance creation was removed. ``config[\"a\"][\"b\"]`` has a" " high overhead and little benefit over ``config[\"a.b\"]``." msgstr "" #: ../../changelog.rst:52 msgid "" ":class:`ConfigDict` instances are no longer callable. This was a shortcut " "for :meth:`ConfigDict.update`." msgstr "" #: ../../changelog.rst:53 msgid "" ":class:`ConfigDict` constructor no longer accepts any parameters. Use the " "`load_*` methods instead." msgstr "" #: ../../changelog.rst:55 msgid "" "Bottle 0.12 changed some aspects of the Simple Template Engine. These " "changes are now final and the old syntax will now longer work." msgstr "" #: ../../changelog.rst:57 msgid "" "The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. " "Example: ``{{base}}``" msgstr "" #: ../../changelog.rst:58 msgid "" "In STPL Templates, the 'rebase' and 'include' keywords were replaced with " "functions in 0.12." msgstr "" #: ../../changelog.rst:59 msgid "" "PEP-263 encoding strings are no longer recognized. Templates are always " "utf-8." msgstr "" #: ../../changelog.rst:61 msgid "" "The 'geventSocketIO' server adapter was removed without notice. It did not " "work anyway." msgstr "" #: ../../changelog.rst:63 msgid "Changes" msgstr "" #: ../../changelog.rst:64 msgid "These changes might require special care when updating." msgstr "" #: ../../changelog.rst:66 msgid "" "Signed cookies now use a stronger HMAC algorithm by default. This will " "result in old cookies to appear invalid after the update. Pass an explicit " "``digestmod=hashlib.md5`` to :meth:`Request.get_cookie` and " ":meth:`Response.set_cookie` to get the old behavior." msgstr "" #: ../../changelog.rst:68 msgid "Other Improvements" msgstr "" #: ../../changelog.rst:69 msgid "" "Bottle() instances are now context managers. If used in a with-statement, " "the default application changes to the specific instance and the shortcuts " "for many instance methods can be used." msgstr "" #: ../../changelog.rst:70 msgid "" "Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator." msgstr "" #: ../../changelog.rst:71 msgid "" "Added `aiohttp `_ and `uvloop " "`_ server adapters." msgstr "" #: ../../changelog.rst:72 msgid "Added command-line arguments for config from json or ini files." msgstr "" #: ../../changelog.rst:73 msgid "" ":meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts " "them with significantly less overhead than other WSGI applications." msgstr "" #: ../../changelog.rst:74 msgid "" "The :attr:`Request.json` property now accepts ``application/json-rpc`` " "requests." msgstr "" #: ../../changelog.rst:75 msgid "" ":func:`static_file` gained support for ``ETag`` headers. It will generate " "ETags and recognizes ``If-None-Match`` headers." msgstr "" #: ../../changelog.rst:76 msgid "Jinja2 templates will produce better error messages than before." msgstr "" #: ../../changelog.rst:82 msgid "Release 0.12" msgstr "" #: ../../changelog.rst:84 msgid "New SimpleTemplate parser implementation" msgstr "" #: ../../changelog.rst:86 msgid "Support for multi-line code blocks (`<% ... %>`)." msgstr "" #: ../../changelog.rst:87 msgid "" "The keywords `include` and `rebase` are functions now and can accept " "variable template names." msgstr "" #: ../../changelog.rst:89 msgid "" "The new :attr:`BaseRequest.route` property returns the :class:`Route` that " "originally matched the request." msgstr "" #: ../../changelog.rst:90 msgid "" "Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in " "CPythons dict() implementation was fixed over a year ago. If you are still " "using Python 2.5 in production, consider upgrading or at least make sure " "that you get security fixed from your distributor." msgstr "" #: ../../changelog.rst:91 msgid "New :class:`ConfigDict` API (see :doc:`configuration`)" msgstr "" #: ../../changelog.rst:93 msgid "" "More information can be found in this `development blog post " "`_." msgstr "" #: ../../changelog.rst:97 msgid "Release 0.11" msgstr "" #: ../../changelog.rst:99 msgid "" "Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore." msgstr "" #: ../../changelog.rst:100 msgid "" "Support for partial downloads (``Range`` header) in :func:`static_file`." msgstr "" #: ../../changelog.rst:101 msgid "" "The new :class:`ResourceManager` interface helps locating files bundled with" " an application." msgstr "" #: ../../changelog.rst:102 msgid "" "Added a server adapter for `waitress " "`_." msgstr "" #: ../../changelog.rst:103 msgid "" "New :meth:`Bottle.merge` method to install all routes from one application " "into another." msgstr "" #: ../../changelog.rst:104 msgid "" "New :attr:`BaseRequest.app` property to get the application object that " "handles a request." msgstr "" #: ../../changelog.rst:105 msgid "" "Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by " "WTForms)." msgstr "" #: ../../changelog.rst:106 msgid ":class:`MultiDict` and subclasses are now pickle-able." msgstr "" #: ../../changelog.rst:109 msgid "API Changes" msgstr "" #: ../../changelog.rst:110 msgid "" ":attr:`Response.status` is a read-write property that can be assigned either" " a numeric status code or a status string with a reason phrase (``200 OK``)." " The return value is now a string to better match existing APIs (WebOb, " "werkzeug). To be absolutely clear, you can use the read-only properties " ":attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`." msgstr "" #: ../../changelog.rst:113 msgid "API Deprecations" msgstr "" #: ../../changelog.rst:114 msgid "" ":class:`SimpleTALTemplate` is now deprecating. There seems to be no demand." msgstr "" #: ../../changelog.rst:117 msgid "Release 0.10" msgstr "" #: ../../changelog.rst:119 msgid "Plugin API v2" msgstr "" #: ../../changelog.rst:121 msgid "To use the new API, set :attr:`Plugin.api` to ``2``." msgstr "" #: ../../changelog.rst:122 msgid "" ":meth:`Plugin.apply` receives a :class:`Route` object instead of a context " "dictionary as second parameter. The new object offers some additional " "information and may be extended in the future." msgstr "" #: ../../changelog.rst:123 msgid "" "Plugin names are considered unique now. The topmost plugin with a given name" " on a given route is installed, all other plugins with the same name are " "silently ignored." msgstr "" #: ../../changelog.rst:125 msgid "The Request/Response Objects" msgstr "" #: ../../changelog.rst:127 msgid "" "Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, " ":attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and " ":attr:`BaseRequest.script_name`." msgstr "" #: ../../changelog.rst:128 msgid "" "Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` " "attributes. In future releases, :attr:`BaseResponse.status` will return a " "string (e.g. ``200 OK``) instead of an integer to match the API of other " "common frameworks. To make the transition as smooth as possible, you should " "use the verbose attributes from now on." msgstr "" #: ../../changelog.rst:129 msgid "" "Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many " "places. The new dict implementation allows attribute access and handles " "unicode form values transparently." msgstr "" #: ../../changelog.rst:131 msgid "Templates" msgstr "模板" #: ../../changelog.rst:133 msgid "" "Added three new functions to the SimpleTemplate default namespace that " "handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and " ":func:`stpl.setdefault`." msgstr "" #: ../../changelog.rst:134 msgid "" "The default escape function for SimpleTemplate now additionally escapes " "single and double quotes." msgstr "" #: ../../changelog.rst:136 msgid "Routing" msgstr "" #: ../../changelog.rst:138 msgid "" "A new route syntax (e.g. ``/object/``) and support for route " "wildcard filters." msgstr "" #: ../../changelog.rst:139 msgid "Four new wildcard filters: `int`, `float`, `path` and `re`." msgstr "" #: ../../changelog.rst:141 msgid "Other changes" msgstr "" #: ../../changelog.rst:143 msgid "Added command line interface to load applications and start servers." msgstr "" #: ../../changelog.rst:144 msgid "" "Introduced a :class:`ConfigDict` that makes accessing configuration a lot " "easier (attribute access and auto-expanding namespaces)." msgstr "" #: ../../changelog.rst:145 msgid "Added support for raw WSGI applications to :meth:`Bottle.mount`." msgstr "" #: ../../changelog.rst:146 msgid ":meth:`Bottle.mount` parameter order changed." msgstr "" #: ../../changelog.rst:147 msgid "" ":meth:`Bottle.route` now accpets an import string for the ``callback`` " "parameter." msgstr "" #: ../../changelog.rst:148 msgid "Dropped Gunicorn 0.8 support. Current supported version is 0.13." msgstr "" #: ../../changelog.rst:149 msgid "Added custom options to Gunicorn server." msgstr "" #: ../../changelog.rst:150 msgid "" "Finally dropped support for type filters. Replace with a custom plugin of " "needed." msgstr "" #: ../../changelog.rst:154 msgid "Release 0.9" msgstr "" #: ../../changelog.rst:157 msgid "Whats new?" msgstr "" #: ../../changelog.rst:158 msgid "" "A brand new plugin-API. See :ref:`plugins` and :doc:`plugindev` for details." msgstr "" #: ../../changelog.rst:159 msgid "" "The :func:`route` decorator got a lot of new features. See " ":meth:`Bottle.route` for details." msgstr "" #: ../../changelog.rst:160 msgid "" "New server adapters for `gevent `_, `meinheld " "`_ and `bjoern " "`_." msgstr "" #: ../../changelog.rst:161 msgid "Support for SimpleTAL templates." msgstr "" #: ../../changelog.rst:162 msgid "Better runtime exception handling for mako templates in debug mode." msgstr "" #: ../../changelog.rst:163 msgid "Lots of documentation, fixes and small improvements." msgstr "" #: ../../changelog.rst:164 msgid "A new :data:`Request.urlparts` property." msgstr "" #: ../../changelog.rst:167 msgid "Performance improvements" msgstr "" #: ../../changelog.rst:168 msgid "" "The :class:`Router` now special-cases ``wsgi.run_once`` environments to " "speed up CGI." msgstr "" #: ../../changelog.rst:169 msgid "" "Reduced module load time by ~30% and optimized template parser. See `8ccb2d " "`_, `f72a7c `_ and `b14b9a " "`_ for details." msgstr "" #: ../../changelog.rst:170 msgid "" "Support for \"App Caching\" on Google App Engine. See `af93ec " "`_." msgstr "" #: ../../changelog.rst:171 msgid "" "Some of the rarely used or deprecated features are now plugins that avoid " "overhead if the feature is not used." msgstr "" #: ../../changelog.rst:174 ../../changelog.rst:185 msgid "API changes" msgstr "" #: ../../changelog.rst:175 msgid "" "This release is mostly backward compatible, but some APIs are marked " "deprecated now and will be removed for the next release. Most noteworthy:" msgstr "" #: ../../changelog.rst:177 msgid "" "The ``static`` route parameter is deprecated. You can escape wild-cards with" " a backslash." msgstr "" #: ../../changelog.rst:178 msgid "" "Type-based output filters are deprecated. They can easily be replaced with " "plugins." msgstr "" #: ../../changelog.rst:182 msgid "Release 0.8" msgstr "" #: ../../changelog.rst:186 msgid "These changes may break compatibility with previous versions." msgstr "" #: ../../changelog.rst:188 msgid "" "The built-in Key/Value database is not available anymore. It is marked " "deprecated since 0.6.4" msgstr "" #: ../../changelog.rst:189 msgid "The Route syntax and behaviour changed." msgstr "" #: ../../changelog.rst:191 msgid "" "Regular expressions must be encapsulated with ``#``. In 0.6 all non-" "alphanumeric characters not present in the regular expression were allowed." msgstr "" #: ../../changelog.rst:192 msgid "" "Regular expressions not part of a route wildcard are escaped automatically. " "You don't have to escape dots or other regular control characters anymore. " "In 0.6 the whole URL was interpreted as a regular expression. You can use " "anonymous wildcards (``/index:#(\\.html)?#``) to achieve a similar " "behaviour." msgstr "" #: ../../changelog.rst:194 msgid "" "The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead." msgstr "" #: ../../changelog.rst:195 msgid "" "The :class:`SimpleTemplate` engine escapes HTML special characters in " "``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` " "syntax to get old behaviour (no escaping)." msgstr "" #: ../../changelog.rst:196 msgid "" "The :class:`SimpleTemplate` engine returns unicode strings instead of lists " "of byte strings." msgstr "" #: ../../changelog.rst:197 msgid "" "``bottle.optimize()`` and the automatic route optimization is obsolete." msgstr "" #: ../../changelog.rst:198 msgid "Some functions and attributes were renamed:" msgstr "" #: ../../changelog.rst:200 msgid ":attr:`Request._environ` is now :attr:`Request.environ`" msgstr "" #: ../../changelog.rst:201 msgid ":attr:`Response.header` is now :attr:`Response.headers`" msgstr "" #: ../../changelog.rst:202 msgid ":func:`default_app` is obsolete. Use :func:`app` instead." msgstr "" #: ../../changelog.rst:204 msgid "The default :func:`redirect` code changed from 307 to 303." msgstr "" #: ../../changelog.rst:205 msgid "Removed support for ``@default``. Use ``@error(404)`` instead." msgstr "" #: ../../changelog.rst:209 msgid "New features" msgstr "" #: ../../changelog.rst:210 msgid "This is an incomplete list of new features and improved functionality." msgstr "" #: ../../changelog.rst:212 msgid "" "The :class:`Request` object got new properties: :attr:`Request.body`, " ":attr:`Request.auth`, :attr:`Request.url`, :attr:`Request.header`, " ":attr:`Request.forms`, :attr:`Request.files`." msgstr "" #: ../../changelog.rst:213 msgid "" "The :meth:`Response.set_cookie` and :meth:`Request.get_cookie` methods are " "now able to encode and decode python objects. This is called a *secure " "cookie* because the encoded values are signed and protected from changes on " "client side. All pickle-able data structures are allowed." msgstr "" #: ../../changelog.rst:214 msgid "" "The new :class:`Router` class drastically improves performance for setups " "with lots of dynamic routes and supports named routes (named route + dict = " "URL string)." msgstr "" #: ../../changelog.rst:215 msgid "" "It is now possible (and recommended) to return :exc:`HTTPError` and " ":exc:`HTTPResponse` instances or other exception objects instead of raising " "them." msgstr "" #: ../../changelog.rst:216 msgid "" "The new function :func:`static_file` equals :func:`send_file` but returns a " ":exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. " ":func:`send_file` is deprecated." msgstr "" #: ../../changelog.rst:217 msgid "" "New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators." msgstr "" #: ../../changelog.rst:218 msgid "The :class:`SimpleTemplate` engine got full unicode support." msgstr "" #: ../../changelog.rst:219 msgid "Lots of non-critical bugfixes." msgstr "" #: ../../changelog.rst:225 msgid "Contributors" msgstr "" #: ../../../AUTHORS:1 msgid "" "Bottle is written and maintained by Marcel Hellkamp ." msgstr "" #: ../../../AUTHORS:3 msgid "" "Thanks to all the people who found bugs, sent patches, spread the word, " "helped each other on the mailing-list and made this project possible. I hope" " the following (alphabetically sorted) list is complete. If you miss your " "name on that list (or want your name removed) please :doc:`tell me " "` or add it yourself." msgstr "" #: ../../../AUTHORS:5 msgid "acasajus" msgstr "" #: ../../../AUTHORS:6 msgid "Adam R. Smith" msgstr "" #: ../../../AUTHORS:7 msgid "Alexey Borzenkov" msgstr "" #: ../../../AUTHORS:8 msgid "Alexis Daboville" msgstr "" #: ../../../AUTHORS:9 msgid "Anton I. Sipos" msgstr "" #: ../../../AUTHORS:10 msgid "Anton Kolechkin" msgstr "" #: ../../../AUTHORS:11 msgid "apexi200sx" msgstr "" #: ../../../AUTHORS:12 msgid "apheage" msgstr "" #: ../../../AUTHORS:13 msgid "BillMa" msgstr "" #: ../../../AUTHORS:14 msgid "Brad Greenlee" msgstr "" #: ../../../AUTHORS:15 msgid "Brandon Gilmore" msgstr "" #: ../../../AUTHORS:16 msgid "Branko Vukelic" msgstr "" #: ../../../AUTHORS:17 msgid "Brian Sierakowski" msgstr "" #: ../../../AUTHORS:18 msgid "Brian Wickman" msgstr "" #: ../../../AUTHORS:19 msgid "Carl Scharenberg" msgstr "" #: ../../../AUTHORS:20 msgid "Damien Degois" msgstr "" #: ../../../AUTHORS:21 msgid "David Buxton" msgstr "" #: ../../../AUTHORS:22 msgid "Duane Johnson" msgstr "" #: ../../../AUTHORS:23 msgid "fcamel" msgstr "" #: ../../../AUTHORS:24 msgid "Frank Murphy" msgstr "" #: ../../../AUTHORS:25 msgid "Frederic Junod" msgstr "" #: ../../../AUTHORS:26 msgid "goldfaber3012" msgstr "" #: ../../../AUTHORS:27 msgid "Greg Milby" msgstr "" #: ../../../AUTHORS:28 msgid "gstein" msgstr "" #: ../../../AUTHORS:29 msgid "Ian Davis" msgstr "" #: ../../../AUTHORS:30 msgid "Itamar Nabriski" msgstr "" #: ../../../AUTHORS:31 msgid "Iuri de Silvio" msgstr "" #: ../../../AUTHORS:32 msgid "Jaimie Murdock" msgstr "" #: ../../../AUTHORS:33 msgid "Jeff Nichols" msgstr "" #: ../../../AUTHORS:34 msgid "Jeremy Kelley" msgstr "" #: ../../../AUTHORS:35 msgid "joegester" msgstr "" #: ../../../AUTHORS:36 msgid "Johannes Krampf" msgstr "" #: ../../../AUTHORS:37 msgid "Jonas Haag" msgstr "" #: ../../../AUTHORS:38 msgid "Joshua Roesslein" msgstr "" #: ../../../AUTHORS:39 msgid "Judson Neer" msgstr "" #: ../../../AUTHORS:40 msgid "Karl" msgstr "" #: ../../../AUTHORS:41 msgid "Kevin Zuber" msgstr "" #: ../../../AUTHORS:42 msgid "Kraken" msgstr "" #: ../../../AUTHORS:43 msgid "Kyle Fritz" msgstr "" #: ../../../AUTHORS:44 msgid "m35" msgstr "" #: ../../../AUTHORS:45 msgid "Marcos Neves" msgstr "" #: ../../../AUTHORS:46 msgid "masklinn" msgstr "" #: ../../../AUTHORS:47 msgid "Michael Labbe" msgstr "" #: ../../../AUTHORS:48 msgid "Michael Soulier" msgstr "" #: ../../../AUTHORS:49 msgid "`reddit `_" msgstr "" #: ../../../AUTHORS:50 msgid "Nicolas Vanhoren" msgstr "" #: ../../../AUTHORS:51 msgid "Oz N Tiram" msgstr "" #: ../../../AUTHORS:52 msgid "Robert Rollins" msgstr "" #: ../../../AUTHORS:53 msgid "rogererens" msgstr "" #: ../../../AUTHORS:54 msgid "rwxrwx" msgstr "" #: ../../../AUTHORS:55 msgid "Santiago Gala" msgstr "" #: ../../../AUTHORS:56 msgid "Sean M. Collins" msgstr "" #: ../../../AUTHORS:57 msgid "Sebastian Wollrath" msgstr "" #: ../../../AUTHORS:58 msgid "Seth" msgstr "" #: ../../../AUTHORS:59 msgid "Sigurd Høgsbro" msgstr "" #: ../../../AUTHORS:60 msgid "Stuart Rackham" msgstr "" #: ../../../AUTHORS:61 msgid "Sun Ning" msgstr "" #: ../../../AUTHORS:62 msgid "Tomás A. Schertel" msgstr "" #: ../../../AUTHORS:63 msgid "Tristan Zajonc" msgstr "" #: ../../../AUTHORS:64 msgid "voltron" msgstr "" #: ../../../AUTHORS:65 msgid "Wieland Hoffmann" msgstr "" #: ../../../AUTHORS:66 msgid "zombat" msgstr "" #: ../../../AUTHORS:67 msgid "Thiago Avelino" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/configuration.po000066400000000000000000000316131470367422500247460ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../configuration.rst:3 msgid "Configuration (DRAFT)" msgstr "配置文件(初稿)" #: ../../configuration.rst:8 msgid "" "This is a draft for a new API. `Tell us `_" " what you think." msgstr "这是一个新的API, 可以 `告诉我们 `_ 你的想法" #: ../../configuration.rst:10 msgid "" "Bottle applications can store their configuration in :attr:`Bottle.config`, " "a dict-like object and central place for application specific settings. This" " dictionary controls many aspects of the framework, tells (newer) plugins " "what to do, and can be used to store your own configuration as well." msgstr "Bottle应用可以在 :attr:`Bottle.config` 这个类似于字典的对象中,存储它们的配置。这个对象在很多方面,影响着Bottle框架和相应的插件。你也可以在这个对象中,存储你的自定义配置。" #: ../../configuration.rst:13 msgid "Configuration Basics" msgstr "基础知识" #: ../../configuration.rst:15 msgid "" "The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. " "All the common dict methods work as expected. Let us start with some " "examples::" msgstr " :attr:`Bottle.config` 这个对象,可以当成一个字典来使用,让我们举个例子::" #: ../../configuration.rst:44 msgid "" "The app object is not always available, but as long as you are within a " "request context, you can use the `request` object to get the current " "application and its configuration::" msgstr "app对象不一定总是可用的,但只要你在处理一个请求,你可以使用 `request` 对象来获得当前的应用对象和它的配置::" #: ../../configuration.rst:51 msgid "Naming Convention" msgstr "命名约定" #: ../../configuration.rst:53 msgid "" "To make life easier, plugins and applications should follow some simple " "rules when it comes to config parameter names:" msgstr "方便起见,插件和应用应该遵循一些简单的规则,特别是在给配置参数命名的时候:" #: ../../configuration.rst:55 msgid "" "All keys should be lowercase strings and follow the rules for python " "identifiers (no special characters but the underscore)." msgstr "所有的key都应该是小写的字符串,并符合Python的变量命名规则(除了下划线外,没有特殊字符)。" #: ../../configuration.rst:56 msgid "" "Namespaces are separated by dots (e.g. ``namespace.field`` or " "``namespace.subnamespace.field``)." msgstr "命名空间通过点来区分(例如: ``namespace.field`` 或 ``namespace.subnamespacew.field`` )。" #: ../../configuration.rst:57 msgid "" "Bottle uses the root namespace for its own configuration. Plugins should " "store all their variables in their own namespace (e.g. ``sqlite.db`` or " "``werkzeug.use_debugger``)." msgstr "Bottle框架,使用根命名空间来存储它的配置。插件应该在它们自己的命名空间中存储它们的变量(例如: `sqlite.db`` 或 ``werkzeug.use_debugger`` )。" #: ../../configuration.rst:58 msgid "" "Your own application should use a separate namespace (e.g. ``myapp.*``)." msgstr "你的应用应该使用一个独立的命名空间(例如: ``myapp.*`` )。" #: ../../configuration.rst:62 msgid "Loading Configuration from a File" msgstr "从文件中加载配置" #: ../../configuration.rst:66 msgid "" "Configuration files are useful if you want to enable non-programmers to " "configure your application, or just don't want to hack python module files " "just to change the database port. A very common syntax for configuration " "files is shown here:" msgstr "在你不想通过修改代码来修改配置的时候,配置文件是非常有用的。常见的配置文件语法如下:" #: ../../configuration.rst:78 msgid "" "With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style " "configuration files from disk and import their values into your existing " "configuration::" msgstr "通过 :meth:`ConfigDict.load_config` 方法,你可以从一些ini文件中导入配置::" #: ../../configuration.rst:85 msgid "Loading Configuration from a python module" msgstr "" #: ../../configuration.rst:89 msgid "" "Loading configuration from a Python module is a common pattern for Python " "programs and frameworks. Bottle assumes that configuration keys are all " "upper case:" msgstr "" #: ../../configuration.rst:98 msgid "" "You can load the this Python module with :met:`ConfigDict.load_module`::" msgstr "" #: ../../configuration.rst:107 msgid "" "Note the second parameter to disable loading as namespaced items as in " ":meth:`ConfigDict.load_dict`. By default, loading from a Python module will " "call this method, unless you specifically call this method with `False` as " "the second argument." msgstr "" #: ../../configuration.rst:110 msgid "Loading Configuration from a nested :class:`dict`" msgstr "从字典中加载配置" #: ../../configuration.rst:114 msgid "" "Another useful method is :meth:`ConfigDict.load_dict`. This method takes an " "entire structure of nested dictionaries and turns it into a flat list of " "keys and values with namespaced keys::" msgstr "另外一个有用的方法,是 :meth:`ConfigDict.load_dict` 。将字典中的配置,放到各自的命名空间下面::" #: ../../configuration.rst:135 msgid "Listening to configuration changes" msgstr "监听配置的变更" #: ../../configuration.rst:139 msgid "" "The ``config`` hook on the application object is triggered each time a value" " in :attr:`Bottle.config` is changed. This hook can be used to react on " "configuration changes at runtime, for example reconnect to a new database, " "change the debug settings on a background service or resize worker thread " "pools. The hook callback receives two arguments (key, new_value) and is " "called before the value is actually changed in the dictionary. Raising an " "exception from a hook callback cancels the change and the old value is " "preserved." msgstr "每次 :attr:`Bottle.config` 中的值有变更的时候,会触发 ``config`` 这个钩子。这个钩子可以用于在运行时,对配置的改动做出响应,例如连接到一个新的数据库,改变后台服务的debug配置,或更改线程池的大小。这个钩子接收两个参数(key, new_value),在 :attr:`Bottle.config` 中的值被改动之前触发。如果这个钩子抛出了异常,那么 :attr:`Bottle.config` 中的值将不会被改动。" #: ../../configuration.rst:148 msgid "" "The hook callbacks cannot *change* the value that is to be stored to the " "dictionary. That is what filters are for." msgstr "这个钩子不能 *改变* 将要存到 :attr:`Bottle.config` 对象中的值。做这件事的是filter(过滤器)。" #: ../../configuration.rst:154 msgid "Filters and other Meta Data" msgstr "过滤器和其它元数据" #: ../../configuration.rst:158 msgid "" ":class:`ConfigDict` allows you to store meta data along with configuration " "keys. Two meta fields are currently defined:" msgstr ":class:`ConfigDict` 对象允许你给配置中每个key定义元数据。当前定义了help和filter:" #: ../../configuration.rst:162 msgid "help" msgstr "" #: ../../configuration.rst:161 msgid "" "A help or description string. May be used by debugging, introspection or " "admin tools to help the site maintainer configuring their application." msgstr "一个描述字符串。可以被debug或管理工具利用,来帮助网站管理员填写配置。" #: ../../configuration.rst:165 msgid "filter" msgstr "" #: ../../configuration.rst:165 msgid "" "A callable that accepts and returns a single value. If a filter is defined " "for a key, any new value stored to that key is first passed through the " "filter callback. The filter can be used to cast the value to a different " "type, check for invalid values (throw a ValueError) or trigger side effects." msgstr "一个可运行的对象,接受和返回一个值。如果一个key定义了一个filter,任何将要存到这个key中的值,都会先传给filter的相应回调函数。在回调函数中,可做类型转换,有效性检验等工作。" #: ../../configuration.rst:167 msgid "" "This feature is most useful for plugins. They can validate their config " "parameters or trigger side effects using filters and document their " "configuration via ``help`` fields::" msgstr "这个功能比较适合被插件使用。它们可以检查它们的配置参数,或触发其它动作,或在 ``help`` 字段中,给配置添加说明::" #: ../../configuration.rst:189 msgid "API Documentation" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:1 msgid "" "A dict-like configuration storage with additional support for namespaces, " "validators, meta-data, overlays and more." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict:4 msgid "" "This dict-like class is heavily optimized for read access. All read-only " "methods as well as item access should be as fast as the built-in dict." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:1 msgid "Load values from a Python module." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:3 msgid "Example modue ``config.py``::" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:0 #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:0 msgid "Parameters" msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_module:17 msgid "" "If true (default), dictionary values are assumed to represent namespaces " "(see :meth:`load_dict`)." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:1 msgid "Load values from an ``*.ini`` style config file." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:3 msgid "" "A configuration file consists of sections, each led by a ``[section]`` " "header, followed by key/value entries separated by either ``=`` or ``:``. " "Section names and keys are case-insensitive. Leading and trailing whitespace" " is removed from keys and values. Values can be omitted, in which case the " "key/value delimiter may also be left out. Values can also span multiple " "lines, as long as they are indented deeper than the first line of the value." " Commands are prefixed by ``#`` or ``;`` and may only appear on their own on" " an otherwise empty line." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:13 msgid "" "Both section and key names may contain dots (``.``) as namespace separators." " The actual configuration parameter name is constructed by joining section " "name and key name together and converting to lower case." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:18 msgid "" "The special sections ``bottle`` and ``ROOT`` refer to the root namespace and" " the ``DEFAULT`` section defines default values for all other sections." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:22 msgid "With Python 3, extended string interpolation is enabled." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:24 msgid "The path of a config file, or a list of paths." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_config:25 msgid "" "All keyword parameters are passed to the underlying " ":class:`python:configparser.ConfigParser` constructor call." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.load_dict:1 msgid "" "Load values from a dictionary structure. Nesting can be used to represent " "namespaces." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.update:1 msgid "" "If the first parameter is a string, all keys are prefixed with this " "namespace. Apart from that it works just as the usual dict.update()." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:1 msgid "Insert key with a value of default if key is not in the dictionary." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.setdefault:3 msgid "Return the value for key if key is in the dictionary, else default." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_get:1 msgid "Return the value of a meta field for a key." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_set:1 msgid "Set the meta field for a key to a new value." msgstr "" #: ../../../bottle.pydocstring of bottle.ConfigDict.meta_list:1 msgid "Return an iterable of meta field names defined for a key." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/contact.po000066400000000000000000000046611470367422500235350ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../contact.rst:3 msgid "Contact" msgstr "" #: ../../contact.rst:6 msgid "About the Author" msgstr "" #: ../../contact.rst:7 msgid "" "Hi, I'm *Marcel Hellkamp* (aka *defnull*), author of Bottle and the guy " "behind this website. I'm 27 years old and studying computer science at the " "Georg-August-University in Göttingen, Germany. Python is my favorite " "language, but I also code in ruby and JavaScript a lot. Watch me on `twitter" " `_ or visit my profile at `GitHub " "`_ to get in contact. A `mailinglist " "`_ is open for Bottle related " "questions, too." msgstr "" #: ../../contact.rst:10 msgid "About Bottle" msgstr "关于Bottle" #: ../../contact.rst:11 msgid "" "This is my first open source project so far. It started and a small " "experiment but soon got so much positive feedback I decided to make " "something real out of it. Here it is." msgstr "" #: ../../contact.rst:14 msgid "Impressum und Kontaktdaten" msgstr "" #: ../../contact.rst:15 msgid "" "(This is required by `German law " "`_)" msgstr "" #: ../../contact.rst:17 msgid "" "Die Nutzung der folgenden Kontaktdaten ist ausschließlich für die " "Kontaktaufnahme mit dem Betreiber dieser Webseite bei rechtlichen Problemen " "vorgesehen. Insbesondere die Nutzung zu Werbe- oder ähnlichen Zwecken ist " "ausdrücklich untersagt." msgstr "" #: ../../contact.rst:22 msgid "**Betreiber**: Marcel Hellkamp" msgstr "" #: ../../contact.rst:23 msgid "**Ort**: D - 37075 Göttingen" msgstr "" #: ../../contact.rst:24 msgid "**Strasse**: Theodor-Heuss Strasse 13" msgstr "" #: ../../contact.rst:25 msgid "**Telefon**: +49 (0) 551 20005915" msgstr "" #: ../../contact.rst:26 msgid "**E-Mail**: marc at gsites dot de" msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/deployment.po000066400000000000000000000331751470367422500242640ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../deployment.rst:27 msgid "Deployment" msgstr "部署" #: ../../deployment.rst:29 msgid "" "The bottle :func:`run` function, when called without any parameters, starts " "a local development server on port 8080. You can access and test your " "application via http://localhost:8080/ if you are on the same host." msgstr "不添加任何参数,直接运行Bottle的 :func:`run` 函数,会启动一个本地的开发服务器,监听8080端口。你可在同一部主机上访问http://localhost:8080/来测试你的应用。" #: ../../deployment.rst:31 msgid "" "To get your application available to the outside world, specify the IP the " "server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server" " listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The " "listening port can be changed in a similar way, but you need root or admin " "rights to choose a port below 1024. Port 80 is the standard for HTTP " "servers::" msgstr "" #: ../../deployment.rst:37 msgid "Server Options" msgstr "可选服务器" #: ../../deployment.rst:39 msgid "" "The built-in default server is based on `wsgiref WSGIServer " "`_. This non-threading HTTP server is perfectly fine " "for development, but may become a performance bottleneck when server load " "increases. There are three ways to eliminate this bottleneck:" msgstr "" #: ../../deployment.rst:41 msgid "" "Use a different server that is either multi-threaded or supports " "asynchronous IO." msgstr "" #: ../../deployment.rst:42 msgid "" "Start multiple server processes and spread the load with a load-balancer." msgstr "运行多个服务器,使用负载均衡" #: ../../deployment.rst:43 msgid "Do both." msgstr "同时使用上面两种方法" #: ../../deployment.rst:45 msgid "" "**Multi-threaded** servers are the 'classic' way to do it. They are very " "robust, reasonably fast and easy to manage. As a drawback, they can only " "handle a limited number of connections at the same time and utilize only one" " CPU core due to the \"Global Interpreter Lock\" (GIL) of the Python " "runtime. This does not hurt most applications, they are waiting for network " "IO most of the time anyway, but may slow down CPU intensive tasks (e.g. " "image processing)." msgstr "" #: ../../deployment.rst:47 msgid "" "**Asynchronous IO** servers are very fast, can handle a virtually unlimited " "number of concurrent connections and are easy to manage. To take full " "advantage of their potential, you need to design your application " "accordingly and understand the concepts of the specific server." msgstr "" #: ../../deployment.rst:49 msgid "" "**Multi-processing** (forking) servers are not limited by the GIL and " "utilize more than one CPU core, but make communication between server " "instances more expensive. You need a database or external message query to " "share state between processes, or design your application so that it does " "not need any shared state. The setup is also a bit more complicated, but " "there are good tutorials available." msgstr "**多进程** (forking) 服务器就没有受到GIL的限制,能利用多个CPU核心,但服务器实例之间的交流代价比较高昂。你需要一个数据库或消息队列来在进程之间共享状态,或将你的应用设计成根本不需要共享状态。多进程服务器的安装也比较负责,但已经有很多好的教程了。" #: ../../deployment.rst:52 msgid "Switching the Server Backend" msgstr "更改服务器后端" #: ../../deployment.rst:54 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded default server::" msgstr "" #: ../../deployment.rst:58 msgid "" "Bottle ships with a lot of ready-to-use adapters for the most common WSGI " "servers and automates the setup process. Here is an incomplete list:" msgstr "Bottle为很多常见的WSGI服务器都编写了适配器,能自动化安装过程。下面是一个不完整的清单:" #: ../../deployment.rst:61 msgid "Name" msgstr "名称" #: ../../deployment.rst:61 msgid "Homepage" msgstr "主页" #: ../../deployment.rst:61 msgid "Description" msgstr "描述" #: ../../deployment.rst:63 msgid "cgi" msgstr "" #: ../../deployment.rst:63 msgid "Run as CGI script" msgstr "" #: ../../deployment.rst:64 msgid "flup" msgstr "" #: ../../deployment.rst:64 msgid "flup_" msgstr "" #: ../../deployment.rst:64 msgid "Run as FastCGI process" msgstr "" #: ../../deployment.rst:65 msgid "gae" msgstr "" #: ../../deployment.rst:65 msgid "gae_" msgstr "" #: ../../deployment.rst:65 msgid "Helper for Google App Engine deployments" msgstr "用于Google App Engine" #: ../../deployment.rst:66 msgid "wsgiref" msgstr "" #: ../../deployment.rst:66 msgid "wsgiref_" msgstr "" #: ../../deployment.rst:66 msgid "Single-threaded default server" msgstr "默认的单线程服务器" #: ../../deployment.rst:67 msgid "cherrypy" msgstr "" #: ../../deployment.rst:67 msgid "cherrypy_" msgstr "" #: ../../deployment.rst:67 msgid "Multi-threaded and very stable" msgstr "多线程,稳定" #: ../../deployment.rst:68 msgid "paste" msgstr "" #: ../../deployment.rst:68 msgid "paste_" msgstr "" #: ../../deployment.rst:68 msgid "Multi-threaded, stable, tried and tested" msgstr "多线程,稳定,久经考验,充分测试" #: ../../deployment.rst:69 msgid "waitress" msgstr "" #: ../../deployment.rst:69 msgid "waitress_" msgstr "" #: ../../deployment.rst:69 msgid "Multi-threaded, poweres Pyramid" msgstr "多线程,源于Pyramid" #: ../../deployment.rst:70 msgid "gunicorn" msgstr "" #: ../../deployment.rst:70 msgid "gunicorn_" msgstr "" #: ../../deployment.rst:70 msgid "Pre-forked, partly written in C" msgstr "" #: ../../deployment.rst:71 msgid "eventlet" msgstr "" #: ../../deployment.rst:71 msgid "eventlet_" msgstr "" #: ../../deployment.rst:71 msgid "Asynchronous framework with WSGI support." msgstr "支持WSGI的异步框架" #: ../../deployment.rst:72 msgid "gevent" msgstr "" #: ../../deployment.rst:72 msgid "gevent_" msgstr "" #: ../../deployment.rst:72 ../../deployment.rst:73 msgid "Asynchronous (greenlets)" msgstr "异步 (greenlets)" #: ../../deployment.rst:73 msgid "diesel" msgstr "" #: ../../deployment.rst:73 msgid "diesel_" msgstr "" #: ../../deployment.rst:74 msgid "tornado" msgstr "" #: ../../deployment.rst:74 msgid "tornado_" msgstr "" #: ../../deployment.rst:74 msgid "Asynchronous, powers some parts of Facebook" msgstr "异步,支撑Facebook的部分应用" #: ../../deployment.rst:75 msgid "twisted" msgstr "" #: ../../deployment.rst:75 msgid "twisted_" msgstr "" #: ../../deployment.rst:75 msgid "Asynchronous, well tested but... twisted" msgstr "异步, well tested but... twisted" #: ../../deployment.rst:76 msgid "meinheld" msgstr "" #: ../../deployment.rst:76 msgid "meinheld_" msgstr "" #: ../../deployment.rst:76 msgid "Asynchronous, partly written in C" msgstr "异步,部分用C语言编写" #: ../../deployment.rst:77 msgid "bjoern" msgstr "" #: ../../deployment.rst:77 msgid "bjoern_" msgstr "" #: ../../deployment.rst:77 msgid "Asynchronous, very fast and written in C" msgstr "异步,用C语言编写,非常快" #: ../../deployment.rst:78 msgid "auto" msgstr "" #: ../../deployment.rst:78 msgid "Automatically selects an available server adapter" msgstr "自动选择一个可用的服务器" #: ../../deployment.rst:81 msgid "The full list is available through :data:`server_names`." msgstr "完整的列表在 :data:`server_names` 。" #: ../../deployment.rst:83 msgid "" "If there is no adapter for your favorite server or if you need more control " "over the server setup, you may want to start the server manually. Refer to " "the server documentation on how to run WSGI applications. Here is an example" " for paste_::" msgstr "如果没有适合你的服务器的适配器,或者你需要更多地控制服务器的安装,你也许需要手动启动服务器。可参考你的服务器的文档,看看是如何运行一个WSGI应用。下面是一个使用 paste_ 的例子。" #: ../../deployment.rst:91 msgid "Apache mod_wsgi" msgstr "" #: ../../deployment.rst:93 msgid "" "Instead of running your own HTTP server from within Bottle, you can attach " "Bottle applications to an `Apache server `_ using mod_wsgi_." msgstr "除了直接在Bottle里面运行HTTP服务器,你也可以将你的应用部署到一个Apache服务器上,使用 mod_wsgi_ 来运行。" #: ../../deployment.rst:95 msgid "" "All you need is an ``app.wsgi`` file that provides an ``application`` " "object. This object is used by mod_wsgi to start your application and should" " be a WSGI-compatible Python callable." msgstr "你需要的只是提供一个 ``application`` 对象的 ``app.wsgi`` 文件。mod_wsgi会使用这个对象来启动你的应用,这个对象必须是兼容WSGI的 callable对象。" #: ../../deployment.rst:97 msgid "File ``/var/www/yourapp/app.wsgi``::" msgstr " ``/var/www/yourapp/app.wsgi`` 文件 " #: ../../deployment.rst:108 msgid "The Apache configuration may look like this::" msgstr "Apache的配置" #: ../../deployment.rst:126 msgid "uWSGI" msgstr "" #: ../../deployment.rst:128 msgid "" "uWSGI_ is a modern alternative to FastCGI and the recommended deployment " "option on servers like nginx_, lighttpd_, and cherokee_. The uWSGI project " "provides an application server that runs your application, and defines a " "protocol that frontend webservers can speak to. Have a look at the excellent" " `Quickstart for Python/WSGI applications `_." msgstr "" #: ../../deployment.rst:132 msgid "Google AppEngine" msgstr "" #: ../../deployment.rst:136 msgid "" "New App Engine applications using the Python 2.7 runtime environment support" " any WSGI application and should be configured to use the Bottle application" " object directly. For example suppose your application's main module is " "``myapp.py``::" msgstr "" #: ../../deployment.rst:146 msgid "" "Then you can configure App Engine's ``app.yaml`` to use the ``app`` object " "like so::" msgstr "" #: ../../deployment.rst:158 msgid "" "It is always a good idea to let GAE serve static files directly. Here is " "example for a working ``app.yaml`` (using the legacy Python 2.5 runtime " "environment)::" msgstr "" #: ../../deployment.rst:175 msgid "Load Balancer (Manual Setup)" msgstr "负载均衡 (手动安装)" #: ../../deployment.rst:177 msgid "" "A single Python process can utilize only one CPU at a time, even if there " "are more CPU cores available. The trick is to balance the load between " "multiple independent Python processes to utilize all of your CPU cores." msgstr "单一的Python进程一次只能使用一个CPU内核,即使CPU是多核的。我们的方法就是在多核CPU的机器上,使用多线程来实现负载均衡。" #: ../../deployment.rst:179 msgid "" "Instead of a single Bottle application server, you start one instance for " "each CPU core available using different local port (localhost:8080, 8081, " "8082, ...). You can choose any server adapter you want, even asynchronous " "ones. Then a high performance load balancer acts as a reverse proxy and " "forwards each new requests to a random port, spreading the load between all " "available back-ends. This way you can use all of your CPU cores and even " "spread out the load between different physical servers." msgstr "不只是启动一个应用服务器,你需要同时启动多个应用服务器,监听不同的端口(localhost:8080, 8081, 8082, ...)。你可选择任何服务器,甚至那些异步服务器。然后一个高性能的负载均衡器,像一个反向代理那样工作,将新的请求发送到一个随机端口,在多个服务器之间分散压力。这样你就可以利用所有的CPU核心,甚至在多个机器上实现负载均衡。" #: ../../deployment.rst:181 msgid "" "One of the fastest load balancers available is Pound_ but most common web " "servers have a proxy-module that can do the work just fine." msgstr " Pound_ 是最快的负载均衡器之一,但是只要有代理模块的Web服务器,也可以充当这一角色。" #: ../../deployment.rst:183 msgid "Pound example::" msgstr "Pound的例子::" #: ../../deployment.rst:201 msgid "Apache example::" msgstr "Apache的例子::" #: ../../deployment.rst:209 msgid "Lighttpd example::" msgstr "Lighttpd的例子::" #: ../../deployment.rst:221 msgid "Good old CGI" msgstr "CGI这个老好人" #: ../../deployment.rst:223 msgid "" "A CGI server starts a new process for each request. This adds a lot of " "overhead but is sometimes the only option, especially on cheap hosting " "packages. The `cgi` server adapter does not actually start a CGI server, but" " transforms your bottle application into a valid CGI application::" msgstr "CGI服务器会为每个请求启动一个进程。虽然这样代价高昂,但有时这是唯一的选择。 `cgi` 这个适配器实际上并没有启动一个CGI服务器,只是将你的Bottle应用转换成了一个有效的CGI应用。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/development.po000066400000000000000000000552641470367422500244310ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../development.rst:2 msgid "Developer Notes" msgstr "开发者笔记" #: ../../development.rst:4 msgid "" "This document is intended for developers and package maintainers interested " "in the bottle development and release workflow. If you want to contribute, " "you are just right!" msgstr "这份文档是为那些对Bottle的开发和发布流程感兴趣的开发者和软件包维护者准备的。如果你想要做贡献,看它是对的!" #: ../../development.rst:8 msgid "Get involved" msgstr "参与进来" #: ../../development.rst:10 msgid "" "There are several ways to join the community and stay up to date. Here are " "some of them:" msgstr "有多种加入社区的途径,保持消息的灵通。这里是一些方法:" #: ../../development.rst:12 msgid "" "**Mailing list**: Join our mailing list by sending an email to " "`bottlepy+subscribe@googlegroups.com " "`_ (no google account required)." msgstr "**邮件列表**: 发送邮件到 `bottlepy+subscribe@googlegroups.com `_ 以加入我们的邮件列表(无需Google账户)" #: ../../development.rst:13 msgid "" "**Twitter**: `Follow us on Twitter `_ or " "search for the `#bottlepy `_ tag." msgstr "" #: ../../development.rst:14 msgid "" "**IRC**: Join `#bottlepy on irc.freenode.net " "`_ or use the `web chat interface " "`_." msgstr "**IRC**: 加入 `#irc.freenode.net上的bottlepy频道 `_ 或使用 `web聊天界面 `_ " #: ../../development.rst:15 msgid "" "**Google plus**: We sometimes `blog about Bottle, releases and technical " "stuff " "`_" " on our Google+ page." msgstr "**Google plus**: 有时我们会在Google+页面上发表一些 `与Bottle有关的博客 `_ " #: ../../development.rst:19 msgid "Get the Sources" msgstr "获取源代码" #: ../../development.rst:21 msgid "" "The bottle `development repository `_ " "and the `issue tracker `_ are " "both hosted at `github `_. If you plan " "to contribute, it is a good idea to create an account there and fork the " "main repository. This way your changes and ideas are visible to other " "developers and can be discussed openly. Even without an account, you can " "clone the repository or just download the latest development version as a " "source archive." msgstr "Bottle的 `开发仓库 `_ 和 `问题追踪 `_ 都搭建在 `github `_ 上面。如果你打算做贡献,创建一个github帐号然后fork一下吧。你做出的更改或建议都可被其他开发者看到,可以一起讨论。即使没有github帐号,你也可以clone代码仓库,或下载最新开发版本的压缩包。" #: ../../development.rst:23 msgid "**git:** ``git clone git://github.com/bottlepy/bottle.git``" msgstr "**git:** ``git clone git://github.com/bottlepy/bottle.git``" #: ../../development.rst:24 msgid "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" msgstr "**git/https:** ``git clone https://github.com/bottlepy/bottle.git``" #: ../../development.rst:25 msgid "" "**Download:** Development branch as `tar archive " "`_ or `zip file " "`_." msgstr "**Download:** Development branch as `tar archive `_ or `zip file `_." #: ../../development.rst:26 msgid "" "**Translations:** `transifex.com/projects/p/bottle " "`_" msgstr "" #: ../../development.rst:30 msgid "Releases and Updates" msgstr "发布和更新" #: ../../development.rst:32 msgid "" "Bottle is released at irregular intervals and distributed through `PyPI " "`_. Release candidates and bugfix-" "revisions of outdated releases are only available from the git repository " "mentioned above. Some Linux distributions may offer packages for outdated " "releases, though." msgstr "" #: ../../development.rst:34 msgid "" "The Bottle version number splits into three parts " "(**major.minor.revision**). These are *not* used to promote new features but" " to indicate important bug-fixes and/or API changes. Critical bugs are fixed" " in at least the two latest minor releases and announced in all available " "channels (mailinglist, twitter, github). Non-critical bugs or features are " "not guaranteed to be backported. This may change in the future, through." msgstr "Bottle的版本号分隔为三个部分(**major.minor.revision**)。版本号 *不会* 用于引入新特征,只是为了指出重要的bug-fix或API的改动。关键的bug会在近两个新的版本中修复,然后通过所有渠道发布(邮件列表, twitter, github)。不重要的bug修复或特征不保证添加到旧版本中。这个情况在未来也许会改变。" #: ../../development.rst:37 msgid "Major Release (x.0)" msgstr "" #: ../../development.rst:37 msgid "" "The major release number is increased on important milestones or updates " "that completely break backward compatibility. You probably have to work over" " your entire application to use a new release. These releases are very rare," " through." msgstr "在重要的里程碑达成或新的更新和旧版本彻底不兼容时,会增加major版本号。为了使用新版本,你也许需要修改整个应用,但major版本号极少会改变。" #: ../../development.rst:40 msgid "Minor Release (x.y)" msgstr "" #: ../../development.rst:40 msgid "" "The minor release number is increased on updates that change the API or " "behaviour in some way. You might get some depreciation warnings any may have" " to tweak some configuration settings to restore the old behaviour, but in " "most cases these changes are designed to be backward compatible for at least" " one minor release. You should update to stay up do date, but don't have to." " An exception is 0.8, which *will* break backward compatibility hard. (This " "is why 0.7 was skipped). Sorry about that." msgstr "在更改了API之后,或增加minor版本号。你可能会收到一些API已过时的警告,调整设置以继续使用旧的特征,但在大多数情况下,这些更新都会对旧版本兼容。你应当保持更新,但这不是必须的。0.8版本是一个特例,它 *不兼容* 旧版本(所以我们跳过了0.7版本直接发布0.8版本),不好意思。" #: ../../development.rst:43 msgid "Revision (x.y.z)" msgstr "" #: ../../development.rst:43 msgid "" "The revision number is increased on bug-fixes and other patches that do not " "change the API or behaviour. You can safely update without editing your " "application code. In fact, you really should as soon as possible, because " "important security fixes are released this way." msgstr "在修复了一些bug,和改动不会修改API的时候,会增加revision版本号。你可以放心更新,而不用修改你应用的代码。事实上,你确实应该更新这类版本,因为它常常修复一些安全问题。" #: ../../development.rst:47 msgid "Pre-Release Versions" msgstr "" #: ../../development.rst:46 msgid "" "Release candidates are marked by an ``rc`` in their revision number. These " "are API stable most of the time and open for testing, but not officially " "released yet. You should not use these for production." msgstr "RC版本会在版本号中添加 ``rc`` 字样。API已基本稳定,已经开放测试,但还没正式发布。你不应该在生产环境中使用rc版本。" #: ../../development.rst:50 msgid "Repository Structure" msgstr "代码仓库结构" #: ../../development.rst:52 msgid "The source repository is structured as follows:" msgstr "代码仓库的结构如下:" #: ../../development.rst:55 msgid "``master`` branch" msgstr "" #: ../../development.rst:55 msgid "" "This is the integration, testing and development branch. All changes that " "are planned to be part of the next release are merged and tested here." msgstr "该分支用于集成,测试和开发。所有计划添加到下一版本的改动,会在这里合并和测试。" #: ../../development.rst:58 msgid "``release-x.y`` branches" msgstr "" #: ../../development.rst:58 msgid "" "As soon as the master branch is (almost) ready for a new release, it is " "branched into a new release branch. This \"release candidate\" is feature-" "frozen but may receive bug-fixes and last-minute changes until it is " "considered production ready and officially released. From that point on it " "is called a \"support branch\" and still receives bug-fixes, but only " "important ones. The revision number is increased on each push to these " "branches, so you can keep up with important changes." msgstr "只要master分支已经可以用来发布一个新的版本,它会被安排到一个新的发行分支里面。在RC阶段,不再添加或删除特征,只接受bug-fix和小改动,直到认为它可以用于生产环境和正式发布。基于这点考虑,我们称之为“支持分支(support branch)”,依然接受bug-fix,但仅限关键的bug-fix。每次更改后,版本号都会更新,这样你就能及时获取重要的改动了。" #: ../../development.rst:62 msgid "Feature branches" msgstr "" #: ../../development.rst:61 msgid "" "All other branches are feature branches. These are based on the master " "branch and only live as long as they are still active and not merged back " "into ``master``." msgstr "所有这类分支都是用于新增特征的。基于master分支,在开发、合并完毕后,就会被删除。" #: ../../development.rst:65 msgid "What does this mean for a developer?" msgstr "对于开发者,这意味着什么?" #: ../../development.rst:66 msgid "" "If you want to add a feature, create a new branch from ``master``. If you " "want to fix a bug, branch ``release-x.y`` for each affected release. Please " "use a separate branch for each feature or bug to make integration as easy as" " possible. Thats all. There are git workflow examples at the bottom of this " "page." msgstr "如果你想添加一个特征,可以从 ``master`` 分支创建一个分支。如果你想修复一个bug,可从 ``release-x.y`` 这类分支创建一个分支。无论是添加特征还是修复bug,都建议在一个独立的分支上进行,这样合并工作就简单了。就这些了!在页面底部会有git工作流程的例子。" #: ../../development.rst:68 msgid "" "Oh, and never ever change the release number. We'll do that on integration. " "You never know in which order we pull pending requests anyway :)" msgstr "Oh,请不要修改版本号。我们会在集成的时候进行修改。因为你不知道我们什么时候会将你的request pull下来:)" #: ../../development.rst:72 msgid "What does this mean for a maintainer ?" msgstr "对于软件包维护者,这意味着什么?" #: ../../development.rst:73 msgid "" "Watch the tags (and the mailing list) for bug-fixes and new releases. If you" " want to fetch a specific release from the git repository, trust the tags, " "not the branches. A branch may contain changes that are not released yet, " "but a tag marks the exact commit which changed the version number." msgstr "关注那些bugfix和新版本的tag,还有邮件列表。如果你想从代码仓库中获取特定的版本,请使用tag,而不是分支。分支中也许会包含一些未发布的改动,但tag会标记是那个commit更改了版本号。" #: ../../development.rst:77 msgid "Submitting Patches" msgstr "提交补丁" #: ../../development.rst:79 msgid "" "The best way to get your changes integrated into the main development branch" " is to fork the main repository at github, create a new feature-branch, " "apply your changes and send a pull-request. Further down this page is a " "small collection of git workflow examples that may guide you. Submitting " "git-compatible patches to the mailing list is fine too. In any case, please " "follow some basic rules:" msgstr "让你的补丁被集成进来的最好方法,是在github上面fork整个项目,创建一个新的分支,修改代码,然后发送一个pull-request。页面下方是git工作流程的例子,也许会有帮助。提交git兼容的补丁文件到邮件列表也是可以的。无论使用什么方法,请遵守以下的基本规则:" #: ../../development.rst:81 msgid "" "**Documentation:** Tell us what your patch does. Comment your code. If you " "introduced a new feature, add to the documentation so others can learn about" " it." msgstr "**文档:** 告诉我们你的补丁做了什么。注释你的代码。如果你添加了新的特征,请添加相应的使用方法。" #: ../../development.rst:82 msgid "" "**Test:** Write tests to prove that your code works as expected and does not" " break anything. If you fixed a bug, write at least one test-case that " "triggers the bug. Make sure that all tests pass before you submit a patch." msgstr "**测试:** 编写测试以证明你的补丁如期工作,且没有破坏任何东西。如果你修复了一个bug,至少写一个测试用例来触发这个bug。在提交补丁之前,请确保所有测试已通过。" #: ../../development.rst:83 msgid "" "**One patch at a time:** Only fix one bug or add one feature at a time. " "Design your patches so that they can be applyed as a whole. Keep your " "patches clean, small and focused." msgstr "**一次只提交一个补丁:** 一次只修改一个bug,一次只添加一个新特征。保持补丁的干净。" #: ../../development.rst:84 msgid "" "**Sync with upstream:** If the ``upstream/master`` branch changed while you " "were working on your patch, rebase or pull to make sure that your patch " "still applies without conflicts." msgstr "**与上流同步:** 如果在你编写补丁的时候, ``upstream/master`` 分支被修改了,那么先rebase或将新的修改pull下来,确保你的补丁在合并的时候不会造成冲突。" #: ../../development.rst:88 msgid "Building the Documentation" msgstr "生成文档" #: ../../development.rst:90 msgid "" "You need a recent version of Sphinx to build the documentation. The " "recommended way is to install :command:`virtualenv` using your distribution " "package repository and install sphinx manually to get an up-to-date version." msgstr "你需要一个Sphinx的新版本来生产整份文档。建议将Sphinx安装到一个 :command:`virtualenv` 环境。" #: ../../development.rst:121 msgid "GIT Workflow Examples" msgstr "GIT工作流程" #: ../../development.rst:123 msgid "" "The following examples assume that you have an (free) `github account " "`_. This is not mandatory, but makes things a lot " "easier." msgstr "接下来的例子都假设你已经有一个 `git的免费帐号 `_ 。虽然不是必须的,但可简单化很多东西。" #: ../../development.rst:125 msgid "" "First of all you need to create a fork (a personal clone) of the official " "repository. To do this, you simply click the \"fork\" button on the `bottle " "project page `_. When the fork is done, " "you will be presented with a short introduction to your new repository." msgstr "首先,你需要从官方代码仓库创建一个fork。只需在 `bottle项目页面 `_ 点击一下\"fork\"按钮就行了。创建玩fork之后,会得到一个关于这个新仓库的简介。" #: ../../development.rst:127 msgid "" "The fork you just created is hosted at github and read-able by everyone, but" " write-able only by you. Now you need to clone the fork locally to actually " "make changes to it. Make sure you use the private (read-write) URL and *not*" " the public (read-only) one::" msgstr "你刚刚创建的fork托管在github上面,对所有人都是可见的,但只有你有修改的权限。现在你需要将其从线上clone下面,做出实际的修改。确保你使用的是(可写-可读)的私有URL,而不是(只读)的公开URL。" #: ../../development.rst:131 msgid "" "Once the clone is complete your repository will have a remote named " "\"origin\" that points to your fork on github. Don’t let the name confuse " "you, this does not point to the original bottle repository, but to your own " "fork. To keep track of the official repository, add another remote named " "\"upstream\"::" msgstr "在你将代码仓库clone下来后,就有了一个\"origin\"分支,指向你在github上的fork。不要让名字迷惑了你,它并不指向bottle的官方代码仓库,只是指向你自己的fork。为了追踪官方的代码仓库,可添加一个新的\"upstream\"远程分支。" #: ../../development.rst:137 msgid "" "Note that \"upstream\" is a public clone URL, which is read-only. You cannot" " push changes directly to it. Instead, we will pull from your public " "repository. This is described later." msgstr "注意,\"upstream\"分支使用的是公开的URL,是只读的。你不能直接往该分支push东西,而是由我们来你的公开代码仓库pull,后面会讲到。" #: ../../development.rst:140 msgid "Submit a Feature" msgstr "提交一个特征" #: ../../development.rst:141 msgid "" "New features are developed in separate feature-branches to make integration " "easy. Because they are going to be integrated into the ``master`` branch, " "they must be based on ``upstream/master``. To create a new feature-branch, " "type the following::" msgstr "在独立的特征分支内开发新的特征,会令集成工作更简单。因为它们会被合并到 ``master`` 分支,所有它们必须是基于 ``upstream/master`` 的分支。下列命令创建一个特征分支。" #: ../../development.rst:145 msgid "" "Now implement your feature, write tests, update the documentation, make sure" " that all tests pass and commit your changes::" msgstr "现在可开始写代码,写测试,更新文档。在提交更改之前,记得确保所有测试已经通过。" #: ../../development.rst:149 msgid "" "If the ``upstream/master`` branch changed in the meantime, there may be " "conflicts with your changes. To solve these, 'rebase' your feature-branch " "onto the top of the updated ``upstream/master`` branch::" msgstr "与此同时,如果 ``upstream/master`` 这个分支有改动,那么你的提交就有可能造成冲突,可通过rebase操作来解决。" #: ../../development.rst:154 msgid "" "This is equivalent to undoing all your changes, updating your branch to the " "latest version and reapplying all your patches again. If you released your " "branch already (see next step), this is not an option because it rewrites " "your history. You can do a normal pull instead. Resolve any conflicts, run " "the tests again and commit." msgstr "这相当于先撤销你的所有改动,更新你的分支到最新版本,再重做你的所有改动。如果你已经发布了你的分支(下一步会提及),这就不是一个好主意了,因为会覆写你的提交历史。这种情况下,你应该先将最新版本pull下来,手动解决所有冲突,运行测试,再提交。" #: ../../development.rst:156 msgid "" "Now you are almost ready to send a pull request. But first you need to make " "your feature-branch public by pushing it to your github fork::" msgstr "现在,你已经做好准备发一个pull-request了。但首先你应该公开你的特征分支,很简单,将其push到你github的fork上面就行了。" #: ../../development.rst:160 msgid "" "After you’ve pushed your commit(s) you need to inform us about the new " "feature. One way is to send a pull-request using github. Another way would " "be to start a thread in the mailing-list, which is recommended. It allows " "other developers to see and discuss your patches and you get some feedback " "for free :)" msgstr "在你push完你所有的commit之后,你需要告知我们这个新特征。一种办法是通过github发一个pull-request。另一种办法是把这个消息发到邮件列表,这也是我们推荐的方式,这样其他开发者就能看到和讨论你的补丁,你也能免费得到一些反馈 :)" #: ../../development.rst:162 msgid "" "If we accept your patch, we will integrate it into the official development " "branch and make it part of the next release." msgstr "如果我们接受了你的补丁,我们会将其集成到官方的开发分支中,它将成为下个发布版本的一部分。" #: ../../development.rst:165 msgid "Fix a Bug" msgstr "修复Bug" #: ../../development.rst:166 msgid "" "The workflow for bug-fixes is very similar to the one for features, but " "there are some differences:" msgstr "修复Bug和添加一个特征差不多,下面是一些不同点:" #: ../../development.rst:168 msgid "" "Branch off of the affected release branches instead of just the development " "branch." msgstr "修复所有受影响的分支,而不仅仅是开发分支(Branch off of the affected release branches instead of just the development branch)。" #: ../../development.rst:169 msgid "Write at least one test-case that triggers the bug." msgstr "至少编写一个触发该Bug的测试用例。" #: ../../development.rst:170 msgid "" "Do this for each affected branch including ``upstream/master`` if it is " "affected. ``git cherry-pick`` may help you reducing repetitive work." msgstr "修复所有受影响的分支,包括 ``upstream/master`` ,如果它也受影响。 ``git cherry-pick`` 可帮你完成一些重复工作。" #: ../../development.rst:171 msgid "" "Name your branch after the release it is based on to avoid confusion. " "Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``." msgstr "字后面要加上其修复的版本号,以防冲突。例子: ``my_bugfix-x.y`` 或 ``my_bugfix-dev`` 。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/faq.po000066400000000000000000000105561470367422500226510ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../faq.rst:10 msgid "Frequently Asked Questions" msgstr "常见问题" #: ../../faq.rst:13 msgid "About Bottle" msgstr "关于Bottle" #: ../../faq.rst:16 msgid "Is bottle suitable for complex applications?" msgstr "Bottle适合用于复杂的应用吗?" #: ../../faq.rst:18 msgid "" "Bottle is a *micro* framework designed for prototyping and building small " "web applications and services. It stays out of your way and allows you to " "get things done fast, but misses some advanced features and ready-to-use " "solutions found in other frameworks (MVC, ORM, form validation, scaffolding," " XML-RPC). Although it *is* possible to add these features and build complex" " applications with Bottle, you should consider using a full-stack Web " "framework like pylons_ or paste_ instead." msgstr "Bottle是一个 *迷你* 框架,被设计来提供原型开发和创建小的Web应用和服务。它能快速上手,并帮助你快速完成任务,但缺少一些高级功能和一些其他框架已提供的已知问题解决方法(例如:MVC, ORM,表单验证,手脚架,XML-RPC)。尽管 *可以* 添加这些功能,然后通过Bottle来开发复杂的应用,但我们还是建议你使用一些功能完备的Web框架,例如 pylons_ 或 paste_ 。" #: ../../faq.rst:22 msgid "Common Problems and Pitfalls" msgstr "常见的,意料之外的问题" #: ../../faq.rst:29 msgid "\"Template Not Found\" in mod_wsgi/mod_python" msgstr "在mod_wsgi/mod_python中的 \"Template Not Found\" 错误" #: ../../faq.rst:31 msgid "" "Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ " "or mod_wsgi_ environment, the working directory (``./``) depends on your " "Apache settings. You should add an absolute path to the template search " "path::" msgstr "Bottle会在 ``./`` 和 ``./views/`` 目录中搜索模板。在一个 mod_python_ 或 mod_wsgi_ 环境,当前工作目录( ``./`` )是由Apache的设置决定的。你应该在模板的搜索路径中添加一个绝对路径。" #: ../../faq.rst:35 msgid "so bottle searches the right paths." msgstr "这样,Bottle就能在正确的目录下搜索模板了" #: ../../faq.rst:38 msgid "Dynamic Routes and Slashes" msgstr "动态route和反斜杠" #: ../../faq.rst:40 msgid "" "In :ref:`dynamic route syntax `, a placeholder " "token (````) matches everything up to the next slash. This equals to " "``[^/]+`` in regular expression syntax. To accept slashes too, you have to " "add a custom regular pattern to the placeholder. An example: " "``/images/`` would match ``/images/icons/error.png`` but " "``/images/`` won't." msgstr "" #: ../../faq.rst:43 msgid "Problems with reverse proxies" msgstr "反向代理的问题" #: ../../faq.rst:45 msgid "" "Redirects and url-building only works if bottle knows the public address and" " location of your application. If you run bottle locally behind a reverse " "proxy or load balancer, some information might get lost along the way. For " "example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect " "the local request by your proxy, not the real request by the client. Here is" " a small WSGI middleware snippet that helps to fix these values::" msgstr "只用Bottle知道公共地址和应用位置的情况下,重定向和url-building才会起作用。(译者注:保留原文)Redirects and url-building only works if bottle knows the public address and location of your application.如果Bottle应用运行在反向代理或负载均衡后面,一些信息也许会丢失。例如, ``wsgi.url_scheme`` 的值或 ``Host`` 头或许只能获取到代理的请求信息,而不是真实的用户请求。下面是一个简单的中间件代码片段,处理上面的问题,获取正确的值。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/index.po000066400000000000000000000116371470367422500232120ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: # Dormouse Young , 2016 msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../index.rst:20 msgid "Bottle: Python Web Framework" msgstr "Bottle : Python Web 框架" #: ../../index.rst:22 msgid "" "Bottle is a fast, simple and lightweight WSGI_ micro web-framework for " "Python_. It is distributed as a single file module and has no dependencies " "other than the `Python Standard Library `_." msgstr "Bottle 是一个快速、简单、轻量级的 Python_ WSGI_ 微型 Web 框架。它只有一个文件,只依赖 `Python 标准库 `_ 。" #: ../../index.rst:25 msgid "" "**Routing:** Requests to function-call mapping with support for clean and " "dynamic URLs." msgstr "**URL映射(Routing):** 将URL请求映射到Python函数,支持动态URL,且URL更简洁。" #: ../../index.rst:26 msgid "" "**Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates." msgstr "**模板(Templates):** 快速且pythonic的 :ref:`内置模板引擎 ` ,同时支持 mako_ , jinja2_ 和 cheetah_ 等模板。" #: ../../index.rst:27 msgid "" "**Utilities:** Convenient access to form data, file uploads, cookies, " "headers and other HTTP-related metadata." msgstr "**基础功能(Utilities):** 方便地访问表单数据,上传文件,使用cookie,查看HTTP元数据。" #: ../../index.rst:28 msgid "" "**Server:** Built-in HTTP development server and support for paste_, " "bjoern_, gae_, cherrypy_ or any other WSGI_ capable HTTP server." msgstr "" #: ../../index.rst:31 msgid "Example: \"Hello World\" in a bottle" msgstr "示例: \"Hello World\"" #: ../../index.rst:42 msgid "" "Run this script or paste it into a Python console, then point your browser " "to ``_. That's it." msgstr "将其保存为py文件并执行,用浏览器访问 ``_ 即可看到效果。就这么简单!" #: ../../index.rst:45 msgid "Download and Install" msgstr "下载和安装" #: ../../index.rst:48 msgid "" "Install the latest stable release with ``pip install bottle`` or download " "`bottle.py`__ (unstable) into your project directory. There are no hard [1]_" " dependencies other than the Python standard library. Bottle supports " "**Python 2.7 and Python 3**." msgstr "" #: ../../index.rst:50 msgid "Support for Python 2.5 and 2.6 was dropped with this release." msgstr "" #: ../../index.rst:55 msgid "User's Guide" msgstr "用户指南" #: ../../index.rst:56 msgid "" "Start here if you want to learn how to use the bottle framework for web " "development. If you have any questions not answered here, feel free to ask " "the `mailing list `_." msgstr "如果你有将Bottle用于Web开发的打算,请继续看下去。如果这份文档没有解决你遇到的问题,尽管在 `邮件列表 `_ 中吼出来吧(译者注:用英文哦)。" #: ../../index.rst:71 msgid "Knowledge Base" msgstr "知识库" #: ../../index.rst:72 msgid "A collection of articles, guides and HOWTOs." msgstr "收集文章,使用指南和HOWTO" #: ../../index.rst:84 msgid "Development and Contribution" msgstr "开发和贡献" #: ../../index.rst:86 msgid "" "These chapters are intended for developers interested in the bottle " "development and release workflow." msgstr "这些章节是为那些对Bottle的开发和发布流程感兴趣的开发者准备的。" #: ../../index.rst:103 msgid "License" msgstr "许可证" #: ../../index.rst:105 msgid "Code and documentation are available according to the MIT License:" msgstr "代码和文件皆使用MIT许可证:" #: ../../index.rst:110 msgid "" "The Bottle logo however is *NOT* covered by that license. It is allowed to " "use the logo as a link to the bottle homepage or in direct context with the " "unmodified library. In all other cases please ask first." msgstr "然而,许可证 *不包含* Bottle的logo。logo用作指向Bottle主页的连接,或未修改过的类库。如要用于其它用途,请先请求许可。" #: ../../index.rst:115 msgid "Footnotes" msgstr "脚注" #: ../../index.rst:116 msgid "" "Usage of the template or server adapter classes requires the corresponding " "template or server modules." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/plugindev.po000066400000000000000000000502721470367422500240760ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../plugindev.rst:6 msgid "Plugin Development Guide" msgstr "插件开发指南" #: ../../plugindev.rst:8 msgid "" "This guide explains the plugin API and how to write custom plugins. I " "suggest reading :ref:`plugins` first if you have not done that already. You " "might also want to have a look at the :doc:`/plugins/index` for some " "practical examples." msgstr "这份指南介绍了插件的API,以及如何编写自己的插件。我建议先阅读 :ref:`plugins` 这一部分,再看这份指南。 :doc:`/plugins/index` 这里也有一些实际的例子。" #: ../../plugindev.rst:12 msgid "" "This is a draft. If you see any errors or find that a specific part is not " "explained clear enough, please tell the `mailing-list " "`_ or file a `bug report " "`_." msgstr "这是一份初稿。如果你发现了任何错误,或某些部分解释的不够清楚,请通过 `邮件列表 `_ 或 `bug report `_ 告知。" #: ../../plugindev.rst:16 msgid "How Plugins Work: The Basics" msgstr "插件工作方式:基础知识" #: ../../plugindev.rst:18 msgid "" "The plugin API builds on the concept of `decorators " "`_. To put it briefly, " "a plugin is a decorator applied to every single route callback of an " "application." msgstr "插件的API是通过Python的 `修饰器 `_ 来实现的。简单来说,一个插件就是应用在route回调函数上的修饰器。" #: ../../plugindev.rst:20 msgid "" "This is just a simplification. Plugins can do a lot more than just " "decorating route callbacks, but it is a good starting point. Lets have a " "look at some code::" msgstr "" #: ../../plugindev.rst:36 msgid "" "This plugin measures the execution time for each request and adds an " "appropriate ``X-Exec-Time`` header to the response. As you can see, the " "plugin returns a wrapper and the wrapper calls the original callback " "recursively. This is how decorators usually work." msgstr "这个插件计算每次请求的响应时间,并在响应头中添加了 ``X-Exec-Time`` 字段。如你所见,插件返回了一个wrapper函数,由它来调用原先的回调函数。这就是修饰器的常见工作方式了。" #: ../../plugindev.rst:38 msgid "" "The last line tells Bottle to install the plugin to the default application." " This causes the plugin to be automatically applied to all routes of that " "application. In other words, ``stopwatch()`` is called once for each route " "callback and the return value is used as a replacement for the original " "callback." msgstr "最后一行,将该插件安装到Bottle的默认应用里面。这样,应用中的所有route都会应用这个插件了。就是说,每次请求都会调用 ``stopwatch()`` ,更改了route的默认行为。" #: ../../plugindev.rst:40 msgid "" "Plugins are applied on demand, that is, as soon as a route is requested for " "the first time. For this to work properly in multi-threaded environments, " "the plugin should be thread-safe. This is not a problem most of the time, " "but keep it in mind." msgstr "插件是按需加载的,就是在route第一次被访问的时候加载。为了在多线程环境下工作,插件应该是线程安全的。在大多数情况下,这都不是一个问题,但务必提高警惕。" #: ../../plugindev.rst:42 msgid "" "Once all plugins are applied to a route, the wrapped callback is cached and " "subsequent requests are handled by the cached version directly. This means " "that a plugin is usually applied only once to a specific route. That cache, " "however, is cleared every time the list of installed plugins changes. Your " "plugin should be able to decorate the same route more than once." msgstr "一旦route中使用了插件后,插件中的回调函数会被缓存起来,接下来都是直接使用缓存中的版本来响应请求。意味着每个route只会请求一次插件。在应用的插件列表变化的时候,这个缓存会被清空。你的插件应当可以多次修饰同一个route。" #: ../../plugindev.rst:44 msgid "" "The decorator API is quite limited, though. You don't know anything about " "the route being decorated or the associated application object and have no " "way to efficiently store data that is shared among all routes. But fear not!" " Plugins are not limited to just decorator functions. Bottle accepts " "anything as a plugin as long as it is callable or implements an extended " "API. This API is described below and gives you a lot of control over the " "whole process." msgstr "这种修饰器般的API受到种种限制。你不知道route或相应的应用对象是如何被修饰的,也不知道如何有效地存储那些在route之间共享的数据。但别怕!插件不仅仅是修饰器函数。只要一个插件是callable的或实现了一个扩展的API(后面会讲到),Bottle都可接受。扩展的API给你更多的控制权。" #: ../../plugindev.rst:48 msgid "Plugin API" msgstr "插件API" #: ../../plugindev.rst:50 msgid "" ":class:`Plugin` is not a real class (you cannot import it from " ":mod:`bottle`) but an interface that plugins are expected to implement. " "Bottle accepts any object of any type as a plugin, as long as it conforms to" " the following API." msgstr "``Plugin`` 类不是一个真正的类(你不能从bottle中导入它),它只是一个插件需要实现的接口。只要一个对象实现了以下接口,Bottle就认可它作为一个插件。" #: ../../plugindev.rst:54 msgid "" "Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is " "defined, it is always preferred over calling the plugin directly. All other " "methods and attributes are optional." msgstr "插件应该是callable的,或实现了 :meth:`apply` 方法。如果定义了 :meth:`apply` 方法,那么会优先调用,而不是直接调用插件。其它的方法和属性都是可选的。" #: ../../plugindev.rst:58 msgid "" "Both :meth:`Bottle.uninstall` and the `skip` parameter of " ":meth:`Bottle.route()` accept a name string to refer to a plugin or plugin " "type. This works only for plugins that have a name attribute." msgstr ":meth:`Bottle.uninstall` 方法和 :meth:`Bottle.route()` 中的 `skip` 参数都接受一个与名字有关的字符串,对应插件或其类型。只有插件中有一个name属性的时候,这才会起作用。" #: ../../plugindev.rst:62 msgid "" "The Plugin API is still evolving. This integer attribute tells bottle which " "version to use. If it is missing, bottle defaults to the first version. The " "current version is ``2``. See :ref:`plugin-changelog` for details." msgstr "插件的API还在逐步改进。这个整形数告诉Bottle使用哪个版本的插件。如果没有这个属性,Bottle默认使用第一个版本。当前版本是 ``2`` 。详见 :ref:`plugin-changelog` 。" #: ../../plugindev.rst:66 msgid "" "Called as soon as the plugin is installed to an application (see " ":meth:`Bottle.install`). The only parameter is the associated application " "object." msgstr "插件被安装的时候调用(见 :meth:`Bottle.install` )。唯一的参数是相应的应用对象。" #: ../../plugindev.rst:70 msgid "" "As long as :meth:`apply` is not defined, the plugin itself is used as a " "decorator and applied directly to each route callback. The only parameter is" " the callback to decorate. Whatever is returned by this method replaces the " "original callback. If there is no need to wrap or replace a given callback, " "just return the unmodified callback parameter." msgstr "如果没有定义 :meth:`apply` 方法,插件本身会被直接当成一个修饰器使用(译者注:Python的Magic Method,调用一个类即是调用类的__call__函数),应用到各个route。唯一的参数就是其所修饰的函数。这个方法返回的东西会直接替换掉原先的回调函数。如果无需如此,则直接返回未修改过的回调函数即可。" #: ../../plugindev.rst:74 msgid "" "If defined, this method is used in favor of :meth:`__call__` to decorate " "route callbacks. The additional `route` parameter is an instance of " ":class:`Route` and provides a lot of meta-information and context for that " "route. See :ref:`route-context` for details." msgstr "如果存在,会优先调用,而不调用 :meth:`__call__` 。额外的 `route` 参数是 :class:`Route` 类的一个实例,提供很多该route信息和上下文。详见 :ref:`route-context` 。" #: ../../plugindev.rst:78 msgid "" "Called immediately before the plugin is uninstalled or the application is " "closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`)." msgstr "插件被卸载或应用关闭的时候被调用,详见 :meth:`Bottle.uninstall` 或 :meth:`Bottle.close` 。" #: ../../plugindev.rst:81 msgid "" "Both :meth:`Plugin.setup` and :meth:`Plugin.close` are *not* called for " "plugins that are applied directly to a route via the :meth:`Bottle.route()` " "decorator, but only for plugins installed to an application." msgstr ":meth:`Plugin.setup` 方法和 :meth:`Plugin.close` 方法 *不* 会被调用,如果插件是通过 :meth:`Bottle.route` 方法来应用到route上面的,但会在安装插件的时候被调用。" #: ../../plugindev.rst:87 msgid "Plugin API changes" msgstr "插件API的改动" #: ../../plugindev.rst:89 msgid "" "The Plugin API is still evolving and changed with Bottle 0.10 to address " "certain issues with the route context dictionary. To ensure backwards " "compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` " "attribute to tell bottle which API to use. The API differences are " "summarized here." msgstr "插件的API还在不断改进中。在Bottle 0.10版本中的改动,定位了route上下文字典中已确定的问题。为了保持对0.9版本插件的兼容,我们添加了一个可选的 :attr:`Plugin.api` 属性,告诉Bottle使用哪个版本的API。API之间的不同点总结如下。" #: ../../plugindev.rst:91 msgid "**Bottle 0.9 API 1** (:attr:`Plugin.api` not present)" msgstr "**Bottle 0.9 API 1** (无 :attr:`Plugin.api` 属性)" #: ../../plugindev.rst:93 msgid "Original Plugin API as described in the 0.9 docs." msgstr "" #: ../../plugindev.rst:95 msgid "**Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2)" msgstr "**Bottle 0.10 API 2** ( :attr:`Plugin.api` 属性为2)" #: ../../plugindev.rst:97 msgid "" "The `context` parameter of the :meth:`Plugin.apply` method is now an " "instance of :class:`Route` instead of a context dictionary." msgstr " :meth:`Plugin.apply` 方法中的 `context` 参数,现在是 :class:`Route` 类的一个实例,不再是一个上下文字典。" #: ../../plugindev.rst:103 msgid "The Route Context" msgstr "Route上下文" #: ../../plugindev.rst:105 msgid "" "The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed" " informations about the associated route. The most important attributes are " "summarized here:" msgstr ":class:`Route` 的实例被传递给 :meth:`Plugin.apply` 函数,以提供更多该route的相关信息。最重要的属性总结如下。" #: ../../plugindev.rst:108 msgid "Attribute" msgstr "属性" #: ../../plugindev.rst:108 msgid "Description" msgstr "描述" #: ../../plugindev.rst:110 msgid "app" msgstr "" #: ../../plugindev.rst:110 msgid "The application object this route is installed to." msgstr "安装该route的应用对象" #: ../../plugindev.rst:111 msgid "rule" msgstr "" #: ../../plugindev.rst:111 msgid "The rule string (e.g. ``/wiki/``)." msgstr "" #: ../../plugindev.rst:112 msgid "method" msgstr "" #: ../../plugindev.rst:112 msgid "The HTTP method as a string (e.g. ``GET``)." msgstr "HTTP方法的字符串(例如: ``GET``)" #: ../../plugindev.rst:113 msgid "callback" msgstr "" #: ../../plugindev.rst:113 msgid "" "The original callback with no plugins applied. Useful for introspection." msgstr "未应用任何插件的原始回调函数,用于内省。" #: ../../plugindev.rst:115 msgid "name" msgstr "" #: ../../plugindev.rst:115 msgid "The name of the route (if specified) or ``None``." msgstr "route的名字,如未指定则为 ``None``" #: ../../plugindev.rst:116 msgid "plugins" msgstr "" #: ../../plugindev.rst:116 msgid "" "A list of route-specific plugins. These are applied in addition to " "application-wide plugins. (see :meth:`Bottle.route`)." msgstr "route安装的插件列表,除了整个应用范围内的插件,额外添加的(见 :meth:`Bottle.route` )" #: ../../plugindev.rst:118 msgid "skiplist" msgstr "" #: ../../plugindev.rst:118 msgid "" "A list of plugins to not apply to this route (again, see " ":meth:`Bottle.route`)." msgstr "应用安装了,但该route没安装的插件列表(见 meth:`Bottle.route` )" #: ../../plugindev.rst:120 msgid "config" msgstr "" #: ../../plugindev.rst:120 msgid "" "Additional keyword arguments passed to the :meth:`Bottle.route` decorator " "are stored in this dictionary. Used for route-specific configuration and " "meta-data." msgstr "传递给 :meth:`Bottle.route` 修饰器的额外参数,存在一个字典中,用于特定的设置和元数据" #: ../../plugindev.rst:125 msgid "" "For your plugin, :attr:`Route.config` is probably the most important " "attribute. Keep in mind that this dictionary is local to the route, but " "shared between all plugins. It is always a good idea to add a unique prefix " "or, if your plugin needs a lot of configuration, store it in a separate " "namespace within the `config` dictionary. This helps to avoid naming " "collisions between plugins." msgstr "对你的应用而言, :attr:`Route.config` 也许是最重要的属性了。记住,这个字典会在所有插件中共享,建议添加一个独一无二的前缀。如果你的插件需要很多设置,将其保存在 `config` 字典的一个独立的命名空间吧。防止插件之间的命名冲突。" #: ../../plugindev.rst:129 msgid "Changing the :class:`Route` object" msgstr "改变 :class:`Route` 对象" #: ../../plugindev.rst:131 msgid "" "While some :class:`Route` attributes are mutable, changes may have unwanted " "effects on other plugins. It is most likely a bad idea to monkey-patch a " "broken route instead of providing a helpful error message and let the user " "fix the problem." msgstr ":class:`Route` 的一些属性是不可变的,改动也许会影响到其它插件。坏主意就是,monkey-patch一个损坏的route,而不是提供有效的帮助信息来让用户修复问题。" #: ../../plugindev.rst:133 msgid "" "In some rare cases, however, it might be justifiable to break this rule. " "After you made your changes to the :class:`Route` instance, raise " ":exc:`RouteReset` as an exception. This removes the current route from the " "cache and causes all plugins to be re-applied. The router is not updated, " "however. Changes to `rule` or `method` values have no effect on the router, " "but only on plugins. This may change in the future, though." msgstr "在极少情况下,破坏规则也许是恰当的。在你更改了 :class:`Route` 实例后,抛一个 :exc:`RouteReset` 异常。这会从缓存中删除当前的route,并重新应用所有插件。无论如何,router没有被更新。改变 `rule` 或 `method` 的值并不会影响到router,只会影响到插件。这个情况在将来也许会改变。" #: ../../plugindev.rst:137 msgid "Runtime optimizations" msgstr "运行时优化" #: ../../plugindev.rst:139 msgid "" "Once all plugins are applied to a route, the wrapped route callback is " "cached to speed up subsequent requests. If the behavior of your plugin " "depends on configuration, and you want to be able to change that " "configuration at runtime, you need to read the configuration on each " "request. Easy enough." msgstr "插件应用到route以后,被插件封装起来的回调函数会被缓存,以加速后续的访问。如果你的插件的行为依赖一些设置,你需要在运行时更改这些设置,你需要在每次请求的时候读取设置信息。够简单了吧。" #: ../../plugindev.rst:141 msgid "" "For performance reasons, however, it might be worthwhile to choose a " "different wrapper based on current needs, work with closures, or enable or " "disable a plugin at runtime. Let's take the built-in HooksPlugin as an " "example: If no hooks are installed, the plugin removes itself from all " "affected routes and has virtually no overhead. As soon as you install the " "first hook, the plugin activates itself and takes effect again." msgstr "" #: ../../plugindev.rst:143 msgid "" "To achieve this, you need control over the callback cache: " ":meth:`Route.reset` clears the cache for a single route and " ":meth:`Bottle.reset` clears all caches for all routes of an application at " "once. On the next request, all plugins are re-applied to the route as if it " "were requested for the first time." msgstr "为了达到这个目的,你需要控制回调函数的缓存: :meth:`Route.reset` 函数清空单一route的缓存, :meth:`Bottle.reset` 函数清空所有route的缓存。在下一次请求的时候,所有插件被重新应用到route上面,就像第一次请求时那样。" #: ../../plugindev.rst:145 msgid "" "Both methods won't affect the current request if called from within a route " "callback, of cause. To force a restart of the current request, raise " ":exc:`RouteReset` as an exception." msgstr "如果在route的回调函数里面调用,两种方法都不会影响当前的请求。当然,可以抛出一个 :exc:`RouteReset` 异常,来改变当前的请求。" #: ../../plugindev.rst:149 msgid "Plugin Example: SQLitePlugin" msgstr "插件例子: SQLitePlugin" #: ../../plugindev.rst:151 msgid "" "This plugin provides an sqlite3 database connection handle as an additional " "keyword argument to wrapped callbacks, but only if the callback expects it. " "If not, the route is ignored and no overhead is added. The wrapper does not " "affect the return value, but handles plugin-related exceptions properly. " ":meth:`Plugin.setup` is used to inspect the application and search for " "conflicting plugins." msgstr "这个插件提供对sqlite3数据库的访问,如果route的回调函数提供了关键字参数(默认是\"db\"),则\"db\"可做为数据库连接,如果route的回调函数没有提供该参数,则忽略该route。wrapper不会影响返回值,但是会处理插件相关的异常。 :meth:`Plugin.setup` 方法用于检查应用,查找冲突的插件。" #: ../../plugindev.rst:218 msgid "" "This plugin is actually useful and very similar to the version bundled with " "Bottle. Not bad for less than 60 lines of code, don't you think? Here is a " "usage example::" msgstr "这个插件十分有用,已经和Bottle提供的那个版本很类似了(译者注:=。= 一模一样)。只要60行代码,还不赖嘛!下面是一个使用例子。" #: ../../plugindev.rst:239 msgid "" "The first route needs a database connection and tells the plugin to create a" " handle by requesting a ``db`` keyword argument. The second route does not " "need a database and is therefore ignored by the plugin. The third route does" " expect a 'db' keyword argument, but explicitly skips the sqlite plugin. " "This way the argument is not overruled by the plugin and still contains the " "value of the same-named url argument." msgstr "第一个route提供了一个\"db\"参数,告诉插件它需要一个数据库连接。第二个route不需要一个数据库连接,所以会被插件忽略。第三个route确实有一个\"db\"参数,但显式的禁用了sqlite插件,这样,\"db\"参数不会被插件修改,还是包含URL传过来的那个值。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/plugins/000077500000000000000000000000001470367422500232145ustar00rootroot00000000000000python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/plugins/index.po000066400000000000000000000160551470367422500246720ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../plugins/index.rst:5 msgid "List of available Plugins" msgstr "可用插件列表" #: ../../plugins/index.rst:7 msgid "" "This is a list of third-party plugins that add extend Bottles core " "functionality or integrate other libraries with the Bottle framework." msgstr "这是一份第三方插件的列表,扩展Bottle的核心功能,或集成其它类库。" #: ../../plugins/index.rst:9 msgid "" "Have a look at :ref:`plugins` for general questions about plugins " "(installation, usage). If you plan to develop a new plugin, the " ":doc:`/plugindev` may help you." msgstr "在 :ref:`plugins` 查看常见的插件问题(安装,使用)。如果你计划开发一个新的插件, :doc:`/plugindev` 也许对你有帮助。" #: ../../plugins/index.rst:12 msgid "`Bottle-Beaker `_" msgstr "" #: ../../plugins/index.rst:12 msgid "Beaker to session and caching library with WSGI Middleware" msgstr "" #: ../../plugins/index.rst:15 msgid "`Bottle-Cork `_" msgstr "" #: ../../plugins/index.rst:15 msgid "" "Cork provides a simple set of methods to implement Authentication and " "Authorization in web applications based on Bottle." msgstr "Cork插件基于Bottle,提供了一些简单的方法来实现Web应用的权限验证。" #: ../../plugins/index.rst:18 msgid "`Bottle-Cors-plugin `_" msgstr "" #: ../../plugins/index.rst:18 msgid "" "Cors-plugin is the easiest way to implement cors on your bottle web " "application" msgstr "" #: ../../plugins/index.rst:21 msgid "`Bottle-Extras `_" msgstr "" #: ../../plugins/index.rst:21 msgid "Meta package to install the bottle plugin collection." msgstr "安装Bottle插件的集合" #: ../../plugins/index.rst:24 msgid "`Bottle-Flash `_" msgstr "" #: ../../plugins/index.rst:24 msgid "flash plugin for bottle" msgstr "Bottle的flash插件" #: ../../plugins/index.rst:27 msgid "`Bottle-Hotqueue `_" msgstr "" #: ../../plugins/index.rst:27 msgid "FIFO Queue for Bottle built upon redis" msgstr "基于redis的FIFO队列服务" #: ../../plugins/index.rst:30 msgid "`Macaron `_" msgstr "" #: ../../plugins/index.rst:30 msgid "Macaron is an object-relational mapper (ORM) for SQLite." msgstr "Macaron是用于SQLite的ORM" #: ../../plugins/index.rst:33 msgid "`Bottle-Memcache `_" msgstr "" #: ../../plugins/index.rst:33 msgid "Memcache integration for Bottle." msgstr "Memcache集成" #: ../../plugins/index.rst:36 msgid "`Bottle-Mongo `_" msgstr "" #: ../../plugins/index.rst:36 msgid "MongoDB integration for Bottle" msgstr "MongoDB集成" #: ../../plugins/index.rst:39 msgid "`Bottle-OAuthlib `_" msgstr "" #: ../../plugins/index.rst:39 msgid "Adapter for oauthlib - create your own OAuth2.0 implementation" msgstr "" #: ../../plugins/index.rst:42 msgid "`Bottle-Redis `_" msgstr "" #: ../../plugins/index.rst:42 msgid "Redis integration for Bottle." msgstr "Redis集成" #: ../../plugins/index.rst:45 msgid "`Bottle-Renderer `_" msgstr "" #: ../../plugins/index.rst:45 msgid "Renderer plugin for bottle" msgstr "Renderer插件" #: ../../plugins/index.rst:48 msgid "`Bottle-Servefiles `_" msgstr "" #: ../../plugins/index.rst:48 msgid "A reusable app that serves static files for bottle apps" msgstr "一个可重用的APP,为Bottle应用提供静态文件服务。" #: ../../plugins/index.rst:51 msgid "`Bottle-Sqlalchemy `_" msgstr "" #: ../../plugins/index.rst:51 msgid "SQLAlchemy integration for Bottle." msgstr "SQLAlchemy集成" #: ../../plugins/index.rst:54 msgid "`Bottle-Sqlite `_" msgstr "" #: ../../plugins/index.rst:54 msgid "SQLite3 database integration for Bottle." msgstr "SQLite3数据库集成" #: ../../plugins/index.rst:57 msgid "`Bottle-Web2pydal `_" msgstr "" #: ../../plugins/index.rst:57 msgid "Web2py Dal integration for Bottle." msgstr "Wbe2py的Dal集成" #: ../../plugins/index.rst:60 msgid "`Bottle-Werkzeug `_" msgstr "" #: ../../plugins/index.rst:60 msgid "" "Integrates the `werkzeug` library (alternative request and response objects," " advanced debugging middleware and more)." msgstr "集成 `werkzeug` (可选的request和response对象,更高级的调试中间件等等)" #: ../../plugins/index.rst:63 msgid "" "`bottle-smart-filters `_" msgstr "" #: ../../plugins/index.rst:63 msgid "Bottle Querystring smart guessing." msgstr "" #: ../../plugins/index.rst:66 msgid "`bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:66 msgid "JSON Web Token authentication plugin for bottle.py" msgstr "" #: ../../plugins/index.rst:69 msgid "`Bottle-jwt `_" msgstr "" #: ../../plugins/index.rst:69 msgid "JWT integration for bottle" msgstr "" #: ../../plugins/index.rst:72 msgid "`canister `_" msgstr "" #: ../../plugins/index.rst:72 msgid "a bottle wrapper to provide logging, sessions and authentication" msgstr "" #: ../../plugins/index.rst:75 msgid "`bottle-cerberus `_" msgstr "" #: ../../plugins/index.rst:75 msgid "Cerberus integration for bottle" msgstr "" #: ../../plugins/index.rst:78 msgid "`Bottle-errorsrest `_" msgstr "" #: ../../plugins/index.rst:78 msgid "All errors generated from bottle are returned in json" msgstr "" #: ../../plugins/index.rst:82 msgid "`Bottle-tools `_" msgstr "" #: ../../plugins/index.rst:81 msgid "" "Decorators that auto-supply function arguments using POST/query string data." msgstr "" #: ../../plugins/index.rst:84 msgid "" "Plugins listed here are not part of Bottle or the Bottle project, but " "developed and maintained by third parties." msgstr "这里列出的插件不属于Bottle或Bottle项目,是第三方开发并维护的。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/recipes.po000066400000000000000000000334531470367422500235350ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../recipes.rst:16 msgid "Recipes" msgstr "秘诀" #: ../../recipes.rst:18 msgid "" "This is a collection of code snippets and examples for common use cases." msgstr "这里收集了一些常见用例的代码片段和例子." #: ../../recipes.rst:21 msgid "Keeping track of Sessions" msgstr "使用Session" #: ../../recipes.rst:23 msgid "" "There is no built-in support for sessions because there is no *right* way to" " do it (in a micro framework). Depending on requirements and environment you" " could use beaker_ middleware with a fitting backend or implement it " "yourself. Here is an example for beaker sessions with a file-based backend::" msgstr "Bottle自身并没有提供Session的支持,因为在一个迷你框架里面,没有合适的方法来实现。根据需求和使用环境,你可以使用 beaker_ 中间件或自己来实现。下面是一个使用beaker的例子,Session数据存放在\"./data\"目录里面::" #: ../../recipes.rst:45 msgid "" "WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent " "requests modify the same session at the same time, one of the updates might " "get lost. For this reason, sessions should only be populated once and " "treated as a read-only store after that. If you find yourself updating " "sessions regularly, and don't want to risk losing any updates, think about " "using a real database instead or seek alternative session middleware " "libraries." msgstr "" #: ../../recipes.rst:49 msgid "Debugging with Style: Debugging Middleware" msgstr "Debugging with Style: 调试中间件" #: ../../recipes.rst:51 msgid "" "Bottle catches all Exceptions raised in your app code to prevent your WSGI " "server from crashing. If the built-in :func:`debug` mode is not enough and " "you need exceptions to propagate to a debugging middleware, you can turn off" " this behaviour::" msgstr "Bottle捕获所有应用抛出的异常,防止异常导致WSGI服务器崩溃。如果内置的 :func:`debug` 模式不能满足你的要求,你想在你自己写的中间件里面处理这些异常,那么你可以关闭这个功能。" #: ../../recipes.rst:59 msgid "" "Now, bottle only catches its own exceptions (:exc:`HTTPError`, " ":exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can " "handle the rest." msgstr "现在,Bottle仅会捕获并处理它自己抛出的异常( :exc:`HTTPError` , :exc:`HTTPResponse` 和 :exc:`BottleException` ),你的中间件可以处理剩下的那些异常。" #: ../../recipes.rst:61 msgid "" "The werkzeug_ and paste_ libraries both ship with very powerful debugging " "WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for " "werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for " "paste_. They both allow you do inspect the stack and even execute python " "code within the stack context, so **do not use them in production**." msgstr "werkzeug_ 和 paste_ 这两个第三方库都提供了非常强大的调试中间件。如果是 werkzeug_ ,可看看 :class:`werkzeug.debug.DebuggedApplication` ,如果是 paste_ ,可看看 :class:`paste.evalexception.middleware.EvalException` 。它们都可让你检查运行栈,甚至在保持运行栈上下文的情况下,执行Python代码。所以 **不要在生产环境中使用它们** 。" #: ../../recipes.rst:65 msgid "Unit-Testing Bottle Applications" msgstr "" #: ../../recipes.rst:67 msgid "" "Unit-testing is usually performed against methods defined in your web " "application without running a WSGI environment." msgstr "Unit测试一般用于测试应用中的函数,但不需要一个WSGI环境。" #: ../../recipes.rst:69 msgid "A simple example using `Nose `_::" msgstr "使用 `Nose `_ 的简单例子。" #: ../../recipes.rst:80 ../../recipes.rst:97 msgid "Test script::" msgstr "测试代码::" #: ../../recipes.rst:87 msgid "" "In the example the Bottle route() method is never executed - only index() is" " tested." msgstr "在这个例子中,Bottle的route()函数没有被执行,仅测试了index()函数。" #: ../../recipes.rst:89 msgid "" "If the code being tested requires access to ``bottle.request`` you can mock " "it using `Boddle `_::" msgstr "" #: ../../recipes.rst:108 msgid "Functional Testing Bottle Applications" msgstr "功能测试" #: ../../recipes.rst:110 msgid "" "Any HTTP-based testing system can be used with a running WSGI server, but " "some testing frameworks work more intimately with WSGI, and provide the " "ability the call WSGI applications in a controlled environment, with " "tracebacks and full use of debugging tools. `Testing tools for WSGI " "`_ is a good starting point." msgstr "任何基于HTTP的测试系统都可用于测试WSGI服务器,但是有些测试框架与WSGI服务器工作得更好。它们可以在一个可控环境里运行WSGI应用,充分利用traceback和调试工具。 `Testing tools for WSGI `_ 是一个很好的上手工具。" #: ../../recipes.rst:112 msgid "" "Example using `WebTest `_ and `Nose " "`_::" msgstr "使用 `WebTest `_ 和 `Nose `_ 的例子。" #: ../../recipes.rst:132 msgid "Embedding other WSGI Apps" msgstr "嵌入其他WSGI应用" #: ../../recipes.rst:134 msgid "" "This is not the recommend way (you should use a middleware in front of " "bottle to do this) but you can call other WSGI applications from within your" " bottle app and let bottle act as a pseudo-middleware. Here is an example::" msgstr "并不建议你使用这个方法,你应该在Bottle前面使用一个中间件来做这样的事情。但你确实可以在Bottle里面调用其他WSGI应用,让Bottle扮演一个中间件的角色。下面是一个例子。" #: ../../recipes.rst:150 msgid "" "Again, this is not the recommend way to implement subprojects. It is only " "here because many people asked for this and to show how bottle maps to WSGI." msgstr "再次强调,并不建议使用这种方法。之所以介绍这种方法,是因为很多人问起,如何在Bottle中调用WSGI应用。" #: ../../recipes.rst:154 msgid "Ignore trailing slashes" msgstr "忽略尾部的反斜杠" #: ../../recipes.rst:156 msgid "" "For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To" " treat both URLs the same you can add two ``@route`` decorators::" msgstr "在Bottle看来, ``/example`` 和 ``/example/`` 是两个不同的route [1]_ 。为了一致对待这两个URL,你应该添加两个route。" #: ../../recipes.rst:162 msgid "add a WSGI middleware that strips trailing slashes from all URLs::" msgstr "" #: ../../recipes.rst:175 msgid "or add a ``before_request`` hook to strip the trailing slashes::" msgstr "" #: ../../recipes.rst:182 msgid "Footnotes" msgstr "脚注" #: ../../recipes.rst:183 msgid "Because they are. See " msgstr "因为确实如此,见 " #: ../../recipes.rst:187 msgid "Keep-alive requests" msgstr "Keep-alive 请求" #: ../../recipes.rst:191 msgid "For a more detailed explanation, see :doc:`async`." msgstr "详见 :doc:`async` 。" #: ../../recipes.rst:193 msgid "" "Several \"push\" mechanisms like XHR multipart need the ability to write " "response data without closing the connection in conjunction with the " "response header \"Connection: keep-alive\". WSGI does not easily lend itself" " to this behavior, but it is still possible to do so in Bottle by using the " "gevent_ async framework. Here is a sample that works with either the gevent_" " HTTP server or the paste_ HTTP server (it may work with others, but I have " "not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the" " paste_ server::" msgstr "像XHR这样的\"push\"机制,需要在HTTP响应头中加入 \"Connection: keep-alive\" ,以便在不关闭连接的情况下,写入响应数据。WSGI并不支持这种行为,但如果在Bottle中使用 gevent_ 这个异步框架,还是可以实现的。下面是一个例子,可配合 gevent_ HTTP服务器或 paste_ HTTP服务器使用(也许支持其他服务器,但是我没试过)。在run()函数里面使用 ``server='gevent'`` 或 ``server='paste'`` 即可使用这两种服务器。" #: ../../recipes.rst:210 msgid "" "If you browse to ``http://localhost:8080/stream``, you should see 'START', " "'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to " "see them all at once)." msgstr "通过浏览器访问 ``http://localhost:8080/stream`` ,可看到'START','MIDDLE',和'END'这三个字眼依次出现,一共用了8秒。" #: ../../recipes.rst:213 msgid "Gzip Compression in Bottle" msgstr "Gzip压缩" #: ../../recipes.rst:216 msgid "For a detailed discussion, see compression_" msgstr "详见 compression_" #: ../../recipes.rst:218 msgid "" "A common feature request is for Bottle to support Gzip compression, which " "speeds up sites by compressing static resources (like CSS and JS files) " "during a request." msgstr "Gzip压缩,可加速网站静态资源(例如CSS和JS文件)的访问。人们希望Bottle支持Gzip压缩,(但是不支持)......" #: ../../recipes.rst:220 msgid "" "Supporting Gzip compression is not a straightforward proposition, due to a " "number of corner cases that crop up frequently. A proper Gzip implementation" " must:" msgstr "支持Gzip压缩并不简单,一个合适的Gzip实现应该满足以下条件。" #: ../../recipes.rst:222 msgid "Compress on the fly and be fast doing so." msgstr "压缩速度要快" #: ../../recipes.rst:223 msgid "Do not compress for browsers that don't support it." msgstr "如果浏览器不支持,则不压缩" #: ../../recipes.rst:224 msgid "Do not compress files that are compressed already (images, videos)." msgstr "不压缩那些已经充分压缩的文件(图像,视频)" #: ../../recipes.rst:225 msgid "Do not compress dynamic files." msgstr "不压缩动态文件" #: ../../recipes.rst:226 msgid "Support two differed compression algorithms (gzip and deflate)." msgstr "支持两种压缩算法(gzip和deflate)" #: ../../recipes.rst:227 msgid "Cache compressed files that don't change often." msgstr "缓存那些不经常变化的压缩文件" #: ../../recipes.rst:228 msgid "De-validate the cache if one of the files changed anyway." msgstr "不验证缓存中那些已经变化的文件(De-validate the cache if one of the files changed anyway)" #: ../../recipes.rst:229 msgid "Make sure the cache does not get to big." msgstr "确保缓存不太大" #: ../../recipes.rst:230 msgid "" "Do not cache small files because a disk seek would take longer than on-the-" "fly compression." msgstr "不缓存小文件,因为寻道时间或许比压缩时间还长" #: ../../recipes.rst:232 msgid "" "Because of these requirements, it is the recommendation of the Bottle " "project that Gzip compression is best handled by the WSGI server Bottle runs" " on top of. WSGI servers such as cherrypy_ provide a GzipFilter_ middleware " "that can be used to accomplish this." msgstr "因为有上述种种限制,建议由WSGI服务器来处理Gzip压缩而不是Bottle。像 cherrypy_ 就提供了一个 GzipFilter_ 中间件来处理Gzip压缩。" #: ../../recipes.rst:236 msgid "Using the hooks plugin" msgstr "使用钩子" #: ../../recipes.rst:238 msgid "" "For example, if you want to allow Cross-Origin Resource Sharing for the " "content returned by all of your URL, you can use the hook decorator and " "setup a callback function::" msgstr "例如,你想提供跨域资源共享,可参考下面的例子。" #: ../../recipes.rst:256 msgid "" "You can also use the ``before_request`` to take an action before every " "function gets called." msgstr "你也可以使用 ``before_request`` ,这样在route的回调函数被调用之前,都会调用你的钩子函数。" #: ../../recipes.rst:261 msgid "Using Bottle with Heroku" msgstr "在Heroku中使用Bottle" #: ../../recipes.rst:263 msgid "" "Heroku_, a popular cloud application platform now provides support for " "running Python applications on their infastructure." msgstr "Heroku_ ,一个流行的云应用平台,提供Python支持。" #: ../../recipes.rst:266 msgid "" "This recipe is based upon the `Heroku Quickstart " "`_, with Bottle specific " "code replacing the `Write Your App " "`_ section of " "the `Getting Started with Python on Heroku/Cedar " "`_ guide::" msgstr "这份教程基于 `Heroku Quickstart `_, 用Bottle特有的代码替换了 `Getting Started with Python on Heroku/Cedar `_ 中的`Write Your App `_ 这部分::" #: ../../recipes.rst:282 msgid "" "Heroku's app stack passes the port that the application needs to listen on " "for requests, using the `os.environ` dictionary." msgstr "Heroku使用 `os.environ` 字典来提供Bottle应用需要监听的端口。" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/routing.po000066400000000000000000000206341470367422500235670ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../routing.rst:3 msgid "Request Routing" msgstr "URL映射" #: ../../routing.rst:5 msgid "" "Bottle uses a powerful routing engine to find the right callback for each " "request. The :ref:`tutorial ` shows you the basics. This " "document covers advanced techniques and rule mechanics in detail." msgstr "Bottle内置一个强大的route引擎,可以给每个浏览器请求找到正确的回调函数。 :ref:`tutorial ` 中已经介绍了一些基础知识。接下来是一些进阶知识和route的规则。" #: ../../routing.rst:8 msgid "Rule Syntax" msgstr "route的语法" #: ../../routing.rst:10 msgid "" "The :class:`Router` distinguishes between two basic types of routes: " "**static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. " "``/hello/``). A route that contains one or more *wildcards* it is " "considered dynamic. All other routes are static." msgstr ":class:`Router` 类中明确区分两种类型的route: **静态route** (例如 ``/contact`` )和 **动态route** (例如 ``/hello/`` )。包含了 *通配符* 的route即是动态route,除此之外的都是静态的。" #: ../../routing.rst:14 msgid "" "The simplest form of a wildcard consists of a name enclosed in angle " "brackets (e.g. ````). The name should be unique for a given route and " "form a valid python identifier (alphanumeric, starting with a letter). This " "is because wildcards are used as keyword arguments for the request callback " "later." msgstr "包含通配符,最简单的形式就是将其放到一对<>里面(例如 ```` )。在同一个route里面,这个变量名需要是唯一的。因为稍后会将其当作参数传给回调函数,所以这个变量名的第一个字符应该是字母。" #: ../../routing.rst:16 msgid "" "Each wildcard matches one or more characters, but stops at the first slash " "(``/``). This equals a regular expression of ``[^/]+`` and ensures that only" " one path segment is matched and routes with more than one wildcard stay " "unambiguous." msgstr "每一个通配符匹配一个或多个字符,直到遇到 ``/`` 。类似于 ``[^/]+`` 这样一个正则表达式,确保在route包含多个通配符的时候不出现歧义。" #: ../../routing.rst:18 msgid "The rule ``//`` matches as follows:" msgstr "``//`` 这个规则匹配的情况如下" #: ../../routing.rst:21 msgid "Path" msgstr "路径" #: ../../routing.rst:21 msgid "Result" msgstr "结果" #: ../../routing.rst:23 msgid "/save/123" msgstr "" #: ../../routing.rst:23 msgid "``{'action': 'save', 'item': '123'}``" msgstr "" #: ../../routing.rst:24 msgid "/save/123/" msgstr "" #: ../../routing.rst:24 ../../routing.rst:25 ../../routing.rst:26 msgid "`No Match`" msgstr "不匹配" #: ../../routing.rst:25 msgid "/save/" msgstr "" #: ../../routing.rst:26 msgid "//123" msgstr "" #: ../../routing.rst:29 msgid "" "Is it possible to escape characters like colon ``:`` with a backslash " "``\\``. This will prevent to trigger the old syntax in case you need to use " "``:``. For example: the rule ``//item:`` triggers the old " "syntax, (see below) but ``/action/item\\:`` works as intended with the " "new syntax." msgstr "" #: ../../routing.rst:33 msgid "" "You can change the exact behaviour in many ways using filters. This is " "described in the next section." msgstr "你可通过过滤器来改变这一行为,稍后会介绍。" #: ../../routing.rst:36 msgid "Wildcard Filters" msgstr "通配符过滤器" #: ../../routing.rst:40 msgid "" "Filters are used to define more specific wildcards, and/or transform the " "matched part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "过滤器被用于定义更特殊的通配符,可在URL中\"被匹配到的部分\"被传递给回调函数之前,处理其内容。可通过 ```` 或 ```` 这样的语句来声明一个过滤器。\"config\"部分的语法由被使用的过滤器决定。" #: ../../routing.rst:42 msgid "The following standard filters are implemented:" msgstr "Bottle中已实现以下过滤器:" #: ../../routing.rst:44 msgid "**:int** matches (signed) digits and converts the value to integer." msgstr "**:int** 匹配一个整形数,并将其转换为int" #: ../../routing.rst:45 msgid "**:float** similar to :int but for decimal numbers." msgstr "**:float** 同上,匹配一个浮点数" #: ../../routing.rst:46 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and may be used to match more than one path segment." msgstr "**:path** 匹配所有字符,包括'/'" #: ../../routing.rst:47 msgid "" "**:re[:exp]** allows you to specify a custom regular expression in the " "config field. The matched value is not modified." msgstr "**:re[:exp]** 允许在exp中写一个正则表达式" #: ../../routing.rst:49 msgid "" "You can add your own filters to the router. All you need is a function that " "returns three elements: A regular expression string, a callable to convert " "the URL fragment to a python value, and a callable that does the opposite. " "The filter function is called with the configuration string as the only " "parameter and may parse it as needed::" msgstr "你可在route中添加自己写的过滤器。过滤器是一个有三个返回值的函数:一个正则表达式,一个callable的对象(转换URL片段为Python对象),另一个callable对象(转换Python对象为URL片段)。过滤器仅接受一个参数,就是设置字符串(译者注:例如re过滤器的exp部分)。" #: ../../routing.rst:75 msgid "Legacy Syntax" msgstr "旧语法" #: ../../routing.rst:79 msgid "" "The new rule syntax was introduce in **Bottle 0.10** to simplify some common" " use cases, but the old syntax still works and you can find lot code " "examples still using it. The differences are best described by example:" msgstr "在 **Bottle 0.10** 版本中引入了新的语法,来简单化一些常见用例,但依然兼容旧的语法。新旧语法的区别如下。" #: ../../routing.rst:82 msgid "Old Syntax" msgstr "旧语法" #: ../../routing.rst:82 msgid "New Syntax" msgstr "新语法" #: ../../routing.rst:84 msgid "``:name``" msgstr "" #: ../../routing.rst:84 msgid "````" msgstr "" #: ../../routing.rst:85 msgid "``:name#regexp#``" msgstr "" #: ../../routing.rst:85 msgid "````" msgstr "" #: ../../routing.rst:86 msgid "``:#regexp#``" msgstr "" #: ../../routing.rst:86 msgid "``<:re:regexp>``" msgstr "" #: ../../routing.rst:87 msgid "``:##``" msgstr "" #: ../../routing.rst:87 msgid "``<:re>``" msgstr "" #: ../../routing.rst:90 msgid "" "Try to avoid the old syntax in future projects if you can. It is not " "currently deprecated, but will be eventually." msgstr "请尽量在新项目中避免使用旧的语法,虽然它现在还没被废弃,但终究会的。" #: ../../routing.rst:95 msgid "Explicit routing configuration" msgstr "显式的route配置" #: ../../routing.rst:97 msgid "" "Route decorator can also be directly called as method. This way provides " "flexibility in complex setups, allowing you to directly control, when and " "how routing configuration done." msgstr "route修饰器也可以直接当作函数来调用。在复杂的部署中,这种方法或许更灵活,直接由你来控制“何时”及“如何”配置route。" #: ../../routing.rst:99 msgid "" "Here is a basic example of explicit routing configuration for default bottle" " application::" msgstr "下面是一个简单的例子" #: ../../routing.rst:105 msgid "" "In fact, any :class:`Bottle` instance routing can be configured same way::" msgstr "实际上,bottle可以是任何 :class:`Bottle` 类的实例" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/stpl.po000066400000000000000000000246611470367422500230660ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../stpl.rst:3 msgid "SimpleTemplate Engine" msgstr "SimpleTemplate 模板引擎" #: ../../stpl.rst:7 msgid "" "Bottle comes with a fast, powerful and easy to learn built-in template " "engine called *SimpleTemplate* or *stpl* for short. It is the default engine" " used by the :func:`view` and :func:`template` helpers but can be used as a " "stand-alone general purpose template engine too. This document explains the " "template syntax and shows examples for common use cases." msgstr "Bottle自带了一个快速,强大,易用的模板引擎,名为 *SimpleTemplate* 或简称为 *stpl* 。它是 :func:`view` 和 :func:`template` 两个函数默认调用的模板引擎。接下来会介绍该引擎的模板语法和一些常见用例。" #: ../../stpl.rst:10 msgid "Basic API Usage:" msgstr "基础API :" #: ../../stpl.rst:11 msgid ":class:`SimpleTemplate` implements the :class:`BaseTemplate` API::" msgstr ":class:`SimpleTemplate` 类实现了 :class:`BaseTemplate` 接口" #: ../../stpl.rst:18 msgid "" "In this document we use the :func:`template` helper in examples for the sake" " of simplicity::" msgstr "简单起见,我们在例子中使用 :func:`template` 函数" #: ../../stpl.rst:24 msgid "" "You can also pass a dictionary into the template using keyword arguments::" msgstr "" #: ../../stpl.rst:31 msgid "" "Just keep in mind that compiling and rendering templates are two different " "actions, even if the :func:`template` helper hides this fact. Templates are " "usually compiled only once and cached internally, but rendered many times " "with different keyword arguments." msgstr "注意,编译模板和渲染模板是两件事情,尽管 :func:`template` 函数隐藏了这一事实。通常,模板只会被编译一次,然后会被缓存起来,但是会根据不同的参数,被多次渲染。" #: ../../stpl.rst:34 msgid ":class:`SimpleTemplate` Syntax" msgstr ":class:`SimpleTemplate` 的语法" #: ../../stpl.rst:36 msgid "" "Python is a very powerful language but its whitespace-aware syntax makes it " "difficult to use as a template language. SimpleTemplate removes some of " "these restrictions and allows you to write clean, readable and maintainable " "templates while preserving full access to the features, libraries and speed " "of the Python language." msgstr "虽然Python是一门强大的语言,但它对空白敏感的语法令其很难作为一个模板语言。SimpleTemplate移除了一些限制,允许你写出干净的,有可读性的,可维护的模板,且保留了Python的强大功能。" #: ../../stpl.rst:40 msgid "" "The :class:`SimpleTemplate` syntax compiles directly to python bytecode and " "is executed on each :meth:`SimpleTemplate.render` call. Do not render " "untrusted templates! They may contain and execute harmful python code." msgstr " :class:`SimpleTemplate` 模板会被编译为Python字节码,且在每次通过 :meth:`SimpleTemplate.render` 渲染的时候执行。请不要渲染不可靠的模板!它们也许包含恶意代码。" #: ../../stpl.rst:43 msgid "Inline Expressions" msgstr "内嵌表达式" #: ../../stpl.rst:45 msgid "" "You already learned the use of the ``{{...}}`` syntax from the \"Hello " "World!\" example above, but there is more: any python expression is allowed " "within the curly brackets as long as it evaluates to a string or something " "that has a string representation::" msgstr "" #: ../../stpl.rst:54 msgid "" "The contained python expression is executed at render-time and has access to" " all keyword arguments passed to the :meth:`SimpleTemplate.render` method. " "HTML special characters are escaped automatically to prevent `XSS " "`_ attacks. You can start" " the expression with an exclamation mark to disable escaping for that " "expression::" msgstr "{{}}中的Python语句会在渲染的时候被执行,可访问传递给 :meth:`SimpleTemplate.render` 方法的所有参数。默认情况下,自动转义HTML标签以防止 `XSS `_ 攻击。可在语句前加上\"!\"来关闭自动转义。" #: ../../stpl.rst:62 msgid "Embedded python code" msgstr "嵌入Pyhton代码" #: ../../stpl.rst:66 msgid "" "The template engine allows you to embed lines or blocks of python code " "within your template. Code lines start with ``%`` and code blocks are " "surrounded by ``<%`` and ``%>`` tokens::" msgstr "" #: ../../stpl.rst:76 msgid "" "Embedded python code follows regular python syntax, but with two additional " "syntax rules:" msgstr "" #: ../../stpl.rst:78 msgid "" "**Indentation is ignored.** You can put as much whitespace in front of " "statements as you want. This allows you to align your code with the " "surrounding markup and can greatly improve readability." msgstr "" #: ../../stpl.rst:79 msgid "" "Blocks that are normally indented now have to be closed explicitly with an " "``end`` keyword." msgstr "" #: ../../stpl.rst:89 msgid "" "Both the ``%`` and the ``<%`` tokens are only recognized if they are the " "first non-whitespace characters in a line. You don't have to escape them if " "they appear mid-text in your template markup. Only if a line of text starts " "with one of these tokens, you have to escape it with a backslash. In the " "rare case where the backslash + token combination appears in your markup at " "the beginning of a line, you can always help yourself with a string literal " "in an inline expression::" msgstr "" #: ../../stpl.rst:96 msgid "" "If you find yourself needing to escape a lot, consider using :ref:`custom " "tokens `." msgstr "" #: ../../stpl.rst:98 msgid "" "Note that ``%`` and ``<% %>`` work in *exactly* the same way. The latter is " "only a convenient way to type less and avoid clutter for longer code " "segments. This means that in ``<% %>`` blocks, all indented code must be " "terminated with an ``end``, as in the following example::" msgstr "" #: ../../stpl.rst:114 msgid "Whitespace Control" msgstr "" #: ../../stpl.rst:116 msgid "" "Code blocks and code lines always span the whole line. Whitespace in front " "of after a code segment is stripped away. You won't see empty lines or " "dangling whitespace in your template because of embedded code::" msgstr "" #: ../../stpl.rst:124 msgid "This snippet renders to clean and compact html::" msgstr "" #: ../../stpl.rst:130 msgid "" "But embedding code still requires you to start a new line, which may not " "what you want to see in your rendered template. To skip the newline in front" " of a code segment, end the text line with a double-backslash::" msgstr "" #: ../../stpl.rst:138 msgid "This time the rendered template looks like this::" msgstr "" #: ../../stpl.rst:142 msgid "" "This only works directly in front of code segments. In all other places you " "can control the whitespace yourself and don't need any special syntax." msgstr "" #: ../../stpl.rst:145 msgid "Template Functions" msgstr "" #: ../../stpl.rst:147 msgid "" "Each template is preloaded with a bunch of functions that help with the most" " common use cases. These functions are always available. You don't have to " "import or provide them yourself. For everything not covered here there are " "probably good python libraries available. Remember that you can ``import`` " "anything you want within your templates. They are python programs after all." msgstr "" #: ../../stpl.rst:151 msgid "" "Prior to this release, :func:`include` and :func:`rebase` were syntax " "keywords, not functions." msgstr "" #: ../../stpl.rst:156 msgid "" "Render a sub-template with the specified variables and insert the resulting " "text into the current template. The function returns a dictionary containing" " the local variables passed to or defined within the sub-template::" msgstr "" #: ../../stpl.rst:164 msgid "" "Mark the current template to be later included into a different template. " "After the current template is rendered, its resulting text is stored in a " "variable named ``base`` and passed to the base-template, which is then " "rendered. This can be used to `wrap` a template with surrounding text, or " "simulate the inheritance feature found in other template engines::" msgstr "" #: ../../stpl.rst:169 msgid "This can be combined with the following ``base.tpl``::" msgstr "" #: ../../stpl.rst:181 msgid "" "Accessing undefined variables in a template raises :exc:`NameError` and " "stops rendering immediately. This is standard python behavior and nothing " "new, but vanilla python lacks an easy way to check the availability of a " "variable. This quickly gets annoying if you want to support flexible inputs " "or use the same template in different situations. These functions may help:" msgstr "" #: ../../stpl.rst:189 msgid "" "Return True if the variable is defined in the current template namespace, " "False otherwise." msgstr "如果变量已定义则返回True,反之返回False。" #: ../../stpl.rst:194 msgid "Return the variable, or a default value." msgstr "返回该变量,或一个默认值" #: ../../stpl.rst:198 msgid "" "If the variable is not defined, create it with the given default value. " "Return the variable." msgstr "如果该变量未定义,则定义它,赋一个默认值,返回该变量" #: ../../stpl.rst:201 msgid "" "Here is an example that uses all three functions to implement optional " "template variables in different ways::" msgstr "下面是使用了这三个函数的例子,实现了模板中的可选参数。" #: ../../stpl.rst:215 msgid ":class:`SimpleTemplate` API" msgstr ":class:`SimpleTemplate` API" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.prepare:1 msgid "" "Run preparations (parsing, caching, ...). It should be possible to call this" " again to refresh a template or to update settings." msgstr "" #: ../../../bottle.pydocstring of bottle.SimpleTemplate.render:1 msgid "Render the template using keyword arguments as local variables." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/tutorial.po000066400000000000000000002301611470367422500237410ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: defnull \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../tutorial.rst:24 msgid "Tutorial" msgstr "教程" #: ../../tutorial.rst:26 msgid "" "This tutorial introduces you to the concepts and features of the Bottle web " "framework and covers basic and advanced topics alike. You can read it from " "start to end, or use it as a reference later on. The automatically generated" " :doc:`api` may be interesting for you, too. It covers more details, but " "explains less than this tutorial. Solutions for the most common questions " "can be found in our :doc:`recipes` collection or on the :doc:`faq` page. If " "you need any help, join our `mailing list " "`_ or visit us in our `IRC channel " "`_." msgstr "这份教程将向你介绍Bottle的开发理念和功能特性。既介绍Bottle的基本用法,也包含了进阶用法。你可以从头到尾通读一遍,也可当做开发时的参考。你也许对自动生成的 :doc:`api` 感兴趣。它包含了更多的细节,但解释没有这份教程详细。在 :doc:`recipes` 或 :doc:`faq` 可找到常见问题的解决办法。如果需要任何帮助,可加入我们的 `邮件列表 `_ 或在 `IRC频道 `_ 和我们交流。" #: ../../tutorial.rst:31 msgid "Installation" msgstr "安装" #: ../../tutorial.rst:33 msgid "" "Bottle does not depend on any external libraries. You can just download " "`bottle.py `_ into your project directory and start coding:" msgstr "Bottle不依赖其他库,你需要做的仅是下载 `bottle.py `_ (开发版)到你的项目文件夹,然后开始写代码。" #: ../../tutorial.rst:39 msgid "" "This will get you the latest development snapshot that includes all the new " "features. If you prefer a more stable environment, you should stick with the" " stable releases. These are available on `PyPI " "`_ and can be installed via " ":command:`pip` (recommended), :command:`easy_install` or your package " "manager:" msgstr "在终端运行以上命令,即可下载到Bottle的最新开发版,包含了所有新功能特性。如果更需要稳定性,你应该坚持使用Bottle的稳定版本。可在 `PyPI `_ 下载稳定版本,然后通过 :command:`pip` (推荐), :command:`easy_install` 或你的包管理软件安装。" #: ../../tutorial.rst:47 msgid "" "Either way, you'll need Python 2.7 or newer (including 3.4+) to run bottle " "applications. If you do not have permissions to install packages system-wide" " or simply don't want to, create a `virtualenv " "`_ first:" msgstr "" #: ../../tutorial.rst:55 msgid "Or, if virtualenv is not installed on your system:" msgstr "如果还未安装virtualenv:" #: ../../tutorial.rst:67 msgid "Quickstart: \"Hello World\"" msgstr "" #: ../../tutorial.rst:69 msgid "" "This tutorial assumes you have Bottle either :ref:`installed `" " or copied into your project directory. Let's start with a very basic " "\"Hello World\" example::" msgstr "到目前为止,我假设你已经 :ref:`安装 ` 好了bottle或已将bottle.py拷贝到你的项目文件夹。接下来我们就可以写一个非常简单的\"Hello World\"了::" #: ../../tutorial.rst:79 msgid "" "This is it. Run this script, visit http://localhost:8080/hello and you will " "see \"Hello World!\" in your browser. Here is how it works:" msgstr "就这么简单!保存为py文件并执行,用浏览器访问 http://localhost:8080/hello 就可以看到\"Hello World!\"。它的执行流程大致如下:" #: ../../tutorial.rst:81 msgid "" "The :func:`route` decorator binds a piece of code to an URL path. In this " "case, we link the ``/hello`` path to the ``hello()`` function. This is " "called a `route` (hence the decorator name) and is the most important " "concept of this framework. You can define as many routes as you want. " "Whenever a browser requests a URL, the associated function is called and the" " return value is sent back to the browser. It's as simple as that." msgstr "" #: ../../tutorial.rst:83 msgid "" "The :func:`run` call in the last line starts a built-in development server. " "It runs on ``localhost`` port ``8080`` and serves requests until you hit " ":kbd:`Control-c`. You can switch the server backend later, but for now a " "development server is all we need. It requires no setup at all and is an " "incredibly painless way to get your application up and running for local " "tests." msgstr "最后一行调用的 :func:`run` 函数启动了内置的开发服务器。它监听 `localhost` 的8080端口并响应请求, :kbd:`Control-c` 可将其关闭。到目前为止,这个内置的开发服务器已经足够用于日常的开发测试了。它根本不需要安装,就可以让你的应用跑起来。在教程的后面,你将学会如何让你的应用跑在其他服务器上面(译者注:内置服务器不能满足生产环境的要求)" #: ../../tutorial.rst:85 msgid "" "The :ref:`tutorial-debugging` is very helpful during early development, but " "should be switched off for public applications. Keep that in mind." msgstr ":ref:`tutorial-debugging` 在早期开发的时候非常有用,但请务必记得,在生产环境中将其关闭。" #: ../../tutorial.rst:87 msgid "" "This is just a demonstration of the basic concept of how applications are " "built with Bottle. Continue reading and you'll see what else is possible." msgstr "" #: ../../tutorial.rst:92 msgid "The Default Application" msgstr "`默认应用`" #: ../../tutorial.rst:94 msgid "" "For the sake of simplicity, most examples in this tutorial use a module-" "level :func:`route` decorator to define routes. This adds routes to a global" " \"default application\", an instance of :class:`Bottle` that is " "automatically created the first time you call :func:`route`. Several other " "module-level decorators and functions relate to this default application, " "but if you prefer a more object oriented approach and don't mind the extra " "typing, you can create a separate application object and use that instead of" " the global one::" msgstr "基于简单性考虑,这份教程中的大部分例子都使用一个模块层面的 :func:`route` 修饰器函数来定义route。这样的话,所有route都添加到了一个全局的“默认应用”里面,即是在第一次调用 :func:`route` 函数时,创建的一个 :class:`Bottle` 类的实例。其他几个模块层面的修饰器函数都与这个“默认应用”有关,如果你偏向于面向对象的做法且不介意多打点字,你可以创建一个独立的应用对象,这样就可避免使用全局范围的“默认应用”。" #: ../../tutorial.rst:106 msgid "" "The object-oriented approach is further described in the :ref:`default-app` " "section. Just keep in mind that you have a choice." msgstr "接下来的 :ref:`default-app` 章节中将更详细地介绍这种做法。现在,你只需知道不止有一种选择就好了。" #: ../../tutorial.rst:114 msgid "Request Routing" msgstr "URL映射" #: ../../tutorial.rst:116 msgid "" "In the last chapter we built a very simple web application with only a " "single route. Here is the routing part of the \"Hello World\" example " "again::" msgstr "在上一章中,我们实现了一个十分简单的web应用,只有一个URL映射(route)。让我们再来看一下“Hello World”中与routing有关的部分::" #: ../../tutorial.rst:122 msgid "" "The :func:`route` decorator links an URL path to a callback function, and " "adds a new route to the :ref:`default application `. An " "application with just one route is kind of boring, though. Let's add some " "more (don't forget ``from bottle import template``)::" msgstr "" #: ../../tutorial.rst:129 msgid "" "This example demonstrates two things: You can bind more than one route to a " "single callback, and you can add wildcards to URLs and access them via " "keyword arguments." msgstr "这个例子说明了两件事情,一个回调函数可绑定多个route,你也可以在URL中添加通配符,然后在回调函数中使用它们。" #: ../../tutorial.rst:136 msgid "Dynamic Routes" msgstr "动态URL映射" #: ../../tutorial.rst:138 msgid "" "Routes that contain wildcards are called `dynamic routes` (as opposed to " "`static routes`) and match more than one URL at the same time. A simple " "wildcard consists of a name enclosed in angle brackets (e.g. ````) and" " accepts one or more characters up to the next slash (``/``). For example, " "the route ``/hello/`` accepts requests for ``/hello/alice`` as well as" " ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``." msgstr "包含通配符的route,我们称之为动态route(与之对应的是静态route),它能匹配多个URL地址。一个通配符包含在一对尖括号里面(像这样 ```` ),通配符之间用\"/\"分隔开来。如果我们将URL定义为 ``/hello/`` 这样,那么它就能匹配 ``/hello/alice`` 和 ``/hello/bob`` 这样的浏览器请求,但不能匹配 ``/hello`` , ``/hello/`` 和 ``/hello/mr/smith`` 。" #: ../../tutorial.rst:140 msgid "" "Each wildcard passes the covered part of the URL as a keyword argument to " "the request callback. You can use them right away and implement RESTful, " "nice-looking and meaningful URLs with ease. Here are some other examples " "along with the URLs they'd match::" msgstr "URL中的通配符都会当作参数传给回调函数,直接在回调函数中使用。这样可以漂亮地实现RESTful形式的URL。例子如下::" #: ../../tutorial.rst:150 msgid "" "Filters can be used to define more specific wildcards, and/or transform the " "covered part of the URL before it is passed to the callback. A filtered " "wildcard is declared as ```` or ````. The " "syntax for the optional config part depends on the filter used." msgstr "" #: ../../tutorial.rst:152 msgid "" "The following filters are implemented by default and more may be added:" msgstr "已实现下面几种形式的过滤器,后续可能会继续添加:" #: ../../tutorial.rst:154 msgid "" "**:int** matches (signed) digits only and converts the value to integer." msgstr "**:int** 匹配一个数字,自动将其转换为int类型。" #: ../../tutorial.rst:155 msgid "**:float** similar to :int but for decimal numbers." msgstr "**:float** 与:int类似,用于浮点数。" #: ../../tutorial.rst:156 msgid "" "**:path** matches all characters including the slash character in a non-" "greedy way and can be used to match more than one path segment." msgstr "**:path** 匹配一个路径(包含\"/\")" #: ../../tutorial.rst:157 msgid "" "**:re** allows you to specify a custom regular expression in the config " "field. The matched value is not modified." msgstr "**:re** 匹配config部分的一个正则表达式,不更改被匹配到的值" #: ../../tutorial.rst:159 msgid "Let's have a look at some practical examples::" msgstr "让我们来看看具体的使用例子::" #: ../../tutorial.rst:173 msgid "You can add your own filters as well. See :doc:`routing` for details." msgstr "" #: ../../tutorial.rst:177 msgid "HTTP Request Methods" msgstr "HTTP请求方法" #: ../../tutorial.rst:181 msgid "" "The HTTP protocol defines several `request methods`__ (sometimes referred to" " as \"verbs\") for different tasks. GET is the default for all routes with " "no other method specified. These routes will match GET requests only. To " "handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` " "keyword argument to the :func:`route` decorator or use one of the five " "alternative decorators: :func:`get`, :func:`post`, :func:`put`, " ":func:`delete` or :func:`patch`." msgstr "" #: ../../tutorial.rst:183 msgid "" "The POST method is commonly used for HTML form submission. This example " "shows how to handle a login form using POST::" msgstr "POST方法一般用于HTML表单的提交。下面是一个使用POST来实现用户登录的例子::" #: ../../tutorial.rst:206 msgid "" "In this example the ``/login`` URL is linked to two distinct callbacks, one " "for GET requests and another for POST requests. The first one displays a " "HTML form to the user. The second callback is invoked on a form submission " "and checks the login credentials the user entered into the form. The use of " ":attr:`Request.forms` is further described in the :ref:`tutorial-request` " "section." msgstr "在这个例子中, ``/login`` 绑定了两个回调函数,一个回调函数响应GET请求,一个回调函数响应POST请求。如果浏览器使用GET请求访问 ``/login`` ,则调用login_form()函数来返回登录页面,浏览器使用POST方法提交表单后,调用login_submit()函数来检查用户有效性,并返回登录结果。接下来的 :ref:`tutorial-request` 章节中,会详细介绍 :attr:`Request.forms` 的用法。" #: ../../tutorial.rst:209 msgid "Special Methods: HEAD and ANY" msgstr "特殊请求方法: HEAD 和 ANY" #: ../../tutorial.rst:210 msgid "" "The HEAD method is used to ask for the response identical to the one that " "would correspond to a GET request, but without the response body. This is " "useful for retrieving meta-information about a resource without having to " "download the entire document. Bottle handles these requests automatically by" " falling back to the corresponding GET route and cutting off the request " "body, if present. You don't have to specify any HEAD routes yourself." msgstr "HEAD方法类似于GET方法,但服务器不会返回HTTP响应正文,一般用于获取HTTP原数据而不用下载整个页面。Bottle像处理GET请求那样处理HEAD请求,但是会自动去掉HTTP响应正文。你无需亲自处理HEAD请求。" #: ../../tutorial.rst:212 msgid "" "Additionally, the non-standard ANY method works as a low priority fallback: " "Routes that listen to ANY will match requests regardless of their HTTP " "method but only if no other more specific route is defined. This is helpful " "for *proxy-routes* that redirect requests to more specific sub-applications." msgstr "另外,非标准的ANY方法做为一个低优先级的fallback:在没有其它route的时候,监听ANY方法的route会匹配所有请求,而不管请求的方法是什么。这对于用做代理的route很有用,可将所有请求都重定向给子应用。" #: ../../tutorial.rst:214 msgid "" "To sum it up: HEAD requests fall back to GET routes and all requests fall " "back to ANY routes, but only if there is no matching route for the original " "request method. It's as simple as that." msgstr "总而言之:HEAD请求被响应GET请求的route来处理,响应ANY请求的route处理所有请求,但仅限于没有其它route来匹配原先的请求的情况。就这么简单。" #: ../../tutorial.rst:219 msgid "Routing Static Files" msgstr "静态文件映射" #: ../../tutorial.rst:221 msgid "" "Static files such as images or CSS files are not served automatically. You " "have to add a route and a callback to control which files get served and " "where to find them::" msgstr "Bottle不会处理像图片或CSS文件的静态文件请求。你需要给静态文件提供一个route,一个回调函数(用于查找和控制静态文件的访问)。" #: ../../tutorial.rst:228 msgid "" "The :func:`static_file` function is a helper to serve files in a safe and " "convenient way (see :ref:`tutorial-static-files`). This example is limited " "to files directly within the ``/path/to/your/static/files`` directory " "because the ```` wildcard won't match a path with a slash in it. " "To serve files in subdirectories, change the wildcard to use the `path` " "filter::" msgstr ":func:`static_file` 函数用于响应静态文件的请求。 (详见 :ref:`tutorial-static-files` )这个例子只能响应在 ``/path/to/your/static/files`` 目录下的文件请求,因为 ```` 这样的通配符定义不能匹配一个路径(路径中包含\"/\")。 为了响应子目录下的文件请求,我们需要更改 `path` 过滤器的定义::" #: ../../tutorial.rst:234 msgid "" "Be careful when specifying a relative root-path such as " "``root='./static/files'``. The working directory (``./``) and the project " "directory are not always the same." msgstr "使用 ``root='./static/files'`` 这样的相对路径的时候,请注意当前工作目录 (``./``) 不一定是项目文件夹。" #: ../../tutorial.rst:242 msgid "Error Pages" msgstr "错误页面" #: ../../tutorial.rst:244 msgid "" "If anything goes wrong, Bottle displays an informative but fairly plain " "error page. You can override the default for a specific HTTP status code " "with the :func:`error` decorator::" msgstr "如果出错了,Bottle会显示一个默认的错误页面,提供足够的debug信息。你也可以使用 :func:`error` 函数来自定义你的错误页面::" #: ../../tutorial.rst:251 msgid "" "From now on, `404 File not Found` errors will display a custom error page to" " the user. The only parameter passed to the error-handler is an instance of " ":exc:`HTTPError`. Apart from that, an error-handler is quite similar to a " "regular request callback. You can read from :data:`request`, write to " ":data:`response` and return any supported data-type except for " ":exc:`HTTPError` instances." msgstr "从现在开始,在遇到404错误的时候,将会返回你在上面自定义的页面。传给error404函数的唯一参数,是一个 :exc:`HTTPError` 对象的实例。除此之外,这个回调函数与我们用来响应普通请求的回调函数没有任何不同。你可以从 :data:`request` 中读取数据, 往 :data:`response` 中写入数据和返回所有支持的数据类型,除了 :exc:`HTTPError` 的实例。" #: ../../tutorial.rst:253 msgid "" "Error handlers are used only if your application returns or raises an " ":exc:`HTTPError` exception (:func:`abort` does just that). Changing " ":attr:`Request.status` or returning :exc:`HTTPResponse` won't trigger the " "error handler." msgstr "只有在你的应用返回或raise一个 :exc:`HTTPError` 异常的时候(就像 :func:`abort` 函数那样),处理Error的函数才会被调用。更改 :attr:`Request.status` 或返回 :exc:`HTTPResponse` 不会触发错误处理函数。" #: ../../tutorial.rst:263 msgid "Generating content" msgstr "生成内容" #: ../../tutorial.rst:265 msgid "" "In pure WSGI, the range of types you may return from your application is " "very limited. Applications must return an iterable yielding byte strings. " "You may return a string (because strings are iterable) but this causes most " "servers to transmit your content char by char. Unicode strings are not " "allowed at all. This is not very practical." msgstr "在纯WSGI环境里,你的应用能返回的内容类型相当有限。应用必须返回一个iterable的字节型字符串。你可以返回一个字符串(因为字符串是iterable的),但这会导致服务器按字符来传输你的内容。Unicode字符串根本不允许。这不是很实用。" #: ../../tutorial.rst:267 msgid "" "Bottle is much more flexible and supports a wide range of types. It even " "adds a ``Content-Length`` header if possible and encodes unicode " "automatically, so you don't have to. What follows is a list of data types " "you may return from your application callbacks and a short description of " "how these are handled by the framework:" msgstr "Bottle支持返回更多的内容类型,更具弹性。它甚至能在合适的情况下,在HTTP头中添加 `Content-Length` 字段和自动转换unicode编码。下面列出了所有你能返回的内容类型,以及框架处理方式的一个简述。" #: ../../tutorial.rst:270 msgid "Dictionaries" msgstr "" #: ../../tutorial.rst:270 msgid "" "As mentioned above, Python dictionaries (or subclasses thereof) are " "automatically transformed into JSON strings and returned to the browser with" " the ``Content-Type`` header set to ``application/json``. This makes it easy" " to implement json-based APIs. Data formats other than json are supported " "too. See the :ref:`tutorial-output-filter` to learn more." msgstr "上面已经提及,Python中的字典类型(或其子类)会被自动转换为JSON字符串。返回给浏览器的时候,HTTP头的 ``Content-Type`` 字段被自动设置为 `` application/json`` 。可十分简单地实现基于JSON的API。Bottle同时支持json之外的数据类型,详见 :ref:`tutorial-output-filter` 。" #: ../../tutorial.rst:273 msgid "Empty Strings, ``False``, ``None`` or other non-true values:" msgstr "" #: ../../tutorial.rst:273 msgid "" "These produce an empty output with the ``Content-Length`` header set to 0." msgstr "输出为空, ``Content-Length`` 设为0。" #: ../../tutorial.rst:276 msgid "Unicode strings" msgstr "Unicode的问题" #: ../../tutorial.rst:276 msgid "" "Unicode strings (or iterables yielding unicode strings) are automatically " "encoded with the codec specified in the ``Content-Type`` header (utf8 by " "default) and then treated as normal byte strings (see below)." msgstr "Unicode字符串 (or iterables yielding unicode strings) 被自动转码, ``Content-Type`` 被默认设置为utf8,接着视之为普通字符串(见下文)。" #: ../../tutorial.rst:279 msgid "Byte strings" msgstr "" #: ../../tutorial.rst:279 msgid "" "Bottle returns strings as a whole (instead of iterating over each char) and " "adds a ``Content-Length`` header based on the string length. Lists of byte " "strings are joined first. Other iterables yielding byte strings are not " "joined because they may grow too big to fit into memory. The ``Content-" "Length`` header is not set in this case." msgstr "Bottle将字符串当作一个整体来返回(而不是按字符来遍历),并根据字符串长度添加 ``Content-Length`` 字段。包含字节型字符串的列表先被合并。其它iterable的字节型字符串不会被合并,因为它们也许太大来,耗内存。在这种情况下, ``Content-Length`` 字段不会被设置。" #: ../../tutorial.rst:282 msgid "Instances of :exc:`HTTPError` or :exc:`HTTPResponse`" msgstr "" #: ../../tutorial.rst:282 msgid "" "Returning these has the same effect as when raising them as an exception. In" " case of an :exc:`HTTPError`, the error handler is applied. See :ref" ":`tutorial-errorhandling` for details." msgstr "返回它们和直接raise出来有一样的效果。对于 :exc:`HTTPError` 来说,会调用错误处理程序。详见 :ref:`tutorial-errorhandling` 。" #: ../../tutorial.rst:285 msgid "File objects" msgstr "" #: ../../tutorial.rst:285 msgid "" "Everything that has a ``.read()`` method is treated as a file or file-like " "object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI " "server framework. Some WSGI server implementations can make use of optimized" " system calls (sendfile) to transmit files more efficiently. In other cases " "this just iterates over chunks that fit into memory. Optional headers such " "as ``Content-Length`` or ``Content-Type`` are *not* set automatically. Use " ":func:`send_file` if possible. See :ref:`tutorial-static-files` for details." msgstr "任何有 ``.read()`` 方法的对象都被当成一个file-like对象来对待,会被传给 WSGI Server 框架定义的 ``wsgi.file_wrapper`` callable对象来处理。一些WSGI Server实现会利用优化过的系统调用(sendfile)来更有效地传输文件,另外就是分块遍历。可选的HTTP头,例如 ``Content-Length`` 和 ``Content-Type`` 不会被自动设置。尽可能使用 :func:`send_file` 。详见 :ref:`tutorial-static-files` 。" #: ../../tutorial.rst:288 msgid "Iterables and generators" msgstr "" #: ../../tutorial.rst:288 msgid "" "You are allowed to use ``yield`` within your callbacks or return an " "iterable, as long as the iterable yields byte strings, unicode strings, " ":exc:`HTTPError` or :exc:`HTTPResponse` instances. Nested iterables are not " "supported, sorry. Please note that the HTTP status code and the headers are " "sent to the browser as soon as the iterable yields its first non-empty " "value. Changing these later has no effect." msgstr "你可以在回调函数中使用 ``yield`` 语句,或返回一个iterable的对象,只要该对象返回的是字节型字符串,unicode字符串, :exc:`HTTPError` 或 :exc:`HTTPResponse` 实例。不支持嵌套iterable对象,不好意思。注意,在iterable对象返回第一个非空值的时候,就会把HTTP状态码和HTTP头发送给浏览器。稍后再更改它们就起不到什么作用了。" #: ../../tutorial.rst:290 msgid "" "The ordering of this list is significant. You may for example return a " "subclass of :class:`str` with a ``read()`` method. It is still treated as a " "string instead of a file, because strings are handled first." msgstr "以上列表的顺序非常重要。在你返回一个 :class:`str` 类的子类的时候,即使它有 ``.read()`` 方法,它依然会被当成一个字符串对待,而不是文件,因为字符串先被处理。" #: ../../tutorial.rst:293 msgid "Changing the Default Encoding" msgstr "改变默认编码" #: ../../tutorial.rst:294 msgid "" "Bottle uses the `charset` parameter of the ``Content-Type`` header to decide" " how to encode unicode strings. This header defaults to ``text/html; " "charset=UTF8`` and can be changed using the :attr:`Response.content_type` " "attribute or by setting the :attr:`Response.charset` attribute directly. " "(The :class:`Response` object is described in the section :ref:`tutorial-" "response`.)" msgstr "Bottle使用 ``Content-Type`` 的 `charset` 参数来决定编码unicode字符串的方式。默认的 ``Content-Type`` 是 ``text/html;charset=UTF8`` ,可在 :attr:`Response.content_type` 属性中修改,或直接设置 :attr:`Response.charset` 的值。关于 :class:`Response` 对象的介绍,详见 :ref:`tutorial-response` 。" #: ../../tutorial.rst:309 msgid "" "In some rare cases the Python encoding names differ from the names supported" " by the HTTP specification. Then, you have to do both: first set the " ":attr:`Response.content_type` header (which is sent to the client unchanged)" " and then set the :attr:`Response.charset` attribute (which is used to " "encode unicode)." msgstr "在极少情况下,Python中定义的编码名字和HTTP标准中的定义不一样。这样,你就必须同时修改 :attr:`Response.content_type`` (发送给客户端的)和设置 :attr:`Response.charset` 属性 (用于编码unicode)。" #: ../../tutorial.rst:314 msgid "Static Files" msgstr "静态文件" #: ../../tutorial.rst:316 msgid "" "You can directly return file objects, but :func:`static_file` is the " "recommended way to serve static files. It automatically guesses a mime-type," " adds a ``Last-Modified`` header, restricts paths to a ``root`` directory " "for security reasons and generates appropriate error responses (403 on " "permission errors, 404 on missing files). It even supports the ``If-" "Modified-Since`` header and eventually generates a ``304 Not Modified`` " "response. You can pass a custom MIME type to disable guessing." msgstr "" #: ../../tutorial.rst:329 msgid "" "You can raise the return value of :func:`static_file` as an exception if you" " really need to." msgstr "如果确实需要,你可将 :func:`static_file` 的返回值当作异常raise出来。" #: ../../tutorial.rst:332 msgid "Forced Download" msgstr "强制下载" #: ../../tutorial.rst:333 msgid "" "Most browsers try to open downloaded files if the MIME type is known and " "assigned to an application (e.g. PDF files). If this is not what you want, " "you can force a download dialog and even suggest a filename to the user::" msgstr "大多数浏览器在知道MIME类型的时候,会尝试直接调用相关程序来打开文件(例如PDF文件)。如果你不想这样,你可强制浏览器只是下载该文件,甚至提供文件名。::" #: ../../tutorial.rst:339 msgid "" "If the ``download`` parameter is just ``True``, the original filename is " "used." msgstr "如果 ``download`` 参数的值为 ``True`` ,会使用原始的文件名。" #: ../../tutorial.rst:344 msgid "HTTP Errors and Redirects" msgstr "HTTP错误和重定向" #: ../../tutorial.rst:346 msgid "" "The :func:`abort` function is a shortcut for generating HTTP error pages." msgstr ":func:`abort` 函数是生成HTTP错误页面的一个捷径。" #: ../../tutorial.rst:355 msgid "" "To redirect a client to a different URL, you can send a ``303 See Other`` " "response with the ``Location`` header set to the new URL. :func:`redirect` " "does that for you::" msgstr "为了将用户访问重定向到其他URL,你在 ``Location`` 中设置新的URL,接着返回一个 ``303 See Other`` 。 :func:`redirect` 函数可以帮你做这件事情。" #: ../../tutorial.rst:362 msgid "You may provide a different HTTP status code as a second parameter." msgstr "你可以在第二个参数中提供另外的HTTP状态码。" #: ../../tutorial.rst:365 msgid "" "Both functions will interrupt your callback code by raising an " ":exc:`HTTPResponse` exception." msgstr "" #: ../../tutorial.rst:368 msgid "Other Exceptions" msgstr "其他异常" #: ../../tutorial.rst:369 msgid "" "All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will " "result in a ``500 Internal Server Error`` response, so they won't crash your" " WSGI server. You can turn off this behavior to handle exceptions in your " "middleware by setting ``bottle.app().catchall`` to ``False``." msgstr "除了 :exc:`HTTPResponse` 或 :exc:`HTTPError` 以外的其他异常,都会导致500错误,所以不会造成WSGI服务器崩溃。你将 ``bottle.app().catchall`` 的值设为 ``False`` 来关闭这种行为,以便在你的中间件中处理异常。" #: ../../tutorial.rst:375 msgid "The :class:`Response` Object" msgstr ":class:`Response` 对象" #: ../../tutorial.rst:377 msgid "" "Response metadata such as the HTTP status code, response headers and cookies" " are stored in an object called :data:`response` up to the point where they " "are transmitted to the browser. You can manipulate these metadata directly " "or use the predefined helper methods to do so. The full API and feature list" " is described in the API section (see :class:`Response`), but the most " "common use cases and features are covered here, too." msgstr "诸如HTTP状态码,HTTP响应头,用户cookie等元数据都保存在一个名字为 :data:`response` 的对象里面,接着被传输给浏览器。你可直接操作这些元数据或使用一些更方便的函数。在API章节可查到所有相关API(详见 :class:`Response` ),这里主要介绍一些常用方法。" #: ../../tutorial.rst:380 msgid "Status Code" msgstr "状态码" #: ../../tutorial.rst:381 msgid "" "The `HTTP status code `_ controls the behavior of the browser and" " defaults to ``200 OK``. In most scenarios you won't need to set the " ":attr:`Response.status` attribute manually, but use the :func:`abort` helper" " or return an :exc:`HTTPResponse` instance with the appropriate status code." " Any integer is allowed, but codes other than the ones defined by the `HTTP " "specification `_ will only confuse the browser and break " "standards." msgstr "`HTTP状态码 `_ 控制着浏览器的行为,默认为 ``200 OK`` 。多数情况下,你不必手动修改 :attr:`Response.status` 的值,可使用 :func:`abort` 函数或return一个 :exc:`HTTPResponse` 实例(带有合适的状态码)。虽然所有整数都可当作状态码返回,但浏览器不知道如何处理 `HTTP标准 `_ 中定义的那些状态码之外的数字,你也破坏了大家约定的标准。" #: ../../tutorial.rst:384 msgid "Response Header" msgstr "响应头" #: ../../tutorial.rst:385 msgid "" "Response headers such as ``Cache-Control`` or ``Location`` are defined via " ":meth:`Response.set_header`. This method takes two parameters, a header name" " and a value. The name part is case-insensitive::" msgstr "``Cache-Control`` 和 ``Location`` 之类的响应头通过 :meth:`Response.set_header` 来定义。这个方法接受两个参数,一个是响应头的名字,一个是它的值,名字是大小写敏感的。" #: ../../tutorial.rst:392 msgid "" "Most headers are unique, meaning that only one header per name is send to " "the client. Some special headers however are allowed to appear more than " "once in a response. To add an additional header, use " ":meth:`Response.add_header` instead of :meth:`Response.set_header`::" msgstr "大多数的响应头是唯一的,meaning that only one header per name is send to the client。一些特殊的响应头在一次response中允许出现多次。使用 :meth:`Response.add_header` 来添加一个额外的响应头,而不是 :meth:`Response.set_header` ::" #: ../../tutorial.rst:397 msgid "" "Please note that this is just an example. If you want to work with cookies, " "read :ref:`ahead `." msgstr "请注意,这只是一个例子。如果你想使用cookie,详见 :ref:`ahead ` 。" #: ../../tutorial.rst:403 ../../tutorial.rst:533 msgid "Cookies" msgstr "" #: ../../tutorial.rst:405 msgid "" "A cookie is a named piece of text stored in the user's browser profile. You " "can access previously defined cookies via :meth:`Request.get_cookie` and set" " new cookies with :meth:`Response.set_cookie`::" msgstr "Cookie是储存在浏览器配置文件里面的一小段文本。你可通过 :meth:`Request.get_cookie` 来访问已存在的Cookie,或通过 :meth:`Response.set_cookie` 来设置新的Cookie。" #: ../../tutorial.rst:415 msgid "" "The :meth:`Response.set_cookie` method accepts a number of additional " "keyword arguments that control the cookies lifetime and behavior. Some of " "the most common settings are described here:" msgstr ":meth:`Response.set_cookie` 方法接受一系列额外的参数,来控制Cookie的生命周期及行为。一些常用的设置如下:" #: ../../tutorial.rst:417 msgid "**max_age:** Maximum age in seconds. (default: ``None``)" msgstr "**max_age:** 最大有效时间,以秒为单位 (默认: ``None``)" #: ../../tutorial.rst:418 msgid "" "**expires:** A datetime object or UNIX timestamp. (default: ``None``)" msgstr "**expires:** 一个datetime对象或一个UNIX timestamp (默认: ``None``)" #: ../../tutorial.rst:419 msgid "" "**domain:** The domain that is allowed to read the cookie. (default: " "current domain)" msgstr "**domain:** 可访问该Cookie的域名 (默认: 当前域名)" #: ../../tutorial.rst:420 msgid "**path:** Limit the cookie to a given path (default: ``/``)" msgstr "**path:** 限制cookie的访问路径 (默认: ``/``)" #: ../../tutorial.rst:421 msgid "**secure:** Limit the cookie to HTTPS connections (default: off)." msgstr "**secure:** 只允许在HTTPS链接中访问cookie (默认: off)" #: ../../tutorial.rst:422 msgid "" "**httponly:** Prevent client-side javascript to read this cookie (default:" " off, requires Python 2.7 or newer)." msgstr "" #: ../../tutorial.rst:423 msgid "" "**same_site:** Disables third-party use for a cookie. Allowed attributes: " "`lax` and `strict`. In strict mode the cookie will never be sent. In lax " "mode the cookie is only sent with a top-level GET request." msgstr "" #: ../../tutorial.rst:425 msgid "" "If neither `expires` nor `max_age` is set, the cookie expires at the end of " "the browser session or as soon as the browser window is closed. There are " "some other gotchas you should consider when using cookies:" msgstr "如果 `expires` 和 `max_age` 两个值都没设置,cookie会在当前的浏览器session失效或浏览器窗口关闭后失效。在使用cookie的时候,应该注意一下几个陷阱。" #: ../../tutorial.rst:427 msgid "Cookies are limited to 4 KB of text in most browsers." msgstr "在大多数浏览器中,cookie的最大容量为4KB。" #: ../../tutorial.rst:428 msgid "" "Some users configure their browsers to not accept cookies at all. Most " "search engines ignore cookies too. Make sure that your application still " "works without cookies." msgstr "一些用户将浏览器设置为不接受任何cookie。大多数搜索引擎也忽略cookie。确保你的应用在无cookie的时候也能工作。" #: ../../tutorial.rst:429 msgid "" "Cookies are stored at client side and are not encrypted in any way. Whatever" " you store in a cookie, the user can read it. Worse than that, an attacker " "might be able to steal a user's cookies through `XSS " "`_" " vulnerabilities on your side. Some viruses are known to read the browser " "cookies, too. Thus, never store confidential information in cookies." msgstr "cookie被储存在客户端,也没被加密。你在cookie中储存的任何数据,用户都可以读取。更坏的情况下,cookie会被攻击者通过 `XSS `_ 偷走,一些已知病毒也会读取浏览器的cookie。既然如此,就不要在cookie中储存任何敏感信息。" #: ../../tutorial.rst:430 msgid "Cookies are easily forged by malicious clients. Do not trust cookies." msgstr "cookie可以被伪造,不要信任cookie!" #: ../../tutorial.rst:435 msgid "Signed Cookies" msgstr "Cookie签名" #: ../../tutorial.rst:436 msgid "" "As mentioned above, cookies are easily forged by malicious clients. Bottle " "can cryptographically sign your cookies to prevent this kind of " "manipulation. All you have to do is to provide a signature key via the " "`secret` keyword argument whenever you read or set a cookie and keep that " "key a secret. As a result, :meth:`Request.get_cookie` will return ``None`` " "if the cookie is not signed or the signature keys don't match::" msgstr "上面提到,cookie容易被客户端伪造。Bottle可通过加密cookie来防止此类攻击。你只需在读取和设置cookie的时候,通过 `secret` 参数来提供一个密钥。如果cookie未签名或密钥不匹配, :meth:`Request.get_cookie` 方法返回 ``None`` " #: ../../tutorial.rst:456 msgid "" "In addition, Bottle automatically pickles and unpickles any data stored to " "signed cookies. This allows you to store any pickle-able object (not only " "strings) to cookies, as long as the pickled data does not exceed the 4 KB " "limit." msgstr "例外,Bottle自动序列化储存在签名cookie里面的数据。你可在cookie中储存任何可序列化的对象(不仅仅是字符串),只要对象大小不超过4KB。" #: ../../tutorial.rst:458 msgid "" "Signed cookies are not encrypted (the client can still see the content) and " "not copy-protected (the client can restore an old cookie). The main " "intention is to make pickling and unpickling safe and prevent manipulation, " "not to store secret information at client side." msgstr "签名cookie在客户端不加密(译者注:即在客户端没有经过二次加密),也没有写保护(客户端可使用之前的cookie)。给cookie签名的主要意义在于在cookie中存储序列化对象和防止伪造cookie,依然不要在cookie中存储敏感信息。" #: ../../tutorial.rst:471 msgid "Request Data" msgstr "请求数据 (Request Data)" #: ../../tutorial.rst:473 msgid "" "Cookies, HTTP header, HTML ```` fields and other request data is " "available through the global :data:`request` object. This special object " "always refers to the *current* request, even in multi-threaded environments " "where multiple client connections are handled at the same time::" msgstr "可通过全局的 :data:`request` 对象来访问Cookies,HTTP头,HTML的 ```` 字段,以及其它的请求数据。这个特殊的对象总是指向 *当前* 的请求,即使在同时处理多个客户端连接的多线程情况下。" #: ../../tutorial.rst:482 msgid "" "The :data:`request` object is a subclass of :class:`BaseRequest` and has a " "very rich API to access data. We only cover the most commonly used features " "here, but it should be enough to get started." msgstr ":data:`request` 对象继承自 :class:`BaseRequest` ,提供了丰富的API来访问数据。虽然我们只介绍最常用的特性,也足够入门了。" #: ../../tutorial.rst:487 msgid "Introducing :class:`FormsDict`" msgstr "介绍 :class:`FormsDict` " #: ../../tutorial.rst:489 msgid "" "Bottle uses a special type of dictionary to store form data and cookies. " ":class:`FormsDict` behaves like a normal dictionary, but has some additional" " features to make your life easier." msgstr "Bottle使用了一个特殊的字典来储存表单数据和cookies。 :class:`FormsDict` 表现得像一个普通的字典,但提供了更方便的额外功能。" #: ../../tutorial.rst:491 msgid "" "**Attribute access**: All values in the dictionary are also accessible as " "attributes. These virtual attributes return unicode strings, even if the " "value is missing or unicode decoding fails. In that case, the string is " "empty, but still present::" msgstr "**属性访问** :字典中所有的值都可以当做属性来访问。这些虚拟的属性返回unicode字符串。在字典中缺少对应的值,或unicode解码失败的情况下,属性返回的字符串为空。" #: ../../tutorial.rst:506 msgid "" "**Multiple values per key:** :class:`FormsDict` is a subclass of " ":class:`MultiDict` and can store more than one value per key. The standard " "dictionary access methods will only return a single value, but the " ":meth:`~MultiDict.getall` method returns a (possibly empty) list of all " "values for a specific key::" msgstr "**一个key对应多个value:** :class:`FormsDict` 是 :class:`MutilDict` 的子类,一个key可存储多个value。标准的字典访问方法只返回一个值,但 :meth:`~MultiDict.getall` 方法会返回一个包含了所有value的一个list(也许为空)。" #: ../../tutorial.rst:511 msgid "" "**WTForms support:** Some libraries (e.g. `WTForms " "`_) want all-unicode dictionaries as input." " :meth:`FormsDict.decode` does that for you. It decodes all values and " "returns a copy of itself, while preserving multiple values per key and all " "the other features." msgstr "**WTForms支持:** 一些第三方库(例如 `WTForms `_ )希望输入中的所有字典都是unicode的。 :meth:`FormsDict.decode` 帮你做了这件事情。它将所有value重新编码,并返回原字典的一个拷贝,同时保留所有特性,例如一个key对应多个value。" #: ../../tutorial.rst:515 msgid "" "In **Python 2** all keys and values are byte-strings. If you need unicode, " "you can call :meth:`FormsDict.getunicode` or fetch values via attribute " "access. Both methods try to decode the string (default: utf8) and return an " "empty string if that fails. No need to catch :exc:`UnicodeError`::" msgstr "在 **Python2** 中,所有的key和value都是byte-string。如果你需要unicode,可使用 :meth:`FormsDict.getunicode` 方法或像访问属性那样访问。这两种方法都试着将字符串转码(默认: utf8),如果失败,将返回一个空字符串。无需捕获 :exc:`UnicodeError` 异常。" #: ../../tutorial.rst:522 msgid "" "In **Python 3** all strings are unicode, but HTTP is a byte-based wire " "protocol. The server has to decode the byte strings somehow before they are " "passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 " "(aka latin1), a reversible single-byte codec that can be re-encoded with a " "different encoding later. Bottle does that for :meth:`FormsDict.getunicode` " "and attribute access, but not for the dict-access methods. These return the " "unchanged values as provided by the server implementation, which is probably" " not what you want." msgstr "在 **Python3** 中,所有的字符串都是unicode。但HTTP是基于字节的协议,在byte-string被传给应用之前,服务器必须将其转码。安全起见,WSGI协议建议使用ISO-8859-1 (即是latin1),一个可反转的单字节编码,可被转换为其他编码。Bottle通过 :meth:`FormsDict.getunicode` 和属性访问实现了转码,但不支持字典形式的访问。通过字典形式的访问,将直接返回服务器返回的字符串,未经处理,这或许不是你想要的。" #: ../../tutorial.rst:529 msgid "" "If you need the whole dictionary with correctly decoded values (e.g. for " "WTForms), you can call :meth:`FormsDict.decode` to get a re-encoded copy." msgstr "如果你整个字典包含正确编码后的值(e.g. for WTForms),可通过 :meth:`FormsDict.decode` 方法来获取一个转码后的拷贝(译者注:一个新的实例)。" #: ../../tutorial.rst:535 msgid "" "Cookies are small pieces of text stored in the clients browser and sent back" " to the server with each request. They are useful to keep some state around " "for more than one request (HTTP itself is stateless), but should not be used" " for security related stuff. They can be easily forged by the client." msgstr "Cookie是客户端浏览器存储的一些文本数据,在每次请求的时候发送回给服务器。Cookie被用于在多次请求间保留状态信息(HTTP本身是无状态的),但不应该用于保存安全相关信息。因为客户端很容易伪造Cookie。" #: ../../tutorial.rst:537 msgid "" "All cookies sent by the client are available through " ":attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a " "simple cookie-based view counter::" msgstr "可通过 :attr:`BaseRequest.cookies` (一个 :class:`FormsDict`) 来访问所有客户端发来的Cookie。下面的是一个基于Cookie的访问计数。" #: ../../tutorial.rst:547 msgid "" "The :meth:`BaseRequest.get_cookie` method is a different way do access " "cookies. It supports decoding :ref:`signed cookies ` as described in a separate section." msgstr ":meth:`BaseRequest.get_cookie` 是访问cookie的另一种方法。它支持解析 :ref:`signed cookies ` 。" #: ../../tutorial.rst:550 msgid "HTTP Headers" msgstr "HTTP头" #: ../../tutorial.rst:552 msgid "" "All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or " "``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible " "through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict`" " is basically a dictionary with case-insensitive keys::" msgstr "所有客户端发送过来的HTTP头(例如 ``Referer``, ``Agent`` 和 ``Accept-Language``)存储在一个 :class:`WSGIHeaderDict` 中,可通过 :attr:`BaseRequest.headers` 访问。 :class:`WSGIHeaderDict` 基本上是一个字典,其key大小写敏感。" #: ../../tutorial.rst:564 msgid "Query Variables" msgstr "查询变量" #: ../../tutorial.rst:566 msgid "" "The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit" " a small number of key/value pairs to the server. You can use the " ":attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these " "values and the :attr:`BaseRequest.query_string` attribute to get the whole " "string." msgstr "查询字符串(例如 ``/forum?id=1&page=5`` )一般用于向服务器传输键值对。你可通过 :attr:`BaseRequest.query` ( :class:`FormsDict` 类的实例) 来访问,和通过 :attr:`BaseRequest.query_string` 来获取整个字符串。" #: ../../tutorial.rst:579 msgid "HTML `` Handling" msgstr "处理HTML的 `` 标签" #: ../../tutorial.rst:581 msgid "" "Let us start from the beginning. In HTML, a typical ```` looks " "something like this:" msgstr "让我们从头开始。在HTML中,一个典型的 ```` 标签看起来是这样的。" #: ../../tutorial.rst:591 msgid "" "The ``action`` attribute specifies the URL that will receive the form data. " "``method`` defines the HTTP method to use (``GET`` or ``POST``). With " "``method=\"get\"`` the form values are appended to the URL and available " "through :attr:`BaseRequest.query` as described above. This is considered " "insecure and has other limitations, so we use ``method=\"post\"`` here. If " "in doubt, use ``POST`` forms." msgstr "``action`` 属性指定了用于接收表单数据的URL, ``method`` 定义了使用的HTTP方法( ``GET`` 或 ``POST`` )。如果使用GET方法,表单中的数据会附加到URL后面,可通过 :attr:`BaseRequest.query` 来访问。这被认为是不安全的,且有其它限制。所以这里我们使用POST方法。如果有疑惑,就使用 ``POST`` 吧。" #: ../../tutorial.rst:593 msgid "" "Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms`" " as a :class:`FormsDict`. The server side code may look like this::" msgstr "通过POST方法传输的表单字段,作为一个 :class:`FormsDict` 存储在 :attr:`BaseRequest.forms` 中。服务器端的代码看起来是这样的。" #: ../../tutorial.rst:616 msgid "" "There are several other attributes used to access form data. Some of them " "combine values from different sources for easier access. The following table" " should give you a decent overview." msgstr "有其它一些属性也可以用来访问表单数据。为了方便,一些属性包含了多个来源的数据。下面的表格可给你一个直观的印象。" #: ../../tutorial.rst:619 msgid "Attribute" msgstr "属性" #: ../../tutorial.rst:619 msgid "GET Form fields" msgstr "" #: ../../tutorial.rst:619 msgid "POST Form fields" msgstr "POST表单数据" #: ../../tutorial.rst:619 msgid "File Uploads" msgstr "" #: ../../tutorial.rst:621 msgid ":attr:`BaseRequest.query`" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:622 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:624 ../../tutorial.rst:625 #: ../../tutorial.rst:626 ../../tutorial.rst:626 msgid "yes" msgstr "" #: ../../tutorial.rst:621 ../../tutorial.rst:621 ../../tutorial.rst:622 #: ../../tutorial.rst:622 ../../tutorial.rst:623 ../../tutorial.rst:623 #: ../../tutorial.rst:624 ../../tutorial.rst:625 ../../tutorial.rst:625 #: ../../tutorial.rst:626 msgid "no" msgstr "" #: ../../tutorial.rst:622 msgid ":attr:`BaseRequest.forms`" msgstr "" #: ../../tutorial.rst:623 msgid ":attr:`BaseRequest.files`" msgstr "" #: ../../tutorial.rst:624 msgid ":attr:`BaseRequest.params`" msgstr "" #: ../../tutorial.rst:625 msgid ":attr:`BaseRequest.GET`" msgstr "" #: ../../tutorial.rst:626 msgid ":attr:`BaseRequest.POST`" msgstr "" #: ../../tutorial.rst:631 msgid "File uploads" msgstr "文件上传" #: ../../tutorial.rst:633 msgid "" "To support file uploads, we have to change the ```` tag a bit. First, " "we tell the browser to encode the form data in a different way by adding an " "``enctype=\"multipart/form-data\"`` attribute to the ```` tag. Then, " "we add ```` tags to allow the user to select a file. " "Here is an example:" msgstr "为了支持文件上传,我们需要小改一下上面 ```` 标签,加上 ``enctype=\"multipart/form-data\"`` 属性,告诉浏览器用另一种方式编码表单数据。接下来,我们添加 ```` 标签,让用户可以选择需要上传的文件。例子如下。" #: ../../tutorial.rst:643 msgid "" "Bottle stores file uploads in :attr:`BaseRequest.files` as " ":class:`FileUpload` instances, along with some metadata about the upload. " "Let us assume you just want to save the file to disk::" msgstr "Bottle将上传的文件当做一个 :class:`FileUpload` 实例存储在 :attr:`BaseRequest.files` 中,伴随着一些这次上传的元数据。我们假设你仅是想把上传的文件保存到磁盘中。" #: ../../tutorial.rst:657 msgid "" ":attr:`FileUpload.filename` contains the name of the file on the clients " "file system, but is cleaned up and normalized to prevent bugs caused by " "unsupported characters or path segments in the filename. If you need the " "unmodified name as sent by the client, have a look at " ":attr:`FileUpload.raw_filename`." msgstr ":attr:`FileUpload.filename` 包含客户端传上来的文件的文件名,但为了防止异常字符带来的bug,这里的文件名已经被处理过。如果你需要未经改动的文件名,看看 :attr:`FileUpload.raw_filename` 。" #: ../../tutorial.rst:659 msgid "" "The :attr:`FileUpload.save` method is highly recommended if you want to " "store the file to disk. It prevents some common errors (e.g. it does not " "overwrite existing files unless you tell it to) and stores the file in a " "memory efficient way. You can access the file object directly via " ":attr:`FileUpload.file`. Just be careful." msgstr "如果你想将文件保存到磁盘,强烈建议你使用 :attr:`FileUpload.save` 方法。它避免了一些常见的错误(例如,它不会覆盖已经存在的文件,除非你告诉它可以覆盖),并且更有效地使用内存。你可以通过 :attr:`FileUpload.file` 来直接访问文件对象,但是要谨慎。" #: ../../tutorial.rst:663 msgid "JSON Content" msgstr "JSON内容" #: ../../tutorial.rst:665 msgid "" "Some JavaScript or REST clients send ``application/json`` content to the " "server. The :attr:`BaseRequest.json` attribute contains the parsed data " "structure, if available." msgstr "一些JavaScript或支持REST的客户端会发送 ``application/json`` 内容给服务器。如果可用(合法的JSON), :attr:`BaseRequest.json` 会包含解析后的数据结构。" #: ../../tutorial.rst:669 msgid "The raw request body" msgstr "原始的请求数据" #: ../../tutorial.rst:671 msgid "" "You can access the raw body data as a file-like object via " ":attr:`BaseRequest.body`. This is a :class:`BytesIO` buffer or a temporary " "file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` " "setting. In both cases the body is completely buffered before you can access" " the attribute. If you expect huge amounts of data and want to get direct " "unbuffered access to the stream, have a look at ``request['wsgi.input']``." msgstr "你可以把 :attr:`BaseRequest.body` 当做一个file-like 对象来访问。根据内容的长度,以及 :attr:`BaseRequest.MEMFILE_MAX` 中的设置,它可以是一个 :class:`BytesIO` 缓存或一个磁盘上的临时文件。无论如何,它都是被缓存的。如果你无需缓存,想直接访问文件流,可看看 ``request['wsgi.input']`` 。" #: ../../tutorial.rst:676 msgid "WSGI Environment" msgstr "WSGI环境" #: ../../tutorial.rst:678 msgid "" "Each :class:`BaseRequest` instance wraps a WSGI environment dictionary. The " "original is stored in :attr:`BaseRequest.environ`, but the request object " "itself behaves like a dictionary, too. Most of the interesting data is " "exposed through special methods or attributes, but if you want to access " "`WSGI environ variables `_ directly, you can do so::" msgstr "" #: ../../tutorial.rst:696 msgid "Templates" msgstr "模板" #: ../../tutorial.rst:698 msgid "" "Bottle comes with a fast and powerful built-in template engine called " ":doc:`stpl`. To render a template you can use the :func:`template` function " "or the :func:`view` decorator. All you have to do is to provide the name of " "the template and the variables you want to pass to the template as keyword " "arguments. Here’s a simple example of how to render a template::" msgstr "Bottle内置了一个快速的,强大的模板引擎,称为 :doc:`stpl` 。可通过 :func:`template` 函数或 :func:`view` 修饰器来渲染一个模板。只需提供模板的名字和传递给模板的变量。下面是一个渲染模板的简单例子::" #: ../../tutorial.rst:705 msgid "" "This will load the template file ``hello_template.tpl`` and render it with " "the ``name`` variable set. Bottle will look for templates in the " "``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` " "list." msgstr "这会加载 ``hello_template.tpl`` 模板文件,并提供 ``name`` 变量。默认情况,Bottle会在 ``./views/`` 目录查找模板文件(译者注:或当前目录)。可在 ``bottle.TEMPLATE_PATH`` 这个列表中添加更多的模板路径。" #: ../../tutorial.rst:707 msgid "" "The :func:`view` decorator allows you to return a dictionary with the " "template variables instead of calling :func:`template`::" msgstr ":func:`view` 修饰器允许你在回调函数中返回一个字典,并将其传递给模板,和 :func:`template` 函数做同样的事情。" #: ../../tutorial.rst:716 msgid "Syntax" msgstr "语法" #: ../../tutorial.rst:719 msgid "" "The template syntax is a very thin layer around the Python language. Its " "main purpose is to ensure correct indentation of blocks, so you can format " "your template without worrying about indentation. Follow the link for a full" " syntax description: :doc:`stpl`" msgstr "模板语法类似于Python的语法。它要确保语句块的正确缩进,所以你在写模板的时候无需担心会出现缩进问题。详细的语法描述可看 :doc:`stpl` 。" #: ../../tutorial.rst:721 msgid "Here is an example template::" msgstr "简单的模板例子::" #: ../../tutorial.rst:732 msgid "Caching" msgstr "缓存" #: ../../tutorial.rst:733 msgid "" "Templates are cached in memory after compilation. Modifications made to the " "template files will have no affect until you clear the template cache. Call " "``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode." msgstr "模板在经过编译后被缓存在内存里。你在修改模板文件后,要调用 ``bottle.TEMPLATES.clear()`` 函数清除缓存才能看到效果。在debug模式下,缓存被禁用了,无需手动清除缓存。" #: ../../tutorial.rst:743 msgid "Plugins" msgstr "插件" #: ../../tutorial.rst:747 msgid "" "Bottle's core features cover most common use-cases, but as a micro-framework" " it has its limits. This is where \"Plugins\" come into play. Plugins add " "missing functionality to the framework, integrate third party libraries, or " "just automate some repetitive work." msgstr "Bottle的核心功能覆盖了常见的使用情况,但是作为一个迷你框架,它有它的局限性。所以我们引入了插件机制,插件可以给框架添加其缺少的功能,集成第三方的库,或是自动化一些重复性的工作。" #: ../../tutorial.rst:749 msgid "" "We have a growing :doc:`/plugins/index` and most plugins are designed to be " "portable and re-usable across applications. The chances are high that your " "problem has already been solved and a ready-to-use plugin exists. If not, " "the :doc:`/plugindev` may help you." msgstr "我们有一个不断增长的 :doc:`/plugins/index` 插件列表,大多数插件都被设计为可插拔的。有很大可能,你的问题已经被解决,而且已经有现成的插件可以使用了。如果没有现成的插件, :doc:`/plugindev` 有介绍如何开发一个插件。" #: ../../tutorial.rst:751 msgid "" "The effects and APIs of plugins are manifold and depend on the specific " "plugin. The ``SQLitePlugin`` plugin for example detects callbacks that " "require a ``db`` keyword argument and creates a fresh database connection " "object every time the callback is called. This makes it very convenient to " "use a database::" msgstr "插件扮演着各种各样的角色。例如, ``SQLitePlugin`` 插件给每个route的回调函数都添加了一个 ``db`` 参数,在回调函数被调用的时候,会新建一个数据库连接。这样,使用数据库就非常简单了。" #: ../../tutorial.rst:771 msgid "" "Other plugin may populate the thread-safe :data:`local` object, change " "details of the :data:`request` object, filter the data returned by the " "callback or bypass the callback completely. An \"auth\" plugin for example " "could check for a valid session and return a login page instead of calling " "the original callback. What happens exactly depends on the plugin." msgstr "其它插件或许在线程安全的 :data:`local` 对象里面发挥作用,改变 :data:`request` 对象的细节,过滤回调函数返回的数据或完全绕开回调函数。举个例子,一个用于登录验证的插件会在调用原先的回调函数响应请求之前,验证用户的合法性,如果是非法访问,则返回登录页面而不是调用回调函数。具体的做法要看插件是如何实现的。" #: ../../tutorial.rst:775 msgid "Application-wide Installation" msgstr "整个应用的范围内安装插件" #: ../../tutorial.rst:777 msgid "" "Plugins can be installed application-wide or just to some specific routes " "that need additional functionality. Most plugins can safely be installed to " "all routes and are smart enough to not add overhead to callbacks that do not" " need their functionality." msgstr "可以在整个应用的范围内安装插件,也可以只是安装给某些route。大多数插件都可安全地安装给所有route,也足够智能,可忽略那些并不需要它们的route。" #: ../../tutorial.rst:779 msgid "" "Let us take the ``SQLitePlugin`` plugin for example. It only affects route " "callbacks that need a database connection. Other routes are left alone. " "Because of this, we can install the plugin application-wide with no " "additional overhead." msgstr "让我们拿 ``SQLitePlugin`` 插件举例,它只会影响到那些需要数据库连接的route,其它route都被忽略了。正因为如此,我们可以放心地在整个应用的范围内安装这个插件。" #: ../../tutorial.rst:781 msgid "" "To install a plugin, just call :func:`install` with the plugin as first " "argument::" msgstr "调用 :func:`install` 函数来安装一个插件::" #: ../../tutorial.rst:786 msgid "" "The plugin is not applied to the route callbacks yet. This is delayed to " "make sure no routes are missed. You can install plugins first and add routes" " later, if you want to. The order of installed plugins is significant, " "though. If a plugin requires a database connection, you need to install the " "database plugin first." msgstr "插件没有马上应用到所有route上面,它被延迟执行来确保没有遗漏任何route。你可以先安装插件,再添加route。有时,插件的安装顺序很重要,如果另外一个插件需要连接数据库,那么你就需要先安装操作数据库的插件。" #: ../../tutorial.rst:790 msgid "Uninstall Plugins" msgstr "卸载插件" #: ../../tutorial.rst:791 msgid "" "You can use a name, class or instance to :func:`uninstall` a previously " "installed plugin::" msgstr "调用 :func:`uninstall` 函数来卸载已经安装的插件" #: ../../tutorial.rst:801 msgid "" "Plugins can be installed and removed at any time, even at runtime while " "serving requests. This enables some neat tricks (installing slow debugging " "or profiling plugins only when needed) but should not be overused. Each time" " the list of plugins changes, the route cache is flushed and all plugins are" " re-applied." msgstr "在任何时候,插件都可以被安装或卸载,即使是在服务器正在运行的时候。一些小技巧应用到了这个特征,例如在需要的时候安装一些供debug和性能测试的插件,但不可滥用这个特性。每一次安装或卸载插件的时候,route缓存都会被刷新,所有插件被重新加载。" #: ../../tutorial.rst:804 msgid "" "The module-level :func:`install` and :func:`uninstall` functions affect the " ":ref:`default-app`. To manage plugins for a specific application, use the " "corresponding methods on the :class:`Bottle` application object." msgstr "模块层面的 :func:`install` 和 :func:`unistall` 函数会影响 :ref:`default-app` 。针对应用来管理插件,可使用 :class:`Bottle` 应用对象的相应方法。" #: ../../tutorial.rst:808 msgid "Route-specific Installation" msgstr "安装给特定的route" #: ../../tutorial.rst:810 msgid "" "The ``apply`` parameter of the :func:`route` decorator comes in handy if you" " want to install plugins to only a small number of routes::" msgstr ":func:`route` 修饰器的 ``apply`` 参数可以给指定的route安装插件" #: ../../tutorial.rst:820 msgid "Blacklisting Plugins" msgstr "插件黑名单" #: ../../tutorial.rst:822 msgid "" "You may want to explicitly disable a plugin for a number of routes. The " ":func:`route` decorator has a ``skip`` parameter for this purpose::" msgstr "如果你想显式地在一些route上面禁用某些插件,可使用 :func:`route` 修饰器的 ``skip`` 参数::" #: ../../tutorial.rst:844 msgid "" "The ``skip`` parameter accepts a single value or a list of values. You can " "use a name, class or instance to identify the plugin that is to be skipped. " "Set ``skip=True`` to skip all plugins at once." msgstr "``skip`` 参数接受单一的值或是一个list。你可使用插件的名字,类,实例来指定你想要禁用的插件。如果 ``skip`` 的值为True,则禁用所有插件。" #: ../../tutorial.rst:847 msgid "Plugins and Sub-Applications" msgstr "插件和子应用" #: ../../tutorial.rst:849 msgid "" "Most plugins are specific to the application they were installed to. " "Consequently, they should not affect sub-applications mounted with " ":meth:`Bottle.mount`. Here is an example::" msgstr "大多数插件只会影响到安装了它们的应用。因此,它们不应该影响通过 :meth:`Bottle.mount` 方法挂载上来的子应用。这里有一个例子。" #: ../../tutorial.rst:860 msgid "" "Whenever you mount an application, Bottle creates a proxy-route on the main-" "application that forwards all requests to the sub-application. Plugins are " "disabled for this kind of proxy-route by default. As a result, our " "(fictional) `WTForms` plugin affects the ``/contact`` route, but does not " "affect the routes of the ``/blog`` sub-application." msgstr "在你挂载一个应用的时候,Bottle在主应用上面创建一个代理route,将所有请求转接给子应用。在代理route上,默认禁用了插件。如上所示,我们的 ``WTForms`` 插件影响了 ``/contact`` route,但不会影响挂载在root上面的 ``/blog`` 。" #: ../../tutorial.rst:862 msgid "" "This behavior is intended as a sane default, but can be overridden. The " "following example re-activates all plugins for a specific proxy-route::" msgstr "这个是一个合理的行为,但可被改写。下面的例子,在指定的代理route上面应用了插件。" #: ../../tutorial.rst:866 msgid "" "But there is a snag: The plugin sees the whole sub-application as a single " "route, namely the proxy-route mentioned above. In order to affect each " "individual route of the sub-application, you have to install the plugin to " "the mounted application explicitly." msgstr "这里存在一个小难题: 插件会整个子应用当作一个route看待,即是上面提及的代理route。如果想在子应用的每个route上面应用插件,你必须显式地在子应用上面安装插件。" #: ../../tutorial.rst:871 msgid "Development" msgstr "开发" #: ../../tutorial.rst:873 msgid "" "So you have learned the basics and want to write your own application? Here " "are some tips that might help you being more productive." msgstr "" #: ../../tutorial.rst:879 msgid "Default Application" msgstr "默认应用" #: ../../tutorial.rst:881 msgid "" "Bottle maintains a global stack of :class:`Bottle` instances and uses the " "top of the stack as a default for some of the module-level functions and " "decorators. The :func:`route` decorator, for example, is a shortcut for " "calling :meth:`Bottle.route` on the default application::" msgstr "Bottle维护一个全局的 :class:`Bottle` 实例的栈,模块层面的函数和修饰器使用栈顶实例作为默认应用。例如 :func:`route` 修饰器,相当于在默认应用上面调用了 :meth:`Bottle.route` 方法。" #: ../../tutorial.rst:889 msgid "" "This is very convenient for small applications and saves you some typing, " "but also means that, as soon as your module is imported, routes are " "installed to the global default application. To avoid this kind of import " "side-effects, Bottle offers a second, more explicit way to build " "applications::" msgstr "" #: ../../tutorial.rst:899 msgid "" "Separating the application object improves re-usability a lot, too. Other " "developers can safely import the ``app`` object from your module and use " ":meth:`Bottle.mount` to merge applications together." msgstr "分离应用对象,大大提高了可重用性。其他开发者可安全地从你的应用中导入 ``app`` 对象,然后通过 :meth:`Bottle.mount` 方法来合并到其它应用中。" #: ../../tutorial.rst:904 msgid "" "Starting with bottle-0.13 you can use :class:`Bottle` instances as context " "managers::" msgstr "" #: ../../tutorial.rst:929 msgid "Debug Mode" msgstr "调试模式" #: ../../tutorial.rst:931 msgid "During early development, the debug mode can be very helpful." msgstr "在开发的早期阶段,调试模式非常有用。" #: ../../tutorial.rst:939 msgid "" "In this mode, Bottle is much more verbose and provides helpful debugging " "information whenever an error occurs. It also disables some optimisations " "that might get in your way and adds some checks that warn you about possible" " misconfiguration." msgstr "在调试模式下,当错误发生的时候,Bottle会提供更多的调试信息。同时禁用一些可能妨碍你的优化措施,检查你的错误设置。" #: ../../tutorial.rst:941 msgid "Here is an incomplete list of things that change in debug mode:" msgstr "下面是调试模式下会发生改变的东西,但这份列表不完整:" #: ../../tutorial.rst:943 msgid "The default error page shows a traceback." msgstr "默认的错误页面会打印出运行栈。" #: ../../tutorial.rst:944 msgid "Templates are not cached." msgstr "模板不会被缓存。" #: ../../tutorial.rst:945 msgid "Plugins are applied immediately." msgstr "插件马上生效。" #: ../../tutorial.rst:947 msgid "Just make sure not to use the debug mode on a production server." msgstr "请确保不要在生产环境中使用调试模式。" #: ../../tutorial.rst:950 msgid "Auto Reloading" msgstr "自动加载" #: ../../tutorial.rst:952 msgid "" "During development, you have to restart the server a lot to test your recent" " changes. The auto reloader can do this for you. Every time you edit a " "module file, the reloader restarts the server process and loads the newest " "version of your code." msgstr "在开发的时候,你需要不断地重启服务器来验证你最新的改动。自动加载功能可以替你做这件事情。在你编辑完一个模块文件后,它会自动重启服务器进程,加载最新版本的代码。" #: ../../tutorial.rst:962 msgid "" "How it works: the main process will not start a server, but spawn a new " "child process using the same command line arguments used to start the main " "process. All module-level code is executed at least twice! Be careful." msgstr "它的工作原理,主进程不会启动服务器,它使用相同的命令行参数,创建一个子进程来启动服务器。请注意,所有模块级别的代码都被执行了至少两次。" #: ../../tutorial.rst:967 msgid "" "The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` " "and start as a normal non-reloading app server. As soon as any of the loaded" " modules changes, the child process is terminated and re-spawned by the main" " process. Changes in template files will not trigger a reload. Please use " "debug mode to deactivate template caching." msgstr "子进程中 ``os.environ['BOOTLE_CHILD']`` 变量的值被设为 ``True`` ,它运行一个不会自动加载的服务器。在代码改变后,主进程会终止掉子进程,并创建一个新的子进程。更改模板文件不会触发自动重载,请使用debug模式来禁用模板缓存。" #: ../../tutorial.rst:973 msgid "" "The reloading depends on the ability to stop the child process. If you are " "running on Windows or any other operating system not supporting " "``signal.SIGINT`` (which raises ``KeyboardInterrupt`` in Python), " "``signal.SIGTERM`` is used to kill the child. Note that exit handlers and " "finally clauses, etc., are not executed after a ``SIGTERM``." msgstr "自动加载需要终止子进程。如果你运行在Windows等不支持 ``signal.SIGINT`` (会在Python中raise ``KeyboardInterrupt`` 异常)的系统上,会使用 ``signal.SIGTERM`` 来杀掉子进程。在子进程被 ``SIGTERM`` 杀掉的时候,exit handlers和finally等语句不会被执行。" #: ../../tutorial.rst:981 msgid "Command Line Interface" msgstr "命令行接口" #: ../../tutorial.rst:985 msgid "Starting with version 0.10 you can use bottle as a command-line tool:" msgstr "从0.10版本开始,你可像一个命令行工具那样使用Bottle:" #: ../../tutorial.rst:1009 msgid "" "The `ADDRESS` field takes an IP address or an IP:PORT pair and defaults to " "``localhost:8080``. The other parameters should be self-explanatory." msgstr "`ADDRESS` 参数接受一个IP地址或IP:端口,其默认为 ``localhost:8080`` 。其它参数都很好地自我解释了。" #: ../../tutorial.rst:1011 msgid "" "Both plugins and applications are specified via import expressions. These " "consist of an import path (e.g. ``package.module``) and an expression to be " "evaluated in the namespace of that module, separated by a colon. See " ":func:`load` for details. Here are some examples:" msgstr "插件和应用都通过一个导入表达式来指定。包含了导入的路径(例如: ``package.module`` )和模块命名空间内的一个表达式,两者用\":\"分开。下面是一个简单例子,详见 :func:`load` 。" #: ../../tutorial.rst:1032 msgid "Deployment" msgstr "部署" #: ../../tutorial.rst:1034 msgid "" "Bottle runs on the built-in `wsgiref WSGIServer " "`_" " by default. This non-threading HTTP server is perfectly fine for " "development, but may become a performance bottleneck when server load " "increases." msgstr "" #: ../../tutorial.rst:1036 msgid "" "The easiest way to increase performance is to install a multi-threaded " "server library like paste_ or cherrypy_ and tell Bottle to use that instead " "of the single-threaded server::" msgstr "最早的解决办法是让Bottle使用 paste_ 或 cherrypy_ 等多线程的服务器。" #: ../../tutorial.rst:1040 msgid "" "This, and many other deployment options are described in a separate article:" " :doc:`deployment`" msgstr "在 :doc:`deployment` 章节中,会介绍更多部署的选择。" #: ../../tutorial.rst:1048 msgid "Glossary" msgstr "词汇表" #: ../../tutorial.rst:1051 msgid "callback" msgstr "" #: ../../tutorial.rst:1053 msgid "" "Programmer code that is to be called when some external action happens. In " "the context of web frameworks, the mapping between URL paths and application" " code is often achieved by specifying a callback function for each URL." msgstr "" #: ../../tutorial.rst:1057 msgid "decorator" msgstr "" #: ../../tutorial.rst:1059 msgid "" "A function returning another function, usually applied as a function " "transformation using the ``@decorator`` syntax. See `python documentation " "for function definition " "`_ for more " "about decorators." msgstr "" #: ../../tutorial.rst:1060 msgid "environ" msgstr "" #: ../../tutorial.rst:1062 msgid "" "A structure where information about all documents under the root is saved, " "and used for cross-referencing. The environment is pickled after the " "parsing stage, so that successive runs only need to read and parse new and " "changed documents." msgstr "" #: ../../tutorial.rst:1066 msgid "handler function" msgstr "" #: ../../tutorial.rst:1068 msgid "" "A function to handle some specific event or situation. In a web framework, " "the application is developed by attaching a handler function as callback for" " each specific URL comprising the application." msgstr "" #: ../../tutorial.rst:1071 msgid "source directory" msgstr "" #: ../../tutorial.rst:1073 msgid "" "The directory which, including its subdirectories, contains all source files" " for one Sphinx project." msgstr "" python-bottle-0.13.2/docs/_locale/zh_CN/LC_MESSAGES/tutorial_app.po000066400000000000000000001307361470367422500246100ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) 2009-2020, Marcel Hellkamp # This file is distributed under the same license as the Bottle package. # # Translators: msgid "" msgstr "" "Project-Id-Version: bottle\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-12-31 18:35+0100\n" "PO-Revision-Date: 2020-12-31 17:35+0000\n" "Last-Translator: Thiago Avelino \n" "Language-Team: Chinese (China) (http://www.transifex.com/bottle/bottle/language/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: zh_CN\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ../../tutorial_app.rst:19 msgid "Tutorial: Todo-List Application" msgstr "Tutorial: Todo-List 应用" #: ../../tutorial_app.rst:23 msgid "" "This tutorial is a work in progress and written by `noisefloor " "`_." msgstr "" #: ../../tutorial_app.rst:26 msgid "" "This tutorial should give a brief introduction to the Bottle_ WSGI " "Framework. The main goal is to be able, after reading through this tutorial," " to create a project using Bottle. Within this document, not all abilities " "will be shown, but at least the main and important ones like routing, " "utilizing the Bottle template abilities to format output and handling GET / " "POST parameters." msgstr "这份教程简单介绍了Bottle框架,目的是让你看完后能在项目中使用Bottle。它没有涵盖所有东西,但介绍了URL映射,模板,处理GET/POST请求等基础知识。" #: ../../tutorial_app.rst:28 msgid "" "To understand the content here, it is not necessary to have a basic " "knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. " "You should have a fair understanding of the Python_ programming language. " "Furthermore, the example used in the tutorial retrieves and stores data in a" " SQL database, so a basic idea about SQL helps, but is not a must to " "understand the concepts of Bottle. Right here, SQLite_ is used. The output " "of Bottle sent to the browser is formatted in some examples by the help of " "HTML. Thus, a basic idea about the common HTML tags does help as well." msgstr "" #: ../../tutorial_app.rst:30 msgid "" "For the sake of introducing Bottle, the Python code \"in between\" is kept " "short, in order to keep the focus. Also all code within the tutorial is " "working fine, but you may not necessarily use it \"in the wild\", e.g. on a " "public web server. In order to do so, you may add e.g. more error handling, " "protect the database with a password, test and escape the input etc." msgstr "作为一份教程,我们的代码尽可能做到了简明扼要。尽管教程中的代码能够工作,但是我们还是不建议你在公共服务器中使用教程中的代码。如果你想要这样做,你应该添加足够的错误处理,并且加密你的数据库,处理用户的输入。" #: ../../tutorial_app.rst:32 msgid "Table of Contents" msgstr "" #: ../../tutorial_app.rst:35 msgid "Goals" msgstr "目标" #: ../../tutorial_app.rst:37 msgid "" "At the end of this tutorial, we will have a simple, web-based ToDo list. The" " list contains a text (with max 100 characters) and a status (0 for closed, " "1 for open) for each item. Through the web-based user interface, open items " "can be view and edited and new items can be added." msgstr "在这份教程结束的时候,我们将完成一个简单的,基于Web的ToDo list(待办事项列表)。列表中的每一个待办事项都包含一条文本(最长100个字符)和一个状态(0表示关闭,1表示开启)。通过网页,已开启的待办事项可以被查看和编辑,可添加待办事项到列表中。" #: ../../tutorial_app.rst:39 msgid "" "During development, all pages will be available on ``localhost`` only, but " "later on it will be shown how to adapt the application for a \"real\" " "server, including how to use with Apache's mod_wsgi." msgstr "在开发过程中,所有的页面都只可以通过 ``localhost`` 来访问,完了会介绍如何将应用部署到\"真实\"服务器的服务器上面,包括使用mod_wsgi来部署到Apache服务器上面。" #: ../../tutorial_app.rst:41 msgid "" "Bottle will do the routing and format the output, with the help of " "templates. The items of the list will be stored inside a SQLite database. " "Reading and writing the database will be done by Python code." msgstr "Bottle会负责URL映射,通过模板来输出页面。待办事项列表被存储在一个SQLite数据库中,通过Python代码来读写数据库。" #: ../../tutorial_app.rst:43 msgid "" "We will end up with an application with the following pages and " "functionality:" msgstr "我们会完成以下页面和功能:" #: ../../tutorial_app.rst:45 msgid "start page ``http://localhost:8080/todo``" msgstr "首页 ``http://localhost:8080/todo``" #: ../../tutorial_app.rst:46 msgid "adding new items to the list: ``http://localhost:8080/new``" msgstr "添加待办事项: ``http://localhost:8080/new``" #: ../../tutorial_app.rst:47 msgid "page for editing items: ``http://localhost:8080/edit/``" msgstr "" #: ../../tutorial_app.rst:48 msgid "catching errors" msgstr "捕获错误" #: ../../tutorial_app.rst:51 msgid "Before We Start..." msgstr "开始之前..." #: ../../tutorial_app.rst:55 msgid "Install Bottle" msgstr "安装Bottle" #: ../../tutorial_app.rst:56 msgid "" "Assuming that you have a fairly new installation of Python (version 2.5 or " "higher), you only need to install Bottle in addition to that. Bottle has no " "other dependencies than Python itself." msgstr "假设你已经安装好了Python (2.5或更改版本),接下来你只需要下载Bottle就行了。除了Python标准库,Bottle没有其他依赖。" #: ../../tutorial_app.rst:58 msgid "" "You can either manually install Bottle or use Python's easy_install: " "``easy_install bottle``" msgstr "你可通过Python的esay_install命令来安装Bottle: ``easy_install bottle``" #: ../../tutorial_app.rst:62 msgid "Further Software Necessities" msgstr "其它软件" #: ../../tutorial_app.rst:63 msgid "" "As we use SQLite3 as a database, make sure it is installed. On Linux " "systems, most distributions have SQLite3 installed by default. SQLite is " "available for Windows and MacOS X as well and the `sqlite3` module is part " "of the python standard library." msgstr "因为我们使用SQLite3来做数据库,请确保它已安装。如果是Linux系统,大多数的发行版已经默认安装了SQLite3。SQLite同时可工作在Windows系统和MacOS X系统上面。Pyhton标准库中,已经包含了 `sqlite3` 模块。" #: ../../tutorial_app.rst:66 msgid "Create An SQL Database" msgstr "创建一个SQL数据库" #: ../../tutorial_app.rst:67 msgid "" "First, we need to create the database we use later on. To do so, save the " "following script in your project directory and run it with python. You can " "use the interactive interpreter too::" msgstr "首先,我们需要先创建一个数据库,稍后会用到。在你的项目文件夹执行以下脚本即可,你也可以在Python解释器逐条执行。" #: ../../tutorial_app.rst:78 msgid "" "This generates a database-file `todo.db` with tables called ``todo`` and " "three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for " "each row, which is used later on to reference the rows. The column ``task`` " "holds the text which describes the task, it can be max 100 characters long. " "Finally, the column ``status`` is used to mark a task as open (value 1) or " "closed (value 0)." msgstr "现在,我们已经创建了一个名字为 `todo.db` 的数据库文件,数据库中有一张名为 ``todo`` 的表,表中有 ``id`` , ``task`` , 及 ``status`` 这三列。每一行的 ``id`` 都是唯一的,稍后会根据id来获取数据。 ``task`` 用于保存待办事项的文本,最大长度为100个字符。最后 ``status`` 用于标明待办事项的状态,0为开启,1为关闭。" #: ../../tutorial_app.rst:81 msgid "Using Bottle for a Web-Based ToDo List" msgstr "基于Bottle的待办事项列表" #: ../../tutorial_app.rst:83 msgid "" "Now it is time to introduce Bottle in order to create a web-based " "application. But first, we need to look into a basic concept of Bottle: " "routes." msgstr "为了创建我们的Web应用,我们先来介绍一下Bottle框架。首先,我们需要了解Bottle中的route,即URL映射。" #: ../../tutorial_app.rst:87 msgid "Understanding routes" msgstr "route URL映射" #: ../../tutorial_app.rst:88 msgid "" "Basically, each page visible in the browser is dynamically generated when " "the page address is called. Thus, there is no static content. That is " "exactly what is called a \"route\" within Bottle: a certain address on the " "server. So, for example, when the page ``http://localhost:8080/todo`` is " "called from the browser, Bottle \"grabs\" the call and checks if there is " "any (Python) function defined for the route \"todo\". If so, Bottle will " "execute the corresponding Python code and return its result." msgstr "基本上,浏览器访问的每一页面都是动态生成的。Bottle通过route,将浏览器访问的URL映射到具体的Python函数。例如,在我们访问 ``http://localhost:8080/todo`` 的时候,Bottle会查找 ``todo`` 这个route映射到了哪个函数上面,接着调用该函数来响应浏览器请求。" #: ../../tutorial_app.rst:92 msgid "First Step - Showing All Open Items" msgstr "第一步 - 显示所有已开启的待办事项" #: ../../tutorial_app.rst:93 msgid "" "So, after understanding the concept of routes, let's create the first one. " "The goal is to see all open items from the ToDo list::" msgstr "在我们了解什么是route后,让我们来试着写一个。访问它即可查看所有已开启的待办事项 ::" #: ../../tutorial_app.rst:108 msgid "" "Save the code a ``todo.py``, preferably in the same directory as the file " "``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the " "``sqlite3.connect()`` statement." msgstr "将上面的代码保存为 ``todo.py`` ,放到 ``todo.db`` 文件所在的目录。如果你想将它们分开放,则需要在 ``sqlite3.connect()`` 函数中写上 ``todo.db`` 文件的路径。" #: ../../tutorial_app.rst:110 msgid "" "Let's have a look what we just did: We imported the necessary module " "``sqlite3`` to access to SQLite database and from Bottle we imported " "``route`` and ``run``. The ``run()`` statement simply starts the web server " "included in Bottle. By default, the web server serves the pages on localhost" " and port 8080. Furthermore, we imported ``route``, which is the function " "responsible for Bottle's routing. As you can see, we defined one function, " "``todo_list()``, with a few lines of code reading from the database. The " "important point is the `decorator statement`_ ``@route('/todo')`` right " "before the ``def todo_list()`` statement. By doing this, we bind this " "function to the route ``/todo``, so every time the browsers calls " "``http://localhost:8080/todo``, Bottle returns the result of the function " "``todo_list()``. That is how routing within bottle works." msgstr "来看看我们写的代码。导入了必须的 ``sqlite3`` 模块,从Bottle中导入 ``route`` 和 ``run`` 。``run()`` 函数启动了Bottle的内置开发服务器,默认情况下,开发服务器在监听本地的8080端口。``route`` 是Bottle实现URL映射功能的修饰器。你可以看到,我们定义了一个 ``todo_list()`` 函数,读取了数据库中的数据。然后我们使用 ``@route('/todo')`` 来将 ``todo_list()`` 函数和``todo`` 这个route绑定在一起。每一次浏览器访问 ``http://localhost:8080/todo`` 的时候,Bottle都会调用 ``todo_list()`` 函数来响应请求,并返回页面,这就是route的工作方式了。" #: ../../tutorial_app.rst:112 msgid "" "Actually you can bind more than one route to a function. So the following " "code::" msgstr "事实上,你可以给一个函数添加多个route。" #: ../../tutorial_app.rst:119 msgid "" "will work fine, too. What will not work is to bind one route to more than " "one function." msgstr "这样是正确的。但是反过来,你不能将一个route和多个函数绑定在一起。" #: ../../tutorial_app.rst:121 msgid "" "What you will see in the browser is what is returned, thus the value given " "by the ``return`` statement. In this example, we need to convert ``result`` " "in to a string by ``str()``, as Bottle expects a string or a list of strings" " from the return statement. But here, the result of the database query is a " "list of tuples, which is the standard defined by the `Python DB API`_." msgstr "你在浏览器中看到的即是你在 ``todo_list()`` 函数中返回的页面。在这个例子中,我们通过 ``str()`` 函数将结果转换成字符串,因为Bottle期望函数的返回值是一个字符串或一个字符串的列表。但 `Python DB API`_ 中规定了,数据库查询的返回值是一个元组的列表。" #: ../../tutorial_app.rst:123 msgid "" "Now, after understanding the little script above, it is time to execute it " "and watch the result yourself. Remember that on Linux- / Unix-based systems " "the file ``todo.py`` needs to be executable first. Then, just run ``python " "todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. " "In case you made no mistake writing the script, the output should look like " "this::" msgstr "现在,我们已经了解上面的代码是如何工作的,是时候运行它来看看效果了。记得在Linux或Unix系统中, ``todo.py`` 文件需要标记为可执行(译者注:没有必要)。然后,通过 ``python todo.py`` 命令来执行该脚本,接着用浏览器访问 ``http://localhost:8080/todo`` 来看看效果。如果代码没有写错,你应该会在页面看到以下输出 ::" #: ../../tutorial_app.rst:127 msgid "" "If so - congratulations! You are now a successful user of Bottle. In case it" " did not work and you need to make some changes to the script, remember to " "stop Bottle serving the page, otherwise the revised version will not be " "loaded." msgstr "如果是这样,那么恭喜你!如果出现错误,那么你需要检查代码时候写错,修改完后记得重启HTTP服务器,要不新的版本不会生效。" #: ../../tutorial_app.rst:129 msgid "" "Actually, the output is not really exciting nor nice to read. It is the raw " "result returned from the SQL query." msgstr "实际上,这个输出很难看,只是SQL查询的结果。" #: ../../tutorial_app.rst:131 msgid "" "So, in the next step we format the output in a nicer way. But before we do " "that, we make our life easier." msgstr "所以,下一步我们会把它变得更好看。" #: ../../tutorial_app.rst:135 msgid "Debugging and Auto-Reload" msgstr "调试和自动加载" #: ../../tutorial_app.rst:136 msgid "" "Maybe you already noticed that Bottle sends a short error message to the " "browser in case something within the script is wrong, e.g. the connection to" " the database is not working. For debugging purposes it is quite helpful to " "get more details. This can be easily achieved by adding the following " "statement to the script::" msgstr "或许你已经注意到了,如果代码出错的话,Bottle会在页面上显示一个简短的错误信息。例如,连接数据库失败。为了方便调试, 我们希望错误信息更加具体,可加上以下语句。" #: ../../tutorial_app.rst:144 msgid "" "By enabling \"debug\", you will get a full stacktrace of the Python " "interpreter, which usually contains useful information for finding bugs. " "Furthermore, templates (see below) are not cached, thus changes to templates" " will take effect without stopping the server." msgstr "开启调试模式后,出错时页面会打印出完整的Python运行栈。另外,在调试模式下,模板也不会被缓存,任何对模板的修改会马上生效,而不用重启服务器。" #: ../../tutorial_app.rst:148 msgid "" "That ``debug(True)`` is supposed to be used for development only, it should " "*not* be used in production environments." msgstr "``debug(True)`` 是为开发时的调试服务的, *不应* 在生产环境中开启调试模式。" #: ../../tutorial_app.rst:152 msgid "" "Another quite nice feature is auto-reloading, which is enabled by modifying " "the ``run()`` statement to" msgstr "另外一个十分有用的功能是自动加载,可修改 ``run()`` 语句来开启。" #: ../../tutorial_app.rst:158 msgid "" "This will automatically detect changes to the script and reload the new " "version once it is called again, without the need to stop and start the " "server." msgstr "这样会自动检测对脚本的修改,并自动重启服务器来使其生效。" #: ../../tutorial_app.rst:160 msgid "" "Again, the feature is mainly supposed to be used while developing, not on " "production systems." msgstr "同上,这个功能并不建议在生产环境中使用。" #: ../../tutorial_app.rst:164 msgid "Bottle Template To Format The Output" msgstr "使用模板来格式化输出" #: ../../tutorial_app.rst:165 msgid "" "Now let's have a look at casting the output of the script into a proper " "format." msgstr "现在我们试着格式化脚本的输出,使其更适合查看。" #: ../../tutorial_app.rst:167 msgid "" "Actually Bottle expects to receive a string or a list of strings from a " "function and returns them by the help of the built-in server to the browser." " Bottle does not bother about the content of the string itself, so it can be" " text formatted with HTML markup, too." msgstr "实际上,Bottle期望route的回调函数返回一个字符串或一个字符串列表,通过内置的HTTP服务器将其返回给浏览器。Bottle不关心字符串的内容,所以我们可以将其格式化成HTML格式。" #: ../../tutorial_app.rst:169 msgid "" "Bottle brings its own easy-to-use template engine with it. Templates are " "stored as separate files having a ``.tpl`` extension. The template can be " "called then from within a function. Templates can contain any type of text " "(which will be most likely HTML-markup mixed with Python statements). " "Furthermore, templates can take arguments, e.g. the result set of a database" " query, which will be then formatted nicely within the template." msgstr "Bottle内置了独创的模板引擎。模板是后缀名为 ``.tpl`` 的文本文件。模板的内容混合着HTML标签和Python语句,模板也可以接受参数。例如数据库的查询结果,我们可以在模板内将其漂亮地格式化。" #: ../../tutorial_app.rst:171 msgid "" "Right here, we are going to cast the result of our query showing the open " "ToDo items into a simple table with two columns: the first column will " "contain the ID of the item, the second column the text. The result set is, " "as seen above, a list of tuples, each tuple contains one set of results." msgstr "接下来,我们要将数据库的查询结果格式化为一个两列的表格。表格的第一列为待办事项的ID,第二列为待办事项的内容。查询结果是一个元组的列表,列表中的每个元组后包含一个结果。" #: ../../tutorial_app.rst:173 msgid "To include the template in our example, just add the following lines::" msgstr "在例子中使用模板,只需要添加以下代码。" #: ../../tutorial_app.rst:183 msgid "" "So we do here two things: first, we import ``template`` from Bottle in order" " to be able to use templates. Second, we assign the output of the template " "``make_table`` to the variable ``output``, which is then returned. In " "addition to calling the template, we assign ``result``, which we received " "from the database query, to the variable ``rows``, which is later on used " "within the template. If necessary, you can assign more than one variable / " "value to a template." msgstr "我们添加了两样东西。首先我们从Bottle中导入了 ``template`` 函数以使用模板功能,接着,我们渲染 ``make_table`` 这个模板(参数是rows=result),把模板函数的返回值赋予 ``output`` 变量,并返回 ``output`` 。如有必要,我们可添加更多的参数。" #: ../../tutorial_app.rst:185 msgid "" "Templates always return a list of strings, thus there is no need to convert " "anything. We can save one line of code by writing ``return " "template('make_table', rows=result)``, which gives exactly the same result " "as above." msgstr "" #: ../../tutorial_app.rst:187 msgid "" "Now it is time to write the corresponding template, which looks like this::" msgstr "对应的模板文件。" #: ../../tutorial_app.rst:201 msgid "" "Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` " "is stored." msgstr "将上面的代码保存为 ``make_table.tpl`` 文件,和 ``todo.py`` 放在同一个目录。" #: ../../tutorial_app.rst:203 msgid "" "Let's have a look at the code: every line starting with % is interpreted as " "Python code. Because it is effectively Python, only valid Python statements " "are allowed. The template will raise exceptions, just as any other Python " "code would. The other lines are plain HTML markup." msgstr "" #: ../../tutorial_app.rst:205 msgid "" "As you can see, we use Python's ``for`` statement two times, in order to go " "through ``rows``. As seen above, ``rows`` is a variable which holds the " "result of the database query, so it is a list of tuples. The first ``for`` " "statement accesses the tuples within the list, the second one the items " "within the tuple, which are put each into a cell of the table. It is " "important that you close all ``for``, ``if``, ``while`` etc. statements with" " ``%end``, otherwise the output may not be what you expect." msgstr "如你所见,为了遍历 ``rows`` ,我们两次使用了Python的 ``for`` 语句。 ``rows``是持有查询结果的变量,一个元组的列表。第一个 ``for`` 语句遍历了列表中所有的元组,第二个 ``for`` 语句遍历了元组中的元素,将其放进表格中。 ``for`` , ``if`` , ``while`` 语句都需要通过 ``%end`` 来关闭,要不会得到不正确的结果。" #: ../../tutorial_app.rst:207 msgid "" "If you need to access a variable within a non-Python code line inside the " "template, you need to put it into double curly braces. This tells the " "template to insert the actual value of the variable right in place." msgstr "如果想要在不以%开头的行中访问变量,则需要把它放在两个大括号中间。这告诉模板,需要用变量的实际值将其替换掉。" #: ../../tutorial_app.rst:209 msgid "" "Run the script again and look at the output. Still not really nice, but at " "least more readable than the list of tuples. You can spice-up the very " "simple HTML markup above, e.g. by using in-line styles to get a better " "looking output." msgstr "" #: ../../tutorial_app.rst:213 msgid "Using GET and POST Values" msgstr "使用GET和POST" #: ../../tutorial_app.rst:214 msgid "" "As we can review all open items properly, we move to the next step, which is" " adding new items to the ToDo list. The new item should be received from a " "regular HTML-based form, which sends its data by the GET method." msgstr "能够查看所有代码事项后,让我们进入到下一步,添加新的待办事项到列表中。新的待办事项应该在一个常规的HTML表单中,通过GET方式提交。" #: ../../tutorial_app.rst:216 msgid "" "To do so, we first add a new route to our script and tell the route that it " "should get GET data::" msgstr "让我们先来添加一个接受GET请求的route。" #: ../../tutorial_app.rst:239 msgid "" "To access GET (or POST) data, we need to import ``request`` from Bottle. To " "assign the actual data to a variable, we use the statement " "``request.GET.task.strip()`` statement, where ``task`` is the name of the " "GET data we want to access. That's all. If your GET data has more than one " "variable, multiple ``request.GET.get()`` statements can be used and assigned" " to other variables." msgstr "" #: ../../tutorial_app.rst:241 msgid "" "The rest of this piece of code is just processing of the gained data: " "writing to the database, retrieve the corresponding id from the database and" " generate the output." msgstr "接下来是对数据的操作:写入数据库,获取返回的ID,生成页面。" #: ../../tutorial_app.rst:243 msgid "" "But where do we get the GET data from? Well, we can use a static HTML page " "holding the form. Or, what we do right now, is to use a template which is " "output when the route ``/new`` is called without GET data." msgstr "因为我们是从HTML表单中获取数据,所以现在让我们来创建这个表单吧。我们通过 ``/new`` 这个URL来添加待办事项。" #: ../../tutorial_app.rst:245 msgid "The code needs to be extended to::" msgstr "代码需要扩展如下::" #: ../../tutorial_app.rst:268 msgid "``new_task.tpl`` looks like this::" msgstr "对应的 ``new_task.tpl`` 模板如下。" #: ../../tutorial_app.rst:276 msgid "That's all. As you can see, the template is plain HTML this time." msgstr "如你所见,这个模板只是纯HTML的,不包含Python代码。" #: ../../tutorial_app.rst:278 msgid "Now we are able to extend our to do list." msgstr "这样,我们就完成了添加待办事项这个功能。" #: ../../tutorial_app.rst:280 msgid "" "By the way, if you prefer to use POST data: this works exactly the same way," " just use ``request.POST.get()`` instead." msgstr "如果你想通过POST来获取数据,那么用 ``request.POST.get()`` 来代替 ``request.GET.get()`` 就行了。" #: ../../tutorial_app.rst:284 msgid "Editing Existing Items" msgstr "修改已有待办事项" #: ../../tutorial_app.rst:285 msgid "The last point to do is to enable editing of existing items." msgstr "最后,我们需要做的是修改已有待办事项。" #: ../../tutorial_app.rst:287 msgid "" "By using only the routes we know so far it is possible, but may be quite " "tricky. But Bottle knows something called \"dynamic routes\", which makes " "this task quite easy." msgstr "仅使用我们当前了解到的route类型,是可以完成这个任务的,但太取巧了。Bottle还提供了一种 ``动态route`` ,可以更简单地实现。" #: ../../tutorial_app.rst:289 msgid "The basic statement for a dynamic route looks like this::" msgstr "基本的动态route声明如下::" #: ../../tutorial_app.rst:293 msgid "" "This tells Bottle to accept for ```` any string up to the next " "slash. Furthermore, the value of ``something`` will be passed to the " "function assigned to that route, so the data can be processed within the " "function, like this::" msgstr "" #: ../../tutorial_app.rst:321 msgid "" "It is basically pretty much the same what we already did above when adding " "new items, like using ``GET`` data etc. The main addition here is using the " "dynamic route ````, which here passes the number to the " "corresponding function. As you can see, ``no`` is integer ID and used within" " the function to access the right row of data within the database." msgstr "" #: ../../tutorial_app.rst:324 msgid "" "The template ``edit_task.tpl`` called within the function looks like this::" msgstr "对应的 ``edit_task.tpl`` 模板如下。" #: ../../tutorial_app.rst:339 msgid "" "Again, this template is a mix of Python statements and HTML, as already " "explained above." msgstr "再一次,模板中混合了HTML代码和Python代码,之前已解释过。" #: ../../tutorial_app.rst:341 msgid "" "A last word on dynamic routes: you can even use a regular expression for a " "dynamic route, as demonstrated later." msgstr "你也可在动态route中使用正则表达式,稍后会提及。" #: ../../tutorial_app.rst:345 msgid "Validating Dynamic Routes" msgstr "验证动态route" #: ../../tutorial_app.rst:346 msgid "" "Using dynamic routes is fine, but for many cases it makes sense to validate " "the dynamic part of the route. For example, we expect an integer number in " "our route for editing above. But if a float, characters or so are received, " "the Python interpreter throws an exception, which is not what we want." msgstr "在某些场景下,需要验证route中的可变部分。例如,在上面的例子中,我们的 ``no`` 需要是一个整形数,如果我们的输入是一个浮点数,或字符串,Python解释器将会抛出一个异常,这并不是我们想要的结果。" #: ../../tutorial_app.rst:348 msgid "" "For those cases, Bottle offers the ```` wildcard filter, which " "matches (signed) digits and converts the value to integer. In order to apply" " the wildcard filter, extend the code as follows::" msgstr "" #: ../../tutorial_app.rst:356 msgid "" "Save the code and call the page again using incorrect value for " "````, e.g. a float. You will receive not an exception, but a \"404 " "Not Found\" error." msgstr "" #: ../../tutorial_app.rst:360 msgid "Dynamic Routes Using Regular Expressions" msgstr "在动态route中使用正则表达式" #: ../../tutorial_app.rst:361 msgid "" "Bottle can also handle dynamic routes, where the \"dynamic part\" of the " "route can be a regular expression." msgstr "Bottle允许在动态route中使用正则表达式。" #: ../../tutorial_app.rst:363 msgid "" "So, just to demonstrate that, let's assume that all single items in our ToDo" " list should be accessible by their plain number, by a term like e.g. " "\"item1\". For obvious reasons, you do not want to create a route for every " "item. Furthermore, the simple dynamic routes do not work either, as part of " "the route, the term \"item\" is static." msgstr "我们假设需要通过 ``item1`` 这样的形式来访问数据库中id为1的待办事项。显然,我们不想为每个待办事项都创建一个route。鉴于route中的\"item\"部分是固定的,简单的route就无法满足需求了,我们需要在route中使用正则表达式。" #: ../../tutorial_app.rst:365 msgid "As said above, the solution is a regular expression::" msgstr "使用正则表达式的解决方法如下。" #: ../../tutorial_app.rst:380 msgid "" "The line ``@route(/item)`` starts like a normal route, but " "the third part of the wildcard is interpreted as a regular expression, which" " is the dynamic part of the route. So in this case, we want to match any " "digit between 0 and 9. The following function \"show_item\" just checks " "whether the given item is present in the database or not. In case it is " "present, the corresponding text of the task is returned. As you can see, " "only the regular expression part of the route is passed forward. " "Furthermore, it is always forwarded as a string, even if it is a plain " "integer number, like in this case." msgstr "" #: ../../tutorial_app.rst:384 msgid "Returning Static Files" msgstr "返回静态文件" #: ../../tutorial_app.rst:385 msgid "" "Sometimes it may become necessary to associate a route not to a Python " "function, but just return a static file. So if you have for example a help " "page for your application, you may want to return this page as plain HTML. " "This works as follows::" msgstr "有时候,我们只是想返回已有的静态文件。例如我们的应用中有个静态的帮助页面help.html,我们不希望每次访问帮助页面的时候都动态生成。" #: ../../tutorial_app.rst:393 msgid "" "At first, we need to import the ``static_file`` function from Bottle. As you" " can see, the ``return static_file`` statement replaces the ``return`` " "statement. It takes at least two arguments: the name of the file to be " "returned and the path to the file. Even if the file is in the same directory" " as your application, the path needs to be stated. But in this case, you can" " use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file " "automatically, but in case you like to state it explicitly, add a third " "argument to ``static_file``, which would be here ``mimetype='text/html'``. " "``static_file`` works with any type of route, including the dynamic ones." msgstr "首先,我们需要从Bottle中导入 ``static_file`` 函数。它接受至少两个参数,一个是需要返回的文件的文件名,一个是该文件的路径。即使该文件和你的应用在同一个目录下,还是要指定文件路径(可以使用\".\")。Bottle会猜测文件的MIME类型,并自动设置。如果你想显式指定MIME类型,可以在static_file函数里面加上例如 ``mimetype='text/html'`` 这样的参数。 ``static_file`` 函数可和任何route配合使用,包括动态route。" #: ../../tutorial_app.rst:397 msgid "Returning JSON Data" msgstr "返回JSON数据" #: ../../tutorial_app.rst:398 msgid "" "There may be cases where you do not want your application to generate the " "output directly, but return data to be processed further on, e.g. by " "JavaScript. For those cases, Bottle offers the possibility to return JSON " "objects, which is sort of standard for exchanging data between web " "applications. Furthermore, JSON can be processed by many programming " "languages, including Python" msgstr "有时我们希望返回JSON,以便在客户端使用JavaScript来生成页面,Bottle直接支持返回JSON数据。JSON似乎已经是Web应用之间交换数据的标准格式了。更进一步,JSON可以被很多语言解析处理,包括Python。" #: ../../tutorial_app.rst:400 msgid "" "So, let's assume we want to return the data generated in the regular " "expression route example as a JSON object. The code looks like this::" msgstr "我们假设现在需要返回JSON数据。" #: ../../tutorial_app.rst:415 msgid "" "As you can, that is fairly simple: just return a regular Python dictionary " "and Bottle will convert it automatically into a JSON object prior to " "sending. So if you e.g. call \"http://localhost/json1\" Bottle should in " "this case return the JSON object ``{\"task\": [\"Read A-byte-of-python to " "get a good introduction into Python\"]}``." msgstr "" #: ../../tutorial_app.rst:420 msgid "Catching Errors" msgstr "捕获错误" #: ../../tutorial_app.rst:421 msgid "" "The next step may is to catch the error with Bottle itself, to keep away any" " type of error message from the user of your application. To do that, Bottle" " has an \"error-route\", which can be a assigned to a HTML-error." msgstr "为了避免用户看到出错信息,我们需要捕获应用运行时出现的错误,以提供更友好的错误提示。Bottle提供了专门用于捕获错误的route。" #: ../../tutorial_app.rst:423 msgid "In our case, we want to catch a 403 error. The code is as follows::" msgstr "例如,我们想捕获403错误。" #: ../../tutorial_app.rst:431 msgid "" "So, at first we need to import ``error`` from Bottle and define a route by " "``error(403)``, which catches all \"403 forbidden\" errors. The function " "\"mistake\" is assigned to that. Please note that ``error()`` always passes " "the error-code to the function - even if you do not need it. Thus, the " "function always needs to accept one argument, otherwise it will not work." msgstr "首先,我们需要从Bottle中导入 ``error`` ,然后通过 ``error(403)`` 来定义创建一个route,用于捕获所有\"403 forbidden\"错误。注意,该route总是会将error-code传给 ``mistake()`` 函数,即使你不需要它。所以回调函数至少要接受一个参数,否则会失效。" #: ../../tutorial_app.rst:433 msgid "" "Again, you can assign more than one error-route to a function, or catch " "various errors with one function each. So this code::" msgstr "一样的,同一个回调函数可以捕获多种错误。" #: ../../tutorial_app.rst:440 msgid "works fine, the following one as well::" msgstr "效果和下面一样。" #: ../../tutorial_app.rst:452 msgid "Summary" msgstr "总结" #: ../../tutorial_app.rst:453 msgid "" "After going through all the sections above, you should have a brief " "understanding how the Bottle WSGI framework works. Furthermore you have all " "the knowledge necessary to use Bottle for your applications." msgstr "通过以上章节,你应该对Bottle框架有了一个大致的了解,可以使用Bottle进行开发了。" #: ../../tutorial_app.rst:455 msgid "" "The following chapter give a short introduction how to adapt Bottle for " "larger projects. Furthermore, we will show how to operate Bottle with web " "servers which perform better on a higher load / more web traffic than the " "one we used so far." msgstr "接下来的章节会简单介绍一下,如何在大型项目中使用Bottle。此外,我们还会介绍如何将Bottle部署到更高性能的Web服务器上。" #: ../../tutorial_app.rst:458 msgid "Server Setup" msgstr "安装服务器" #: ../../tutorial_app.rst:460 msgid "" "So far, we used the standard server used by Bottle, which is the `WSGI " "reference Server`_ shipped along with Python. Although this server is " "perfectly suitable for development purposes, it is not really suitable for " "larger applications. But before we have a look at the alternatives, let's " "have a look how to tweak the settings of the standard server first." msgstr "到目前为止,我们还是使用Bottle内置的,随Python一起发布的 `WSGI reference Server`_ 服务器。尽管该服务器十分适合用于开发环境,但是它确实不适用于大项目。在我们介绍其他服务器之前,我们先看看如何优化内置服务器的设置。" #: ../../tutorial_app.rst:464 msgid "Running Bottle on a different port and IP" msgstr "更改服务器的端口和IP" #: ../../tutorial_app.rst:465 msgid "" "As standard, Bottle serves the pages on the IP address 127.0.0.1, also known" " as ``localhost``, and on port ``8080``. To modify the setting is pretty " "simple, as additional parameters can be passed to Bottle's ``run()`` " "function to change the port and the address." msgstr "" #: ../../tutorial_app.rst:467 msgid "" "To change the port, just add ``port=portnumber`` to the run command. So, for" " example::" msgstr "如果要更改该设置,更改 ``run`` 函数的参数即可。" #: ../../tutorial_app.rst:471 msgid "would make Bottle listen to port 80." msgstr "更改端口,监听80端口" #: ../../tutorial_app.rst:473 msgid "To change the IP address where Bottle is listening::" msgstr "更改监听的IP地址" #: ../../tutorial_app.rst:477 msgid "If needed, both parameters can be combined, like::" msgstr "" #: ../../tutorial_app.rst:481 msgid "" "The ``port`` and ``host`` parameter can also be applied when Bottle is " "running with a different server, as shown in the following section." msgstr "当Bottle运行在其他服务器上面时, ``port`` 和 ``host`` 参数依然适用,稍后会介绍。" #: ../../tutorial_app.rst:485 msgid "Running Bottle with a different server" msgstr "在其他服务器上运行" #: ../../tutorial_app.rst:486 msgid "" "As said above, the standard server is perfectly suitable for development, " "personal use or a small group of people only using your application based on" " Bottle. For larger tasks, the standard server may become a bottleneck, as " "it is single-threaded, thus it can only serve one request at a time." msgstr "在大型项目上,Bottle自带的服务器会成为一个性能瓶颈,因为它是单线程的,一次只能响应一个请求。" #: ../../tutorial_app.rst:488 msgid "" "But Bottle has already various adapters to multi-threaded servers on board, " "which perform better on higher load. Bottle supports Cherrypy_, Flup_ and " "Paste_." msgstr "" #: ../../tutorial_app.rst:490 msgid "" "If you want to run for example Bottle with the Paste server, use the " "following code::" msgstr "如果想运行在Paste服务器上面,代码如下(译者注:需要先安装Paste)。" #: ../../tutorial_app.rst:496 msgid "" "This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and " "``FapwsServer``." msgstr "其他服务器如 ``FlupServer``, ``CherryPyServer`` 和 ``FapwsServer`` 也类似。" #: ../../tutorial_app.rst:500 msgid "Running Bottle on Apache with mod_wsgi" msgstr "使用 mod_wsgi_ 运行在Apache上" #: ../../tutorial_app.rst:501 msgid "" "Maybe you already have an Apache_ or you want to run a Bottle-based " "application large scale - then it is time to think about Apache with " "mod_wsgi_." msgstr "或许你已经有了一个 Apache_ 服务器,那么可以考虑使用 mod_wsgi_ 。" #: ../../tutorial_app.rst:503 msgid "" "We assume that your Apache server is up and running and mod_wsgi is working " "fine as well. On a lot of Linux distributions, mod_wsgi can be easily " "installed via whatever package management system is in use." msgstr "我们假设你的Apache已经能跑起来,且mod_wsgi也能工作了。在很多Linux发行版上,都能通过包管理软件简单地安装mod_wsgi。" #: ../../tutorial_app.rst:505 msgid "" "Bottle brings an adapter for mod_wsgi with it, so serving your application " "is an easy task." msgstr "Bottle已经自带用于mod_wsgi的适配器,所以让Bottle跑在mod_wsgi上面是很简单的。" #: ../../tutorial_app.rst:507 msgid "" "In the following example, we assume that you want to make your application " "\"ToDo list\" accessible through ``http://www.mypage.com/todo`` and your " "code, templates and SQLite database are stored in the path " "``/var/www/todo``." msgstr "接下来的例子里,我们假设你希望通过 ``http://www.mypage.com/todo`` 来访问\"ToDo list\"这个应用,且代码、模板、和SQLite数据库存放在 ``/var/www/todo`` 目录。" #: ../../tutorial_app.rst:509 msgid "" "When you run your application via mod_wsgi, it is imperative to remove the " "``run()`` statement from your code, otherwise it won't work here." msgstr "如果通过mod_wsgi来运行你应用,那么必须从代码中移除 ``run()`` 函数。" #: ../../tutorial_app.rst:511 msgid "" "After that, create a file called ``adapter.wsgi`` with the following " "content::" msgstr "然后,创建一个 ``adapter.wsgi`` 文件,内容如下。" #: ../../tutorial_app.rst:522 msgid "" "and save it in the same path, ``/var/www/todo``. Actually the name of the " "file can be anything, as long as the extension is ``.wsgi``. The name is " "only used to reference the file from your virtual host." msgstr "将其保存到 ``/var/www/todo`` 目录下面。其实,可以给该文件起任何名字,只要后缀名为 ``.wsgi`` 即可。" #: ../../tutorial_app.rst:524 msgid "" "Finally, we need to add a virtual host to the Apache configuration, which " "looks like this::" msgstr "最后,我们需要在Apache的配置中添加一个虚拟主机。" #: ../../tutorial_app.rst:540 msgid "" "After restarting the server, your ToDo list should be accessible at " "``http://www.mypage.com/todo``" msgstr "重启Apache服务器后,即可通过 ``http://www.mypage.com/todo`` 来访问你的应用。" #: ../../tutorial_app.rst:543 msgid "Final Words" msgstr "结语" #: ../../tutorial_app.rst:545 msgid "" "Now we are at the end of this introduction and tutorial to Bottle. We " "learned about the basic concepts of Bottle and wrote a first application " "using the Bottle framework. In addition to that, we saw how to adapt Bottle " "for large tasks and serve Bottle through an Apache web server with mod_wsgi." msgstr "现在,我们这个教程已经结束了。我们学习了Bottle的基础知识,然后使用Bottle来写了第一个应用。另外,我们还介绍了如何在大型项目中使用Bottle,以及使用mod_wsgi在Apache中运行Bottle应用。" #: ../../tutorial_app.rst:547 msgid "" "As said in the introduction, this tutorial is not showing all shades and " "possibilities of Bottle. What we skipped here is e.g. receiving file objects" " and streams and how to handle authentication data. Furthermore, we did not " "show how templates can be called from within another template. For an " "introduction into those points, please refer to the full `Bottle " "documentation`_ ." msgstr "我们并没有在这份教程里介绍Bottle的方方面面。我们没有介绍如何上传文件,验证数据的可靠性。还有,我们也没介绍如何在模板中调用另一个模板。以上,可以在 `Bottle documentation`_ 中找到答案。" #: ../../tutorial_app.rst:550 msgid "Complete Example Listing" msgstr "完整代码" #: ../../tutorial_app.rst:552 msgid "" "As the ToDo list example was developed piece by piece, here is the complete " "listing:" msgstr "我们是一步一步地开发待办事项列表的,这里是完整的代码。" #: ../../tutorial_app.rst:554 msgid "Main code for the application ``todo.py``::" msgstr "``todo.py``" #: ../../tutorial_app.rst:675 msgid "Template ``make_table.tpl``::" msgstr "``make_table.tpl``模板" #: ../../tutorial_app.rst:689 msgid "Template ``edit_task.tpl``::" msgstr " ``edit_task.tpl`` 模板" #: ../../tutorial_app.rst:704 msgid "Template ``new_task.tpl``::" msgstr "``new_task.tpl`` 模板" python-bottle-0.13.2/docs/api.rst000077500000000000000000000136051470367422500166620ustar00rootroot00000000000000============================== API Reference ============================== .. module:: bottle :platform: Unix, Windows :synopsis: WSGI micro framework .. moduleauthor:: Marcel Hellkamp Bottle prides itself on having source code that is easy to read and follow, so most questions about APIs or inner workings can be answered quickly by inspecting sources. Your IDE should give you the same information you'll find on this page, as most of it is auto-generates from docstrings and method signatures anyway. If you are new to bottle, you may find the :doc:`tutorial` more helpful as a starting point. Global functions ================ The module defines several functions, constants, and an exception. .. function:: app() default_app() Return the current :ref:`default-app`. This is actually a callable instances of :class:`AppStack`. .. autofunction:: debug .. autofunction:: install .. autofunction:: uninstall .. autofunction:: run Global decorators ================= Bottle maintains a stack of :class:`Bottle` instances (see :func:`app` and :class:`AppStack`) and uses the top of the stack as a :ref:`default-app` for some of the module-level functions and decorators. All of those have a corresponding method on the :class:`Bottle` class. .. function:: route(path, method='GET', callback=None, **options) get(...) post(...) put(...) delete(...) patch(...) Decorator to install a route to the current default application. See :meth:`Bottle.route` for details. .. function:: error(...) Decorator to install an error handler to the current default application. See :meth:`Bottle.error` for details. .. autofunction:: hook Request Context =============== The global :data:`request` and :data:`response` instances are only valid from within an request handler function and represent the *current* HTTP request or response. .. autodata:: request .. autodata:: response Helper Functions ================ .. autofunction:: abort .. autofunction:: redirect .. autofunction:: static_file Exceptions ========== .. autoexception:: BottleException :members: .. autoexception:: HTTPResponse :members: .. autoexception:: HTTPError :members: The :class:`Bottle` Class ========================= .. autoclass:: Bottle :members: The :class:`Request` Object =================================================== The :class:`Request` class wraps a WSGI environment and provides helpful methods to parse and access form data, cookies, file uploads and other metadata. Most of the attributes are read-only. .. autoclass:: Request :members: .. autoclass:: BaseRequest :members: :special-members: __setattr__ .. autoclass:: LocalRequest :members: The :class:`Response` Object ============================ The :class:`Response` class stores the HTTP status code as well as headers and cookies that are to be sent to the client. Similar to :data:`bottle.request` there is a thread-local :data:`bottle.response` instance that can be used to adjust the `current` response. Moreover, you can instantiate :class:`Response` and return it from your request handler. In this case, the custom instance overrules the headers and cookies defined in the global one. .. autoclass:: Response :members: .. autoclass:: BaseResponse :members: .. autoclass:: LocalResponse :members: Data Structures =============== .. autoclass:: AppStack :members: .. method:: pop() Return the current default application and remove it from the stack. .. autoclass:: ConfigDict :members: .. autoclass:: MultiDict :members: .. autoclass:: WSGIHeaderDict :members: .. autoclass:: HeaderDict :members: .. autoclass:: FormsDict :members: .. autoclass:: FileUpload :members: Request routing =============== .. autoclass:: Router :members: .. autoclass:: Route :members: Templating ========== All template engines supported by :mod:`bottle` implement the :class:`BaseTemplate` API. This way it is possible to switch and mix template engines without changing the application code at all. .. autoclass:: BaseTemplate :members: .. autofunction:: view .. autofunction:: template .. autodata:: TEMPLATE_PATH Global search path for templates. You can write your own adapter for your favourite template engine or use one of the predefined adapters. Currently there are four fully supported template engines: ======================== =============================== ==================== ======================== Class URL Decorator Render function ======================== =============================== ==================== ======================== :class:`SimpleTemplate` :doc:`stpl` :func:`view` :func:`template` :class:`MakoTemplate` http://www.makotemplates.org :func:`mako_view` :func:`mako_template` :class:`CheetahTemplate` http://www.cheetahtemplate.org/ :func:`cheetah_view` :func:`cheetah_template` :class:`Jinja2Template` http://jinja.pocoo.org/ :func:`jinja2_view` :func:`jinja2_template` ======================== =============================== ==================== ======================== To use :class:`MakoTemplate` as your default template engine, just import its specialised decorator and render function:: from bottle import mako_view as view, mako_template as template HTTP utilities ============== .. autofunction:: parse_date .. autofunction:: parse_auth .. autofunction:: cookie_encode .. autofunction:: cookie_decode .. autofunction:: cookie_is_encoded .. autofunction:: path_shift .. autodata:: HTTP_CODES :no-value: Misc utilities ============== .. autoclass:: DictProperty .. autoclass:: cached_property .. autoclass:: lazy_attribute .. autofunction:: yieldroutes .. autofunction:: load .. autofunction:: load_app python-bottle-0.13.2/docs/async.rst000066400000000000000000000202301470367422500172130ustar00rootroot00000000000000Asynchronous Applications ========================= Asynchronous design patterns don't mix well with the synchronous nature of `WSGI `_. This is why most asynchronous frameworks (tornado, twisted, ...) implement a specialized API to expose their asynchronous features. Bottle is a WSGI framework and shares the synchronous nature of WSGI, but thanks to the awesome `gevent project `_, it is still possible to write asynchronous applications with bottle. This article documents the usage of Bottle with Asynchronous WSGI. The Limits of Synchronous WSGI ------------------------------- Briefly worded, the `WSGI specification (pep 3333) `_ defines a request/response circle as follows: The application callable is invoked once for each request and must return a body iterator. The server then iterates over the body and writes each chunk to the socket. As soon as the body iterator is exhausted, the client connection is closed. Simple enough, but there is a snag: All this happens synchronously. If your application needs to wait for data (IO, sockets, databases, ...), it must either yield empty strings (busy wait) or block the current thread. Both solutions occupy the handling thread and prevent it from answering new requests. There is consequently only one ongoing request per thread. Most servers limit the number of threads to avoid their relatively high overhead. Pools of 20 or less threads are common. As soon as all threads are occupied, any new connection is stalled. The server is effectively dead for everyone else. If you want to implement a chat that uses long-polling ajax requests to get real-time updates, you'd reach the limited at 20 concurrent connections. That's a pretty small chat. Greenlets to the rescue ------------------------ Most servers limit the size of their worker pools to a relatively low number of concurrent threads, due to the high overhead involved in switching between and creating new threads. While threads are cheap compared to processes (forks), they are still expensive to create for each new connection. The `gevent `_ module adds *greenlets* to the mix. Greenlets behave similar to traditional threads, but are very cheap to create. A gevent-based server can spawn thousands of greenlets (one for each connection) with almost no overhead. Blocking individual greenlets has no impact on the servers ability to accept new requests. The number of concurrent connections is virtually unlimited. This makes creating asynchronous applications incredibly easy, because they look and feel like synchronous applications. A gevent-based server is actually not asynchronous, but massively multi-threaded. Here is an example:: from gevent import monkey; monkey.patch_all() from time import sleep from bottle import route, run @route('/stream') def stream(): yield 'START' sleep(3) yield 'MIDDLE' sleep(5) yield 'END' run(host='0.0.0.0', port=8080, server='gevent') The first line is important. It causes gevent to monkey-patch most of Python's blocking APIs to not block the current thread, but pass the CPU to the next greenlet instead. It actually replaces Python's threading with gevent-based pseudo-threads. This is why you can still use ``time.sleep()`` which would normally block the whole thread. If you don't feel comfortable with monkey-patching python built-ins, you can use the corresponding gevent functions (``gevent.sleep()`` in this case). If you run this script and point your browser to ``http://localhost:8080/stream``, you should see `START`, `MIDDLE`, and `END` show up one by one (rather than waiting 8 seconds to see them all at once). It works exactly as with normal threads, but now your server can handle thousands of concurrent requests without any problems. .. note:: Some browsers buffer a certain amount of data before they start rendering a page. You might need to yield more than a few bytes to see an effect in these browsers. Additionally, many browsers have a limit of one concurrent connection per URL. If this is the case, you can use a second browser or a benchmark tool (e.g. `ab` or `httperf`) to measure performance. Event Callbacks --------------- A very common design pattern in asynchronous frameworks (including tornado, twisted, node.js and friends) is to use non-blocking APIs and bind callbacks to asynchronous events. The socket object is kept open until it is closed explicitly to allow callbacks to write to the socket at a later point. Here is an example based on the `tornado library `_:: class MainHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): worker = SomeAsyncWorker() worker.on_data(lambda chunk: self.write(chunk)) worker.on_finish(lambda: self.finish()) The main benefit is that the request handler terminates early. The handling thread can move on and accept new requests while the callbacks continue to write to sockets of previous requests. This is how these frameworks manage to process a lot of concurrent requests with only a small number of OS threads. With Gevent+WSGI, things are different: First, terminating early has no benefit because we have an unlimited pool of (pseudo)threads to accept new connections. Second, we cannot terminate early because that would close the socket (as required by WSGI). Third, we must return an iterable to conform to WSGI. In order to conform to the WSGI standard, all we have to do is to return a body iterable that we can write to asynchronously. With the help of `gevent.queue `_, we can *simulate* a detached socket and rewrite the previous example as follows:: @route('/fetch') def fetch(): body = gevent.queue.Queue() worker = SomeAsyncWorker() worker.on_data(body.put) worker.on_finish(lambda: body.put(StopIteration)) worker.start() return body From the server perspective, the queue object is iterable. It blocks if empty and stops as soon as it reaches ``StopIteration``. This conforms to WSGI. On the application side, the queue object behaves like a non-blocking socket. You can write to it at any time, pass it around and even start a new (pseudo)thread that writes to it asynchronously. This is how long-polling is implemented most of the time. Finally: WebSockets ------------------- Lets forget about the low-level details for a while and speak about WebSockets. Since you are reading this article, you probably know what WebSockets are: A bidirectional communication channel between a browser (client) and a web application (server). Thankfully the `gevent-websocket `_ package does all the hard work for us. Here is a simple WebSocket endpoint that receives messages and just sends them back to the client:: from bottle import request, Bottle, abort app = Bottle() @app.route('/websocket') def handle_websocket(): wsock = request.environ.get('wsgi.websocket') if not wsock: abort(400, 'Expected WebSocket request.') while True: try: message = wsock.receive() wsock.send("Your message was: %r" % message) except WebSocketError: break from gevent.pywsgi import WSGIServer from geventwebsocket import WebSocketError from geventwebsocket.handler import WebSocketHandler server = WSGIServer(("0.0.0.0", 8080), app, handler_class=WebSocketHandler) server.serve_forever() The while-loop runs until the client closes the connection. You get the idea :) The client-site JavaScript API is really straight forward, too:: python-bottle-0.13.2/docs/bottle.svg000066400000000000000000000241751470367422500173720ustar00rootroot00000000000000 python-bottle-0.13.2/docs/changelog.rst000077500000000000000000000350101470367422500200320ustar00rootroot00000000000000.. highlight:: python .. currentmodule:: bottle ============= Release Notes ============= Release 0.13 ============== .. warning:: This release contains breaking changers, please read the notes below .. rubric:: Dropped support for Python versions that reached their end-of-life. Bottle up to 0.12 supported an absurd range of Python versions (2.5 to 3.12) and keeping support for Python versions as ancient as 2.5 required a ton of workarounds and compromises, but served no real purpose. If you need support for older Python versions, you can stay on bottle 0.12. The updated list of tested and supported python releases is as follows: * Python 2 >= 2.7.3 * Python 3 >= 3.8 Support for Python 2.5 was marked as deprecated since 0.12. We decided to go a step further and also remove support for 2.6 and 3.1 to 3.7 even if it was never deprecated explicitly in bottle. This means that this release is *not* backwards compatible in Python <2.7.3 or <3.8 environments. Maintainers for distributions or systems that still use these old python versions should not update to Bottle 0.13 and stick with 0.12 instead. .. rubric:: Stabilized APIs * The documented API of the :class:`ConfigDict` class is now considered stable and ready to use. .. rubric:: Deprecated APIs * Python 2 support is now deprecated and will be dropped with the next release. * The command line executable installed along with bottle will be renamed from `bottle.py` to just `bottle`. You can still execute bottle directly as a script (e.g. `./bottle.py` or `python3 bottle.py`) or as a module (via `python3 -m bottle`). Just the executable installed by your packaging tool (e.g. `pip`) into the `bin` folder of your (virtual) environment will change. * The old route syntax (``/hello/:name``) is deprecated in favor of the more readable and flexible ``/hello/`` syntax. * :meth:`Bottle.mount` now recognizes Bottle instance and will warn about parameters that are not compatible with the new mounting behavior. The old behavior (mount applications as WSGI callable) still works and is used as a fallback automatically. * The undocumented :func:`local_property` helper is now deprecated. * The server adapter for google app engine is not useful anymore and marked as deprecated. * Bottle uses pickle to store arbitrary objects into signed cookies. This is safe, as long as the signature key remains a secret. Unfortunately, people tend to push code with signature keys to github all the time, so we decided to remove pickle-support from bottle. Signed cookies will now issue a deprecation warning if the value is not a string, and support for non-string values will be removed in 0.14. The global :func:`cookie_encode`, :func:`cookie_decode` and :func:`is_cookie_encoded` are now also deprecated. If you are using this feature, think about using json to serialize your objects before storing them into cookies, or switch to a session system that stores data server-side instead of client-side. .. rubric:: Removed APIs (deprecated since 0.12) * Plugins with the old API (``api=1`` or no api attribute) will no longer work. * Parameter order of :meth:`Bottle.mount` changed in 0.10. The old order will now result in an error instead of a warning. * The :class:`ConfigDict` class was introduced in 0.11 and changed during 0.12. These changes are now final. * Attribute access and assignment was removed due to high overhead and limited usability. * Namespaced sub-instance creation was removed. ``config["a"]["b"]`` has a high overhead and little benefit over ``config["a.b"]``. * :class:`ConfigDict` instances are no longer callable. This was a shortcut for :meth:`ConfigDict.update`. * :class:`ConfigDict` constructor no longer accepts any parameters. Use the `load_*` methods instead. * Bottle 0.12 changed some aspects of the Simple Template Engine. These changes are now final and the old syntax will now longer work. * The magic ``{{rebase()}}`` call was replaced by a ``base`` variable. Example: ``{{base}}`` * In STPL Templates, the ``rebase`` and ``include`` keywords were replaced with functions in 0.12. * PEP-263 encoding strings are no longer recognized. Templates are always utf-8. * The 'geventSocketIO' server adapter was removed without notice. It did not work anyway. .. rubric:: Changes These changes might require special care when updating. * Signed cookies now use a stronger HMAC algorithm by default. This will result in old cookies to appear invalid after the update. Pass an explicit ``digestmod=hashlib.md5`` to :meth:`BaseRequest.get_cookie` and :meth:`BaseResponse.set_cookie` to get the old behavior. * Bottle now ships with its own multipart form data parser (borrowed from `multipart `_) and no longer relies on ``cgi.FieldStorage``, which was removed in Python 3.13. This may change the way broken (non-standard) form submissions are parsed. The new parser is more strict and correct than ohe old one. * Installing bottle with `pip` or similar tools will now install an additional command line executable named `bottle` into the `bin` folder of your (virtual) environment. This will replace the now deprecated `bottle.py` executable in a later release. See above. .. rubric:: Other Improvements * :class:`Bottle` instances are now context managers. If used in a with-statement, the default application changes to the specific instance and the shortcuts for many instance methods can be used. * Added support for ``PATCH`` requests and the :meth:`Bottle.patch` decorator. * Added `aiohttp `_ and `uvloop `_ server adapters. * Added command-line arguments for config from json or ini files. * :meth:`Bottle.mount` now recognizes instances of :class:`Bottle` and mounts them with significantly less overhead than other WSGI applications. * The :attr:`BaseRequest.json` property now accepts ``application/json-rpc`` requests. * :func:`static_file` gained support for ``ETag`` headers. It will generate ETags and recognizes ``If-None-Match`` headers. * :func:`static_file` will now guess the mime type of ``*.gz`` and other compressed files correctly (e.g. ``application/gzip``) and NOT set the ``Content-Encoding`` header. * Jinja2 templates will produce better error messages than before. Release 0.12 ============== * New SimpleTemplate parser implementation * Support for multi-line code blocks (`<% ... %>`). * The keywords `include` and `rebase` are functions now and can accept variable template names. * The new :attr:`BaseRequest.route` property returns the :class:`Route` that originally matched the request. * Removed the ``BaseRequest.MAX_PARAMS`` limit. The hash collision bug in CPythons dict() implementation was fixed over a year ago. If you are still using Python 2.5 in production, consider upgrading or at least make sure that you get security fixed from your distributor. * New :class:`ConfigDict` API (see :doc:`configuration`) More information can be found in this `development blog post `_. Release 0.11 ============== * Native support for Python 2.x and 3.x syntax. No need to run 2to3 anymore. * Support for partial downloads (``Range`` header) in :func:`static_file`. * The new :class:`ResourceManager` interface helps locating files bundled with an application. * Added a server adapter for `waitress `_. * New :meth:`Bottle.merge` method to install all routes from one application into another. * New :attr:`BaseRequest.app` property to get the application object that handles a request. * Added :meth:`FormsDict.decode()` to get an all-unicode version (needed by WTForms). * :class:`MultiDict` and subclasses are now pickle-able. .. rubric:: API Changes * :attr:`BaseResponse.status` is a read-write property that can be assigned either a numeric status code or a status string with a reason phrase (``200 OK``). The return value is now a string to better match existing APIs (WebOb, werkzeug). To be absolutely clear, you can use the read-only properties :attr:`BaseResponse.status_code` and :attr:`BaseResponse.status_line`. .. rubric:: API Deprecations * :class:`SimpleTALTemplate` is now deprecating. There seems to be no demand. Release 0.10 ============== * Plugin API v2 * To use the new API, set :attr:`Plugin.api` to ``2``. * :meth:`Plugin.apply` receives a :class:`Route` object instead of a context dictionary as second parameter. The new object offers some additional information and may be extended in the future. * Plugin names are considered unique now. The topmost plugin with a given name on a given route is installed, all other plugins with the same name are silently ignored. * The Request/Response Objects * Added :attr:`BaseRequest.json`, :attr:`BaseRequest.remote_route`, :attr:`BaseRequest.remote_addr`, :attr:`BaseRequest.query` and :attr:`BaseRequest.script_name`. * Added :attr:`BaseResponse.status_line` and :attr:`BaseResponse.status_code` attributes. In future releases, :attr:`BaseResponse.status` will return a string (e.g. ``200 OK``) instead of an integer to match the API of other common frameworks. To make the transition as smooth as possible, you should use the verbose attributes from now on. * Replaced :class:`MultiDict` with a specialized :class:`FormsDict` in many places. The new dict implementation allows attribute access and handles unicode form values transparently. * Templates * Added three new functions to the SimpleTemplate default namespace that handle undefined variables: :func:`stpl.defined`, :func:`stpl.get` and :func:`stpl.setdefault`. * The default escape function for SimpleTemplate now additionally escapes single and double quotes. * Routing * A new route syntax (e.g. ``/object/``) and support for route wildcard filters. * Four new wildcard filters: `int`, `float`, `path` and `re`. * Other changes * Added command line interface to load applications and start servers. * Introduced a :class:`ConfigDict` that makes accessing configuration a lot easier (attribute access and auto-expanding namespaces). * Added support for raw WSGI applications to :meth:`Bottle.mount`. * :meth:`Bottle.mount` parameter order changed. * :meth:`Bottle.route` now accepts an import string for the ``callback`` parameter. * Dropped Gunicorn 0.8 support. Current supported version is 0.13. * Added custom options to Gunicorn server. * Finally dropped support for type filters. Replace with a custom plugin of needed. Release 0.9 ============ .. rubric:: Whats new? * A brand new plugin-API. See :doc:`plugins/index` and :doc:`plugins/dev` for details. * The :func:`route` decorator got a lot of new features. See :meth:`Bottle.route` for details. * New server adapters for `gevent `_, `meinheld `_ and `bjoern `_. * Support for SimpleTAL templates. * Better runtime exception handling for mako templates in debug mode. * Lots of documentation, fixes and small improvements. * A new :data:`BaseRequest.urlparts` property. .. rubric:: Performance improvements * The :class:`Router` now special-cases ``wsgi.run_once`` environments to speed up CGI. * Reduced module load time by ~30% and optimized template parser. See `8ccb2d `_, `f72a7c `_ and `b14b9a `_ for details. * Support for "App Caching" on Google App Engine. See `af93ec `_. * Some of the rarely used or deprecated features are now plugins that avoid overhead if the feature is not used. .. rubric:: API changes This release is mostly backward compatible, but some APIs are marked deprecated now and will be removed for the next release. Most noteworthy: * The ``static`` route parameter is deprecated. You can escape wild-cards with a backslash. * Type-based output filters are deprecated. They can easily be replaced with plugins. Release 0.8 ============ .. rubric:: API changes These changes may break compatibility with previous versions. * The built-in Key/Value database is not available anymore. It is marked deprecated since 0.6.4 * The Route syntax and behaviour changed. * Regular expressions must be encapsulated with ``#``. In 0.6 all non-alphanumeric characters not present in the regular expression were allowed. * Regular expressions not part of a route wildcard are escaped automatically. You don't have to escape dots or other regular control characters anymore. In 0.6 the whole URL was interpreted as a regular expression. You can use anonymous wildcards (``/index:#(\.html)?#``) to achieve a similar behaviour. * The ``BreakTheBottle`` exception is gone. Use :class:`HTTPResponse` instead. * The :class:`SimpleTemplate` engine escapes HTML special characters in ``{{bad_html}}`` expressions automatically. Use the new ``{{!good_html}}`` syntax to get old behaviour (no escaping). * The :class:`SimpleTemplate` engine returns unicode strings instead of lists of byte strings. * ``bottle.optimize()`` and the automatic route optimization is obsolete. * Some functions and attributes were renamed: * :attr:`BaseRequest._environ` is now :attr:`BaseRequest.environ` * :attr:`BaseResponse.header` is now :attr:`BaseResponse.headers` * :func:`default_app` is obsolete. Use :func:`app` instead. * The default :func:`redirect` code changed from 307 to 303. * Removed support for ``@default``. Use ``@error(404)`` instead. .. rubric:: New features This is an incomplete list of new features and improved functionality. * The :class:`Request` object got new properties: :attr:`BaseRequest.body`, :attr:`BaseRequest.auth`, :attr:`BaseRequest.url`, :attr:`BaseRequest.header`, :attr:`BaseRequest.forms`, :attr:`BaseRequest.files`. * The :meth:`BaseResponse.set_cookie` and :meth:`BaseRequest.get_cookie` methods are now able to encode and decode python objects. This is called a *secure cookie* because the encoded values are signed and protected from changes on client side. All pickle-able data structures are allowed. * The new :class:`Router` class drastically improves performance for setups with lots of dynamic routes and supports named routes (named route + dict = URL string). * It is now possible (and recommended) to return :exc:`HTTPError` and :exc:`HTTPResponse` instances or other exception objects instead of raising them. * The new function :func:`static_file` equals :func:`send_file` but returns a :exc:`HTTPResponse` or :exc:`HTTPError` instead of raising it. :func:`send_file` is deprecated. * New :func:`get`, :func:`post`, :func:`put` and :func:`delete` decorators. * The :class:`SimpleTemplate` engine got full unicode support. * Lots of non-critical bugfixes. python-bottle-0.13.2/docs/conf.py000066400000000000000000000016161470367422500166520ustar00rootroot00000000000000# -*- coding: utf-8 -*- import sys import os import time # Use the matching bottle version, not a globally installed one. bottle_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../')) sys.path.insert(0, bottle_dir) import bottle extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode'] master_doc = 'index' project = u'Bottle' copyright = u'2009-%s, %s' % (time.strftime('%Y'), bottle.__author__) version = ".".join(bottle.__version__.split(".")[:2]) release = bottle.__version__ add_function_parentheses = True add_module_names = False autodoc_member_order = 'bysource' autodoc_class_signature = 'separated' pygments_style = 'sphinx' intersphinx_mapping = {'python': ('https://docs.python.org/3', None), 'werkzeug': ('https://werkzeug.palletsprojects.com/en/3.0.x', None)} locale_dirs = ['_locale/'] gettext_compact = False python-bottle-0.13.2/docs/configuration.rst000066400000000000000000000156371470367422500207640ustar00rootroot00000000000000============= Configuration ============= .. currentmodule:: bottle Bottle applications can store their configuration in :attr:`Bottle.config`, a dict-like object and central place for application specific settings. This dictionary controls many aspects of the framework, tells (newer) plugins what to do, and can be used to store your own configuration as well. Configuration Basics ==================== The :attr:`Bottle.config` object behaves a lot like an ordinary dictionary. All the common dict methods work as expected. Let us start with some examples:: import bottle app = bottle.default_app() # or bottle.Bottle() if you prefer app.config['autojson'] = False # Turns off the "autojson" feature app.config['sqlite.db'] = ':memory:' # Tells the sqlite plugin which db to use app.config['myapp.param'] = 'value' # Example for a custom config value. # Change many values at once app.config.update({ 'autojson': False, 'sqlite.db': ':memory:', 'myapp.param': 'value' }) # Add default values app.config.setdefault('myapp.param2', 'some default') # Receive values param = app.config['myapp.param'] param2 = app.config.get('myapp.param2', 'fallback value') # An example route using configuration values @app.route('/about', view='about.rst') def about(): email = app.config.get('my.email', 'nomail@example.com') return {'email': email} Helper functions can rely on :attr:`BaseRequest.app` to get the application and configuration associated with the *current* request:: from bottle import request def is_admin(user): return user == request.app.config['myapp.admin_user'] Naming Convention ================= To make life easier, plugins and applications should follow some simple rules when it comes to config parameter names: - All keys should be lowercase strings and follow the rules for python identifiers (no special characters but the underscore). - Namespaces are separated by dots (e.g. ``namespace.field`` or ``namespace.subnamespace.field``). - Bottle uses the root namespace for its own configuration. Plugins should store all their variables in their own namespace (e.g. ``sqlite.db`` or ``werkzeug.use_debugger``). - Your own application should use a separate namespace (e.g. ``myapp.*``). Load configuration from a File ================================= .. versionadded 0.12 Configuration files are useful if you want to enable non-programmers to configure your application, or just don't want to hack python module files just to change the database port. A very common syntax for configuration files is shown here: .. code-block:: ini [sqlite] db = /tmp/test.db commit = auto [myapp] admin_user = defnull With :meth:`ConfigDict.load_config` you can load these ``*.ini`` style configuration files from disk and import their values into your existing configuration:: app.config.load_config('/etc/myapp.conf') Load configuration from a python module ========================================== .. versionadded 0.13 Loading configuration from a Python module is a common pattern for Python programs and frameworks. :meth:`ConfigDict.load_module` imports a python module by name and adds all upper-case variables to configuration. .. code-block:: python DEBUG = True SQLITE = {"db": ":memory:"} .. code-block:: >>> c = ConfigDict() >>> c.load_module('config') {'debug': True, 'sqlite.db': 'memory'} >>> c.load_module("config", squash=False) {'debug': True, 'sqlite': {'db': 'memory'}} Configuration is flattened by default, similar to the behavior of :meth:`ConfigDict.load_dict`. You can prevent that by passing ``squash=False`` as a parameter. Loading configuration from a :class:`dict` ========================================== .. versionadded 0.12 Another useful method is :meth:`ConfigDict.load_dict`. This method takes an entire structure of nested dictionaries and turns it into a flat list of keys and values with namespaced keys:: # Load an entire dict structure app.config.load_dict({ 'autojson': False, 'sqlite': { 'db': ':memory:' }, 'myapp': { 'param': 'value', 'param2': 'value2' } }) assert app.config['myapp.param'] == 'value' # Load configuration from a json file with open('/etc/myapp.json') as fp: app.config.load_dict(json.load(fp)) .. _conf-hook: Listening to configuration changes ================================== .. versionadded 0.12 Bottle triggers the ``config`` application hook each time a value in :attr:`Bottle.config` is about to be changed. This hook can be used to dynamically re-configure plugins or parts of your application once configuration changes at runtime. For example: * Enable or disable maintenance or debug mode. * Reconnect to a new database. * Change the settings on a plugin or background service. * Resize worker thread pools. The hook callback receives two arguments (key, new_value) and is called before the value is actually changed in the dictionary. Raising an exception from this callback will prevent the change and preserve the old value. :: @app.hook('config') def on_config_change(key, value): if key == 'debug': switch_own_debug_mode_to(value) The hook callbacks cannot *change* the value that is to be stored to the dictionary. That is what filters are for. .. _conf-meta: Filters and other Meta Data =========================== .. versionadded 0.12 :class:`ConfigDict` allows you to store meta data along with configuration keys. Two meta fields are currently defined: ``help`` A help or description string. May be used by debugging, introspection or admin tools to help the site maintainer configuring their application. ``filter`` A callable that accepts and returns a single value. If a filter is defined for a key, any new value stored to that key is first passed through the filter callback. The filter can be used to cast the value to a different type, check for invalid values (throw a ValueError) or trigger side effects. This feature is most useful for plugins. They can validate their config parameters or trigger side effects using filters and document their configuration via ``help`` fields:: class SomePlugin(object): def setup(app): app.config.meta_set('some.int', 'filter', int) app.config.meta_set('some.list', 'filter', lambda val: str(val).split(';')) app.config.meta_set('some.list', 'help', 'A semicolon separated list.') def apply(self, callback, route): ... import bottle app = bottle.default_app() app.install(SomePlugin()) app.config['some.list'] = 'a;b;c' # Actually stores ['a', 'b', 'c'] app.config['some.int'] = 'not an int' # raises ValueError API Documentation ================= .. versionadded 0.12 .. autoclass:: ConfigDict :members: :no-index:python-bottle-0.13.2/docs/contributors.rst000066400000000000000000000000771470367422500206420ustar00rootroot00000000000000============ Contributors ============ .. include:: ../AUTHORSpython-bottle-0.13.2/docs/deployment.rst000066400000000000000000000132001470367422500202550ustar00rootroot00000000000000.. highlight:: python .. currentmodule:: bottle .. _flup: https://pypi.org/project/flup/ .. _gae: http://code.google.com/appengine/docs/python/overview.html .. _wsgiref: http://docs.python.org/library/wsgiref.html .. _cherrypy: https://cherrypy.dev/ .. _paste: https://pythonpaste.readthedocs.io/ .. _gunicorn: http://pypi.python.org/pypi/gunicorn .. _tornado: http://www.tornadoweb.org/ .. _twisted: http://twistedmatrix.com/ .. _diesel: http://dieselweb.org/ .. _meinheld: http://pypi.python.org/pypi/meinheld .. _bjoern: http://pypi.python.org/pypi/bjoern .. _gevent: http://www.gevent.org/ .. _eventlet: http://eventlet.net/ .. _waitress: http://readthedocs.org/docs/waitress/en/latest/ .. _apache: http://httpd.apache.org/ .. _mod_wsgi: http://code.google.com/p/modwsgi/ .. _pound: http://www.apsis.ch/pound .. _nginx: http://nginx.org/ .. _lighttpd: http://www.lighttpd.net/ .. _cherokee: http://cherokee-project.com/ .. _uWSGI: https://uwsgi-docs.readthedocs.io/en/latest/ .. _cheroot: https://cheroot.cherrypy.dev/ .. _tutorial-deployment: ================================================================================ Deployment ================================================================================ The bottle :func:`run` function, when called without any parameters, starts a local development server on port 8080. You can access and test your application via http://localhost:8080/ if you are on the same host. To get your application available to the outside world, specify the IP the server should listen to (e.g. ``run(host='192.168.0.1')``) or let the server listen to all interfaces at once (e.g. ``run(host='0.0.0.0')``). The listening port can be changed in a similar way, but you need root or admin rights to choose a port below 1024. Port 80 is the standard for HTTP servers:: # Listen to HTTP on all interfaces if __name__ == '__main__': run(host='0.0.0.0', port=80) Scaling for Production ================================================================================ The built-in development server is base on `wsgiref WSGIServer `_, which is a very simple non-threading HTTP server implementation. This is perfectly fine for development, but may become a performance bottleneck when server load increases. The easiest way to increase performance is to install a multi-threaded server library like cheroot_ or gunicorn_ and tell Bottle to use that instead of the single-threaded wsgiref server:: run(server='cheroot', ...) # Pure Python, runs everywhere run(server='gunicorn', ...) # High performance Or using the ``bottle`` command line interface: .. code-block:: sh python3 -m bottle --server gunicorn [...] mymodule:app For production deployments gunicorn_ is a really good choice. It comes with its own command line utility that supports a lot more options than bottle. Since :class:`Bottle` instances are WSGI applications, you can tell gunicorn_ (or any other WSGI server) to load your app instead of calling :func:`run` yourself: .. code-block:: sh gunicorn -w 4 mymodule:app This will start your application with 4 gunicorn workers and sane default settings. For more details and more complete examples, check out `Gunicorn Documentation `_. Server adapters ------------------------------------------------------------------------------ Bottle ships with a bunch of ready-to-use adapters for the most common WSGI servers so you can try out different server backends easily. You can select a server backend via `run(server='NAME')` or `python3 -m bottle --server NAME`. Here is an incomplete list: ======== ============ ====================================================== Name Homepage Description ======== ============ ====================================================== cgi Run as CGI script flup flup_ Run as FastCGI process gae gae_ Helper for Google App Engine deployments wsgiref wsgiref_ Single-threaded default server cherrypy cherrypy_ Multi-threaded (deprectated)) cheroot cheroot_ Successor of cheerypy paste paste_ Multi-threaded, stable, tried and tested waitress waitress_ Multi-threaded, poweres Pyramid gunicorn gunicorn_ Pre-forked, partly written in C eventlet eventlet_ Asynchronous framework with WSGI support. gevent gevent_ Asynchronous (greenlets) diesel diesel_ Asynchronous (greenlets) tornado tornado_ Asynchronous, powers some parts of Facebook twisted twisted_ Asynchronous, well tested but... twisted meinheld meinheld_ Asynchronous, partly written in C bjoern bjoern_ Asynchronous, very fast and written in C auto Automatically selects the first available server adapter ======== ============ ====================================================== Those adapters are very basic and just for convenience, though. If you need more control over your deployment, refer to the server backend documentation and mount your Bottle application just like any other WSGI application. WSGI Deployment ------------------------------------------------------------------------------ If there is no adapter for your favorite server or if you need more control over the server setup, you may want to start the server manually. Refer to the server documentation on how to run WSGI applications. Here is an example for cheroot_:: import cheroot.wsgi import mymodule.app wsgi_server = cheroot.wsgi.Server( bind_addr=('0.0.0.0', 80), wsgi_app=mymodule.app ) try: wsgi_server.start() finally: wsgi_server.stop() python-bottle-0.13.2/docs/development.rst000066400000000000000000000265051470367422500204330ustar00rootroot00000000000000Developer Notes ================= This document is intended for developers and package maintainers interested in the bottle development and release workflow. If you want to contribute, you are just right! Get involved ------------ There are several ways to join the community and stay up to date. Here are some of them: * **Mailing list**: Join our mailing list by sending an email to `bottlepy+subscribe@googlegroups.com `_ (no google account required). * **Twitter**: `Follow us on Twitter `_ or search for the `#bottlepy `_ tag. * **IRC**: Join `#bottlepy on irc.freenode.net `_ or use the `web chat interface `_. * **Google plus**: We sometimes `blog about Bottle, releases and technical stuff `_ on our Google+ page. Get the Sources --------------- The bottle `development repository `_ and the `issue tracker `_ are both hosted at `github `_. If you plan to contribute, it is a good idea to create an account there and fork the main repository. This way your changes and ideas are visible to other developers and can be discussed openly. Even without an account, you can clone the repository or just download the latest development version as a source archive. * **git:** ``git clone git://github.com/bottlepy/bottle.git`` * **git/https:** ``git clone https://github.com/bottlepy/bottle.git`` * **Download:** Development branch as `tar archive `_ or `zip file `_. * **Translations:** `transifex.com/projects/p/bottle `_ Releases and Updates -------------------- Bottle is released at irregular intervals and distributed through `PyPI `_. Release candidates and bugfix-revisions of outdated releases are only available from the git repository mentioned above. Some Linux distributions may offer packages for outdated releases, though. The Bottle version number splits into three parts (**major.minor.revision**). These are *not* used to promote new features but to indicate important bug-fixes and/or API changes. Critical bugs are fixed in at least the two latest minor releases and announced in all available channels (mailinglist, twitter, github). Non-critical bugs or features are not guaranteed to be backported. This may change in the future, through. Major Release (x.0) The major release number is increased on important milestones or updates that completely break backward compatibility. You probably have to work over your entire application to use a new release. These releases are very rare, through. Minor Release (x.y) The minor release number is increased on updates that change the API or behaviour in some way. You might get some depreciation warnings any may have to tweak some configuration settings to restore the old behaviour, but in most cases these changes are designed to be backward compatible for at least one minor release. You should update to stay up do date, but don't have to. An exception is 0.8, which *will* break backward compatibility hard. (This is why 0.7 was skipped). Sorry about that. Revision (x.y.z) The revision number is increased on bug-fixes and other patches that do not change the API or behaviour. You can safely update without editing your application code. In fact, you really should as soon as possible, because important security fixes are released this way. Pre-Release Versions Release candidates are marked by an ``rc`` in their revision number. These are API stable most of the time and open for testing, but not officially released yet. You should not use these for production. Repository Structure -------------------- The source repository is structured as follows: ``master`` branch This is the integration, testing and development branch. All changes that are planned to be part of the next release are merged and tested here. ``release-x.y`` branches As soon as the master branch is (almost) ready for a new release, it is branched into a new release branch. This "release candidate" is feature-frozen but may receive bug-fixes and last-minute changes until it is considered production ready and officially released. From that point on it is called a "support branch" and still receives bug-fixes, but only important ones. The revision number is increased on each push to these branches, so you can keep up with important changes. Feature branches All other branches are feature branches. These are based on the master branch and only live as long as they are still active and not merged back into ``master``. .. rubric:: What does this mean for a developer? If you want to add a feature, create a new branch from ``master``. If you want to fix a bug, branch ``release-x.y`` for each affected release. Please use a separate branch for each feature or bug to make integration as easy as possible. Thats all. There are git workflow examples at the bottom of this page. Oh, and never ever change the release number. We'll do that on integration. You never know in which order we pull pending requests anyway :) .. rubric:: What does this mean for a maintainer ? Watch the tags (and the mailing list) for bug-fixes and new releases. If you want to fetch a specific release from the git repository, trust the tags, not the branches. A branch may contain changes that are not released yet, but a tag marks the exact commit which changed the version number. Submitting Patches ------------------ The best way to get your changes integrated into the main development branch is to fork the main repository at github, create a new feature-branch, apply your changes and send a pull-request. Further down this page is a small collection of git workflow examples that may guide you. Submitting git-compatible patches to the mailing list is fine too. In any case, please follow some basic rules: * **Documentation:** Tell us what your patch does. Comment your code. If you introduced a new feature, add to the documentation so others can learn about it. * **Test:** Write tests to prove that your code works as expected and does not break anything. If you fixed a bug, write at least one test-case that triggers the bug. Make sure that all tests pass before you submit a patch. * **One patch at a time:** Only fix one bug or add one feature at a time. Design your patches so that they can be applied as a whole. Keep your patches clean, small and focused. * **Sync with upstream:** If the ``upstream/master`` branch changed while you were working on your patch, rebase or pull to make sure that your patch still applies without conflicts. Building the Documentation -------------------------- You need a recent version of Sphinx to build the documentation. The recommended way is to install :command:`virtualenv` using your distribution package repository and install sphinx manually to get an up-to-date version. .. code-block:: bash # Install prerequisites which virtualenv || sudo apt-get install python-virtualenv virtualenv --no-site-dependencies venv ./venv/pip install -U sphinx # Clone or download bottle from github git clone https://github.com/bottlepy/bottle.git # Activate build environment source ./venv/bin/activate # Build HTML docs cd bottle/docs make html # Optional: Install prerequisites for PDF generation sudo apt-get install texlive-latex-extra \ texlive-latex-recommended \ texlive-fonts-recommended # Optional: Build the documentation as PDF make latex cd ../build/docs/latex make pdf GIT Workflow Examples --------------------- The following examples assume that you have an (free) `github account `_. This is not mandatory, but makes things a lot easier. First of all you need to create a fork (a personal clone) of the official repository. To do this, you simply click the "fork" button on the `bottle project page `_. When the fork is done, you will be presented with a short introduction to your new repository. The fork you just created is hosted at github and read-able by everyone, but write-able only by you. Now you need to clone the fork locally to actually make changes to it. Make sure you use the private (read-write) URL and *not* the public (read-only) one:: git clone git@github.com:your_github_account/bottle.git Once the clone is complete your repository will have a remote named "origin" that points to your fork on github. Don’t let the name confuse you, this does not point to the original bottle repository, but to your own fork. To keep track of the official repository, add another remote named "upstream":: cd bottle git remote add upstream git://github.com/bottlepy/bottle.git git fetch upstream Note that "upstream" is a public clone URL, which is read-only. You cannot push changes directly to it. Instead, we will pull from your public repository. This is described later. .. rubric:: Submit a Feature New features are developed in separate feature-branches to make integration easy. Because they are going to be integrated into the ``master`` branch, they must be based on ``upstream/master``. To create a new feature-branch, type the following:: git checkout -b cool_feature upstream/master Now implement your feature, write tests, update the documentation, make sure that all tests pass and commit your changes:: git commit -a -m "Cool Feature" If the ``upstream/master`` branch changed in the meantime, there may be conflicts with your changes. To solve these, 'rebase' your feature-branch onto the top of the updated ``upstream/master`` branch:: git fetch upstream git rebase upstream This is equivalent to undoing all your changes, updating your branch to the latest version and reapplying all your patches again. If you released your branch already (see next step), this is not an option because it rewrites your history. You can do a normal pull instead. Resolve any conflicts, run the tests again and commit. Now you are almost ready to send a pull request. But first you need to make your feature-branch public by pushing it to your github fork:: git push origin cool_feature After you’ve pushed your commit(s) you need to inform us about the new feature. One way is to send a pull-request using github. Another way would be to start a thread in the mailing-list, which is recommended. It allows other developers to see and discuss your patches and you get some feedback for free :) If we accept your patch, we will integrate it into the official development branch and make it part of the next release. .. rubric:: Fix a Bug The workflow for bug-fixes is very similar to the one for features, but there are some differences: 1) Branch off of the affected release branches instead of just the development branch. 2) Write at least one test-case that triggers the bug. 3) Do this for each affected branch including ``upstream/master`` if it is affected. ``git cherry-pick`` may help you reducing repetitive work. 4) Name your branch after the release it is based on to avoid confusion. Examples: ``my_bugfix-x.y`` or ``my_bugfix-dev``. python-bottle-0.13.2/docs/faq.rst000066400000000000000000000332511470367422500166540ustar00rootroot00000000000000.. currentmodule:: bottle .. _beaker: https://beaker.readthedocs.io/en/latest/ .. _mod_python: http://www.modpython.org/ .. _mod_wsgi: http://code.google.com/p/modwsgi/ .. _paste: https://pythonpaste.readthedocs.io/ .. _pylons: https://pylonsproject.org/ .. _gevent: http://www.gevent.org/ .. _heroku: http://heroku.com .. _django: https://www.djangoproject.com/ .. _werkzeug: https://werkzeug.palletsprojects.com/en/3.0.x/ ================== F.A.Q. ================== This is a loosely ordered collection of frequently asked questions, solutions for common problems, tips and other bits of knowledge. General questions =========================== Is bottle suitable for complex applications? --------------------------------------------- Bottle is first and foremost a *micro* framework. It is small, fast, easy to learn, stays out of your way and provides just enough functionality to get you started. This is perfect for prototyping, weekend projects, small applications, REST APIs or micro services, but you'll have to get your hands dirty at some point. If there is no :doc:`plugin ` available for the feature you need, you'll have to write some glue code yourself. But that's not as bad as it sounds. Bottle is small and straight forward. Unlike most other frameworks, you can actually find answers by reading its code. If you want to really understand and fully gasp your tech stack, then bottle is for you. But if you have tight deadlines and do not want to deal with any details, a more complete full-stack framework like django_ may be a better choice. What about Flask? --------------------------------------------- Flask was heavily inspired by Bottle (`* `_) and looks very similar on the surface, but took some very different design decisions. Most importantly, Flask is built on top of other libraries (e.g. Werkzeug, Jinja, Click and many more) which makes Flask itself small, but the actual code required to serve a single request is huge in comparison. I would not call it a *micro* framework at this point, but that's just my personal opinion. If you prefer Flask, go for it. Common errors and pitfalls ========================== "Template Not Found" in mod_wsgi/mod_python -------------------------------------------------------------------------------- Bottle searches in ``./`` and ``./views/`` for templates. In a mod_python_ or mod_wsgi_ environment, the working directory (``./``) depends on your Apache settings. You should add an absolute path to the template search path:: bottle.TEMPLATE_PATH.insert(0,'/absolut/path/to/templates/') so bottle searches the right paths. Dynamic Routes and Slashes -------------------------------------------------------------------------------- In :ref:`dynamic route syntax `, a placeholder token (````) matches everything up to the next slash. This equals to ``[^/]+`` in regular expression syntax. To accept slashes too, you have to add a custom regular pattern to the placeholder. An example: ``/images/`` would match ``/images/icons/error.png`` but ``/images/`` won't. Problems with reverse proxies -------------------------------------------------------------------------------- Redirects and url-building only works if bottle knows the public address and location of your application. If you run bottle locally behind a reverse proxy or load balancer, some information might get lost along the way. For example, the ``wsgi.url_scheme`` value or the ``Host`` header might reflect the local request by your proxy, not the real request by the client. Here is a small WSGI middleware snippet that helps to fix these values:: def fix_environ_middleware(app): def fixed_app(environ, start_response): environ['wsgi.url_scheme'] = 'https' environ['HTTP_X_FORWARDED_HOST'] = 'example.com' return app(environ, start_response) return fixed_app app = bottle.default_app() app.wsgi = fix_environ_middleware(app.wsgi) Recieps for common tasks ============================ This is a collection of code snippets and examples for common use cases. Keeping track of Sessions ---------------------------- There is no built-in support for sessions because there is no *right* way to do it (in a micro framework). Depending on requirements and environment you could use beaker_ middleware with a fitting backend or implement it yourself. Here is an example for beaker sessions with a file-based backend:: from bottle import Bottle, request from beaker.middleware import SessionMiddleware app = Bottle() session_opts = { 'session.type': 'file', 'session.cookie_expires': 300, 'session.data_dir': './data', 'session.auto': True } app = SessionMiddleware(app, session_opts) @app.route('/test') def test(): s = request['beaker.session'] s['test'] = s.get('test',0) + 1 s.save() return 'Test counter: %d' % s['test'] app.run() WARNING: Beaker's SessionMiddleware is not thread safe. If two concurrent requests modify the same session at the same time, one of the updates might get lost. For this reason, sessions should only be populated once and treated as a read-only store after that. If you find yourself updating sessions regularly, and don't want to risk losing any updates, think about using a real database instead or seek alternative session middleware libraries. Debugging with Style: Debugging Middleware -------------------------------------------------------------------------------- Bottle catches all Exceptions raised in your app code to prevent your WSGI server from crashing. If the built-in :func:`debug` mode is not enough and you need exceptions to propagate to a debugging middleware, you can turn off this behaviour:: import bottle app = bottle.Bottle() app.catchall = False # Now most exceptions are re-raised within bottle. myapp = DebuggingMiddleware(app) #Replace this with a middleware of your choice (see below) bottle.run(app=myapp) Now, bottle only catches its own exceptions (:exc:`HTTPError`, :exc:`HTTPResponse` and :exc:`BottleException`) and your middleware can handle the rest. The werkzeug_ and paste_ libraries both ship with very powerful debugging WSGI middleware. Look at :class:`werkzeug.debug.DebuggedApplication` for werkzeug_ and :class:`paste.evalexception.middleware.EvalException` for paste_. They both allow you do inspect the stack and even execute python code within the stack context, so **do not use these in production**! Unit-Testing Bottle Applications -------------------------------------------------------------------------------- Unit-testing is usually performed against methods defined in your web application without running a WSGI environment. A simple example:: import bottle @bottle.route('/') def index(): return 'Hi!' if __name__ == '__main__': bottle.run() Test script:: import mywebapp def test_webapp_index(): assert mywebapp.index() == 'Hi!' In the example the Bottle route() method is never executed - only index() is tested. If the code being tested requires access to ``bottle.request`` you can mock it using `Boddle `_:: import bottle @bottle.route('/') def index(): return 'Hi %s!' % bottle.request.params['name'] Test script:: import mywebapp from boddle import boddle def test_webapp_index(): with boddle(params={'name':'Derek'}): assert mywebapp.index() == 'Hi Derek!' Functional Testing Bottle Applications -------------------------------------------------------------------------------- Any HTTP-based testing system can be used with a running WSGI server, but some testing frameworks work more intimately with WSGI, and provide the ability the call WSGI applications in a controlled environment, with tracebacks and full use of debugging tools. Example using `WebTest `_:: from webtest import TestApp import myapp def test_functional_login_logout(): app = TestApp(myapp.app) app.post('/login', {'user': 'foo', 'pass': 'bar'}) # log in and get a cookie assert app.get('/admin').status == '200 OK' # fetch a page successfully assert app.get('/logout').status_code == 200 # log out app.reset() # drop the cookie # fetch the same page, unsuccessfully assert app.get('/admin', expect_errors=True).status == '401 Unauthorized' Ignore trailing slashes -------------------------------------------------------------------------------- For Bottle, ``/example`` and ``/example/`` are two different routes [1]_. To treat both URLs the same you can add two ``@route`` decorators:: @route('/test') @route('/test/') def test(): return 'Slash? no?' add a WSGI middleware that strips trailing slashes from all URLs:: class StripPathMiddleware(object): def __init__(self, app): self.app = app def __call__(self, e, h): e['PATH_INFO'] = e['PATH_INFO'].rstrip('/') return self.app(e,h) app = bottle.app() myapp = StripPathMiddleware(app) bottle.run(app=myapp) or add a ``before_request`` hook to strip the trailing slashes:: @hook('before_request') def strip_path(): request['PATH_INFO'] = request['PATH_INFO'].rstrip('/') .. rubric:: Footnotes .. [1] Because they are. See Keep-alive requests ------------------- .. note:: For a more detailed explanation, see :doc:`async`. Several "push" mechanisms like XHR multipart need the ability to write response data without closing the connection in conjunction with the response header "Connection: keep-alive". WSGI does not easily lend itself to this behavior, but it is still possible to do so in Bottle by using the gevent_ async framework. Here is a sample that works with either the gevent_ HTTP server or the paste_ HTTP server (it may work with others, but I have not tried). Just change ``server='gevent'`` to ``server='paste'`` to use the paste_ server:: from gevent import monkey; monkey.patch_all() import gevent from bottle import route, run @route('/stream') def stream(): yield 'START' gevent.sleep(3) yield 'MIDDLE' gevent.sleep(5) yield 'END' run(host='0.0.0.0', port=8080, server='gevent') If you browse to ``http://localhost:8080/stream``, you should see 'START', 'MIDDLE', and 'END' show up one at a time (rather than waiting 8 seconds to see them all at once). Gzip Compression in Bottle -------------------------- A common feature request is for Bottle to support Gzip compression, which speeds up sites by compressing static resources (like CSS and JS files) during a request. Supporting Gzip compression is not a straightforward proposition, due to a number of corner cases that crop up frequently. A proper Gzip implementation must: * Compress on the fly and be fast doing so. * Do not compress for browsers that don't support it. * Do not compress files that are compressed already (images, videos). * Do not compress dynamic files. * Support two differed compression algorithms (gzip and deflate). * Cache compressed files that don't change often. * De-validate the cache if one of the files changed anyway. * Make sure the cache does not get to big. * Do not cache small files because a disk seek would take longer than on-the-fly compression. Because of these requirements, it is the recommendation of the Bottle project that Gzip compression is best handled by the WSGI server Bottle runs on top of. WSGI servers and reverse proxies often provide built-in features that allow transparent compression without changing the application itself. Using hooks to handle CORS -------------------------- Hooks are useful to unconditionally do something before or after each request. For example, if you want to allow Cross-Origin requests for your entire application, instead of writing a :doc:`plugin ` you can use hooks to add the appropiate headers:: from bottle import hook, response, HTTPResponse cors_headers = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', # 'Access-Control-Allow-Headers': 'X-Token, ...', # 'Access-Control-Expose-Headers': 'X-My-Custom-Header, ...', # 'Access-Control-Max-Age': '86400', # 'Access-Control-Allow-Credentials': 'true', } @hook('before_request') def handle_options(): if request.method == 'OPTIONS': # Bypass request routing and immediately return a response raise HTTPResponse(headers=cors_headers) @hook('after_request') def enable_cors(): for key, value in cors_headers.items(): response.set_header(key, value) Using Bottle with Heroku ------------------------ Heroku_, a popular cloud application platform now provides support for running Python applications on their infrastructure. This recipe is based upon the `Heroku Quickstart `_, with Bottle specific code replacing the `Write Your App `_ section of the `Getting Started with Python on Heroku/Cedar `_ guide:: import os from bottle import route, run @route("/") def hello_world(): return "Hello World!" run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000))) Heroku's app stack passes the port that the application needs to listen on for requests, using the `os.environ` dictionary. python-bottle-0.13.2/docs/index.rst000077500000000000000000000076621470367422500172260ustar00rootroot00000000000000.. highlight:: python .. currentmodule:: bottle .. _mako: http://www.makotemplates.org/ .. _cheetah: http://www.cheetahtemplate.org/ .. _jinja2: http://jinja.pocoo.org/ .. _paste: https://pythonpaste.readthedocs.io/ .. _bjoern: https://github.com/jonashaag/bjoern .. _flup: http://trac.saddi.com/flup .. _gunicorn: https://gunicorn.org/ .. _cheroot: https://cheroot.cherrypy.dev/ .. _WSGI: https://peps.python.org/pep-3333/ .. _Python: http://python.org/ .. _testing: https://github.com/bottlepy/bottle/raw/master/bottle.py .. _issue_tracker: https://github.com/bottlepy/bottle/issues .. _PyPI: http://pypi.python.org/pypi/bottle .. _gae: https://developers.google.com/appengine/ ============================ Bottle: Python Web Framework ============================ Bottle is a fast, simple and lightweight WSGI_ micro web-framework for Python_. It is distributed as a single file module and has no dependencies other than the `Python Standard Library `_. * **Routing:** Requests to function-call mapping with support for clean and dynamic URLs. * **Templates:** Fast and pythonic :ref:`built-in template engine ` and support for mako_, jinja2_ and cheetah_ templates. * **Utilities:** Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata. * **Server:** Built-in HTTP development server and support for a wide range of WSGI_ capable HTTP server (e.g. gunicorn_, paste_ or cheroot_). .. rubric:: Example: "Hello World" in a bottle :: from bottle import route, run, template @route('/hello/') def index(name): return template('Hello {{name}}!', name=name) run(host='localhost', port=8080) Run this script or paste it into a Python console, then point your browser to ``_. That's it. Download and Install ==================== .. __: https://github.com/bottlepy/bottle/raw/master/bottle.py Install the latest stable release with ``pip install bottle`` or download `bottle.py`__ (unstable) into your project directory. There are no hard [1]_ dependencies other than the Python standard library. Dead Snakes =========== Bottle up to version 0.12 supported an absurd number of python versions, some of which reached their end-of-life well over a decade ago. Starting with Bottle 0.13 we will keep compatibility with `maintained versions of Python `_ only and drop support for "dead snakes" with each new bottle release. If you are in the unfortunate position to have to rely on a truly ancient version of Python, just stick with a compatible bottle release. Everyone else should update regularly to benefit from new features and improvements. .. list-table:: Python Support Matrix :widths: 50 25 25 :header-rows: 1 * - Bottle Version - Python 2 - Python 3 * - 0.12 - 2.5, 2.6, 2.7 - 3.2 - 3.12 * - 0.13 - 2.7 - 3.8 - 3.x * - 1.0 (planned) - *dropped* - 3.8 - 3.x Documentation ============= .. toctree:: :maxdepth: 2 :caption: Getting Started tutorial api changelog faq .. toctree:: :maxdepth: 2 :caption: Advanced Topics routing configuration stpl deployment async .. toctree:: :maxdepth: 2 :caption: Plugins plugins/index plugins/dev plugins/list .. toctree:: :maxdepth: 2 :caption: Additional Notes tutorial_app .. toctree:: :maxdepth: 2 :caption: Development development contributors License ================== Code and documentation are available according to the MIT License: .. include:: ../LICENSE :literal: The Bottle logo however is *NOT* covered by that license. It is allowed to use the logo as a link to the bottle homepage or in direct context with the unmodified library. In all other cases please ask first. .. rubric:: Footnotes .. [1] Usage of the template or server adapter classes requires the corresponding template or server modules. python-bottle-0.13.2/docs/plugins/000077500000000000000000000000001470367422500170305ustar00rootroot00000000000000python-bottle-0.13.2/docs/plugins/dev.rst000066400000000000000000000255321470367422500203470ustar00rootroot00000000000000 .. currentmodule:: bottle .. _plugindev: =============== Writing Plugins =============== This guide explains the plugin API and how to write custom plugins. I suggest reading :ref:`plugin-basics` first if you have not done so already. You might also want to have a look at the :doc:`/plugins/index` for some practical examples. Plugin API ========== Any callable that accepts a function and returns a function is a valid plugin. This simple approach has its limits, though. Plugins that need more context and control can implement the extended :class:`Plugin` interface and hook into advanced features. Note that this is not a real class you can import from :mod:`bottle`, just a contract that plugins must implement to be recognized as extended plugins. .. class:: Plugin Plugins must be callable or implement :meth:`apply`. If :meth:`apply` is defined, it is always preferred over calling the plugin directly. All other methods and attributes are optional. .. attribute:: name Both :meth:`Bottle.uninstall` and the `skip` parameter of :meth:`Bottle.route()` accept a name string to refer to a plugin or plugin type. This works only for plugins that have a name attribute. .. attribute:: api The Plugin API is still evolving. This integer attribute tells bottle which version to use. If it is missing, bottle defaults to the first version. The current version is ``2``. See :ref:`plugin-changelog` for details. .. method:: setup(self, app: Bottle) Called as soon as the plugin is installed to an application via :meth:`Bottle.install`. The only parameter is the application object the plugin is installed to. This method is *not* called for plugins that were applied to routes via `apply`, but only for plugins installed to an application. .. method:: __call__(self, callback) As long as :meth:`apply` is not defined, the plugin itself is used as a decorator and applied directly to each route callback. The only parameter is the callback to be decorated. Whatever is returned by this method replaces the original callback. If there is no need to wrap or replace a given callback, just return the unmodified callback parameter. .. method:: apply(self, callback, route: Route) If defined, this method is used in favor of :meth:`__call__` to decorate route callbacks. The additional `route` parameter is an instance of :class:`Route` and provides a lot of context and meta-information and about the route to be decorated. See :ref:`route-context` for details. .. method:: close(self) Called as soon as the plugin is uninstalled or the application is closed (see :meth:`Bottle.uninstall` or :meth:`Bottle.close`). This method is *not* called for plugins that were applied to routes via `apply`, but only for plugins installed to an application. .. _plugin-changelog: Plugin API Versions ------------------- The Plugin API is still evolving and changed with Bottle 0.10 to address certain issues with the route context dictionary. To ensure backwards compatibility with 0.9 Plugins, we added an optional :attr:`Plugin.api` attribute to tell bottle which API to use. The API differences are summarized here. * **Bottle 0.9 API 1** (:attr:`Plugin.api` not present) * Original Plugin API as described in the 0.9 docs. * **Bottle 0.10 API 2** (:attr:`Plugin.api` equals 2) * The `context` parameter of the :meth:`Plugin.apply` method is now an instance of :class:`Route` instead of a context dictionary. .. _route-context: The Route Context ================= The :class:`Route` instance passed to :meth:`Plugin.apply` provides detailed information about the to-be-decorated route, the original route callback and route specific configuration. Keep in mind that :attr:`Route.config` is local to the route, but shared between all plugins. It is always a good idea to add a unique prefix or, if your plugin needs a lot of configuration, store it in a separate namespace within the `config` dictionary. This helps to avoid naming collisions between plugins. While some :class:`Route` attributes are mutable, changes may have unwanted effects on other plugins and also only affect plugins that were not applied yet. If you need to make changes to the route that are recognized by all plugins, raise :exc:`RouteReset` as an exception. This removes the current route from the cache and causes all plugins to be re-applied again. The router is not updated, however. Changes to `rule` or `method` values have no effect on the router, only on plugins. This may change in the future. Runtime optimizations ===================== Once all plugins are applied to a route, the wrapped route callback is cached to speed up subsequent requests. If the behavior of your plugin depends on configuration, and you want to be able to change that configuration at runtime, you need to read the configuration on each request. Easy enough. For performance reasons however, it might be worthwhile to return a different wrapper based on current needs, work with closures, or enable or disable a plugin at runtime. Let's take the built-in ``HooksPlugin`` as an example: If no hooks are installed, the plugin removes itself from all routes and has virtually no overhead. As soon as you install the first hook, the plugin activates itself and takes effect again. To achieve this, you need control over the callback cache: :meth:`Route.reset` clears the cache for a single route and :meth:`Bottle.reset` clears all caches for all routes of an application at once. On the next request, all plugins are re-applied to the route as if it were requested for the first time. Both methods won't affect the current request if called from within a route callback, though. To force a complete restart of the *current* request, raise :exc:`RouteReset` as an exception. Common patterns =============== .. rubric:: Dependency or resource injection Plugins may checks if the callback accepts a specific keyboard parameter and only apply themselves if that parameter is present. For example, route callbacks that expect a ``db`` keyword argument need a database connection. Routes that do not expect such a parameter can be skipped and not decorated. The paramneter name should be configurable to avoid conflicts with other plugins or route parameters. .. rubric:: Request context properties Plugins may add new request-local properties to the current :data:`request`, for example ``request.session`` for a durable session or ``request.user`` for logged in users. See :class:`BaseRequest.__setattr__`. .. rubric:: Response type mapping Plugins may check the return value of the wrapped callback and transform or serialize the output to a new type. The bundled :class:`JsonPlugin` does exactly that. .. rubric:: Zero overhead plugins Plugins that are not needed on a specific route should return the callback unchanged. If they want to remove themselves from a route at runtime, they can call :meth:`Route.reset` and skip the route the next time it is triggered. .. rubric:: Before / after each request Plugins can be a convenient alternative to ``before_request`` or ``after_request`` hooks (see :meth:`Bottle.add_hook`), especially if both are needed. Plugin Example: SQLitePlugin ============================ This plugin provides an sqlite3 database connection handle as an additional keyword argument to wrapped callbacks, but only if the callback expects it. If not, the route is ignored and no overhead is added. The wrapper does not affect the return value, but handles plugin-related exceptions properly. :meth:`Plugin.setup` is used to inspect the application and search for conflicting plugins. :: import sqlite3 import inspect class SQLitePlugin: name = 'sqlite' api = 2 def __init__(self, dbfile=':memory:', autocommit=True, dictrows=True, keyword='db'): self.dbfile = dbfile self.autocommit = autocommit self.dictrows = dictrows self.keyword = keyword def setup(self, app): ''' Make sure that other installed plugins don't affect the same keyword argument.''' for other in app.plugins: if not isinstance(other, SQLitePlugin): continue if other.keyword == self.keyword: raise PluginError("Found another sqlite plugin with "\ "conflicting settings (non-unique keyword).") def apply(self, callback, route): # Override global configuration with route-specific values. conf = route.config.get('sqlite') or {} dbfile = conf.get('dbfile', self.dbfile) autocommit = conf.get('autocommit', self.autocommit) dictrows = conf.get('dictrows', self.dictrows) keyword = conf.get('keyword', self.keyword) # Test if the original callback accepts a 'db' keyword. # Ignore it if it does not need a database handle. args = inspect.getargspec(route.callback)[0] if keyword not in args: return callback def wrapper(*args, **kwargs): # Connect to the database db = sqlite3.connect(dbfile) # This enables column access by name: row['column_name'] if dictrows: db.row_factory = sqlite3.Row # Add the connection handle as a keyword argument. kwargs[keyword] = db try: rv = callback(*args, **kwargs) if autocommit: db.commit() except sqlite3.IntegrityError, e: db.rollback() raise HTTPError(500, "Database Error", e) finally: db.close() return rv # Replace the route callback with the wrapped one. return wrapper This plugin is just an example, but actually usable:: sqlite = SQLitePlugin(dbfile='/tmp/test.db') bottle.install(sqlite) @route('/show/') def show(page, db): row = db.execute('SELECT * from pages where name=?', page).fetchone() if row: return template('showpage', page=row) return HTTPError(404, "Page not found") @route('/static/') def static(fname): return static_file(fname, root='/some/path') @route('/admin/set/', skip=[sqlite]) def change_dbfile(db): sqlite.dbfile = '/tmp/%s.db' % db return "Switched DB to %s.db" % db The first route needs a database connection and tells the plugin to create a handle by accepting a ``db`` keyword argument. The second route does not need a database and is therefore ignored by the plugin. The third route does expect a 'db' keyword argument, but explicitly skips the sqlite plugin. This way the argument is not overruled by the plugin and still contains the value of the same-named url argument. python-bottle-0.13.2/docs/plugins/index.rst000077500000000000000000000167651470367422500207130ustar00rootroot00000000000000.. currentmodule:: bottle .. _plugins: ============= Using Plugins ============= .. versionadded:: 0.9 Bottle's core features cover most common use-cases, but as a micro-framework it has its limits. This is where "Plugins" come into play. Plugins add missing functionality to the framework, integrate third party libraries, or just automate some repetitive work. We have a growing list of :doc:`/plugins/list` and most plugins are designed to be portable and re-usable across applications. Maybe your problem has already been solved and a ready-to-use plugin exists. If not, write your own. See :doc:`/plugins/dev` for details. .. _plugin-basics: Plugin Basics ============= Bottles Plugin system builds on the concept of `decorators `_. To put it briefly, a plugin is a decorator applied to all route callback in an application. Plugins can do more than just decorating route callbacks, but it is still a good starting point to understand the concept. Lets have a look at a practical example:: from bottle import response def stopwatch(callback): def wrapper(*args, **kwargs): start = time.time() result = callback(*args, **kwargs) end = time.time() response.headers['X-Exec-Time'] = str(end - start) return result return wrapper This "stopwatch" decorator measures the execution time of the wrapped function and then writes the result in the non-standard ``X-Exec-Time`` response header. You could just manually apply this decorator to all your route callbacks and call it a day:: from bottle import route @route("/timed") @stopwatch # <-- This works, but do not do this def timed(): time.sleep(1) return "DONE" But we wouldn't be talking about a plugin system if there wasn't a better way to do this! Managing Plugins ================ Explicitly applying decorators to every single route in a growing application quickly becomes tedious and error-prone. If you really want to apply something to *all* routes, there is a simpler way:: from bottle import route, install install(stopwatch) @route("/timed") def timed(): ... The :func:`install` method registries a plugin to be automatically applied to all routes in an application. It does not matter if you call :func:`install` before or after binding routes, all plugins are always applied to all routes. The order of :func:`install` calls is important though. If there are multiple plugins, they are applied in the same order the were installed. Any callable object that works as a route callback decorator is a valid plugin. This includes normal decorators, classes, callables instances, but also plugins that implement the extended :class:`Plugin` API. See :ref:`plugindev` for details. You can also :func:`uninstall` a previously installed plugin by name, class or instance:: sqlite_plugin = SQLitePlugin(dbfile='/tmp/test.db') install(sqlite_plugin) uninstall(sqlite_plugin) # uninstall a specific plugin uninstall(SQLitePlugin) # uninstall all plugins of that type uninstall('sqlite') # uninstall all plugins with that name uninstall(True) # uninstall all plugins at once Plugins can be installed and also removed at any time, even at runtime while serving requests. They are applied on-demand, that is, as soon as the route is requested for the first time. This enables some neat tricks (e.g. installing slow debugging or profiling plugins only when needed) but should not be overused. Each time the list of plugins changes, the route cache is flushed and all plugins need to be re-applied. .. note:: The module-level :func:`install` and :func:`uninstall` functions affect the :ref:`default application `. To manage plugins for a specific application, use the corresponding methods on a :class:`Bottle` instance. Selectively apply or skip Plugins --------------------------------- Most plugins are smart enough to ignore routes that do not need their functionality and do not add any overhead to those routes, but you can also apply or skip specific plugins per route if you need to. To apply a decorator or plugin to just a single route, do not :func:`install` it, but use the ``apply`` keyword of the :func:`route` decorator instead:: @route('/timed', apply=[stopwatch]) def timed(): ... Route-level plugins are applied first (before application-wide plugins) but handled exactly like normal plugins otherwise. You can also explicitly disable an installed plugin for a number of routes. The :func:`route` decorator has a ``skip`` parameter for this purpose:: install(stopwatch) @route('/notime', skip=[stopwatch]) def no_time(): pass The ``skip`` parameter accepts a single value or a list of values. You can use a plugin name, class or instance to identify the plugin that should be skipped. Set ``skip=True`` to skip all plugins at once. Plugins and :meth:`Bottle.mount` -------------------------------- Most plugins are specific to the application they were installed to and should not affect sub-applications mounted with :meth:`Bottle.mount`. Here is an example:: root = Bottle() root.install(plugins.WTForms()) root.mount('/blog', apps.blog) @root.route('/contact') def contact(): return template('contact', email='contact@example.com') When mounting an application, Bottle creates a proxy-route on the mounting application that forwards all requests to the mounted application. Plugins are disabled for this kind of proxy-route by default. Our (fictional) ``WTForms`` plugin affects the ``/contact`` route, but does not affect the routes of the ``/blog`` sub-application. This behavior is intended as a sane default, but can be overridden. The following example re-activates all plugins for a specific proxy-route:: root.mount('/blog', apps.blog, skip=None) Note that a plugin sees the whole sub-application as a single route, namely the proxy-route mentioned above. To wrap each individual route of the sub-application, you have to install the plugin to the mounted application directly. Configuring Plugins =================== Most plugins accept configuration as parameters passed to their constructor. This is the easiest and most obvious way to configure a plugin, e.g. to tell a database plugin which database to connect to:: install(SQLitePlugin(dbfile='/tmp/test.db', ...)) Newer plugins may also read values from :attr:`Bottle.config` (see :doc:`../configuration`). This is useful for configuration that should be easy to change or override for a specific deployment. This pattern even supports runtime changes using :ref:`config hooks `:: app.config["sqlite.db"] = '/tmp/test.db' app.install(SQLitePlugin()) Plugins can also inspect the routes they are applied to and change their behavior for individual routes. Plugin authors have full access to the undecorated route callback as well as parameters passed to the :meth:`route` decorator, including custom parameters that are otherwise ignored by bottle. This allows for a great level of flexibility. Common patterns include: * A database plugin may automatically start a transaction if the route callback accepts a ``db`` keyword. * A forms plugin may ignore routes that do not listen to ``POST`` requests. * An access control plugin may check for a custom ``roles_allowed`` parameter passed to the :meth:`route` decorator. In any case, check the plugin documentation for details. If you want to write your own plugins, check out :doc:`dev`.python-bottle-0.13.2/docs/plugins/list.rst000066400000000000000000000063721470367422500205450ustar00rootroot00000000000000.. currentmodule:: bottle ========================= 3rd Party Plugins ========================= This is a list of third-party plugins that add extend Bottles core functionality or integrate other libraries with the Bottle framework. Have a look at :ref:`plugins` for general questions about plugins (installation, usage). If you plan to develop a new plugin, the :ref:`plugindev` may help you. `Bottle-Beaker `_ Beaker to session and caching library with WSGI Middleware `Bottle-Cork `_ Cork provides a simple set of methods to implement Authentication and Authorization in web applications based on Bottle. `Bottle-Cors-plugin `_ Cors-plugin is the easiest way to implement cors on your bottle web application `Bottle-Extras `_ Meta package to install the bottle plugin collection. `Bottle-Flash `_ flash plugin for bottle `Bottle-Hotqueue `_ FIFO Queue for Bottle built upon redis `Macaron `_ Macaron is an object-relational mapper (ORM) for SQLite. `Bottle-Memcache `_ Memcache integration for Bottle. `Bottle-Mongo `_ MongoDB integration for Bottle `Bottle-OAuthlib `_ Adapter for oauthlib - create your own OAuth2.0 implementation `Bottle-Redis `_ Redis integration for Bottle. `Bottle-Renderer `_ Renderer plugin for bottle `Bottle-Servefiles `_ A reusable app that serves static files for bottle apps `Bottle-Sqlalchemy `_ SQLAlchemy integration for Bottle. `Bottle-Sqlite `_ SQLite3 database integration for Bottle. `Bottle-Web2pydal `_ Web2py Dal integration for Bottle. `Bottle-Werkzeug `_ Integrates the `werkzeug` library (alternative request and response objects, advanced debugging middleware and more). `bottle-smart-filters `_ Bottle Querystring smart guessing. `bottle-jwt `_ JSON Web Token authentication plugin for bottle.py `bottlejwt `_ JWT integration for bottle `canister `_ a bottle wrapper to provide logging, sessions and authentication `bottle-cerberus `_ Cerberus integration for bottle `Bottle-errorsrest `_ All errors generated from bottle are returned in json `Bottle-tools `_ Decorators that auto-supply function arguments using POST/query string data. Plugins listed here are not part of Bottle or the Bottle project, but developed and maintained by third parties. python-bottle-0.13.2/docs/requirements.txt000066400000000000000000000000221470367422500206250ustar00rootroot00000000000000sphinx sphinx-intlpython-bottle-0.13.2/docs/routing.rst000066400000000000000000000125631470367422500175770ustar00rootroot00000000000000.. currentmodule:: bottle ================================================================================ Request Routing ================================================================================ Bottle uses a powerful routing engine to find the right callback for each request. The :ref:`tutorial ` shows you the basics. This document covers advanced techniques and rule mechanics in detail. Rule Syntax -------------------------------------------------------------------------------- The :class:`Router` distinguishes between two basic types of routes: **static routes** (e.g. ``/contact``) and **dynamic routes** (e.g. ``/hello/``). A route that contains one or more *wildcards* it is considered dynamic. All other routes are static. .. versionchanged:: 0.10 The simplest form of a wildcard consists of a name enclosed in angle brackets (e.g. ````). The name should be unique for a given route and form a valid python identifier (alphanumeric, starting with a letter). This is because wildcards are used as keyword arguments for the request callback later. Each wildcard matches one or more characters, but stops at the first slash (``/``). This equals a regular expression of ``[^/]+`` and ensures that only one path segment is matched and routes with more than one wildcard stay unambiguous. The rule ``//`` matches as follows: ============ ========================================= Path Result ============ ========================================= /save/123 ``{'action': 'save', 'item': '123'}`` /save/123/ `No Match` /save/ `No Match` //123 `No Match` ============ ========================================= Is it possible to escape characters like colon ``:`` with a backslash ``\``. This will prevent to trigger the old syntax in case you need to use ``:``. For example: the rule ``//item:`` triggers the old syntax, (see below) but ``/action/item\:`` works as intended with the new syntax. You can change the exact behaviour in many ways using filters. This is described in the next section. Wildcard Filters -------------------------------------------------------------------------------- .. versionadded:: 0.10 Filters are used to define more specific wildcards, and/or transform the matched part of the URL before it is passed to the callback. A filtered wildcard is declared as ```` or ````. The syntax for the optional config part depends on the filter used. The following standard filters are implemented: * **:int** matches (signed) digits and converts the value to integer. * **:float** similar to :int but for decimal numbers. * **:path** matches all characters including the slash character in a non-greedy way and may be used to match more than one path segment. * **:re[:exp]** allows you to specify a custom regular expression in the config field. The matched value is not modified. You can add your own filters to the router. All you need is a function that returns three elements: A regular expression string, a callable to convert the URL fragment to a python value, and a callable that does the opposite. The filter function is called with the configuration string as the only parameter and may parse it as needed:: app = Bottle() def list_filter(config): ''' Matches a comma separated list of numbers. ''' delimiter = config or ',' regexp = r'\d+(%s\d)*' % re.escape(delimiter) def to_python(match): return map(int, match.split(delimiter)) def to_url(numbers): return delimiter.join(map(str, numbers)) return regexp, to_python, to_url app.router.add_filter('list', list_filter) @app.route('/follow/') def follow_users(ids): for id in ids: ... Legacy Syntax -------------------------------------------------------------------------------- .. versionchanged:: 0.10 The new rule syntax was introduce in **Bottle 0.10** to simplify some common use cases, but the old syntax still works and you can find lot code examples still using it. The differences are best described by example: =================== ==================== Old Syntax New Syntax =================== ==================== ``:name`` ```` ``:name#regexp#`` ```` ``:#regexp#`` ``<:re:regexp>`` ``:##`` ``<:re>`` =================== ==================== Try to avoid the old syntax in future projects if you can. It is not currently deprecated, but will be eventually. Explicit routing configuration -------------------------------------------------------------------------------- Route decorator can also be directly called as method. This way provides flexibility in complex setups, allowing you to directly control, when and how routing configuration done. Here is a basic example of explicit routing configuration for default bottle application:: def setup_routing(): bottle.route('/', 'GET', index) bottle.route('/edit', ['GET', 'POST'], edit) In fact, any :class:`Bottle` instance routing can be configured same way:: def setup_routing(app): app.route('/new', ['GET', 'POST'], form_new) app.route('/edit', ['GET', 'POST'], form_edit) app = Bottle() setup_routing(app) python-bottle-0.13.2/docs/stpl.rst000077500000000000000000000204661470367422500170760ustar00rootroot00000000000000============== SimpleTemplate ============== .. currentmodule:: bottle Bottle comes with a fast, powerful and easy to learn built-in template engine called *SimpleTemplate* or *stpl* for short. It is the default engine used by the :func:`view` and :func:`template` helpers but can be used as a stand-alone general purpose template engine too. This document explains the template syntax and shows examples for common use cases. .. rubric:: Basic API Usage: :class:`SimpleTemplate` implements the :class:`BaseTemplate` API:: >>> from bottle import SimpleTemplate >>> tpl = SimpleTemplate('Hello {{name}}!') >>> tpl.render(name='World') u'Hello World!' In this document we use the :func:`template` helper in examples for the sake of simplicity:: >>> from bottle import template >>> template('Hello {{name}}!', name='World') u'Hello World!' You can also pass a dictionary into the template using keyword arguments:: >>> from bottle import template >>> my_dict={'number': '123', 'street': 'Fake St.', 'city': 'Fakeville'} >>> template('I live at {{number}} {{street}}, {{city}}', **my_dict) u'I live at 123 Fake St., Fakeville' Just keep in mind that compiling and rendering templates are two different actions, even if the :func:`template` helper hides this fact. Templates are usually compiled only once and cached internally, but rendered many times with different keyword arguments. :class:`SimpleTemplate` Syntax ============================== Python is a very powerful language but its whitespace-aware syntax makes it difficult to use as a template language. SimpleTemplate removes some of these restrictions and allows you to write clean, readable and maintainable templates while preserving full access to the features, libraries and speed of the Python language. .. warning:: The :class:`SimpleTemplate` syntax compiles directly to python bytecode and is executed on each :meth:`SimpleTemplate.render` call. Do not render untrusted templates! They may contain and execute harmful python code. Inline Expressions ------------------ You already learned the use of the ``{{...}}`` syntax from the "Hello World!" example above, but there is more: any python expression is allowed within the curly brackets as long as it evaluates to a string or something that has a string representation:: >>> template('Hello {{name}}!', name='World') u'Hello World!' >>> template('Hello {{name.title() if name else "stranger"}}!', name=None) u'Hello stranger!' >>> template('Hello {{name.title() if name else "stranger"}}!', name='mArC') u'Hello Marc!' The contained python expression is executed at render-time and has access to all keyword arguments passed to the :meth:`SimpleTemplate.render` method. HTML special characters are escaped automatically to prevent `XSS `_ attacks. You can start the expression with an exclamation mark to disable escaping for that expression:: >>> template('Hello {{name}}!', name='World') u'Hello <b>World</b>!' >>> template('Hello {{!name}}!', name='World') u'Hello World!' Embedded python code -------------------- .. highlight:: html+django The template engine allows you to embed lines or blocks of python code within your template. Code lines start with ``%`` and code blocks are surrounded by ``<%`` and ``%>`` tokens: .. code-block:: text % name = "Bob" # a line of python code

Some plain text in between

<% # A block of python code name = name.title().strip() %>

More plain text

Embedded python code follows regular python syntax, but with two additional syntax rules: * **Indentation is ignored.** You can put as much whitespace in front of statements as you want. This allows you to align your code with the surrounding markup and can greatly improve readability. * Blocks that are normally indented now have to be closed explicitly with an ``end`` keyword. .. code-block:: text
    % for item in basket:
  • {{item}}
  • % end
Both the ``%`` and the ``<%`` tokens are only recognized if they are the first non-whitespace characters in a line. You don't have to escape them if they appear mid-text in your template markup. Only if a line of text starts with one of these tokens, you have to escape it with a backslash. In the rare case where the backslash + token combination appears in your markup at the beginning of a line, you can always help yourself with a string literal in an inline expression: .. code-block:: text This line contains % and <% but no python code. \% This text-line starts with the '%' token. \<% Another line that starts with a token but is rendered as text. {{'\\%'}} this line starts with an escaped token. Whitespace Control ----------------------- Code blocks and code lines always span the whole line. Whitespace in front of after a code segment is stripped away. You won't see empty lines or dangling whitespace in your template because of embedded code::
% if True: content % end
This snippet renders to clean and compact html::
content
But embedding code still requires you to start a new line, which may not what you want to see in your rendered template. To skip the newline in front of a code segment, end the text line with a double-backslash::
\\ %if True: content\\ %end
This time the rendered template looks like this::
content
This only works directly in front of code segments. In all other places you can control the whitespace yourself and don't need any special syntax. Template Functions ================== Each template is preloaded with a bunch of functions that help with the most common use cases. These functions are always available. You don't have to import or provide them yourself. For everything not covered here there are probably good python libraries available. Remember that you can ``import`` anything you want within your templates. They are python programs after all. .. currentmodule:: stpl .. versionchanged:: 0.12 Prior to this release, :func:`include` and :func:`rebase` were syntax keywords, not functions. .. function:: include(sub_template, **variables) Render a sub-template with the specified variables and insert the resulting text into the current template. The function returns a dictionary containing the local variables passed to or defined within the sub-template:: % include('header.tpl', title='Page Title') Page Content % include('footer.tpl') .. function:: rebase(name, **variables) Mark the current template to be later included into a different template. After the current template is rendered, its resulting text is stored in a variable named ``base`` and passed to the base-template, which is then rendered. This can be used to `wrap` a template with surrounding text, or simulate the inheritance feature found in other template engines:: % rebase('base.tpl', title='Page Title')

Page Content ...

This can be combined with the following ``base.tpl``: .. code-block:: html {{title or 'No title'}} {{!base}} Accessing undefined variables in a template raises :exc:`NameError` and stops rendering immediately. This is standard python behavior and nothing new, but vanilla python lacks an easy way to check the availability of a variable. This quickly gets annoying if you want to support flexible inputs or use the same template in different situations. These functions may help: .. function:: defined(name) Return True if the variable is defined in the current template namespace, False otherwise. .. function:: get(name, default=None) Return the variable, or a default value. .. function:: setdefault(name, default) If the variable is not defined, create it with the given default value. Return the variable. Here is an example that uses all three functions to implement optional template variables in different ways:: % setdefault('text', 'No Text')

{{get('title', 'No Title')}}

{{ text }}

% if defined('author'):

By {{ author }}

% end .. currentmodule:: bottle :class:`SimpleTemplate` API ============================== .. autoclass:: SimpleTemplate :members: python-bottle-0.13.2/docs/tutorial.rst000077500000000000000000001242051470367422500177530ustar00rootroot00000000000000.. currentmodule:: bottle =============== User's Guide =============== This guide introduces you to the concepts and features of the Bottle web framework and covers basic and advanced topics alike. You can read it from start to end, or use it as a reference later on. The automatically generated :doc:`api` may be interesting for you, too. It covers more details, but explains less than this tutorial. Solutions for the most common questions can be found in our :doc:`faq` collection or on the :doc:`faq` page. If you need any help, join our `mailing list `_ or visit us in our `IRC channel `_. .. _installation: Installation ============================================================================== Bottle does not depend on any external libraries. You can just download `bottle.py `_ into your project directory and start coding: .. code-block:: bash $ wget https://bottlepy.org/bottle.py This will get you the latest development snapshot that includes all the new features. If you prefer a more stable environment, you should stick with the stable releases. These are available on `PyPI `_ and can be installed via :command:`pip` (recommended) or your package manager: .. code-block:: bash $ pip install --user bottle # better use a venv, see below $ sudo apt-get install python-bottle # works for debian, ubuntu, ... It is usually a better idea to create a `virtualenv `_ per project and use that to install packages: .. code-block:: bash $ python3 -m venv venv # Create virtual environment $ source venv/bin/activate # Change default python to virtual one (venv)$ pip install -U bottle # Install bottle to virtual environment Hello World! ============================================================================== This tutorial assumes you have Bottle either :ref:`installed ` or copied into your project directory. Let's start with a very basic "Hello World" example:: from bottle import route, run @route('/hello') def hello(): return "Hello World!" if __name__ == '__main__': run(host='localhost', port=8080, debug=True) This is it. Run this script, visit http://localhost:8080/hello and you will see "Hello World!" in your browser. Here is how it works: The :func:`route` decorator binds a piece of code to an URL path. In this case, we link the ``/hello`` path to the ``hello()`` function. This is called a `route` (hence the decorator name) and is the most important concept of this framework. You can define as many routes as you want. Whenever a browser requests a URL, the associated function is called and the return value is sent back to the browser. It's as simple as that. The :func:`run` call in the last line starts a built-in development server. It runs on ``localhost`` port ``8080`` and serves requests until you hit :kbd:`Control-c`. You can switch the server backend later (see :doc:`/deployment`), but for now a development server is all we need. It requires no setup at all and is an incredibly painless way to get your application up and running for local tests. :ref:`Debug Mode ` is very helpful during early development, but should be switched off for public applications. Keep that in mind. This is just a demonstration of the basic concept of how applications are built with Bottle. Continue reading and you'll see what else is possible. .. _tutorial-default: The Application Object ============================================================================== For the sake of simplicity, most examples in this tutorial use a module-level :func:`route` and other decorators to define routes. Those refer to a global "default application", an instance of :class:`Bottle` that is automatically created the first time you call :func:`route` or its friends. If you prefer a more explicit approach and don't mind the extra typing, you can create a separate application object and use that instead of the global one:: from bottle import Bottle, run app = Bottle() @app.route('/hello') def hello(): return "Hello World!" if __name__ == '__main__': app.run(host='localhost', port=8080) The object-oriented approach is further described in the :ref:`default-app` section. Just keep in mind that you have a choice. .. _tutorial-debugging: Debug Mode ============================================================================== During early development, the debug mode can be very helpful. :: # Enable debug at runtime bottle.debug(True) # or during startup run(..., debug=True) In this mode, Bottle is much more verbose and provides helpful debugging information whenever an error occurs. It also disables some optimisations that might get in your way and adds some checks that warn you about possible misconfiguration. Here is an incomplete list of things that change in debug mode: * The default error page shows a traceback. * Templates are not cached. * Plugins are applied immediately. Just make sure not to use the debug mode on a production server. Auto Reloading -------------- Tired of restarting the server every time you change youzr code? The auto reloader can do this for you. Every time you edit a module file, the reloader restarts the server process and loads the newest version of your code. :: run(..., debug=True, reloader=True) How it works: the main process will not start a server, but spawn a new child process using the same command line arguments used to start the main process. All module-level code is executed at least twice! Be careful. The child process will have ``os.environ['BOTTLE_CHILD']`` set to ``True`` and start as a normal non-reloading app server. As soon as any of the loaded modules changes, the child process terminates and is re-spawned by the main process. Changes in template files will not trigger a reload. Please use debug mode to deactivate template caching. .. _tutorial-cli: Command Line Interface ============================================================================== Bottle is not only a module, but also a command line executable that can be used to start your app instead of calling :func:`run` programmatically. If you installed bottle via `pip` or similar tools, there will also be a handy `bottle` command on your path. Try one of the following: .. code-block:: console bottle --help python3 -m bottle --help ./path/to/bottle.py --help Here is a quick example: .. code-block:: console $ bottle --debug --reload mymodule Bottle v0.13-dev server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit. .. versionchanged:: 0.13 The executable script installed into (virtual) environments was named ``bottle.py``, which could result in circular imports. The old name is now deprecated and the new executable ist named just ``bottle``. .. _tutorial-routing: Request Routing ============================================================================== In the last chapter we built a very simple web application with only a single route. Here is the routing part of the "Hello World" example again:: @route('/hello') def hello(): return "Hello World!" The :func:`route` decorator links an URL path to a callback function, and adds a new route to the :ref:`default application `. An application with just one route is kind of boring, though. Let's add some more (don't forget ``from bottle import template``):: @route('/') @route('/hello/') def greet(name='Stranger'): return template('Hello {{name}}, how are you?', name=name) This example demonstrates two things: You can bind more than one route to a single callback, and you can add wildcards to URLs and access them via keyword arguments. .. _tutorial-dynamic-routes: Dynamic Routes ------------------------------------------------------------------------------- Routes that contain wildcards are called `dynamic routes` (as opposed to `static routes`) and match more than one URL at the same time. A simple wildcard consists of a name enclosed in angle brackets (e.g. ````) and accepts one or more characters up to the next slash (``/``). For example, the route ``/hello/`` accepts requests for ``/hello/alice`` as well as ``/hello/bob``, but not for ``/hello``, ``/hello/`` or ``/hello/mr/smith``. Each wildcard passes the covered part of the URL as a keyword argument to the request callback. You can use them right away and implement RESTful, nice-looking and meaningful URLs with ease. Here are some other examples along with the URLs they'd match:: @route('/wiki/') # matches /wiki/Learning_Python def show_wiki_page(pagename): ... @route('//') # matches /follow/defnull def user_api(action, user): ... Filters can be used to define more specific wildcards, and/or transform the covered part of the URL before it is passed to the callback. A filtered wildcard is declared as ```` or ````. The syntax for the optional config part depends on the filter used. The following filters are implemented by default and more may be added: * **:int** matches (signed) digits only and converts the value to integer. * **:float** similar to :int but for decimal numbers. * **:path** matches all characters including the slash character in a non-greedy way and can be used to match more than one path segment. * **:re** allows you to specify a custom regular expression in the config field. The matched value is not modified. Let's have a look at some practical examples:: @route('/object/') def callback(id): assert isinstance(id, int) @route('/show/') def callback(name): assert name.isalpha() @route('/static/') def callback(path): return static_file(path, ...) You can add your own filters as well. See :doc:`routing` for details. HTTP Request Methods ------------------------------------------------------------------------------ The HTTP protocol defines several `request methods `_ (sometimes referred to as "verbs") for different tasks. GET is the default for all routes with no other method specified. These routes will match GET requests only. To handle other methods such as POST, PUT, DELETE or PATCH, add a ``method`` keyword argument to the :func:`route` decorator or use one of the five alternative decorators: :func:`get`, :func:`post`, :func:`put`, :func:`delete` or :func:`patch`. The POST method is commonly used for HTML form submission. This example shows how to handle a login form using POST:: from bottle import get, post, request # or route @get('/login') # or @route('/login') def login(): return ''' Username: Password: ''' @post('/login') # or @route('/login', method='POST') def do_login(): username = request.forms.username password = request.forms.password if check_login(username, password): return "

Your login information was correct.

" else: return "

Login failed.

" In this example the ``/login`` URL is linked to two distinct callbacks, one for GET requests and another for POST requests. The first one displays a HTML form to the user. The second callback is invoked on a form submission and checks the login credentials the user entered into the form. The use of :attr:`BaseRequest.forms` is further described in the :ref:`tutorial-request` section. .. rubric:: Special Methods: HEAD and ANY The HEAD method is used to ask for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information about a resource without having to download the entire document. Bottle handles these requests automatically by falling back to the corresponding GET route and cutting off the request body, if present. You don't have to specify any HEAD routes yourself. Additionally, the non-standard ANY method works as a low priority fallback: Routes that listen to ANY will match requests regardless of their HTTP method but only if no other more specific route is defined. This is helpful for *proxy-routes* that redirect requests to more specific sub-applications. To sum it up: HEAD requests fall back to GET routes and all requests fall back to ANY routes, but only if there is no matching route for the original request method. It's as simple as that. .. _tutorial-static-files: Serving Assets ================================================================================== Static files or assets such as images or CSS files are not served automatically. You have to add a route and a callback to control which files get served and where to find them. Bottle comes with a handy :func:`static_file` function that does most of the work and serves files in a safe and convenient way:: from bottle import static_file @route('/static/') def server_static(filepath): return static_file(filepath, root='/path/to/your/static/files') Note that we used the ``:path`` route filter here to allow slash characters in ``filepath`` and serve files from sub-directories, too. The :func:`static_file` helper function has a lot of benefits compared to handling files manually. Most importantly it prevents `directory traversal attacks `_ (e.g. ``GET /static/../../../../etc/secrets``) by restricting file access to the specified ``root`` directory. Make sure to use an absolut path for ``root``, though. Relative paths (staring with ``./``) are resolved against the current work directory which may not always be the same as your project directory. The :func:`static_file` function returns :class:`HTTPResponse` or :class:`HTTPError`, which can be raied as an exception if you need to. .. rubric:: File downloads Most browsers try to open downloaded files with the associated application if the MIME type is known (e.g. PDF files). If this is not what you want, you can force a download dialog and even suggest a filename to the user:: @route('/download/') def download(filename): return static_file(filename, root='/path/to/static/files', download=f"download-{filename}") If the ``download`` parameter is just ``True``, the original filename is used. .. _tutorial-output: Generating content ============================================================================== We already learned that route callbacks can return strings as content, but there is more: Bottle supports a bunch of other data types and even adds ``Content-Length`` and other headers if possible, so you don't have to. Here is a list of data types you may return from your application callbacks and a short description of how these are handled by the framework: Dictionaries Python dictionaries (or subclasses thereof) are automatically transformed into JSON strings and returned to the browser with the ``Content-Type`` header set to ``application/json``. This makes it easy to implement JSON-based APIs and is actually implemented by the :class:`JsonPlugin` which is applied to all routes automatically. You can configure and disable JSON handling if you need to. Empty Strings, ``False``, ``None`` or other non-true values: These will produce an empty response. Lists of strings Lists of byte or unicode strings are joined into a single string then processed as usual (see blow). Unicode strings Unicode strings are automatically encoded with the codec specified in the ``Content-Type`` header (``utf8`` by default) and then processed as byte strings (see below). Byte strings Raw byte strings are written to the response as-is. Instances of :exc:`HTTPError` or :exc:`HTTPResponse` Raising or returning an instance of :exc:`HTTPResponse` will overwrite any changes made to the global :data:`request` object and then continue as usual. In case of an :exc:`HTTPError`, error handler are applied first. See :ref:`tutorial-errorhandling` for details. Files or file-like objects Anything that has a ``.read()`` method is treated as a file or file-like object and passed to the ``wsgi.file_wrapper`` callable defined by the WSGI server framework. Some WSGI server implementations can make use of optimized system calls (e.g. sendfile) to transmit files more efficiently. In other cases this just iterates over chunks that fit into memory. Optional headers such as ``Content-Length`` or ``Content-Type`` are *not* set automatically. For security and other reasons you should always prefer :func:`static_file` over returning raw files, though. See :ref:`tutorial-static-files` for details. Iterables or generators You can ``yield`` either byte- or unicode strings (not both) from your route callback and bottle will write those to the response in a streaming fashion. The ``Content-Length`` header is not set in this case, because the final response size is not known. Nested iterables are not supported, sorry. Please note that HTTP status code and headers are sent to the browser as soon as the iterable yields its first non-empty value. Changing these later has no effect. If the first element of the iterable is either :exc:`HTTPError` or :exc:`HTTPResponse`, the rest of the iterator is ignored. The ordering of this list is significant. You may for example return a subclass of :class:`str` with a ``read()`` method. It is still treated as a string instead of a file, because strings are handled first. .. rubric:: Changing the Default Encoding Bottle uses the `charset` parameter of the ``Content-Type`` header to decide how to encode unicode strings. This header defaults to ``text/html; charset=UTF8`` and can be changed using the :attr:`BaseResponse.content_type` attribute or by setting the :attr:`BaseResponse.charset` attribute directly. (The :class:`Response` object is described in the section :ref:`tutorial-response`.) :: from bottle import response @route('/iso') def get_iso(): response.charset = 'ISO-8859-15' return u'This will be sent with ISO-8859-15 encoding.' @route('/latin9') def get_latin(): response.content_type = 'text/html; charset=latin9' return u'ISO-8859-15 is also known as latin9.' In some rare cases the Python encoding names differ from the names supported by the HTTP specification. Then, you have to do both: first set the :attr:`BaseResponse.content_type` header (which is sent to the client unchanged) and then set the :attr:`BaseResponse.charset` attribute (which is used to encode unicode). .. _tutorial-errorhandling: Error handling ============================================== If anything goes wrong, Bottle displays an informative but fairly plain error page. It contains a stacktrace if :func:`debug` mode is on. You can override the default error page and register an error handler for a specific HTTP status code with the :func:`error` decorator:: from bottle import error @error(404) def error404(error): return 'Nothing here, sorry' From now on, ``404`` (File not found) errors will display a custom error page to the user. The only parameter passed to the error-handler is an instance of :exc:`HTTPError`. Apart from that, an error-handler is quite similar to a regular request callback. You can read from :data:`request`, write to :data:`response` and return any supported data-type except for :exc:`HTTPError` instances. Error handlers are used only if your application returns or raises an :exc:`HTTPError` exception (:func:`abort` does just that). Setting :attr:`BaseRequest.status` to an error code or returning :exc:`HTTPResponse` won't trigger error handlers. .. rubric:: Triggering errors with :func:`abort` The :func:`abort` function is a shortcut for triggering HTTP errors. :: from bottle import route, abort @route('/restricted') def restricted(): abort(401, "Sorry, access denied.") You do not need to return anything when using :func:`abort`. It raises an :exc:`HTTPError` exception. .. rubric:: Other Exceptions All exceptions other than :exc:`HTTPResponse` or :exc:`HTTPError` will result in a ``500 Internal Server Error`` response, so they won't crash your WSGI server. You can turn off this behavior to handle exceptions in your middleware by setting ``bottle.app().catchall`` to ``False``. .. _tutorial-response: The :data:`response` Object -------------------------------------------------------------------------------- Response metadata such as the HTTP status code, response headers and cookies are stored in an object called :data:`response` up to the point where they are transmitted to the browser. You can manipulate these metadata directly or use the predefined helper methods to do so. The full API and feature list is described in the API section (see :class:`BaseResponse`), but the most common use cases and features are covered here, too. .. rubric:: Status Code The HTTP status code controls the behavior of the browser and defaults to ``200 OK``. In most scenarios you won't need to set the :attr:`BaseResponse.status` attribute manually, but use the :func:`abort` helper or return an :exc:`HTTPResponse` instance with the appropriate status code. Any integer is allowed, but codes other than the ones defined by the `HTTP specification `_ will only confuse the browser and break standards. .. rubric:: Response Headers Response headers such as ``Cache-Control`` or ``Location`` are defined via :meth:`BaseResponse.set_header`. This method takes two parameters, a header name and a value. The name part is case-insensitive:: @route('/wiki/') def wiki(page): response.set_header('Content-Language', 'en') ... Most headers are unique, meaning that only one header per name is send to the client. Some special headers however are allowed to appear more than once in a response. To add an additional header, use :meth:`BaseResponse.add_header` instead of :meth:`BaseResponse.set_header`:: response.set_header('Set-Cookie', 'name=value') response.add_header('Set-Cookie', 'name=value2') Please note that this is just an example. If you want to work with cookies, read :ref:`ahead `. .. rubric:: Redirects To redirect a client to a different URL, you can send a ``303 See Other`` response with the ``Location`` header set to the new URL. :func:`redirect` does that for you:: from bottle import route, redirect @route('/wrong/url') def wrong(): redirect("/right/url") .. _tutorial-cookies: Cookies ------------------------------------------------------------------------------- A cookie is a named piece of text stored in the user's browser profile. You can access previously defined cookies via :meth:`BaseRequest.get_cookie` and set new cookies with :meth:`BaseResponse.set_cookie`:: @route('/hello') def hello_again(): if request.get_cookie("visited"): return "Welcome back! Nice to see you again" else: response.set_cookie("visited", "yes") return "Hello there! Nice to meet you" The :meth:`BaseResponse.set_cookie` method accepts a number of additional keyword arguments that control the cookies lifetime and behavior. Some of the most common settings are described here: * **max_age:** Maximum age in seconds. (default: ``None``) * **expires:** A datetime object or UNIX timestamp. (default: ``None``) * **domain:** The domain that is allowed to read the cookie. (default: current domain) * **path:** Limit the cookie to a given path (default: ``/``) * **secure:** Limit the cookie to HTTPS connections (default: off). * **httponly:** Prevent client-side javascript to read this cookie (default: off, requires Python 2.7 or newer). * **samesite:** Disables third-party use for a cookie. Allowed attributes: `lax` and `strict`. In strict mode the cookie will never be sent. In lax mode the cookie is only sent with a top-level GET request. If neither `expires` nor `max_age` is set, the cookie expires at the end of the browser session or as soon as the browser window is closed. There are some other gotchas you should consider when using cookies: * Cookies are limited to 4 KB of text in most browsers. * Some users configure their browsers to not accept cookies at all. Most search engines ignore cookies too. Make sure that your application still works without cookies. * Cookies are stored at client side and are not encrypted in any way. Whatever you store in a cookie, the user can read it. Worse than that, an attacker might be able to steal a user's cookies through `XSS `_ vulnerabilities on your side. Some viruses are known to read the browser cookies, too. Thus, never store confidential information in cookies. * Cookies are easily forged by malicious clients. Do not trust cookies. .. _tutorial-signed-cookies: .. rubric:: Signed Cookies As mentioned above, cookies are easily forged by malicious clients. Bottle can cryptographically sign your cookies to prevent this kind of manipulation. All you have to do is to provide a signature key via the `secret` keyword argument whenever you read or set a cookie and keep that key a secret. As a result, :meth:`BaseRequest.get_cookie` will return ``None`` if the cookie is not signed or the signature keys don't match:: @route('/login') def do_login(): username = request.forms.get('username') password = request.forms.get('password') if check_login(username, password): response.set_cookie("account", username, secret='some-secret-key') return template("

Welcome {{name}}! You are now logged in.

", name=username) else: return "

Login failed.

" @route('/restricted') def restricted_area(): username = request.get_cookie("account", secret='some-secret-key') if username: return template("Hello {{name}}. Welcome back.", name=username) else: return "You are not logged in. Access denied." In addition, Bottle automatically pickles and unpickles any data stored to signed cookies. This allows you to store any pickle-able object (not only strings) to cookies, as long as the pickled data does not exceed the 4 KB limit. .. warning:: Signed cookies are not encrypted (the client can still see the content) and not copy-protected (the client can restore an old cookie). The main intention is to make pickling and unpickling safe and prevent manipulation, not to store secret information at client side. .. _tutorial-request: Request Data ============================================================================== Cookies, HTTP header, form data and other request data is available through the global :data:`request` object. This special object always refers to the *current* request, even in multi-threaded environments where multiple client connections are handled at the same time:: from bottle import request, route, template @route('/hello') def hello(): name = request.cookies.username or 'Guest' return template('Hello {{name}}', name=name) The :data:`request` object is a subclass of :class:`BaseRequest` and has a very rich API to access data. We only cover the most commonly used features here, but it should be enough to get started. HTTP Headers -------------------------------------------------------------------------------- All HTTP headers sent by the client (e.g. ``Referer``, ``Agent`` or ``Accept-Language``) are stored in a :class:`WSGIHeaderDict` and accessible through the :attr:`BaseRequest.headers` attribute. A :class:`WSGIHeaderDict` is basically a dictionary with case-insensitive keys:: from bottle import route, request @route('/is_ajax') def is_ajax(): if request.headers.get('X-Requested-With') == 'XMLHttpRequest': return 'This is an AJAX request' else: return 'This is a normal request' Cookies -------------------------------------------------------------------------------- Cookies are small pieces of text stored in the clients browser and sent back to the server with each request. They are useful to keep some state around for more than one request (HTTP itself is stateless), but should not be used for security related stuff. They can be easily forged by the client. All cookies sent by the client are available through :attr:`BaseRequest.cookies` (a :class:`FormsDict`). This example shows a simple cookie-based view counter:: from bottle import route, request, response @route('/counter') def counter(): count = int( request.cookies.get('counter', '0') ) count += 1 response.set_cookie('counter', str(count)) return 'You visited this page %d times' % count The :meth:`BaseRequest.get_cookie` method is a different way do access cookies. It supports decoding :ref:`signed cookies ` as described in a separate section. Query parameters, Forms and File uploads --------------------------------------------- Query and form data is parsed on demand and accessible via :data:`request` properties and methods. Some of those properties combine values from different sources for easier access. Have a look at the following table for a quick overview. ============================== ============================================================== Property Data source ============================== ============================================================== :attr:`BaseRequest.GET` Query parameters :attr:`BaseRequest.query` Alias for :attr:`BaseRequest.GET` :attr:`BaseRequest.POST` Form fields and file uploads combined :attr:`BaseRequest.forms` Form fields :attr:`BaseRequest.files` File uploads or very large form fields :attr:`BaseRequest.params` Query parameters and form fields combined ============================== ============================================================== .. rubric:: Introducing :class:`FormsDict` Bottle uses a special type of dictionary to store those parameters. :class:`FormsDict` behaves like a normal dictionary, but has some additional features to make your life easier. First of all, :class:`FormsDict` is a subclass of :class:`MultiDict` and can store more than one value per key. The standard dictionary access methods will only return the first of many values, but the :meth:`MultiDict.getall` method returns a (possibly empty) list of all values for a specific key:: for choice in request.forms.getall('multiple_choice'): do_something(choice) To simplify dealing with lots of unreliable user input, :class:`FormsDict` exposes all its values as attributes, but with a twist: These virtual attributes always return properly encoded unicode strings, even if the value is missing or character decoding fails. They never return ``None`` or throw an exception, but return an empty string instead:: name = request.query.name # may be an empty string .. rubric:: A word on unicode and character encodings HTTP is a byte-based wire protocol. The server has to decode byte strings somehow before they are passed to the application. To be on the safe side, WSGI suggests ISO-8859-1 (aka latin1), a reversible single-byte codec that can be re-encoded with a different encoding later. Bottle does that for :meth:`FormsDict.getunicode` and attribute access, but not for :meth:`FormsDict.get` or item-access. These return the unchanged values as provided by the server implementation, which is probably not what you want. :: >>> request.query['city'] 'Göttingen' # An utf8 string provisionally decoded as ISO-8859-1 by the server >>> request.query.city 'Göttingen' # The same string correctly re-encoded as utf8 by bottle If you need the whole dictionary with correctly decoded values (e.g. for WTForms), you can call :meth:`FormsDict.decode` to get a fully re-encoded copy. Query Parameters -------------------------------------------------------------------------------- The query string (as in ``/forum?id=1&page=5``) is commonly used to transmit a small number of key/value pairs to the server. You can use the :attr:`BaseRequest.query` attribute (a :class:`FormsDict`) to access these values and the :attr:`BaseRequest.query_string` attribute to get the whole string. :: from bottle import route, request, response, template @route('/forum') def display_forum(): forum_id = request.query.id page = request.query.page or '1' return template('Forum ID: {{id}} (page {{page}})', id=forum_id, page=page) HTML `
` Handling ---------------------- Let us start from the beginning. In HTML, a typical ```` looks something like this: .. code-block:: html Username: Password:
The ``action`` attribute specifies the URL that will receive the form data. ``method`` defines the HTTP method to use (``GET`` or ``POST``). With ``method="get"`` the form values are appended to the URL and available through :attr:`BaseRequest.query` as described above. This is sometimes considered insecure and has other limitations, so we use ``method="post"`` here. If in doubt, use ``POST`` forms. Form fields transmitted via ``POST`` are stored in :attr:`BaseRequest.forms` as a :class:`FormsDict`. The server side code may look like this:: from bottle import route, request @route('/login') def login(): return '''
Username: Password:
''' @route('/login', method='POST') def do_login(): username = request.forms.username password = request.forms.password if check_login(username, password): return "

Your login information was correct.

" else: return "

Login failed.

" File Uploads ------------ To support file uploads, we have to change the ``
`` tag a bit. First, we tell the browser to encode the form data in a different way by adding an ``enctype="multipart/form-data"`` attribute to the ```` tag. Then, we add ```` tags to allow the user to select a file. Here is an example: .. code-block:: html Category: Select a file:
Bottle stores file uploads in :attr:`BaseRequest.files` as :class:`FileUpload` instances, along with some metadata about the upload. Let us assume you just want to save the file to disk:: @route('/upload', method='POST') def do_upload(): category = request.forms.category upload = request.files.get('upload') name, ext = os.path.splitext(upload.filename) if ext not in ('.png','.jpg','.jpeg'): return 'File extension not allowed.' save_path = get_save_path_for_category(category) upload.save(save_path) # appends upload.filename automatically return 'OK' :attr:`FileUpload.filename` contains the name of the file on the clients file system, but is cleaned up and normalized to prevent bugs caused by unsupported characters or path segments in the filename. If you need the unmodified name as sent by the client, have a look at :attr:`FileUpload.raw_filename`. The :attr:`FileUpload.save` method is highly recommended if you want to store the file to disk. It prevents some common errors (e.g. it does not overwrite existing files unless you tell it to) and stores the file in a memory efficient way. You can access the file object directly via :attr:`FileUpload.file`. Just be careful. JSON -------------------- For JavaScript and REST APIs it is very common to send ``application/json`` to the server instead of from data. The :attr:`BaseRequest.json` attribute contains the parsed data structure if available, or ``None`` for empty requests or those that did not contain ``application/json`` data. Parsing errors trigger an appropiate :exc:`HTTPError`. Raw Request Data -------------------- You can access the raw body data as a file-like object via :attr:`BaseRequest.body`. This is a :class:`io.BytesIO` buffer or a temporary file depending on the content length and :attr:`BaseRequest.MEMFILE_MAX` setting. In both cases the body is completely buffered before you can access the attribute. If you expect huge amounts of data and want to get direct unbuffered access to the stream, have a look at ``request['wsgi.input']``. WSGI Environment -------------------------------------------------------------------------------- Each :class:`BaseRequest` instance wraps a WSGI environment dictionary which is stored in :attr:`BaseRequest.environ`. Most of the interesting information is also exposed through special methods or properties, but if you want to access the raw `WSGI environ `_ directly, you can do so:: @route('/my_ip') def show_ip(): ip = request.environ.get('REMOTE_ADDR') # or ip = request.get('REMOTE_ADDR') # or ip = request['REMOTE_ADDR'] return template("Your IP is: {{ip}}", ip=ip) .. _tutorial-templates: Templates ================================================================================ Bottle comes with a fast and powerful built-in template engine called :doc:`stpl`. To render a template you can use the :func:`template` function or the :func:`view` decorator. All you have to do is to provide the name of the template and the variables you want to pass to the template as keyword arguments. Here’s a simple example of how to render a template:: @route('/hello') @route('/hello/') def hello(name='World'): return template('hello_template', name=name) This will load the template file ``hello_template.tpl`` and render it with the ``name`` variable set. Bottle will look for templates in the ``./views/`` folder or any folder specified in the ``bottle.TEMPLATE_PATH`` list. The :func:`view` decorator allows you to return a dictionary with the template variables instead of calling :func:`template`:: @route('/hello') @route('/hello/') @view('hello_template') def hello(name='World'): return dict(name=name) .. rubric:: Syntax The template syntax is a very thin layer around the Python language. Its main purpose is to ensure correct indentation of blocks, so you can format your template without worrying about indentation. Follow the link for a full syntax description: :doc:`stpl` Here is an example template: .. code-block:: html+django %if name == 'World':

Hello {{name}}!

This is a test.

%else:

Hello {{name.title()}}!

How are you?

%end .. rubric:: Caching Templates are cached in memory after compilation. Modifications made to the template files will have no affect until you clear the template cache. Call ``bottle.TEMPLATES.clear()`` to do so. Caching is disabled in debug mode. .. _default-app: Structuring Applications ================================================================================ Bottle maintains a global stack of :class:`Bottle` instances and uses the top of the stack as a default for some of the module-level functions and decorators. The :func:`route` decorator or `run()` function for example are shortcuts for :meth:`Bottle.route` or :meth:`Bottle.run` on the default application:: @route('/') def hello(): return 'Hello World' if __name__ == '__main__': run() This is very convenient for small applications and saves you some typing, but also means that, as soon as your module is imported, routes are installed to the global default application. To avoid this kind of import side-effects, Bottle offers a second, more explicit way to build applications:: app = Bottle() @app.route('/') def hello(): return 'Hello World' app.run() Separating the application object improves re-usability a lot, too. Other developers can safely import the ``app`` object from your module and use :meth:`Bottle.mount` to merge applications together. .. versionadded:: 0.13 Starting with bottle-0.13 you can use :class:`Bottle` instances as context managers:: app = Bottle() with app: # Our application object is now the default # for all shortcut functions and decorators assert my_app is default_app() @route('/') def hello(): return 'Hello World' # Also useful to capture routes defined in other modules import some_package.more_routes .. _tutorial-glossary: Glossary ======== .. glossary:: callback Programmer code that is to be called when some external action happens. In the context of web frameworks, the mapping between URL paths and application code is often achieved by specifying a callback function for each URL. decorator A function returning another function, usually applied as a function transformation using the ``@decorator`` syntax. See `python documentation for function definition `_ for more about decorators. environ A structure where information about all documents under the root is saved, and used for cross-referencing. The environment is pickled after the parsing stage, so that successive runs only need to read and parse new and changed documents. handler function A function to handle some specific event or situation. In a web framework, the application is developed by attaching a handler function as callback for each specific URL comprising the application. source directory The directory which, including its subdirectories, contains all source files for one Sphinx project. python-bottle-0.13.2/docs/tutorial_app.rst000066400000000000000000001041521470367422500206070ustar00rootroot00000000000000.. _Bottle: http://bottlepy.org .. _Python: http://www.python.org .. _SQLite: http://www.sqlite.org .. _Windows: http://www.sqlite.org/download.html .. _PySQLite: http://pypi.python.org/pypi/pysqlite/ .. _`decorator statement`: http://docs.python.org/glossary.html#term-decorator .. _`Python DB API`: http://www.python.org/dev/peps/pep-0249/ .. _`WSGI reference Server`: http://docs.python.org/library/wsgiref.html#module-wsgiref.simple_server .. _Cherrypy: https://cherrypy.dev/ .. _Flup: https://www.saddi.com/software/flup/ .. _Paste: https://pythonpaste.readthedocs.io .. _Apache: http://www.apache.org .. _`Bottle documentation`: http://bottlepy.org/docs/dev/tutorial.html .. _`mod_wsgi`: http://code.google.com/p/modwsgi/ .. _`json`: http://www.json.org ================= Todo-List Example ================= .. note:: This tutorial is outdated, better start here: :doc:`tutorial`. If you want to help and improve this tutorial, see :doc:`development`. This tutorial should give a brief introduction to the Bottle_ WSGI Framework. The main goal is to be able, after reading through this tutorial, to create a project using Bottle. Within this document, not all abilities will be shown, but at least the main and important ones like routing, utilizing the Bottle template abilities to format output and handling GET / POST parameters. To understand the content here, it is not necessary to have a basic knowledge of WSGI, as Bottle tries to keep WSGI away from the user anyway. You should have a fair understanding of the Python_ programming language. Furthermore, the example used in the tutorial retrieves and stores data in a SQL database, so a basic idea about SQL helps, but is not a must to understand the concepts of Bottle. Right here, SQLite_ is used. The output of Bottle sent to the browser is formatted in some examples by the help of HTML. Thus, a basic idea about the common HTML tags does help as well. For the sake of introducing Bottle, the Python code "in between" is kept short, in order to keep the focus. Also all code within the tutorial is working fine, but you may not necessarily use it "in the wild", e.g. on a public web server. In order to do so, you may add e.g. more error handling, protect the database with a password, test and escape the input etc. .. contents:: Table of Contents Goals =========== At the end of this tutorial, we will have a simple, web-based ToDo list. The list contains a text (with max 100 characters) and a status (0 for closed, 1 for open) for each item. Through the web-based user interface, open items can be view and edited and new items can be added. During development, all pages will be available on ``localhost`` only, but later on it will be shown how to adapt the application for a "real" server, including how to use with Apache's mod_wsgi. Bottle will do the routing and format the output, with the help of templates. The items of the list will be stored inside a SQLite database. Reading and writing the database will be done by Python code. We will end up with an application with the following pages and functionality: * start page ``http://localhost:8080/todo`` * adding new items to the list: ``http://localhost:8080/new`` * page for editing items: ``http://localhost:8080/edit/`` * catching errors Before We Start... ==================== .. rubric:: Install Bottle Assuming that you have a fairly new installation of Python (version 2.5 or higher), you only need to install Bottle in addition to that. Bottle has no other dependencies than Python itself. You can either manually install Bottle or use Python's easy_install: ``easy_install bottle`` .. rubric:: Further Software Necessities As we use SQLite3 as a database, make sure it is installed. On Linux systems, most distributions have SQLite3 installed by default. SQLite is available for Windows and MacOS X as well and the `sqlite3` module is part of the python standard library. .. rubric:: Create An SQL Database First, we need to create the database we use later on. To do so, save the following script in your project directory and run it with python. You can use the interactive interpreter too:: import sqlite3 conn = sqlite3.connect('todo.db') # Warning: This file is created in the current directory conn.execute("CREATE TABLE todo (id INTEGER PRIMARY KEY, task char(100) NOT NULL, status bool NOT NULL)") conn.execute("INSERT INTO todo (task,status) VALUES ('Read A-byte-of-python to get a good introduction into Python',0)") conn.execute("INSERT INTO todo (task,status) VALUES ('Visit the Python website',1)") conn.execute("INSERT INTO todo (task,status) VALUES ('Test various editors for and check the syntax highlighting',1)") conn.execute("INSERT INTO todo (task,status) VALUES ('Choose your favorite WSGI-Framework',0)") conn.commit() This generates a database-file `todo.db` with tables called ``todo`` and three columns ``id``, ``task``, and ``status``. ``id`` is a unique id for each row, which is used later on to reference the rows. The column ``task`` holds the text which describes the task, it can be max 100 characters long. Finally, the column ``status`` is used to mark a task as open (value 1) or closed (value 0). Using Bottle for a Web-Based ToDo List ================================================ Now it is time to introduce Bottle in order to create a web-based application. But first, we need to look into a basic concept of Bottle: routes. .. rubric:: Understanding routes Basically, each page visible in the browser is dynamically generated when the page address is called. Thus, there is no static content. That is exactly what is called a "route" within Bottle: a certain address on the server. So, for example, when the page ``http://localhost:8080/todo`` is called from the browser, Bottle "grabs" the call and checks if there is any (Python) function defined for the route "todo". If so, Bottle will execute the corresponding Python code and return its result. .. rubric:: First Step - Showing All Open Items So, after understanding the concept of routes, let's create the first one. The goal is to see all open items from the ToDo list:: import sqlite3 from bottle import route, run @route('/todo') def todo_list(): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT id, task FROM todo WHERE status LIKE '1'") result = c.fetchall() return str(result) run() Save the code a ``todo.py``, preferably in the same directory as the file ``todo.db``. Otherwise, you need to add the path to ``todo.db`` in the ``sqlite3.connect()`` statement. Let's have a look what we just did: We imported the necessary module ``sqlite3`` to access to SQLite database and from Bottle we imported ``route`` and ``run``. The ``run()`` statement simply starts the web server included in Bottle. By default, the web server serves the pages on localhost and port 8080. Furthermore, we imported ``route``, which is the function responsible for Bottle's routing. As you can see, we defined one function, ``todo_list()``, with a few lines of code reading from the database. The important point is the `decorator statement`_ ``@route('/todo')`` right before the ``def todo_list()`` statement. By doing this, we bind this function to the route ``/todo``, so every time the browsers calls ``http://localhost:8080/todo``, Bottle returns the result of the function ``todo_list()``. That is how routing within bottle works. Actually you can bind more than one route to a function. So the following code:: @route('/todo') @route('/my_todo_list') def todo_list(): ... will work fine, too. What will not work is to bind one route to more than one function. What you will see in the browser is what is returned, thus the value given by the ``return`` statement. In this example, we need to convert ``result`` in to a string by ``str()``, as Bottle expects a string or a list of strings from the return statement. But here, the result of the database query is a list of tuples, which is the standard defined by the `Python DB API`_. Now, after understanding the little script above, it is time to execute it and watch the result yourself. Remember that on Linux- / Unix-based systems the file ``todo.py`` needs to be executable first. Then, just run ``python todo.py`` and call the page ``http://localhost:8080/todo`` in your browser. In case you made no mistake writing the script, the output should look like this:: [(2, u'Visit the Python website'), (3, u'Test various editors for and check the syntax highlighting')] If so - congratulations! You are now a successful user of Bottle. In case it did not work and you need to make some changes to the script, remember to stop Bottle serving the page, otherwise the revised version will not be loaded. Actually, the output is not really exciting nor nice to read. It is the raw result returned from the SQL query. So, in the next step we format the output in a nicer way. But before we do that, we make our life easier. .. rubric:: Debugging and Auto-Reload Maybe you already noticed that Bottle sends a short error message to the browser in case something within the script is wrong, e.g. the connection to the database is not working. For debugging purposes it is quite helpful to get more details. This can be easily achieved by adding the following statement to the script:: from bottle import run, route, debug ... #add this at the very end: debug(True) run() By enabling "debug", you will get a full stacktrace of the Python interpreter, which usually contains useful information for finding bugs. Furthermore, templates (see below) are not cached, thus changes to templates will take effect without stopping the server. .. warning:: That ``debug(True)`` is supposed to be used for development only, it should *not* be used in production environments. Another quite nice feature is auto-reloading, which is enabled by modifying the ``run()`` statement to :: run(reloader=True) This will automatically detect changes to the script and reload the new version once it is called again, without the need to stop and start the server. Again, the feature is mainly supposed to be used while developing, not on production systems. .. rubric:: Bottle Template To Format The Output Now let's have a look at casting the output of the script into a proper format. Actually Bottle expects to receive a string or a list of strings from a function and returns them by the help of the built-in server to the browser. Bottle does not bother about the content of the string itself, so it can be text formatted with HTML markup, too. Bottle brings its own easy-to-use template engine with it. Templates are stored as separate files having a ``.tpl`` extension. The template can be called then from within a function. Templates can contain any type of text (which will be most likely HTML-markup mixed with Python statements). Furthermore, templates can take arguments, e.g. the result set of a database query, which will be then formatted nicely within the template. Right here, we are going to cast the result of our query showing the open ToDo items into a simple table with two columns: the first column will contain the ID of the item, the second column the text. The result set is, as seen above, a list of tuples, each tuple contains one set of results. To include the template in our example, just add the following lines:: from bottle import route, run, debug, template ... result = c.fetchall() c.close() output = template('make_table', rows=result) return output ... So we do here two things: first, we import ``template`` from Bottle in order to be able to use templates. Second, we assign the output of the template ``make_table`` to the variable ``output``, which is then returned. In addition to calling the template, we assign ``result``, which we received from the database query, to the variable ``rows``, which is later on used within the template. If necessary, you can assign more than one variable / value to a template. Templates always return a list of strings, thus there is no need to convert anything. We can save one line of code by writing ``return template('make_table', rows=result)``, which gives exactly the same result as above. Now it is time to write the corresponding template, which looks like this:: %#template to generate a HTML table from a list of tuples (or list of lists, or tuple of tuples or ...)

The open items are as follows:

%for row in rows: %for col in row: %end %end
{{col}}
Save the code as ``make_table.tpl`` in the same directory where ``todo.py`` is stored. Let's have a look at the code: every line starting with % is interpreted as Python code. Because it is effectively Python, only valid Python statements are allowed. The template will raise exceptions, just as any other Python code would. The other lines are plain HTML markup. As you can see, we use Python's ``for`` statement two times, in order to go through ``rows``. As seen above, ``rows`` is a variable which holds the result of the database query, so it is a list of tuples. The first ``for`` statement accesses the tuples within the list, the second one the items within the tuple, which are put each into a cell of the table. It is important that you close all ``for``, ``if``, ``while`` etc. statements with ``%end``, otherwise the output may not be what you expect. If you need to access a variable within a non-Python code line inside the template, you need to put it into double curly braces. This tells the template to insert the actual value of the variable right in place. Run the script again and look at the output. Still not really nice, but at least more readable than the list of tuples. You can spice-up the very simple HTML markup above, e.g. by using in-line styles to get a better looking output. .. rubric:: Using GET and POST Values As we can review all open items properly, we move to the next step, which is adding new items to the ToDo list. The new item should be received from a regular HTML-based form, which sends its data by the GET method. To do so, we first add a new route to our script and tell the route that it should get GET data:: from bottle import route, run, debug, template, request ... return template('make_table', rows=result) ... @route('/new', method='GET') def new_item(): new = request.GET.task.strip() conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("INSERT INTO todo (task,status) VALUES (?,?)", (new, 1)) new_id = c.lastrowid conn.commit() c.close() return '

The new task was inserted into the database, the ID is %s

' % new_id To access GET (or POST) data, we need to import ``request`` from Bottle. To assign the actual data to a variable, we use the statement ``request.GET.task.strip()`` statement, where ``task`` is the name of the GET data we want to access. That's all. If your GET data has more than one variable, multiple ``request.GET.get()`` statements can be used and assigned to other variables. The rest of this piece of code is just processing of the gained data: writing to the database, retrieve the corresponding id from the database and generate the output. But where do we get the GET data from? Well, we can use a static HTML page holding the form. Or, what we do right now, is to use a template which is output when the route ``/new`` is called without GET data. The code needs to be extended to:: ... @route('/new', method='GET') def new_item(): if request.GET.save: new = request.GET.task.strip() conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("INSERT INTO todo (task,status) VALUES (?,?)", (new,1)) new_id = c.lastrowid conn.commit() c.close() return '

The new task was inserted into the database, the ID is %s

' % new_id else: return template('new_task.tpl') ``new_task.tpl`` looks like this::

Add a new task to the ToDo list:

That's all. As you can see, the template is plain HTML this time. Now we are able to extend our to do list. By the way, if you prefer to use POST data: this works exactly the same way, just use ``request.POST.get()`` instead. .. rubric:: Editing Existing Items The last point to do is to enable editing of existing items. By using only the routes we know so far it is possible, but may be quite tricky. But Bottle knows something called "dynamic routes", which makes this task quite easy. The basic statement for a dynamic route looks like this:: @route('/myroute/') This tells Bottle to accept for ```` any string up to the next slash. Furthermore, the value of ``something`` will be passed to the function assigned to that route, so the data can be processed within the function, like this:: @route('/edit/', method='GET') def edit_item(no): if request.GET.save: edit = request.GET.task.strip() status = request.GET.status.strip() if status == 'open': status = 1 else: status = 0 conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("UPDATE todo SET task = ?, status = ? WHERE id LIKE ?", (edit, status, no)) conn.commit() return '

The item number %s was successfully updated

' % no else: conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (str(no),)) cur_data = c.fetchone() return template('edit_task', old=cur_data, no=no) It is basically pretty much the same what we already did above when adding new items, like using ``GET`` data etc. The main addition here is using the dynamic route ````, which here passes the number to the corresponding function. As you can see, ``no`` is integer ID and used within the function to access the right row of data within the database. The template ``edit_task.tpl`` called within the function looks like this:: %#template for editing a task %#the template expects to receive a value for "no" as well a "old", the text of the selected ToDo item

Edit the task with ID = {{no}}


Again, this template is a mix of Python statements and HTML, as already explained above. A last word on dynamic routes: you can even use a regular expression for a dynamic route, as demonstrated later. .. rubric:: Validating Dynamic Routes Using dynamic routes is fine, but for many cases it makes sense to validate the dynamic part of the route. For example, we expect an integer number in our route for editing above. But if a float, characters or so are received, the Python interpreter throws an exception, which is not what we want. For those cases, Bottle offers the ```` wildcard filter, which matches (signed) digits and converts the value to integer. In order to apply the wildcard filter, extend the code as follows:: from bottle import route, run, debug, template, request ... @route('/edit/', method='GET') def edit_item(no): ... Save the code and call the page again using incorrect value for ````, e.g. a float. You will receive not an exception, but a "404 Not Found" error. .. rubric:: Dynamic Routes Using Regular Expressions Bottle can also handle dynamic routes, where the "dynamic part" of the route can be a regular expression. So, just to demonstrate that, let's assume that all single items in our ToDo list should be accessible by their plain number, by a term like e.g. "item1". For obvious reasons, you do not want to create a route for every item. Furthermore, the simple dynamic routes do not work either, as part of the route, the term "item" is static. As said above, the solution is a regular expression:: @route('/item') def show_item(item): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (item,)) result = c.fetchall() c.close() if not result: return 'This item number does not exist!' else: return 'Task: %s' % result[0] The line ``@route(/item)`` starts like a normal route, but the third part of the wildcard is interpreted as a regular expression, which is the dynamic part of the route. So in this case, we want to match any digit between 0 and 9. The following function "show_item" just checks whether the given item is present in the database or not. In case it is present, the corresponding text of the task is returned. As you can see, only the regular expression part of the route is passed forward. Furthermore, it is always forwarded as a string, even if it is a plain integer number, like in this case. .. rubric:: Returning Static Files Sometimes it may become necessary to associate a route not to a Python function, but just return a static file. So if you have for example a help page for your application, you may want to return this page as plain HTML. This works as follows:: from bottle import route, run, debug, template, request, static_file @route('/help') def help(): return static_file('help.html', root='/path/to/file') At first, we need to import the ``static_file`` function from Bottle. As you can see, the ``return static_file`` statement replaces the ``return`` statement. It takes at least two arguments: the name of the file to be returned and the path to the file. Even if the file is in the same directory as your application, the path needs to be stated. But in this case, you can use ``'.'`` as a path, too. Bottle guesses the MIME-type of the file automatically, but in case you like to state it explicitly, add a third argument to ``static_file``, which would be here ``mimetype='text/html'``. ``static_file`` works with any type of route, including the dynamic ones. .. rubric:: Returning JSON Data There may be cases where you do not want your application to generate the output directly, but return data to be processed further on, e.g. by JavaScript. For those cases, Bottle offers the possibility to return JSON objects, which is sort of standard for exchanging data between web applications. Furthermore, JSON can be processed by many programming languages, including Python So, let's assume we want to return the data generated in the regular expression route example as a JSON object. The code looks like this:: @route('/json') def show_json(json): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (json,)) result = c.fetchall() c.close() if not result: return {'task': 'This item number does not exist!'} else: return {'task': result[0]} As you can, that is fairly simple: just return a regular Python dictionary and Bottle will convert it automatically into a JSON object prior to sending. So if you e.g. call "http://localhost/json1" Bottle should in this case return the JSON object ``{"task": ["Read A-byte-of-python to get a good introduction into Python"]}``. .. rubric:: Catching Errors The next step may is to catch the error with Bottle itself, to keep away any type of error message from the user of your application. To do that, Bottle has an "error-route", which can be a assigned to a HTML-error. In our case, we want to catch a 403 error. The code is as follows:: from bottle import error @error(403) def mistake(code): return 'The parameter you passed has the wrong format!' So, at first we need to import ``error`` from Bottle and define a route by ``error(403)``, which catches all "403 forbidden" errors. The function "mistake" is assigned to that. Please note that ``error()`` always passes the error-code to the function - even if you do not need it. Thus, the function always needs to accept one argument, otherwise it will not work. Again, you can assign more than one error-route to a function, or catch various errors with one function each. So this code:: @error(404) @error(403) def mistake(code): return 'There is something wrong!' works fine, the following one as well:: @error(403) def mistake403(code): return 'The parameter you passed has the wrong format!' @error(404) def mistake404(code): return 'Sorry, this page does not exist!' .. rubric:: Summary After going through all the sections above, you should have a brief understanding how the Bottle WSGI framework works. Furthermore you have all the knowledge necessary to use Bottle for your applications. The following chapter give a short introduction how to adapt Bottle for larger projects. Furthermore, we will show how to operate Bottle with web servers which perform better on a higher load / more web traffic than the one we used so far. Server Setup ================================ So far, we used the standard server used by Bottle, which is the `WSGI reference Server`_ shipped along with Python. Although this server is perfectly suitable for development purposes, it is not really suitable for larger applications. But before we have a look at the alternatives, let's have a look how to tweak the settings of the standard server first. .. rubric:: Running Bottle on a different port and IP As standard, Bottle serves the pages on the IP address 127.0.0.1, also known as ``localhost``, and on port ``8080``. To modify the setting is pretty simple, as additional parameters can be passed to Bottle's ``run()`` function to change the port and the address. To change the port, just add ``port=portnumber`` to the run command. So, for example:: run(port=80) would make Bottle listen to port 80. To change the IP address where Bottle is listening:: run(host='123.45.67.89') If needed, both parameters can be combined, like:: run(port=80, host='123.45.67.89') The ``port`` and ``host`` parameter can also be applied when Bottle is running with a different server, as shown in the following section. .. rubric:: Running Bottle with a different server As said above, the standard server is perfectly suitable for development, personal use or a small group of people only using your application based on Bottle. For larger tasks, the standard server may become a bottleneck, as it is single-threaded, thus it can only serve one request at a time. But Bottle has already various adapters to multi-threaded servers on board, which perform better on higher load. Bottle supports Cherrypy_, Flup_ and Paste_. If you want to run for example Bottle with the Paste server, use the following code:: from bottle import PasteServer ... run(server=PasteServer) This works exactly the same way with ``FlupServer``, ``CherryPyServer`` and ``FapwsServer``. .. rubric:: Running Bottle on Apache with mod_wsgi Maybe you already have an Apache_ or you want to run a Bottle-based application large scale - then it is time to think about Apache with mod_wsgi_. We assume that your Apache server is up and running and mod_wsgi is working fine as well. On a lot of Linux distributions, mod_wsgi can be easily installed via whatever package management system is in use. Bottle brings an adapter for mod_wsgi with it, so serving your application is an easy task. In the following example, we assume that you want to make your application "ToDo list" accessible through ``http://www.mypage.com/todo`` and your code, templates and SQLite database are stored in the path ``/var/www/todo``. When you run your application via mod_wsgi, it is imperative to remove the ``run()`` statement from your code, otherwise it won't work here. After that, create a file called ``adapter.wsgi`` with the following content:: import sys, os, bottle sys.path = ['/var/www/todo/'] + sys.path os.chdir(os.path.dirname(__file__)) import todo # This loads your application application = bottle.default_app() and save it in the same path, ``/var/www/todo``. Actually the name of the file can be anything, as long as the extension is ``.wsgi``. The name is only used to reference the file from your virtual host. Finally, we need to add a virtual host to the Apache configuration, which looks like this:: ServerName mypage.com WSGIDaemonProcess todo user=www-data group=www-data processes=1 threads=5 WSGIScriptAlias / /var/www/todo/adapter.wsgi WSGIProcessGroup todo WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all After restarting the server, your ToDo list should be accessible at ``http://www.mypage.com/todo`` Final Words ========================= Now we are at the end of this introduction and tutorial to Bottle. We learned about the basic concepts of Bottle and wrote a first application using the Bottle framework. In addition to that, we saw how to adapt Bottle for large tasks and serve Bottle through an Apache web server with mod_wsgi. As said in the introduction, this tutorial is not showing all shades and possibilities of Bottle. What we skipped here is e.g. receiving file objects and streams and how to handle authentication data. Furthermore, we did not show how templates can be called from within another template. For an introduction into those points, please refer to the full `Bottle documentation`_ . Complete Example Listing ========================= As the ToDo list example was developed piece by piece, here is the complete listing: Main code for the application ``todo.py``:: import sqlite3 from bottle import route, run, debug, template, request, static_file, error # only needed when you run Bottle on mod_wsgi from bottle import default_app @route('/todo') def todo_list(): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT id, task FROM todo WHERE status LIKE '1'") result = c.fetchall() c.close() output = template('make_table', rows=result) return output @route('/new', method='GET') def new_item(): if request.GET.save: new = request.GET.task.strip() conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("INSERT INTO todo (task,status) VALUES (?,?)", (new, 1)) new_id = c.lastrowid conn.commit() c.close() return '

The new task was inserted into the database, the ID is %s

' % new_id else: return template('new_task.tpl') @route('/edit/', method='GET') def edit_item(no): if request.GET.save: edit = request.GET.task.strip() status = request.GET.status.strip() if status == 'open': status = 1 else: status = 0 conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("UPDATE todo SET task = ?, status = ? WHERE id LIKE ?", (edit, status, no)) conn.commit() return '

The item number %s was successfully updated

' % no else: conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (str(no))) cur_data = c.fetchone() return template('edit_task', old=cur_data, no=no) @route('/item') def show_item(item): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (item,)) result = c.fetchall() c.close() if not result: return 'This item number does not exist!' else: return 'Task: %s' % result[0] @route('/help') def help(): static_file('help.html', root='.') @route('/json') def show_json(json): conn = sqlite3.connect('todo.db') c = conn.cursor() c.execute("SELECT task FROM todo WHERE id LIKE ?", (json,)) result = c.fetchall() c.close() if not result: return {'task': 'This item number does not exist!'} else: return {'task': result[0]} @error(403) def mistake403(code): return 'There is a mistake in your url!' @error(404) def mistake404(code): return 'Sorry, this page does not exist!' debug(True) run(reloader=True) # remember to remove reloader=True and debug(True) when you move your # application from development to a productive environment Template ``make_table.tpl``:: %#template to generate a HTML table from a list of tuples (or list of lists, or tuple of tuples or ...)

The open items are as follows:

%for row in rows: %for col in row: %end %end
{{col}}
Template ``edit_task.tpl``:: %#template for editing a task %#the template expects to receive a value for "no" as well a "old", the text of the selected ToDo item

Edit the task with ID = {{no}}


Template ``new_task.tpl``:: %#template for the form for a new task

Add a new task to the ToDo list:

python-bottle-0.13.2/setup.cfg000066400000000000000000000001001470367422500162270ustar00rootroot00000000000000[bdist_wheel] universal = 1 [metadata] license_files = LICENSE python-bottle-0.13.2/setup.py000077500000000000000000000036711470367422500161430ustar00rootroot00000000000000#!/usr/bin/env python import sys from setuptools import setup if sys.version_info < (2, 7): raise NotImplementedError("Sorry, you need at least Python 2.7 or Python 3.6+ to use bottle.") import bottle setup(name='bottle', version=bottle.__version__, description='Fast and simple WSGI-framework for small web-applications.', long_description=bottle.__doc__, long_description_content_type="text/markdown", author=bottle.__author__, author_email='marc@gsites.de', url='http://bottlepy.org/', project_urls={ 'Source': 'https://github.com/bottlepy/bottle', }, py_modules=['bottle'], scripts=['bottle.py'], entry_points={ 'console_scripts': [ 'bottle = bottle:main', ] }, license='MIT', platforms='any', classifiers=['Development Status :: 4 - Beta', "Operating System :: OS Independent", 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries', 'Topic :: Internet :: WWW/HTTP :: HTTP Servers', 'Topic :: Internet :: WWW/HTTP :: WSGI', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware', 'Topic :: Internet :: WWW/HTTP :: WSGI :: Server', 'Topic :: Software Development :: Libraries :: Application Frameworks', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', ], ) python-bottle-0.13.2/test/000077500000000000000000000000001470367422500153765ustar00rootroot00000000000000python-bottle-0.13.2/test/.coveragerc000066400000000000000000000001461470367422500175200ustar00rootroot00000000000000[run] branch = True parallel = True data_file = ../build/.coverage [html] directory = build/coverage python-bottle-0.13.2/test/__init__.py000066400000000000000000000003271470367422500175110ustar00rootroot00000000000000from __future__ import with_statement from .tools import chdir import unittest import sys, os try: import coverage coverage.process_startup() except ImportError: pass import bottle bottle.debug(True) python-bottle-0.13.2/test/build_python.sh000066400000000000000000000023041470367422500204310ustar00rootroot00000000000000#!/bin/bash -e # This script builds a specific python release to a prefix directory # Stop on any errors trap exit ERR VERSION=$1 PREFIX=$2 test -d $PREFIX || mkdir -p $PREFIX || die "ERROR: Could not find/create $PREFIX" PREFIX=`cd $PREFIX; pwd` PATH="$PREFIX/bin:$PATH" # Add ubuntus special lib and include dirs so python can find them. export arch=$(dpkg-architecture -qDEB_HOST_MULTIARCH) export LDFLAGS="-L/usr/lib/$arch -L/lib/$arch" export CFLAGS="-I/usr/include/$arch" export CPPFLAGS="-I/usr/include/$arch" if [ -x $PREFIX/bin/python$VERSION ]; then echo "Found Python executable. Skipping build" exit 0 fi pushd $PREFIX || exit 1 echo "Downloading source ..." wget -N https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz || exit 1 echo "Extracting source ..." tar -xzf Python-$VERSION.tgz || exit 1 pushd Python-$VERSION || exit 1 echo "Running ./configure --prefix=$PREFIX ..." ./configure --prefix=$PREFIX || exit 1 echo "Running make && make install ..." (make -j8 && make install) || exit 1 echo "Installing distribute and pip..." hash -r popd echo "Cleaning up..." rm -rf $VERSION.tar.gz distribute_setup.py cpython-$VERSION popd python-bottle-0.13.2/test/example_settings.py000066400000000000000000000000471470367422500213240ustar00rootroot00000000000000A = { "B": { "C": 3 } }python-bottle-0.13.2/test/test_app.py000066400000000000000000000010301470367422500175610ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ Tests for the functionality of the application object. TODO: Move other tests here. """ import unittest from bottle import Bottle class TestApplicationObject(unittest.TestCase): def test_setattr(self): """ Attributed can be assigned, but only once. """ app = Bottle() app.test = 5 self.assertEqual(5, app.test) self.assertRaises(AttributeError, setattr, app, 'test', 6) del app.test app.test = 6 self.assertEqual(6, app.test) python-bottle-0.13.2/test/test_auth.py000066400000000000000000000005311470367422500177470ustar00rootroot00000000000000# -*- coding: utf-8 -*- import bottle from .tools import ServerTestBase class TestBasicAuth(ServerTestBase): def test__header(self): @bottle.route('/') @bottle.auth_basic(lambda x, y: False) def test(): return {} self.assertStatus(401) self.assertHeader('Www-Authenticate', 'Basic realm="private"') python-bottle-0.13.2/test/test_config.py000066400000000000000000000162301470367422500202560ustar00rootroot00000000000000import tempfile import unittest from bottle import ConfigDict class TestConfDict(unittest.TestCase): def test_isadict(self): """ ConfigDict should behaves like a normal dict. """ # It is a dict-subclass, so this kind of pointless, but it doen't hurt. d, m = dict(), ConfigDict() d['key'], m['key'] = 'value', 'value' d['k2'], m['k2'] = 'v1', 'v1' d['k2'], m['k2'] = 'v2', 'v2' self.assertEqual(d.keys(), m.keys()) self.assertEqual(list(d.values()), list(m.values())) self.assertEqual(d.get('key'), m.get('key')) self.assertEqual(d.get('cay'), m.get('cay')) self.assertEqual(list(iter(d)), list(iter(m))) self.assertEqual([k for k in d], [k for k in m]) self.assertEqual(len(d), len(m)) self.assertEqual('key' in d, 'key' in m) self.assertEqual('cay' in d, 'cay' in m) self.assertRaises(KeyError, lambda: m['cay']) self.assertEqual(d.setdefault('key', "Val2"), m.setdefault('key', "Val2")) self.assertEqual(d.setdefault('key', "Val3"), m.setdefault('key', "Val3")) self.assertEqual(d.get('key'), m.get('key')) with self.assertRaises(KeyError): del m['No key'] def test_write(self): c = ConfigDict() c['key'] = 'value' self.assertEqual(c['key'], 'value') self.assertTrue('key' in c) c['key'] = 'value2' self.assertEqual(c['key'], 'value2') def test_update(self): c = ConfigDict() c['key'] = 'value' c.update(key='value2', key2='value3') self.assertEqual(c['key'], 'value2') self.assertEqual(c['key2'], 'value3') def test_string_save_keys(self): c = ConfigDict() with self.assertRaises(TypeError): c[5] = 'value' with self.assertRaises(TypeError): c.load_dict({5: 'value'}) def test_namespaces(self): c = ConfigDict() c.update('a.b', key='value') self.assertEqual(c['a.b.key'], 'value') def test_meta(self): c = ConfigDict() c.meta_set('bool', 'filter', bool) c.meta_set('int', 'filter', int) c['bool'] = 'I am so true!' c['int'] = '6' self.assertTrue(c['bool'] is True) self.assertEqual(c['int'], 6) self.assertRaises(ValueError, lambda: c.update(int='not an int')) def test_load_dict(self): c = ConfigDict() d = dict(a=dict(b=dict(foo=5, bar=6), baz=7)) c.load_dict(d) self.assertEqual(c['a.b.foo'], 5) self.assertEqual(c['a.b.bar'], 6) self.assertEqual(c['a.baz'], 7) # unicode keys (see issue #720) try: key = unichr(12354) except NameError: key = chr(12354) c = ConfigDict() c.load_dict({key: 'value'}) self.assertEqual('value', c[key]) c = ConfigDict() c.load_dict({key: {'subkey': 'value'}}) self.assertEqual('value', c[key + '.subkey']) def test_load_module(self): c = ConfigDict() c.load_module('test.example_settings', True) self.assertEqual(c['A.B.C'], 3) c = ConfigDict() c.load_module('test.example_settings', False) self.assertEqual(c['A']['B']['C'], 3) def test_overlay(self): source = ConfigDict() source['key'] = 'source' intermediate = source._make_overlay() overlay = intermediate._make_overlay() # Overlay contains values from source self.assertEqual(overlay['key'], 'source') self.assertEqual(overlay.get('key'), 'source') self.assertTrue('key' in overlay) # Overlay is updated with source source['key'] = 'source2' self.assertEqual(source['key'], 'source2') self.assertEqual(overlay['key'], 'source2') # Overlay 'overlays' source (hence the name) overlay['key'] = 'overlay' self.assertEqual(source['key'], 'source2') self.assertEqual(intermediate['key'], 'source2') self.assertEqual(overlay['key'], 'overlay') # Deleting an overlayed key restores the value from source del overlay['key'] self.assertEqual(source['key'], 'source2') self.assertEqual(overlay['key'], 'source2') # Deleting a virtual key is actually not possible. with self.assertRaises(KeyError): del overlay['key'] # Deleting a key in the source also removes it from overlays. del source['key'] self.assertTrue('key' not in overlay) self.assertTrue('key' not in intermediate) self.assertTrue('key' not in source) # New keys in source are copied to overlay source['key2'] = 'source' self.assertEqual(source['key2'], 'source') self.assertEqual(intermediate['key2'], 'source') self.assertEqual(overlay['key2'], 'source') # New keys in overlay do not change the source overlay['key3'] = 'overlay' self.assertEqual(overlay['key3'], 'overlay') self.assertTrue('key3' not in intermediate) self.assertTrue('key3' not in source) # Setting the same key in the source does not affect the overlay # because it already has this key. source['key3'] = 'source' self.assertEqual(source['key3'], 'source') self.assertEqual(intermediate['key3'], 'source') self.assertEqual(overlay['key3'], 'overlay') # But as soon as the overlayed key is deleted, it gets the # copy from the source del overlay['key3'] self.assertEqual(source['key3'], 'source') self.assertEqual(overlay['key3'], 'source') def test_gc_overlays(self): root = ConfigDict() overlay = root._make_overlay() del overlay import gc; gc.collect() root._make_overlay() # This triggers the weakref-collect self.assertEqual(len(root._overlays), 1) class TestINIConfigLoader(unittest.TestCase): @classmethod def setUpClass(self): self.config_file = tempfile.NamedTemporaryFile(suffix='.example.ini', delete=True) self.config_file.write(b'[DEFAULT]\n' b'default: 45\n' b'[bottle]\n' b'port = 8080\n' b'[ROOT]\n' b'namespace.key = test\n' b'[NameSpace.Section]\n' b'sub.namespace.key = test2\n' b'default = otherDefault\n' b'[compression]\n' b'status=single\n') self.config_file.flush() @classmethod def tearDownClass(self): self.config_file.close() def test_load_config(self): c = ConfigDict() c.load_config(self.config_file.name) self.assertDictEqual({ 'compression.default': '45', 'compression.status': 'single', 'default': '45', 'namespace.key': 'test', 'namespace.section.default': 'otherDefault', 'namespace.section.sub.namespace.key': 'test2', 'port': '8080'}, c) python-bottle-0.13.2/test/test_contextlocals.py000066400000000000000000000023261470367422500216740ustar00rootroot00000000000000# -*- coding: utf-8 -*- ''' Some objects are context-local, meaning that they have different values depending on the context they are accessed from. A context is currently defined as a thread. ''' import unittest import bottle import threading def run_thread(func): t = threading.Thread(target=func) t.start() t.join() class TestThreadLocals(unittest.TestCase): def test_request(self): e1 = {'PATH_INFO': '/t1'} e2 = {'PATH_INFO': '/t2'} def run(): bottle.request.bind(e2) self.assertEqual(bottle.request.path, '/t2') bottle.request.bind(e1) self.assertEqual(bottle.request.path, '/t1') run_thread(run) self.assertEqual(bottle.request.path, '/t1') def test_response(self): def run(): bottle.response.bind() bottle.response.content_type='test/thread' self.assertEqual(bottle.response.headers['Content-Type'], 'test/thread') bottle.response.bind() bottle.response.content_type='test/main' self.assertEqual(bottle.response.headers['Content-Type'], 'test/main') run_thread(run) self.assertEqual(bottle.response.headers['Content-Type'], 'test/main') python-bottle-0.13.2/test/test_environ.py000077500000000000000000001142631470367422500205010ustar00rootroot00000000000000# -*- coding: utf-8 -*- ''' Tests for the BaseRequest and BaseResponse objects and their subclasses. ''' import unittest import sys import itertools import bottle from bottle import request, tob, touni, tonat, json_dumps, HTTPError, parse_date, CookieError from . import tools import wsgiref.util import base64 from bottle import BaseRequest, BaseResponse, LocalRequest class TestRequest(unittest.TestCase): def test_app_property(self): e = {} r = BaseRequest(e) self.assertRaises(RuntimeError, lambda: r.app) e.update({'bottle.app': 5}) self.assertEqual(r.app, 5) def test_route_property(self): e = {'bottle.route': 5} r = BaseRequest(e) self.assertEqual(r.route, 5) def test_url_for_property(self): e = {} r = BaseRequest(e) self.assertRaises(RuntimeError, lambda: r.url_args) e.update({'route.url_args': {'a': 5}}) self.assertEqual(r.url_args, {'a': 5}) def test_path(self): """ PATH_INFO normalization. """ # Legal paths tests = [('', '/'), ('x','/x'), ('x/', '/x/'), ('/x', '/x'), ('/x/', '/x/')] for raw, norm in tests: self.assertEqual(norm, BaseRequest({'PATH_INFO': raw}).path) # Strange paths tests = [('///', '/'), ('//x','/x')] for raw, norm in tests: self.assertEqual(norm, BaseRequest({'PATH_INFO': raw}).path) # No path at all self.assertEqual('/', BaseRequest({}).path) def test_method(self): self.assertEqual(BaseRequest({}).method, 'GET') self.assertEqual(BaseRequest({'REQUEST_METHOD':'GET'}).method, 'GET') self.assertEqual(BaseRequest({'REQUEST_METHOD':'GeT'}).method, 'GET') self.assertEqual(BaseRequest({'REQUEST_METHOD':'get'}).method, 'GET') self.assertEqual(BaseRequest({'REQUEST_METHOD':'POst'}).method, 'POST') self.assertEqual(BaseRequest({'REQUEST_METHOD':'FanTASY'}).method, 'FANTASY') def test_script_name(self): """ SCRIPT_NAME normalization. """ # Legal paths tests = [('', '/'), ('x','/x/'), ('x/', '/x/'), ('/x', '/x/'), ('/x/', '/x/')] for raw, norm in tests: self.assertEqual(norm, BaseRequest({'SCRIPT_NAME': raw}).script_name) # Strange paths tests = [('///', '/'), ('///x///','/x/')] for raw, norm in tests: self.assertEqual(norm, BaseRequest({'SCRIPT_NAME': raw}).script_name) # No path at all self.assertEqual('/', BaseRequest({}).script_name) def test_pathshift(self): """ Request.path_shift() """ def test_shift(s, p, c): request = BaseRequest({'SCRIPT_NAME': s, 'PATH_INFO': p}) request.path_shift(c) return [request['SCRIPT_NAME'], request.path] self.assertEqual(['/a/b', '/c/d'], test_shift('/a/b', '/c/d', 0)) self.assertEqual(['/a/b', '/c/d/'], test_shift('/a/b', '/c/d/', 0)) self.assertEqual(['/a/b/c', '/d'], test_shift('/a/b', '/c/d', 1)) self.assertEqual(['/a', '/b/c/d'], test_shift('/a/b', '/c/d', -1)) self.assertEqual(['/a/b/c', '/d/'], test_shift('/a/b', '/c/d/', 1)) self.assertEqual(['/a', '/b/c/d/'], test_shift('/a/b', '/c/d/', -1)) self.assertEqual(['/a/b/c', '/d/'], test_shift('/a/b/', '/c/d/', 1)) self.assertEqual(['/a', '/b/c/d/'], test_shift('/a/b/', '/c/d/', -1)) self.assertEqual(['/a/b/c/d', '/'], test_shift('/', '/a/b/c/d', 4)) self.assertEqual(['/', '/a/b/c/d/'], test_shift('/a/b/c/d', '/', -4)) self.assertRaises(AssertionError, test_shift, '/a/b', '/c/d', 3) self.assertRaises(AssertionError, test_shift, '/a/b', '/c/d', -3) def test_url(self): """ Environ: URL building """ request = BaseRequest({'HTTP_HOST':'example.com'}) self.assertEqual('http://example.com/', request.url) request = BaseRequest({'SERVER_NAME':'example.com'}) self.assertEqual('http://example.com/', request.url) request = BaseRequest({'SERVER_NAME':'example.com', 'SERVER_PORT':'81'}) self.assertEqual('http://example.com:81/', request.url) request = BaseRequest({'wsgi.url_scheme':'https', 'SERVER_NAME':'example.com'}) self.assertEqual('https://example.com/', request.url) request = BaseRequest({'HTTP_HOST':'example.com', 'PATH_INFO':'/path', 'QUERY_STRING':'1=b&c=d', 'SCRIPT_NAME':'/sp'}) self.assertEqual('http://example.com/sp/path?1=b&c=d', request.url) request = BaseRequest({'HTTP_HOST':'example.com', 'PATH_INFO':'/pa th', 'SCRIPT_NAME':'/s p'}) self.assertEqual('http://example.com/s%20p/pa%20th', request.url) def test_dict_access(self): """ Environ: request objects are environment dicts """ e = {} wsgiref.util.setup_testing_defaults(e) request = BaseRequest(e) self.assertEqual(list(request), list(e.keys())) self.assertEqual(len(request), len(e)) for k, v in e.items(): self.assertTrue(k in request) self.assertEqual(request[k], v) request[k] = 'test' self.assertEqual(request[k], 'test') del request['PATH_INFO'] self.assertTrue('PATH_INFO' not in request) def test_readonly_environ(self): request = BaseRequest({'bottle.request.readonly':True}) def test(): request['x']='y' self.assertRaises(KeyError, test) def test_header_access(self): """ Environ: Request objects decode headers """ e = {} wsgiref.util.setup_testing_defaults(e) e['HTTP_SOME_HEADER'] = 'some value' request = BaseRequest(e) request['HTTP_SOME_OTHER_HEADER'] = 'some other value' self.assertTrue('Some-Header' in request.headers) self.assertTrue(request.headers['Some-Header'] == 'some value') self.assertTrue(request.headers['Some-Other-Header'] == 'some other value') def test_header_access_special(self): e = {} wsgiref.util.setup_testing_defaults(e) request = BaseRequest(e) request['CONTENT_TYPE'] = 'test' request['CONTENT_LENGTH'] = '123' self.assertEqual(request.headers['Content-Type'], 'test') self.assertEqual(request.headers['Content-Length'], '123') def test_cookie_dict(self): """ Environ: Cookie dict """ t = dict() t['a=a'] = {'a': 'a'} t['a=a; b=b'] = {'a': 'a', 'b':'b'} t['a=a; a=b'] = {'a': 'b'} for k, v in t.items(): request = BaseRequest({'HTTP_COOKIE': k}) for n in v: self.assertEqual(v[n], request.cookies[n]) self.assertEqual(v[n], request.get_cookie(n)) def test_get(self): """ Environ: GET data """ qs = tonat(tob('a=a&a=1&b=b&c=c&cn=%e7%93%b6'), 'latin1') request = BaseRequest({'QUERY_STRING':qs}) self.assertTrue('a' in request.query) self.assertTrue('b' in request.query) self.assertEqual(['a','1'], request.query.getall('a')) self.assertEqual(['b'], request.query.getall('b')) self.assertEqual('1', request.query['a']) self.assertEqual('b', request.query['b']) self.assertEqual(tonat(tob('瓶'), 'latin1'), request.query['cn']) self.assertEqual(touni('瓶'), request.query.cn) def test_post(self): """ Environ: POST data """ sq = tob('a=a&a=1&b=b&c=&d&cn=%e7%93%b6') e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(sq) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(sq)) e['REQUEST_METHOD'] = "POST" request = BaseRequest(e) self.assertTrue('a' in request.POST) self.assertTrue('b' in request.POST) self.assertEqual(['a','1'], request.POST.getall('a')) self.assertEqual(['b'], request.POST.getall('b')) self.assertEqual('1', request.POST['a']) self.assertEqual('b', request.POST['b']) self.assertEqual('', request.POST['c']) self.assertEqual('', request.POST['d']) self.assertEqual(tonat(tob('瓶'), 'latin1'), request.POST['cn']) self.assertEqual(touni('瓶'), request.POST.cn) def test_bodypost(self): sq = tob('foobar') e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(sq) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(sq)) e['REQUEST_METHOD'] = "POST" request = BaseRequest(e) self.assertEqual('', request.POST['foobar']) def test_body_noclose(self): """ Test that the body file handler is not closed after request.POST """ sq = tob('a=a&a=1&b=b&c=&d') e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(sq) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(sq)) e['REQUEST_METHOD'] = "POST" request = BaseRequest(e) self.assertEqual(sq, request.body.read()) request.POST # This caused a body.close() with Python 3.x self.assertEqual(sq, request.body.read()) def test_params(self): """ Environ: GET and POST are combined in request.param """ e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob('b=b&c=p')) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = '7' e['QUERY_STRING'] = 'a=a&c=g' e['REQUEST_METHOD'] = "POST" request = BaseRequest(e) self.assertEqual(['a','b','c'], sorted(request.params.keys())) self.assertEqual('p', request.params['c']) def test_getpostleak(self): """ Environ: GET and POST should not leak into each other """ e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob('b=b')) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = '3' e['QUERY_STRING'] = 'a=a' e['REQUEST_METHOD'] = "POST" request = BaseRequest(e) self.assertEqual(['a'], list(request.GET.keys())) self.assertEqual(['b'], list(request.POST.keys())) def test_body(self): """ Environ: Request.body should behave like a file object factory """ e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob('abc')) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(3) request = BaseRequest(e) self.assertEqual(tob('abc'), request.body.read()) self.assertEqual(tob('abc'), request.body.read(3)) self.assertEqual(tob('abc'), request.body.readline()) self.assertEqual(tob('abc'), request.body.readline(3)) def test_bigbody(self): """ Environ: Request.body should handle big uploads using files """ e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob('x')*1024*1000) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(1024*1000) request = BaseRequest(e) self.assertTrue(hasattr(request.body, 'fileno')) self.assertEqual(1024*1000, len(request.body.read())) self.assertEqual(1024, len(request.body.read(1024))) self.assertEqual(1024*1000, len(request.body.readline())) self.assertEqual(1024, len(request.body.readline(1024))) def test_tobigbody(self): """ Environ: Request.body should truncate to Content-Length bytes """ e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob('x')*1024) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = '42' request = BaseRequest(e) self.assertEqual(42, len(request.body.read())) self.assertEqual(42, len(request.body.read(1024))) self.assertEqual(42, len(request.body.readline())) self.assertEqual(42, len(request.body.readline(1024))) def _test_chunked(self, body, expect): e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob(body)) e['wsgi.input'].seek(0) e['HTTP_TRANSFER_ENCODING'] = 'chunked' if isinstance(expect, str): self.assertEqual(tob(expect), BaseRequest(e).body.read()) else: self.assertRaises(expect, lambda: BaseRequest(e).body) def test_chunked(self): self._test_chunked('1\r\nx\r\nff\r\n' + 'y'*255 + '\r\n0\r\n', 'x' + 'y'*255) self._test_chunked('8\r\nxxxxxxxx\r\n0\r\n','xxxxxxxx') self._test_chunked('0\r\n', '') def test_chunked_meta_fields(self): self._test_chunked('8 ; foo\r\nxxxxxxxx\r\n0\r\n','xxxxxxxx') self._test_chunked('8;foo\r\nxxxxxxxx\r\n0\r\n','xxxxxxxx') self._test_chunked('8;foo=bar\r\nxxxxxxxx\r\n0\r\n','xxxxxxxx') def test_chunked_not_terminated(self): self._test_chunked('1\r\nx\r\n', HTTPError) def test_chunked_wrong_size(self): self._test_chunked('2\r\nx\r\n', HTTPError) def test_chunked_illegal_size(self): self._test_chunked('x\r\nx\r\n', HTTPError) def test_chunked_not_chunked_at_all(self): self._test_chunked('abcdef', HTTPError) def test_multipart(self): """ Environ: POST (multipart files and multible values per key) """ fields = [('field1','value1'), ('field2','value2'), ('field2','万难')] files = [('file1','filename1.txt','content1'), ('万难','万难foo.py', 'ä\nö\rü')] e = tools.multipart_environ(fields=fields, files=files) request = BaseRequest(e) # File content self.assertTrue('file1' in request.POST) self.assertTrue('file1' in request.files) self.assertTrue('file1' not in request.forms) cmp = tob('content1') if sys.version_info >= (3,2,0) else 'content1' self.assertEqual(cmp, request.POST['file1'].file.read()) # File name and meta data self.assertTrue('万难' in request.POST) self.assertTrue('万难' in request.files) self.assertTrue('万难' not in request.forms) self.assertEqual('foo.py', request.POST['万难'].filename) self.assertTrue(request.files['万难']) self.assertFalse(request.files.file77) # UTF-8 files x = request.POST['万难'].file.read() if (3,2,0) > sys.version_info >= (3,0,0): x = x.encode('utf8') self.assertEqual(tob('ä\nö\rü'), x) # No file self.assertTrue('file3' not in request.POST) self.assertTrue('file3' not in request.files) self.assertTrue('file3' not in request.forms) # Field (single) self.assertEqual('value1', request.POST['field1']) self.assertTrue('field1' not in request.files) self.assertEqual('value1', request.forms['field1']) self.assertEqual('万难', request.forms['field2']) self.assertEqual(touni('万难'), request.forms.field2) # Field (multi) self.assertEqual(2, len(request.POST.getall('field2'))) self.assertEqual(['value2', '万难'], request.POST.getall('field2')) self.assertEqual(['value2', '万难'], request.forms.getall('field2')) self.assertTrue('field2' not in request.files) def test_json_empty(self): """ Environ: Request.json property with empty body. """ self.assertEqual(BaseRequest({}).json, None) def test_json_noheader(self): """ Environ: Request.json property with missing content-type header. """ test = dict(a=5, b='test', c=[1,2,3]) e = {} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob(json_dumps(test))) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(json_dumps(test))) self.assertEqual(BaseRequest(e).json, None) def test_json_tobig(self): """ Environ: Request.json property with huge body. """ test = dict(a=5, tobig='x' * bottle.BaseRequest.MEMFILE_MAX) e = {'CONTENT_TYPE': 'application/json'} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob(json_dumps(test))) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(json_dumps(test))) self.assertRaises(HTTPError, lambda: BaseRequest(e).json) def test_json_valid(self): """ Environ: Request.json property. """ test = dict(a=5, b='test', c=[1,2,3]) e = {'CONTENT_TYPE': 'application/json; charset=UTF-8'} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob(json_dumps(test))) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(json_dumps(test))) self.assertEqual(BaseRequest(e).json, test) def test_json_forged_header_issue616(self): test = dict(a=5, b='test', c=[1,2,3]) e = {'CONTENT_TYPE': 'text/plain;application/json'} wsgiref.util.setup_testing_defaults(e) e['wsgi.input'].write(tob(json_dumps(test))) e['wsgi.input'].seek(0) e['CONTENT_LENGTH'] = str(len(json_dumps(test))) self.assertEqual(BaseRequest(e).json, None) def test_json_header_empty_body(self): """Request Content-Type is application/json but body is empty""" e = {'CONTENT_TYPE': 'application/json'} wsgiref.util.setup_testing_defaults(e) wsgiref.util.setup_testing_defaults(e) e['CONTENT_LENGTH'] = "0" self.assertEqual(BaseRequest(e).json, None) def test_isajax(self): e = {} wsgiref.util.setup_testing_defaults(e) self.assertFalse(BaseRequest(e.copy()).is_ajax) e['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' self.assertTrue(BaseRequest(e.copy()).is_ajax) def test_auth(self): user, pwd = 'marc', 'secret' basic = touni(base64.b64encode(tob('%s:%s' % (user, pwd)))) r = BaseRequest({}) self.assertEqual(r.auth, None) r.environ['HTTP_AUTHORIZATION'] = 'basic %s' % basic self.assertEqual(r.auth, (user, pwd)) r.environ['REMOTE_USER'] = user self.assertEqual(r.auth, (user, pwd)) del r.environ['HTTP_AUTHORIZATION'] self.assertEqual(r.auth, (user, None)) def test_remote_route(self): ips = ['1.2.3.4', '2.3.4.5', '3.4.5.6'] r = BaseRequest({}) self.assertEqual(r.remote_route, []) r.environ['HTTP_X_FORWARDED_FOR'] = ', '.join(ips) self.assertEqual(r.remote_route, ips) r.environ['REMOTE_ADDR'] = ips[1] self.assertEqual(r.remote_route, ips) del r.environ['HTTP_X_FORWARDED_FOR'] self.assertEqual(r.remote_route, [ips[1]]) def test_remote_addr(self): ips = ['1.2.3.4', '2.3.4.5', '3.4.5.6'] r = BaseRequest({}) self.assertEqual(r.remote_addr, None) r.environ['HTTP_X_FORWARDED_FOR'] = ', '.join(ips) self.assertEqual(r.remote_addr, ips[0]) r.environ['REMOTE_ADDR'] = ips[1] self.assertEqual(r.remote_addr, ips[0]) del r.environ['HTTP_X_FORWARDED_FOR'] self.assertEqual(r.remote_addr, ips[1]) def test_user_defined_attributes(self): for cls in (BaseRequest, LocalRequest): r = cls() # New attributes go to the environ dict. r.foo = 'somevalue' self.assertEqual(r.foo, 'somevalue') self.assertTrue('somevalue' in r.environ.values()) # Attributes are read-only once set. self.assertRaises(AttributeError, setattr, r, 'foo', 'x') # Properties raise AttributeError. self.assertRaises(AttributeError, setattr, r, 'body', 'x') # Unknown attributes raise AttributeError. self.assertRaises(AttributeError, getattr, r, 'somevalue') class TestResponse(unittest.TestCase): def test_constructor_body(self): self.assertEqual('', BaseResponse('').body) self.assertEqual('YAY', BaseResponse('YAY').body) def test_constructor_status(self): self.assertEqual(200, BaseResponse('YAY', 200).status_code) self.assertEqual('200 OK', BaseResponse('YAY', 200).status_line) self.assertEqual('200 YAY', BaseResponse('YAY', '200 YAY').status_line) self.assertEqual('200 YAY', BaseResponse('YAY', '200 YAY').status_line) def test_constructor_headerlist(self): from functools import partial make_res = partial(BaseResponse, '', 200) self.assertEqual('yay', make_res(x_test='yay')['x-test']) def test_wsgi_header_values(self): def cmp(app, wire): rs = BaseResponse() rs.set_header('x-test', app) result = [v for (h, v) in rs.headerlist if h.lower()=='x-test'][0] self.assertEqual(wire, result) if bottle.py3k: cmp(1, tonat('1', 'latin1')) cmp('öäü', 'öäü'.encode('utf8').decode('latin1')) # Dropped byte header support in Python 3: #cmp(tob('äöü'), 'äöü'.encode('utf8').decode('latin1')) else: cmp(1, '1') cmp('öäü', 'öäü') cmp(touni('äöü'), 'äöü') def test_set_status(self): rs = BaseResponse() rs.status = 200 self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 200) self.assertEqual(rs.status_line, '200 OK') rs.status = 999 self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 999) self.assertEqual(rs.status_line, '999 Unknown') rs.status = 404 self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 404) self.assertEqual(rs.status_line, '404 Not Found') def test(): rs.status = -200 self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Not Found') # last value def test(): rs.status = 5 self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Not Found') # last value rs.status = '999 Who knows?' # Illegal, but acceptable three digit code self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 999) self.assertEqual(rs.status_line, '999 Who knows?') rs.status = 555 # Strange code self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 555) self.assertEqual(rs.status_line, '555 Unknown') rs.status = '404 Brain not Found' # Custom reason self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 404) self.assertEqual(rs.status_line, '404 Brain not Found') def test(): rs.status = '5 Illegal Code' self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Brain not Found') # last value def test(): rs.status = '-99 Illegal Code' self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Brain not Found') # last value def test(): rs.status = '1000 Illegal Code' self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Brain not Found') # last value def test(): rs.status = '555' # No reason self.assertRaises(ValueError, test) self.assertEqual(rs.status, rs.status_line) # last value self.assertEqual(rs.status_code, 404) # last value self.assertEqual(rs.status_line, '404 Brain not Found') # last value # Unicode in status line (thanks RFC7230 :/) if bottle.py3k: rs.status = '400 Non-ASÎÎ' self.assertEqual(rs.status, rs.status_line) self.assertEqual(rs.status_code, 400) wire = rs._wsgi_status_line().encode('latin1') self.assertEqual(rs.status, wire.decode('utf8')) def test_content_type(self): rs = BaseResponse() rs.content_type = 'test/some' self.assertEqual('test/some', rs.headers.get('Content-Type')) def test_charset(self): rs = BaseResponse() self.assertEqual(rs.charset, 'UTF-8') rs.content_type = 'text/html; charset=latin9' self.assertEqual(rs.charset, 'latin9') rs.content_type = 'text/html' self.assertEqual(rs.charset, 'UTF-8') def test_set_cookie(self): r = BaseResponse() r.set_cookie('name1', 'value', max_age=5) r.set_cookie('name2', 'value 2', path='/foo') cookies = [value for name, value in r.headerlist if name.title() == 'Set-Cookie'] cookies.sort() self.assertEqual(cookies[0], 'name1=value; Max-Age=5') self.assertEqual(cookies[1], 'name2="value 2"; Path=/foo') def test_set_cookie_value_long_string(self): r = BaseResponse() self.assertRaises(ValueError, r.set_cookie, name='test', value='x' * 4097) def test_set_cookie_name_long_string(self): r = BaseResponse() self.assertRaises(ValueError, r.set_cookie, name='x' * 4097, value='simple_value') def test_set_cookie_maxage(self): import datetime r = BaseResponse() r.set_cookie('name1', 'value', max_age=5) r.set_cookie('name2', 'value', max_age=datetime.timedelta(days=1)) cookies = sorted([value for name, value in r.headerlist if name.title() == 'Set-Cookie']) self.assertEqual(cookies[0], 'name1=value; Max-Age=5') self.assertEqual(cookies[1], 'name2=value; Max-Age=86400') def test_set_cookie_expires(self): import datetime r = BaseResponse() r.set_cookie('name1', 'value', expires=42) r.set_cookie('name2', 'value', expires=datetime.datetime(1970,1,1,0,0,43)) cookies = sorted([value for name, value in r.headerlist if name.title() == 'Set-Cookie']) self.assertEqual(cookies[0], 'name1=value; expires=Thu, 01 Jan 1970 00:00:42 GMT') self.assertEqual(cookies[1], 'name2=value; expires=Thu, 01 Jan 1970 00:00:43 GMT') def test_set_cookie_secure(self): r = BaseResponse() r.set_cookie('name1', 'value', secure=True) r.set_cookie('name2', 'value', secure=False) cookies = sorted([value for name, value in r.headerlist if name.title() == 'Set-Cookie']) self.assertEqual(cookies[0].lower(), 'name1=value; secure') self.assertEqual(cookies[1], 'name2=value') def test_set_cookie_httponly(self): if sys.version_info < (2,6,0): return r = BaseResponse() r.set_cookie('name1', 'value', httponly=True) r.set_cookie('name2', 'value', httponly=False) cookies = sorted([value for name, value in r.headerlist if name.title() == 'Set-Cookie']) self.assertEqual('name1=value; httponly', cookies[0].lower()) self.assertEqual('name2=value', cookies[1]) def test_set_cookie_samesite(self): r = BaseResponse() r.set_cookie('name1', 'value', same_site="lax") r.set_cookie('name2', 'value', same_site="strict") try: r.set_cookie('name3', 'value', same_site='invalid') self.fail("Should raise CookieError") except CookieError: pass cookies = sorted([value for name, value in r.headerlist if name.title() == 'Set-Cookie']) self.assertEqual('name1=value; samesite=lax', cookies[0].lower()) self.assertEqual('name2=value; samesite=strict', cookies[1].lower()) def test_clone_cookie(self): r = BaseResponse() r.set_cookie('name1', 'value', same_site="strict") r2 = r.copy(BaseResponse) cookies = sorted([value for name, value in r2.headerlist if name.title() == 'Set-Cookie']) self.assertEqual('name1=value; samesite=strict', cookies[0].lower()) def test_delete_cookie(self): response = BaseResponse() response.set_cookie('name', 'value') response.delete_cookie('name') cookies = [value for name, value in response.headerlist if name.title() == 'Set-Cookie'] self.assertTrue('Max-Age=-1' in cookies[0]) def test_set_header(self): response = BaseResponse() response['x-test'] = 'foo' headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo'], headers) self.assertEqual('foo', response['x-test']) response['X-Test'] = 'bar' headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['bar'], headers) self.assertEqual('bar', response['x-test']) def test_append_header(self): response = BaseResponse() response.set_header('x-test', 'foo') headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo'], headers) self.assertEqual('foo', response['x-test']) response.add_header('X-Test', 'bar') headers = [value for name, value in response.headerlist if name.title() == 'X-Test'] self.assertEqual(['foo', 'bar'], headers) self.assertEqual('bar', response['x-test']) def test_delete_header(self): response = BaseResponse() response['x-test'] = 'foo' self.assertEqual('foo', response['x-test']) del response['X-tESt'] self.assertRaises(KeyError, lambda: response['x-test']) def test_non_string_header(self): response = BaseResponse() response['x-test'] = 5 self.assertEqual('5', response['x-test']) response['x-test'] = None self.assertEqual('', response['x-test']) response['x-test'] = touni('瓶') self.assertEqual(tonat(touni('瓶')), response['x-test']) def test_prevent_control_characters_in_headers(self): masks = '{}test', 'test{}', 'te{}st' tests = '\n', '\r', '\n\r', '\0' # Test HeaderDict apis = 'append', 'replace', '__setitem__', 'setdefault' for api, mask, test in itertools.product(apis, masks, tests): hd = bottle.HeaderDict() func = getattr(hd, api) value = mask.replace("{}", test) self.assertRaises(ValueError, func, value, "test-value") self.assertRaises(ValueError, func, "test-name", value) # Test functions on BaseResponse apis = 'add_header', 'set_header', '__setitem__' for api, mask, test in itertools.product(apis, masks, tests): rs = bottle.BaseResponse() func = getattr(rs, api) value = mask.replace("{}", test) self.assertRaises(ValueError, func, value, "test-value") self.assertRaises(ValueError, func, "test-name", value) def test_expires_header(self): import datetime from bottle import UTC response = BaseResponse() now = datetime.datetime.now(UTC) response.expires = now def seconds(a, b): td = max(a,b) - min(a,b) return td.days*360*24 + td.seconds self.assertEqual(0, seconds(response.expires, now)) now2 = datetime.datetime.fromtimestamp( parse_date(response.headers['Expires']), tz=UTC) self.assertEqual(0, seconds(now, now2)) class TestRedirect(unittest.TestCase): def assertRedirect(self, target, result, query=None, status=303, **args): env = {'SERVER_PROTOCOL': 'HTTP/1.1'} for key in list(args): if key.startswith('wsgi'): args[key.replace('_', '.', 1)] = args[key] del args[key] env.update(args) request.bind(env) bottle.response.bind() try: bottle.redirect(target, **(query or {})) except bottle.HTTPResponse as E: self.assertEqual(status, E.status_code) self.assertTrue(E.headers) self.assertEqual(result, E.headers['Location']) def test_absolute_path(self): self.assertRedirect('/', 'http://127.0.0.1/') self.assertRedirect('/test.html', 'http://127.0.0.1/test.html') self.assertRedirect('/test.html', 'http://127.0.0.1/test.html', PATH_INFO='/some/sub/path/') self.assertRedirect('/test.html', 'http://127.0.0.1/test.html', PATH_INFO='/some/sub/file.html') self.assertRedirect('/test.html', 'http://127.0.0.1/test.html', SCRIPT_NAME='/some/sub/path/') self.assertRedirect('/foo/test.html', 'http://127.0.0.1/foo/test.html') self.assertRedirect('/foo/test.html', 'http://127.0.0.1/foo/test.html', PATH_INFO='/some/sub/file.html') def test_relative_path(self): self.assertRedirect('./', 'http://127.0.0.1/') self.assertRedirect('./test.html', 'http://127.0.0.1/test.html') self.assertRedirect('./test.html', 'http://127.0.0.1/foo/test.html', PATH_INFO='/foo/') self.assertRedirect('./test.html', 'http://127.0.0.1/foo/test.html', PATH_INFO='/foo/bar.html') self.assertRedirect('./test.html', 'http://127.0.0.1/foo/test.html', SCRIPT_NAME='/foo/') self.assertRedirect('./test.html', 'http://127.0.0.1/foo/bar/test.html', SCRIPT_NAME='/foo/', PATH_INFO='/bar/baz.html') self.assertRedirect('./foo/test.html', 'http://127.0.0.1/foo/test.html') self.assertRedirect('./foo/test.html', 'http://127.0.0.1/bar/foo/test.html', PATH_INFO='/bar/file.html') self.assertRedirect('../test.html', 'http://127.0.0.1/test.html', PATH_INFO='/foo/') self.assertRedirect('../test.html', 'http://127.0.0.1/foo/test.html', PATH_INFO='/foo/bar/') self.assertRedirect('../test.html', 'http://127.0.0.1/test.html', PATH_INFO='/foo/bar.html') self.assertRedirect('../test.html', 'http://127.0.0.1/test.html', SCRIPT_NAME='/foo/') self.assertRedirect('../test.html', 'http://127.0.0.1/foo/test.html', SCRIPT_NAME='/foo/', PATH_INFO='/bar/baz.html') self.assertRedirect('../baz/../test.html', 'http://127.0.0.1/foo/test.html', PATH_INFO='/foo/bar/') def test_sheme(self): self.assertRedirect('./test.html', 'https://127.0.0.1/test.html', wsgi_url_scheme='https') self.assertRedirect('./test.html', 'https://127.0.0.1:80/test.html', wsgi_url_scheme='https', SERVER_PORT='80') def test_host_http_1_0(self): # No HTTP_HOST, just SERVER_NAME and SERVER_PORT. self.assertRedirect('./test.html', 'http://example.com/test.html', SERVER_NAME='example.com', SERVER_PROTOCOL='HTTP/1.0', status=302) self.assertRedirect('./test.html', 'http://127.0.0.1:81/test.html', SERVER_PORT='81', SERVER_PROTOCOL='HTTP/1.0', status=302) def test_host_http_1_1(self): self.assertRedirect('./test.html', 'http://example.com/test.html', HTTP_HOST='example.com') self.assertRedirect('./test.html', 'http://example.com:81/test.html', HTTP_HOST='example.com:81') # Trust HTTP_HOST over SERVER_NAME and PORT. self.assertRedirect('./test.html', 'http://example.com:81/test.html', HTTP_HOST='example.com:81', SERVER_NAME='foobar') self.assertRedirect('./test.html', 'http://example.com:81/test.html', HTTP_HOST='example.com:81', SERVER_PORT='80') def test_host_http_proxy(self): # Trust proxy headers over original header. self.assertRedirect('./test.html', 'http://example.com/test.html', HTTP_X_FORWARDED_HOST='example.com', HTTP_HOST='127.0.0.1') def test_specialchars(self): ''' The target URL is not quoted automatically. ''' self.assertRedirect('./te st.html', 'http://example.com/a%20a/b%20b/te st.html', HTTP_HOST='example.com', SCRIPT_NAME='/a a/', PATH_INFO='/b b/') def test_redirect_preserve_cookies(self): env = {'SERVER_PROTOCOL':'HTTP/1.1'} request.bind(env) bottle.response.bind() try: bottle.response.set_cookie('xxx', 'yyy') bottle.redirect('...') except bottle.HTTPResponse as E: h = [v for (k, v) in E.headerlist if k == 'Set-Cookie'] self.assertEqual(h, ['xxx=yyy']) class TestWSGIHeaderDict(unittest.TestCase): def setUp(self): self.env = {} self.headers = bottle.WSGIHeaderDict(self.env) def test_empty(self): self.assertEqual(0, len(bottle.WSGIHeaderDict({}))) def test_native(self): self.env['HTTP_TEST_HEADER'] = 'foobar' self.assertEqual(self.headers['Test-header'], 'foobar') def test_bytes(self): self.env['HTTP_TEST_HEADER'] = tob('foobar') self.assertEqual(self.headers['Test-Header'], 'foobar') def test_unicode(self): self.env['HTTP_TEST_HEADER'] = touni('foobar') self.assertEqual(self.headers['Test-Header'], 'foobar') def test_dict(self): for key in 'foo-bar Foo-Bar foo-Bar FOO-BAR'.split(): self.assertTrue(key not in self.headers) self.assertEqual(self.headers.get(key), None) self.assertEqual(self.headers.get(key, 5), 5) self.assertRaises(KeyError, lambda x: self.headers[x], key) self.env['HTTP_FOO_BAR'] = 'test' for key in 'foo-bar Foo-Bar foo-Bar FOO-BAR'.split(): self.assertTrue(key in self.headers) self.assertEqual(self.headers.get(key), 'test') self.assertEqual(self.headers.get(key, 5), 'test') python-bottle-0.13.2/test/test_exc.py000066400000000000000000000021571470367422500175730ustar00rootroot00000000000000import bottle from .tools import ServerTestBase class SomeError(Exception): pass class TestAppException(ServerTestBase): def test_no_exc(self): @bottle.route('/') def test(): return 'test' self.assertBody('test', '/') def test_memory_error(self): @bottle.route('/') def test(): raise MemoryError with self.assertRaises(MemoryError): self.urlopen("/") def test_system_Exit(self): @bottle.route('/') def test(): raise SystemExit with self.assertRaises(SystemExit): self.urlopen("/") def test_other_error(self): @bottle.route('/') def test(): raise SomeError self.assertStatus(500, '/') self.assertInBody('SomeError') def test_noncatched_error(self): @bottle.route('/') def test(): raise SomeError bottle.request.environ['exc_info'] = None self.app.catchall = False with self.assertRaises(SomeError): self.urlopen("/") self.app.catchall = True self.assertStatus(500, '/') self.assertInBody('SomeError') python-bottle-0.13.2/test/test_fileupload.py000066400000000000000000000047761470367422500211510ustar00rootroot00000000000000# -*- coding: utf-8 -*- ''' Tests for the FileUpload wrapper. ''' import unittest import sys, os.path import bottle from bottle import FileUpload, BytesIO, tob import tempfile class TestFileUpload(unittest.TestCase): def test_name(self): self.assertEqual(FileUpload(None, 'abc', None).name, 'abc') def test_raw_filename(self): self.assertEqual(FileUpload(None, None, 'x/x').raw_filename, 'x/x') def test_content_type(self): fu = FileUpload(None, None, None, {"Content-type": "text/plain"}) self.assertEqual(fu.content_type, 'text/plain') def assertFilename(self, bad, good): fu = FileUpload(None, None, bad) self.assertEqual(fu.filename, good) def test_filename(self): self.assertFilename('with space', 'with-space') self.assertFilename('with more \t\n\r space', 'with-more-space') self.assertFilename('with/path', 'path') self.assertFilename('../path', 'path') self.assertFilename('..\\path', 'path') self.assertFilename('..', 'empty') self.assertFilename('.name.', 'name') self.assertFilename('.name.cfg', 'name.cfg') self.assertFilename(' . na me . ', 'na-me') self.assertFilename('path/', 'empty') self.assertFilename(bottle.tob('ümläüts$'), 'umlauts') self.assertFilename(bottle.touni('ümläüts$'), 'umlauts') self.assertFilename('', 'empty') self.assertFilename('a'+'b'*1337+'c', 'a'+'b'*254) def test_preserve_case_issue_582(self): self.assertFilename('UpperCase', 'UpperCase') def test_save_buffer(self): fu = FileUpload(open(__file__, 'rb'), 'testfile', __file__) buff = BytesIO() fu.save(buff) buff.seek(0) self.assertEqual(fu.file.read(), buff.read()) def test_save_file(self): fu = FileUpload(open(__file__, 'rb'), 'testfile', __file__) buff = tempfile.TemporaryFile() fu.save(buff) buff.seek(0) self.assertEqual(fu.file.read(), buff.read()) def test_save_overwrite_lock(self): fu = FileUpload(open(__file__, 'rb'), 'testfile', __file__) self.assertRaises(IOError, fu.save, __file__) def test_save_dir(self): fu = FileUpload(open(__file__, 'rb'), 'testfile', __file__) dirpath = tempfile.mkdtemp() filepath = os.path.join(dirpath, fu.filename) fu.save(dirpath) self.assertEqual(fu.file.read(), open(filepath, 'rb').read()) os.unlink(filepath) os.rmdir(dirpath) python-bottle-0.13.2/test/test_formsdict.py000066400000000000000000000022301470367422500207760ustar00rootroot00000000000000# -*- coding: utf-8 -*- # '瓶' means "Bottle" import unittest from bottle import FormsDict, touni, tob class TestFormsDict(unittest.TestCase): def test_attr_access(self): """ FomsDict.attribute returs string values as unicode. """ d = FormsDict(py2=tob('瓶'), py3=tob('瓶').decode('latin1')) self.assertEqual(touni('瓶'), d.py2) self.assertEqual(touni('瓶'), d.py3) def test_attr_missing(self): """ FomsDict.attribute returs u'' on missing keys. """ d = FormsDict() self.assertEqual(touni(''), d.missing) def test_attr_unicode_error(self): """ FomsDict.attribute returs u'' on UnicodeError. """ d = FormsDict(latin=touni('öäüß').encode('latin1')) self.assertEqual(touni(''), d.latin) d.input_encoding = 'latin1' self.assertEqual(touni('öäüß'), d.latin) def test_decode_method(self): d = FormsDict(py2=tob('瓶'), py3=tob('瓶').decode('latin1')) d = d.decode() self.assertFalse(d.recode_unicode) self.assertTrue(hasattr(list(d.keys())[0], 'encode')) self.assertTrue(hasattr(list(d.values())[0], 'encode')) python-bottle-0.13.2/test/test_html_helper.py000066400000000000000000000013031470367422500213070ustar00rootroot00000000000000import unittest from bottle import _parse_http_header class TestHttpUtils(unittest.TestCase): # TODO: Move more of the low level http stuff here. def test_accept_header(self): self.assertEqual(_parse_http_header( 'text/xml, text/whitespace ,' 'application/params;param=value; ws = lots ;"quote"="mid\\"quote",' '"more\\"quotes\\"",' 'I\'m in space!!!'), [('text/xml', {}), ('text/whitespace', {}), ('application/params', {'param': 'value', 'ws': 'lots', 'quote': 'mid"quote'}), ('more"quotes"', {}), ('I\'m in space!!!', {})] ) python-bottle-0.13.2/test/test_importhook.py000066400000000000000000000024121470367422500212010ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest import sys, os import bottle class TestImportHooks(unittest.TestCase): def make_module(self, name, **args): mod = sys.modules.setdefault(name, bottle.new_module(name)) mod.__file__ = '' % name mod.__dict__.update(**args) return mod def test_direkt_import(self): mod = self.make_module('bottle_test') import bottle.ext.test self.assertEqual(bottle.ext.test, mod) def test_from_import(self): mod = self.make_module('bottle_test') from bottle.ext import test self.assertEqual(test, mod) def test_data_import(self): mod = self.make_module('bottle_test', item='value') from bottle.ext.test import item self.assertEqual(item, 'value') def test_import_fail(self): ''' Test a simple static page with this server adapter. ''' def test(): import bottle.ext.doesnotexist self.assertRaises(ImportError, test) def test_ext_isfile(self): ''' The virtual module needs a valid __file__ attribute. If not, the Google app engine development server crashes on windows. ''' from bottle import ext self.assertTrue(os.path.isfile(ext.__file__)) python-bottle-0.13.2/test/test_jinja2.py000066400000000000000000000052711470367422500201710ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest from bottle import Jinja2Template, jinja2_template, jinja2_view, touni from .tools import warn, chdir class TestJinja2Template(unittest.TestCase): def test_string(self): """ Templates: Jinja2 string""" t = Jinja2Template('start {{var}} end').render(var='var') self.assertEqual('start var end', ''.join(t)) def test_file(self): """ Templates: Jinja2 file""" with chdir(__file__): t = Jinja2Template(name='./views/jinja2_simple.tpl', lookup=['.']).render(var='var') self.assertEqual('start var end', ''.join(t)) def test_name(self): """ Templates: Jinja2 lookup by name """ with chdir(__file__): t = Jinja2Template(name='jinja2_simple', lookup=['./views/']).render(var='var') self.assertEqual('start var end', ''.join(t)) def test_notfound(self): """ Templates: Unavailable templates""" self.assertRaises(Exception, Jinja2Template, name="abcdef", lookup=['./views/']) def test_error(self): """ Templates: Exceptions""" self.assertRaises(Exception, Jinja2Template, '{% for badsyntax') def test_inherit(self): """ Templates: Jinja2 lookup and inherience """ with chdir(__file__): t = Jinja2Template(name='jinja2_inherit', lookup=['./views/']).render() self.assertEqual('begin abc end', ''.join(t)) def test_custom_filters(self): """Templates: jinja2 custom filters """ from bottle import jinja2_template as template settings = dict(filters = {"star": lambda var: touni("").join((touni('*'), var, touni('*')))}) t = Jinja2Template("start {{var|star}} end", **settings) self.assertEqual("start *var* end", t.render(var="var")) def test_custom_tests(self): """Templates: jinja2 custom tests """ from bottle import jinja2_template as template TEMPL = touni("{% if var is even %}gerade{% else %}ungerade{% endif %}") settings = dict(tests={"even": lambda x: False if x % 2 else True}) t = Jinja2Template(TEMPL, **settings) self.assertEqual("gerade", t.render(var=2)) self.assertEqual("ungerade", t.render(var=1)) def test_template_shortcut(self): result = jinja2_template('start {{var}} end', var='middle') self.assertEqual(touni('start middle end'), result) def test_view_decorator(self): @jinja2_view('start {{var}} end') def test(): return dict(var='middle') self.assertEqual(touni('start middle end'), test()) try: import jinja2 except ImportError: warn("No Jinja2 template support. Skipping tests.") del TestJinja2Template python-bottle-0.13.2/test/test_mako.py000066400000000000000000000042111470367422500177340ustar00rootroot00000000000000from __future__ import with_statement import unittest from .tools import warn, chdir from bottle import MakoTemplate, mako_template, mako_view, touni class TestMakoTemplate(unittest.TestCase): def test_string(self): """ Templates: Mako string""" t = MakoTemplate('start ${var} end').render(var='var') self.assertEqual('start var end', t) def test_file(self): """ Templates: Mako file""" with chdir(__file__): t = MakoTemplate(name='./views/mako_simple.tpl', lookup=['.']).render(var='var') self.assertEqual('start var end\n', t) def test_name(self): """ Templates: Mako lookup by name """ with chdir(__file__): t = MakoTemplate(name='mako_simple', lookup=['./views/']).render(var='var') self.assertEqual('start var end\n', t) def test_notfound(self): """ Templates: Unavailable templates""" self.assertRaises(Exception, MakoTemplate, lookup=['./views/'], name="abcdef") def test_error(self): """ Templates: Exceptions""" self.assertRaises(Exception, MakoTemplate, '%for badsyntax') def test_inherit(self): """ Templates: Mako lookup and inherience """ with chdir(__file__): t = MakoTemplate(name='mako_inherit', lookup=['./views/']).render(var='v') self.assertEqual('o\ncvc\no\n', t) t = MakoTemplate('<%inherit file="mako_base.tpl"/>\nc${var}c\n', lookup=['./views/']).render(var='v') self.assertEqual('o\ncvc\no\n', t) t = MakoTemplate('<%inherit file="views/mako_base.tpl"/>\nc${var}c\n', lookup=['./']).render(var='v') self.assertEqual('o\ncvc\no\n', t) def test_template_shortcut(self): result = mako_template('start ${var} end', var='middle') self.assertEqual(touni('start middle end'), result) def test_view_decorator(self): @mako_view('start ${var} end') def test(): return dict(var='middle') self.assertEqual(touni('start middle end'), test()) try: import mako except ImportError: warn("No Mako template support. Skipping tests.") del TestMakoTemplate python-bottle-0.13.2/test/test_mdict.py000077500000000000000000000036671470367422500201260ustar00rootroot00000000000000import unittest from bottle import MultiDict, HeaderDict class TestMultiDict(unittest.TestCase): def test_isadict(self): """ MultiDict should behaves like a normal dict """ d, m = dict(a=5), MultiDict(a=5) d['key'], m['key'] = 'value', 'value' d['k2'], m['k2'] = 'v1', 'v1' d['k2'], m['k2'] = 'v2', 'v2' self.assertEqual(list(d.keys()), list(m.keys())) self.assertEqual(list(d.values()), list(m.values())) self.assertEqual(list(d.keys()), list(m.iterkeys())) self.assertEqual(list(d.values()), list(m.itervalues())) self.assertEqual(d.get('key'), m.get('key')) self.assertEqual(d.get('cay'), m.get('cay')) self.assertEqual(list(iter(d)), list(iter(m))) self.assertEqual([k for k in d], [k for k in m]) self.assertEqual(len(d), len(m)) self.assertEqual('key' in d, 'key' in m) self.assertEqual('cay' in d, 'cay' in m) self.assertRaises(KeyError, lambda: m['cay']) def test_ismulti(self): """ MultiDict has some special features """ m = MultiDict(a=5) m['a'] = 6 self.assertEqual([5, 6], m.getall('a')) self.assertEqual([], m.getall('b')) self.assertEqual([('a', 5), ('a', 6)], list(m.iterallitems())) def test_isheader(self): """ HeaderDict replaces by default and title()s its keys """ m = HeaderDict(abc_def=5) m['abc_def'] = 6 self.assertEqual(['6'], m.getall('abc_def')) m.append('abc_def', 7) self.assertEqual(['6', '7'], m.getall('abc_def')) self.assertEqual([('Abc-Def', '6'), ('Abc-Def', '7')], list(m.iterallitems())) def test_headergetbug(self): ''' Assure HeaderDict.get() to be case insensitive ''' d = HeaderDict() d['UPPER'] = 'UPPER' d['lower'] = 'lower' self.assertEqual(d.get('upper'), 'UPPER') self.assertEqual(d.get('LOWER'), 'lower') python-bottle-0.13.2/test/test_mount.py000066400000000000000000000105001470367422500201450ustar00rootroot00000000000000# -*- coding: utf-8 -*- import bottle from .tools import ServerTestBase, api from bottle import response class TestAppMounting(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) self.subapp = bottle.Bottle() @self.subapp.route('/') @self.subapp.route('/test/') def test(test='foo'): return test def test_mount_unicode_path_bug602(self): self.app.mount('/mount/', self.subapp) self.assertBody('äöü', '/mount/test/äöü') self.app.route('/route/', callback=lambda param: param) self.assertBody('äöü', '/route/äöü') def test_mount_order_bug581(self): self.app.mount('/test/', self.subapp) # This should not match self.app.route('/', callback=lambda test: test) self.assertStatus(200, '/test/') self.assertBody('foo', '/test/') def test_mount(self): self.app.mount('/test/', self.subapp) self.assertStatus(404, '/') self.assertStatus(404, '/test') self.assertStatus(200, '/test/') self.assertBody('foo', '/test/') self.assertStatus(200, '/test/test/bar') self.assertBody('bar', '/test/test/bar') def test_mount_meta(self): self.app.mount('/test/', self.subapp) self.assertEqual( self.subapp.config['_mount.prefix'], '/test/') self.assertEqual( self.subapp.config['_mount.app'], self.app) @api('0.9', '0.13') def test_no_slash_prefix(self): self.app.mount('/test', self.subapp) self.assertStatus(404, '/') self.assertStatus(200, '/test') self.assertBody('foo', '/test') self.assertStatus(200, '/test/') self.assertBody('foo', '/test/') self.assertStatus(200, '/test/test/bar') self.assertBody('bar', '/test/test/bar') def test_mount_no_plugins(self): def plugin(func): def wrapper(*a, **ka): return 'Plugin' return wrapper self.app.install(plugin) self.app.route('/foo', callback=lambda: 'baz') self.app.mount('/test/', self.subapp) self.assertBody('Plugin', '/foo') self.assertBody('foo', '/test/') def test_mount_wsgi(self): status = {} def app(environ, start_response): start_response('200 OK', [('X-Test', 'WSGI')]) return 'WSGI ' + environ['PATH_INFO'] self.app.mount('/test', app) self.assertStatus(200, '/test/') self.assertBody('WSGI /', '/test') self.assertBody('WSGI /', '/test/') self.assertHeader('X-Test', 'WSGI', '/test/') self.assertBody('WSGI /test/bar', '/test/test/bar') def test_mount_cookie(self): @self.subapp.route('/cookie') def test_cookie(): response.set_cookie('a', 'a') response.set_cookie('b', 'b') self.app.mount('/test/', self.subapp) c = self.urlopen('/test/cookie')['header']['Set-Cookie'] self.assertEqual(['a=a', 'b=b'], list(sorted(c.split(', ')))) def test_mount_wsgi_ctype_bug(self): status = {} def app(environ, start_response): start_response('200 OK', [('Content-Type', 'test/test')]) return 'WSGI ' + environ['PATH_INFO'] self.app.mount('/test', app) self.assertHeader('Content-Type', 'test/test', '/test/') def test_mount_json_bug(self): @self.subapp.route('/json') def route(): return {'a': 5} self.app.mount('/test/', self.subapp) self.assertHeader('Content-Type', 'application/json', '/test/json') def test_mount_get_url(self): @self.subapp.route('/test', name="test") def route(): return bottle.url("test") self.app.mount('/test/', self.subapp) self.assertBody('/test/test', '/test/test') class TestAppMerging(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) self.subapp = bottle.Bottle() @self.subapp.route('/') @self.subapp.route('/test/') def test(test='foo'): return test def test_merge(self): self.app.merge(self.subapp) self.assertStatus(200, '/') self.assertBody('foo', '/') self.assertStatus(200, '/test/bar') self.assertBody('bar', '/test/bar') python-bottle-0.13.2/test/test_multipart.py000066400000000000000000001127051470367422500210360ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest import base64 import sys, os.path, tempfile from io import BytesIO import bottle class BaseMultipartTest(unittest.TestCase): def setUp(self): self.reset() def reset(self): self.data = BytesIO() self.parts = None def write(self, *lines): for line in lines: self.data.write(bottle.tob(line)) def parse(self, ctype=None, clen=-1, **kwargs): self.data.seek(0) ctype, options = bottle._parse_http_header(ctype or "multipart/form-data; boundary=foo")[0] charset = options.get("charset", "utf8") boundary = options.get("boundary") parser = bottle._MultipartParser(self.data, boundary=boundary, content_length=clen, charset=charset, **kwargs) self.parts = list(parser.parse()) return self.parts def assertFile(self, name, filename, ctype, data): for part in self.parts or []: if part.name != name: continue self.assertEqual(part.filename, filename) self.assertEqual(part.content_type, ctype) self.assertEqual(part.raw, bottle.tob(data)) break else: self.fail("Field %s not found" % name) def assertForm(self, name, data): for part in self.parts or []: if part.name != name: continue self.assertEqual(part.filename, None) self.assertEqual(part.content_type, None) self.assertEqual(part.charset, "utf8") self.assertEqual(part.value, data) break else: self.fail("Field %s not found" % name) class TestHeaderParser(BaseMultipartTest): def test_options_parser(self): parse = bottle._parse_http_header self.assertEqual( parse('form-data; name="Test"; filename="Test.txt"'), [('form-data', {"name": "Test", "filename": "Test.txt"})]) self.assertEqual(parse('form-data; name="Test"; FileName="Te\\"st.txt"'), [('form-data', {"name": "Test", "filename": "Te\"st.txt"})]) self.assertEqual(parse('form-data; name="Test"; filename="C:\\test\\bla.txt"'), [('form-data', {"name": "Test", "filename": "C:\\test\\bla.txt"})]) self.assertEqual(parse('form-data; name="Test"; filename="\\\\test\\bla.txt"'), [('form-data', {"name": "Test", "filename": "\\\\test\\bla.txt"})]) class TestMultipartParser(BaseMultipartTest): def assertIterline(self, data, *expected, **options): self.assertEqual( list(bottle._MultipartParser(BytesIO(bottle.tob(data)), 'foo', **options)._lineiter()), [(bottle.tob(l), bottle.tob(nl)) for l,nl in expected]) def test_iterlines(self): self.assertIterline('abc\ndef\r\nghi', ('abc\ndef','\r\n'), ('ghi', '')) def test_iterlines_limit(self): self.assertIterline('abc\ndef\r\nghi', ('abc\ndef','\r\n'), ('g', ''), content_length=10) self.assertIterline('abc\ndef\r\nghi', ('abc\ndef\r',''), content_length=8) def test_fuzzy_lineiter(self): """ Test all possible buffer sizes """ minbuflen = 9 # boundary size of '--foo--\r\n' data = b'data\rdata\ndata\r\ndata\n\rdata\r\n'.replace(b'data', b'X'*minbuflen*2) lines = data.split(b"\r\n")[:-1] for tail in (b"", b"tail"): for buffer_size in range(minbuflen, len(data+tail)+1): splits = list(bottle._MultipartParser( BytesIO(data+tail), 'foo', buffer_size=buffer_size)._lineiter()) partial = b"" merged = [] for part, nl in splits: self.assertTrue(nl in (b"", b"\r\n")) self.assertTrue(len(part) >= buffer_size or nl or part == tail) partial += part if nl: merged.append(partial) partial = b"" self.assertEqual(merged, lines) self.assertEqual(tail, partial) def test_big_file(self): ''' If the size of an uploaded part exceeds memfile_limit, it is written to disk. ''' test_file = 'abc'*1024 boundary = '---------------------------186454651713519341951581030105' request = BytesIO(bottle.tob('\r\n').join(map(bottle.tob,[ '--' + boundary, 'Content-Disposition: form-data; name="file1"; filename="random.png"', 'Content-Type: image/png', '', test_file, '--' + boundary, 'Content-Disposition: form-data; name="file2"; filename="random.png"', 'Content-Type: image/png', '', test_file + 'a', '--' + boundary, 'Content-Disposition: form-data; name="file3"; filename="random.png"', 'Content-Type: image/png', '', test_file*2, '--'+boundary+'--','']))) parts = list(bottle._MultipartParser(request, boundary, memfile_limit=len(test_file)).parse()) p = {p.name: p for p in parts} try: self.assertEqual(p.get('file1').file.read(), bottle.tob(test_file)) self.assertTrue(p.get('file1').is_buffered()) self.assertEqual(p.get('file2').file.read(), bottle.tob(test_file + 'a')) self.assertFalse(p.get('file2').is_buffered()) self.assertEqual(p.get('file3').file.read(), bottle.tob(test_file*2)) self.assertFalse(p.get('file3').is_buffered()) finally: for part in parts: part.close() def test_file_seek(self): ''' The file object should be readable withoud a seek(0). ''' test_file = 'abc'*1024 boundary = '---------------------------186454651713519341951581030105' request = BytesIO(bottle.tob('\r\n').join(map(bottle.tob,[ '--' + boundary, 'Content-Disposition: form-data; name="file1"; filename="random.png"', 'Content-Type: image/png', '', test_file, '--' + boundary + '--','']))) p = list(bottle._MultipartParser(request, boundary).parse()) self.assertEqual(p[0].file.read(), bottle.tob(test_file)) self.assertEqual(p[0].value, test_file) def test_unicode_value(self): ''' The .value property always returns unicode ''' test_file = 'abc'*1024 boundary = '---------------------------186454651713519341951581030105' request = BytesIO(bottle.tob('\r\n').join(map(bottle.tob,[ '--' + boundary, 'Content-Disposition: form-data; name="file1"; filename="random.png"', 'Content-Type: image/png', '', test_file, '--' + boundary + '--','']))) p = list(bottle._MultipartParser(request, boundary).parse()) self.assertEqual(p[0].file.read(), bottle.tob(test_file)) self.assertEqual(p[0].value, test_file) self.assertTrue(hasattr(p[0].value, 'encode')) def test_multiline_header(self): ''' HTTP allows headers to be multiline. ''' test_file = bottle.tob('abc'*1024) test_text = u'Test text\n with\r\n ümläuts!' boundary = '---------------------------186454651713519341951581030105' request = BytesIO(bottle.tob('\r\n').join(map(bottle.tob,[ '--' + boundary, 'Content-Disposition: form-data;', '\tname="file1"; filename="random.png"', 'Content-Type: image/png', '', test_file, '--' + boundary, 'Content-Disposition: form-data;', ' name="text"', '', test_text, '--' + boundary + '--','']))) p = list(bottle._MultipartParser(request, boundary, charset='utf8').parse()) self.assertEqual(p[0].name, "file1") self.assertEqual(p[0].file.read(), test_file) self.assertEqual(p[0].filename, 'random.png') self.assertEqual(p[1].name, "text") self.assertEqual(p[1].value, test_text) class TestBrokenMultipart(BaseMultipartTest): def assertMPError(self, **ka): self.assertRaises(bottle.MultipartError, self.parse, **ka) def test_big_boundary(self): self.assertMPError(buffer_size=1024*3) def test_missing_content_type(self): self.assertMPError(ctype="") def test_unsupported_content_type(self): self.assertMPError(ctype='multipart/fantasy') def test_missing_boundary(self): self.assertMPError(ctype="multipart/form-data") def test_no_terminator(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc') self.assertMPError() def test_no_newline_after_content(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc', '--foo--') self.assertMPError() def test_no_newline_after_middle_content(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc', '--foo\r\n' 'Content-Disposition: form-data; name="file2"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc\r\n', '--foo--') parts = self.parse() self.assertEqual(len(parts), 1) self.assertTrue('name="file2"' in parts[0].value) def test_preamble_before_start_boundary(self): parts = self.write('Preamble\r\n', '--foo\r\n' 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc\r\n', '--foo--') parts = self.parse() self.assertEqual(parts[0].file.read(), bottle.tob('abc')) self.assertEqual(parts[0].filename, 'random.png') self.assertEqual(parts[0].name, 'file1') self.assertEqual(parts[0].content_type, 'image/png') def test_no_start_boundary(self): self.write('--bar\r\n','--nonsense\r\n' 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc\r\n', '--nonsense--') self.assertMPError() def test_disk_limit(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo--') self.assertMPError(memfile_limit=0, disk_limit=1024) def test_mem_limit(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo\r\n', 'Content-Disposition: form-data; name="file2"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo--') self.assertMPError(mem_limit=1024*3) def test_invalid_header(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', 'Bad header\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo--') self.assertMPError() def test_content_length_to_small(self): self.write('--foo\r\n', 'Content-Disposition: form-data; name="file1"; filename="random.png"\r\n', 'Content-Type: image/png\r\n', 'Content-Length: 111\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo--') self.assertMPError() def test_no_disposition_header(self): self.write('--foo\r\n', 'Content-Type: image/png\r\n', '\r\n', 'abc'*1024+'\r\n', '--foo--') self.assertMPError() ''' The files used by the following test were taken from the werkzeug library test suite and are therefore partly copyrighted by the Werkzeug Team under BSD licence. See http://werkzeug.pocoo.org/ ''' b64d=base64.b64decode browser_test_cases = {} browser_test_cases["firefox3-2png1txt"] = { "data": b64d( """ LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0xODY0NTQ2NTE3MTM1MTkzNDE5NTE1ODEwMzAx MDUNCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0iZmlsZTEiOyBmaWxlbmFt ZT0iYW5jaG9yLnBuZyINCkNvbnRlbnQtVHlwZTogaW1hZ2UvcG5nDQoNColQTkcNChoKAAAADUlI RFIAAAAQAAAAEAgGAAAAH/P/YQAAAARnQU1BAACvyDcFiukAAAAZdEVYdFNvZnR3YXJlAEFkb2Jl IEltYWdlUmVhZHlxyWU8AAABnUlEQVQ4y6VTMWvCQBS+qwEFB10KGaS1P6FDpw7SrVvzAwRRx04V Ck4K6iAoDhLXdhFcW9qhZCk4FQoW0gp2U4lQRDAUS4hJmn5Xgg2lsQ198PHu3b3vu5d3L9S2bfIf 47wOer1ewzTNtGEYBP48kUjkfsrb8BIAMb1cLovwRfi07wrYzcCr4/1/Am4FzzhzBGZeefR7E7vd 7j0Iu4wYjUYDBMfD0dBiMUQfstns3toKkHgF6EgmqqruW6bFiHcsxr70awVu63Q6NiOmUinquwfM dF1f28CVgCRJx0jMAQ1BEFquRn7CbYVCYZVbr9dbnJMohoIh9kViu90WEW9nMpmxu4JyubyF/VEs FiNcgCPyoyxiu7XhCPBzdU4s652VnUccbDabPLyN2C6VSmwdhFgel5DB84AJb64mEUlvmqadTKcv 40gkUkUsg1DjeZ7iRsrWgByP71T7/afxYrHIYry/eoBD9mxsaK4VRamFw2EBQknMAWGvRClNTpQJ AfkCxFNgBmiez1ipVA4hdgQcOD/TLfylKIo3vubgL/YBnIw+ioOMLtwAAAAASUVORK5CYIINCi0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tMTg2NDU0NjUxNzEzNTE5MzQxOTUxNTgxMDMwMTA1 DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImZpbGUyIjsgZmlsZW5hbWU9 ImFwcGxpY2F0aW9uX2VkaXQucG5nIg0KQ29udGVudC1UeXBlOiBpbWFnZS9wbmcNCg0KiVBORw0K GgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdh cmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJRSURBVBgZpcHda81xHMDx9+d3fudYzuYw2RaZ5yTW olEiuZpCSjGJFEktUUr8A6ZxQZGHmDtqdrGUXHgoeZqSp1F2bLFWjtkOB8PZzvmd7+djv5XaBRfL 6yVmxv+QjQeu7l25uuZYJmtxM0AVU8Wpw9RQU8w51AxzDqfKhFjwq6Mjdbj1RN0Zv2ZFzaloUdwr L2Is4r+y7hRwxs8G5mUzPxmrwcA8hvnmjIZtcxmr3Y09hHwzJZQvOAwwNZyCYqgaThVXMFzBCD7f Jfv8MpHiKvaV3ePV2f07fMwIiSeIGeYJJoao4HmCiIeIQzPXifY+paJqO4lZi/nWPZ/krabjvlNH yANMBAQiBiqgakQMCunbxHJviM9bQeZdBzHJUzKhguLJlQnf1BghAmZ4gImAgAjk++8jP56QmL2G XG8zsfFCz8skA1mQXKbaU3X8ISIgQsgDcun7FL7cJjFnLUMfLyLRr0SLS4hbhiup5Szd19rpFYKA ESKICCERoS95neyHmyTmbmAodQ4vGpAfmEn6YTtTahv4ODiRkGdOCUUAAUSE/uQNfqTaKFu4jvyn JiIxIzcwg/SjF1RsOk9R+QJMlZCvqvwhQFdbM4XvrynIVHpfn2ZSWYyhzHS+PUtSueUC0cQ0QmpG yE9197TUnwzq1DnUKbXSxOb6S7xtPkjngzbGVVbzvS/FjaGt9DU8xlRRJdTCMDEzRjuyZ1FwaFe9 j+d4eecaPd1dPxNTSlfWHm1v5y/EzBitblXp4JLZ5f6yBbOwaK5tsD+9c33jq/f8w2+mRSjOllPh kAAAAABJRU5ErkJggg0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0xODY0NTQ2NTE3MTM1 MTkzNDE5NTE1ODEwMzAxMDUNCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0i dGV4dCINCg0KZXhhbXBsZSB0ZXh0DQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTE4NjQ1 NDY1MTcxMzUxOTM0MTk1MTU4MTAzMDEwNS0tDQo=""" ), "boundary": "---------------------------186454651713519341951581030105", "files": { "file1": ( "anchor.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGdSURBVDjLpVMxa8JAFL6rAQUHXQoZpLU/ oUOnDtKtW/MDBFHHThUKTgrqICgOEtd2EVxb2qFkKTgVChbSCnZTiVBEMBRLiEmafleCDaWxDX3w 8e7dve+7l3cv1LZt8h/jvA56vV7DNM20YRgE/jyRSOR+ytvwEgAxvVwui/BF+LTvCtjNwKvj/X8C bgXPOHMEZl559HsTu93uPQi7jBiNRgMEx8PR0GIxRB+y2eze2gqQeAXoSCaqqu5bpsWIdyzGvvRr BW7rdDo2I6ZSKeq7B8x0XV/bwJWAJEnHSMwBDUEQWq5GfsJthUJhlVuv11uckyiGgiH2RWK73RYR b2cymbG7gnK5vIX9USwWI1yAI/KjLGK7teEI8HN1TizrnZWdRxxsNps8vI3YLpVKbB2EWB6XkMHz gAlvriYRSW+app1Mpy/jSCRSRSyDUON5nuJGytaAHI/vVPv9p/FischivL96gEP2bGxorhVFqYXD YQFCScwBYa9EKU1OlAkB+QLEU2AGaJ7PWKlUDiF2BBw4P9Mt/KUoije+5uAv9gGcjD6Kg4wu3AAA AABJRU5ErkJggg==""" ), ), "file2": ( "application_edit.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJRSURBVBgZpcHda81xHMDx9+d3fudYzuYw 2RaZ5yTWolEiuZpCSjGJFEktUUr8A6ZxQZGHmDtqdrGUXHgoeZqSp1F2bLFWjtkOB8PZzvmd7+dj v5XaBRfL6yVmxv+QjQeu7l25uuZYJmtxM0AVU8Wpw9RQU8w51AxzDqfKhFjwq6Mjdbj1RN0Zv2ZF zaloUdwrL2Is4r+y7hRwxs8G5mUzPxmrwcA8hvnmjIZtcxmr3Y09hHwzJZQvOAwwNZyCYqgaThVX MFzBCD7fJfv8MpHiKvaV3ePV2f07fMwIiSeIGeYJJoao4HmCiIeIQzPXifY+paJqO4lZi/nWPZ/k rabjvlNHyANMBAQiBiqgakQMCunbxHJviM9bQeZdBzHJUzKhguLJlQnf1BghAmZ4gImAgAjk++8j P56QmL2GXG8zsfFCz8skA1mQXKbaU3X8ISIgQsgDcun7FL7cJjFnLUMfLyLRr0SLS4hbhiup5Szd 19rpFYKAESKICCERoS95neyHmyTmbmAodQ4vGpAfmEn6YTtTahv4ODiRkGdOCUUAAUSE/uQNfqTa KFu4jvynJiIxIzcwg/SjF1RsOk9R+QJMlZCvqvwhQFdbM4XvrynIVHpfn2ZSWYyhzHS+PUtSueUC 0cQ0QmpGyE9197TUnwzq1DnUKbXSxOb6S7xtPkjngzbGVVbzvS/FjaGt9DU8xlRRJdTCMDEzRjuy Z1FwaFe9j+d4eecaPd1dPxNTSlfWHm1v5y/EzBitblXp4JLZ5f6yBbOwaK5tsD+9c33jq/f8w2+m RSjOllPhkAAAAABJRU5ErkJggg==""" ), ), }, "forms": {"text": u"example text"}, } browser_test_cases["firefox3-2pnglongtext"] = { "data": b64d( """ LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0xNDkwNDA0NDczOTc4NzE5MTAzMTc1NDcxMTc0 OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlMSI7IGZpbGVuYW1l PSJhY2NlcHQucG5nIg0KQ29udGVudC1UeXBlOiBpbWFnZS9wbmcNCg0KiVBORw0KGgoAAAANSUhE UgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUg SW1hZ2VSZWFkeXHJZTwAAAKfSURBVDjLpZPrS1NhHMf9O3bOdmwDCWREIYKEUHsVJBI7mg3FvCxL 09290jZj2EyLMnJexkgpLbPUanNOberU5taUMnHZUULMvelCtWF0sW/n7MVMEiN64AsPD8/n83uu cQDi/id/DBT4Dolypw/qsz0pTMbj/WHpiDgsdSUyUmeiPt2+V7SrIM+bSss8ySGdR4abQQv6lrui 6VxsRonrGCS9VEjSQ9E7CtiqdOZ4UuTqnBHO1X7YXl6Daa4yGq7vWO1D40wVDtj4kWQbn94myPGk CDPdSesczE2sCZShwl8CzcwZ6NiUs6n2nYX99T1cnKqA2EKui6+TwphA5k4yqMayopU5mANV3lNQ TBdCMVUA9VQh3GuDMHiVcLCS3J4jSLhCGmKCjBEx0xlshjXYhApfMZRP5CyYD+UkG08+xt+4wLVQ ZA1tzxthm2tEfD3JxARH7QkbD1ZuozaggdZbxK5kAIsf5qGaKMTY2lAU/rH5HW3PLsEwUYy+YCcE RmIjJpDcpzb6l7th9KtQ69fi09ePUej9l7cx2DJbD7UrG3r3afQHOyCo+V3QQzE35pvQvnAZukk5 zL5qRL59jsKbPzdheXoBZc4saFhBS6AO7V4zqCpiawuptwQG+UAa7Ct3UT0hh9p9EnXT5Vh6t4C2 2QaUDh6HwnECOmcO7K+6kW49DKqS2DrEZCtfuI+9GrNHg4fMHVSO5kE7nAPVkAxKBxcOzsajpS4Y h4ohUPPWKTUh3PaQEptIOr6BiJjcZXCwktaAGfrRIpwblqOV3YKdhfXOIvBLeREWpnd8ynsaSJoy ESFphwTtfjN6X1jRO2+FxWtCWksqBApeiFIR9K6fiTpPiigDoadqCEag5YUFKl6Yrciw0VOlhOiv v/Ff8wtn0KzlebrUYwAAAABJRU5ErkJggg0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0x NDkwNDA0NDczOTc4NzE5MTAzMTc1NDcxMTc0OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1k YXRhOyBuYW1lPSJmaWxlMiI7IGZpbGVuYW1lPSJhZGQucG5nIg0KQ29udGVudC1UeXBlOiBpbWFn ZS9wbmcNCg0KiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK 6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLpZPrS5NhGIf9 W7YvBYOkhlkoqCklWChv2WyKik7blnNris72bi6dus0DLZ0TDxW1odtopDs4D8MDZuLU0kXq61Ci jSIIasOvv94VTUfLiB74fXngup7nvrnvJABJ/5PfLnTTdcwOj4RsdYmo5glBWP6iOtzwvIKSWstI 0Wgx80SBblpKtE9KQs/We7EaWoT/8wbWP61gMmCH0lMDvokT4j25TiQU/ITFkek9Ow6+7WH2gwsm ahCPdwyw75uw9HEO2gUZSkfyI9zBPCJOoJ2SMmg46N61YO/rNoa39Xi41oFuXysMfh36/Fp0b7bA fWAH6RGi0HglWNCbzYgJaFjRv6zGuy+b9It96N3SQvNKiV9HvSaDfFEIxXItnPs23BzJQd6DDEVM 0OKsoVwBG/1VMzpXVWhbkUM2K4oJBDYuGmbKIJ0qxsAbHfRLzbjcnUbFBIpx/qH3vQv9b3U03IQ/ HfFkERTzfFj8w8jSpR7GBE123uFEYAzaDRIqX/2JAtJbDat/COkd7CNBva2cMvq0MGxp0PRSCPF8 BXjWG3FgNHc9XPT71Ojy3sMFdfJRCeKxEsVtKwFHwALZfCUk3tIfNR8XiJwc1LmL4dg141JPKtj3 WUdNFJqLGFVPC4OkR4BxajTWsChY64wmCnMxsWPCHcutKBxMVp5mxA1S+aMComToaqTRUQknLTH6 2kHOVEE+VQnjahscNCy0cMBWsSI0TCQcZc5ALkEYckL5A5noWSBhfm2AecMAjbcRWV0pUTh0HE64 TNf0mczcnnQyu/MilaFJCae1nw2fbz1DnVOxyGTlKeZft/Ff8x1BRssfACjTwQAAAABJRU5ErkJg gg0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0xNDkwNDA0NDczOTc4NzE5MTAzMTc1NDcx MTc0OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ0ZXh0Ig0KDQotLWxv bmcgdGV4dA0KLS13aXRoIGJvdW5kYXJ5DQotLWxvb2thbGlrZXMtLQ0KLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0xNDkwNDA0NDczOTc4NzE5MTAzMTc1NDcxMTc0OC0tDQo=""" ), "boundary": "---------------------------14904044739787191031754711748", "files": { "file1": ( "accept.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKfSURBVDjLpZPrS1NhHMf9O3bOdmwDCWRE IYKEUHsVJBI7mg3FvCxL09290jZj2EyLMnJexkgpLbPUanNOberU5taUMnHZUULMvelCtWF0sW/n 7MVMEiN64AsPD8/n83uucQDi/id/DBT4Dolypw/qsz0pTMbj/WHpiDgsdSUyUmeiPt2+V7SrIM+b Sss8ySGdR4abQQv6lrui6VxsRonrGCS9VEjSQ9E7CtiqdOZ4UuTqnBHO1X7YXl6Daa4yGq7vWO1D 40wVDtj4kWQbn94myPGkCDPdSesczE2sCZShwl8CzcwZ6NiUs6n2nYX99T1cnKqA2EKui6+TwphA 5k4yqMayopU5mANV3lNQTBdCMVUA9VQh3GuDMHiVcLCS3J4jSLhCGmKCjBEx0xlshjXYhApfMZRP 5CyYD+UkG08+xt+4wLVQZA1tzxthm2tEfD3JxARH7QkbD1ZuozaggdZbxK5kAIsf5qGaKMTY2lAU /rH5HW3PLsEwUYy+YCcERmIjJpDcpzb6l7th9KtQ69fi09ePUej9l7cx2DJbD7UrG3r3afQHOyCo +V3QQzE35pvQvnAZukk5zL5qRL59jsKbPzdheXoBZc4saFhBS6AO7V4zqCpiawuptwQG+UAa7Ct3 UT0hh9p9EnXT5Vh6t4C22QaUDh6HwnECOmcO7K+6kW49DKqS2DrEZCtfuI+9GrNHg4fMHVSO5kE7 nAPVkAxKBxcOzsajpS4Yh4ohUPPWKTUh3PaQEptIOr6BiJjcZXCwktaAGfrRIpwblqOV3YKdhfXO IvBLeREWpnd8ynsaSJoyESFphwTtfjN6X1jRO2+FxWtCWksqBApeiFIR9K6fiTpPiigDoadqCEag 5YUFKl6Yrciw0VOlhOivv/Ff8wtn0KzlebrUYwAAAABJRU5ErkJggg==""" ), ), "file2": ( "add.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLpZPrS5NhGIf9W7YvBYOkhlko qCklWChv2WyKik7blnNris72bi6dus0DLZ0TDxW1odtopDs4D8MDZuLU0kXq61CijSIIasOvv94V TUfLiB74fXngup7nvrnvJABJ/5PfLnTTdcwOj4RsdYmo5glBWP6iOtzwvIKSWstI0Wgx80SBblpK tE9KQs/We7EaWoT/8wbWP61gMmCH0lMDvokT4j25TiQU/ITFkek9Ow6+7WH2gwsmahCPdwyw75uw 9HEO2gUZSkfyI9zBPCJOoJ2SMmg46N61YO/rNoa39Xi41oFuXysMfh36/Fp0b7bAfWAH6RGi0Hgl WNCbzYgJaFjRv6zGuy+b9It96N3SQvNKiV9HvSaDfFEIxXItnPs23BzJQd6DDEVM0OKsoVwBG/1V MzpXVWhbkUM2K4oJBDYuGmbKIJ0qxsAbHfRLzbjcnUbFBIpx/qH3vQv9b3U03IQ/HfFkERTzfFj8 w8jSpR7GBE123uFEYAzaDRIqX/2JAtJbDat/COkd7CNBva2cMvq0MGxp0PRSCPF8BXjWG3FgNHc9 XPT71Ojy3sMFdfJRCeKxEsVtKwFHwALZfCUk3tIfNR8XiJwc1LmL4dg141JPKtj3WUdNFJqLGFVP C4OkR4BxajTWsChY64wmCnMxsWPCHcutKBxMVp5mxA1S+aMComToaqTRUQknLTH62kHOVEE+VQnj ahscNCy0cMBWsSI0TCQcZc5ALkEYckL5A5noWSBhfm2AecMAjbcRWV0pUTh0HE64TNf0mczcnnQy u/MilaFJCae1nw2fbz1DnVOxyGTlKeZft/Ff8x1BRssfACjTwQAAAABJRU5ErkJggg==""" ), ), }, "forms": {"text": u"--long text\r\n--with boundary\r\n--lookalikes--"}, } browser_test_cases["opera8-2png1txt"] = { "data": b64d( """ LS0tLS0tLS0tLS0tekVPOWpRS21MYzJDcTg4YzIzRHgxOQ0KQ29udGVudC1EaXNwb3NpdGlvbjog Zm9ybS1kYXRhOyBuYW1lPSJmaWxlMSI7IGZpbGVuYW1lPSJhcnJvd19icmFuY2gucG5nIg0KQ29u dGVudC1UeXBlOiBpbWFnZS9wbmcNCg0KiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9h AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHY SURBVDjLlVLPS1RxHJynpVu7KEn0Vt+2l6IO5qGCIsIwCPwD6hTUaSk6REoUHeoQ0qVAMrp0COpY 0SUIPVRgSl7ScCUTst6zIoqg0y7lvpnPt8MWKuuu29w+hxnmx8dzzmE5+l7mxk1u/a3Dd/ejDjSs II/m3vjJ9MF0yt93ZuTkdD0CnnMO/WOnmsxsJp3yd2zfvA3mHOa+zuHTjy/zojrvHX1YqunAZE9M lpUcZAaZQBNIZUg9XdPBP5wePuEO7eyGQXg29QL3jz3y1oqwbvkhCuYEOQMp/HeJohCbICMUVwr0 DvZcOnK9u7GmQNmBQLJCgORxkneqRmAs0BFmDi0bW9E72PPda/BikwWi0OEHkNR14MrewsTAZF+l AAWZEH6LUCwUkUlntrS1tiG5IYlEc6LcjYjSYuncngtdhakbM5dXlhgTNEMYLqB9q49MKgsPjTBX ntVgkDNIgmI1VY2Q7QzgJ9rx++ci3ofziBYiiELQEUAyhB/D29M3Zy+uIkDIhGYvgeKvIkbHxz6T evzq6ut+ANh9fldetMn80OzZVVdgLFjBQ0tpEz68jcB4ifx3pQeictVXIEETnBPCKMLEwBIZAPJD 767V/ETGwsjzYYiC6vzEP9asLo3SGuQvAAAAAElFTkSuQmCCDQotLS0tLS0tLS0tLS16RU85alFL bUxjMkNxODhjMjNEeDE5DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImZp bGUyIjsgZmlsZW5hbWU9ImF3YXJkX3N0YXJfYnJvbnplXzEucG5nIg0KQ29udGVudC1UeXBlOiBp bWFnZS9wbmcNCg0KiVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/I NwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLhZNNSFRR FIC/N++9eWMzhkl/ZJqFMQMRFvTvImkXSdKiVRAURBRRW1eZA9EqaNOiFlZEtQxKyrJwUS0K+qEQ zaTE/AtLHR3HmffuvafFNINDWGdz7z2c7+Nyzr2WiFAIffaMBDW1+B0diAgYgxiDiCDG4DU1QfcL os+fWAXGYUGIUsXiAliUFER+sBAhVCIIVB7QGtEat1oTbcwVz2LMfwR+gPg+oY0bEa3x6sHdUoVd niMUj0M2i/j+PwVJa2QUu7YWp34D7mqNWdNApD6Ks24dpvcL4gfJRQXevbutjI4lGRzCS9iYukPo 5dvxVqWQvn6k/2uyoudd60LGEhG43VBGyI4j2ADZ7vDJ8DZ9Img4hw4cvO/3UZ1vH3p7lrWRLwGV neD4y6G84NaOYSoTVYIFIiAGvXI3OWctJv0TW03jZb5gZSfzl9YBpMcIzUwdzQsuVR9EyR3TeCqm 6w5jZiZQMz8xsxOYzDTi50AMVngJNgrnUweRbwMPiLpHrOJDOl9Vh6HD7GyO52qa0VPj6MwUJpNC 5mYQS/DUJLH3zzRp1cqN8YulTUyODBBzt4X6Ou870z2I8ZHsHJLLYNQ8jusQ6+2exJf9BfivKdAy mKZiaVdodhBRAagAjIbgzxp20lwb6Vp0jADYkQO6IpHfuoqInSJUVoE2HrpyRQ1tic2LC9p3lSHW Ph2rJfL1MeVP2weWvHp8s3ziNZ49i1q6HrR1YHGBNnt1dG2Z++gC4TdvrqNkK1eHj7ljQ/ujHx6N yPw8BFIiKPmNpKar7P7xb/zyT9P+o7OYvzzYSUt8U+TzxytodixEfgN3CFlQMNAcMgAAAABJRU5E rkJggg0KLS0tLS0tLS0tLS0tekVPOWpRS21MYzJDcTg4YzIzRHgxOQ0KQ29udGVudC1EaXNwb3Np dGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ0ZXh0Ig0KDQpibGFmYXNlbCDDtsOkw7wNCi0tLS0tLS0t LS0tLXpFTzlqUUttTGMyQ3E4OGMyM0R4MTktLQ0K""" ), "boundary": "----------zEO9jQKmLc2Cq88c23Dx19", "files": { "file1": ( "arrow_branch.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHYSURBVDjLlVLPS1RxHJynpVu7KEn0Vt+2 l6IO5qGCIsIwCPwD6hTUaSk6REoUHeoQ0qVAMrp0COpY0SUIPVRgSl7ScCUTst6zIoqg0y7lvpnP t8MWKuuu29w+hxnmx8dzzmE5+l7mxk1u/a3Dd/ejDjSsII/m3vjJ9MF0yt93ZuTkdD0CnnMO/WOn msxsJp3yd2zfvA3mHOa+zuHTjy/zojrvHX1YqunAZE9MlpUcZAaZQBNIZUg9XdPBP5wePuEO7eyG QXg29QL3jz3y1oqwbvkhCuYEOQMp/HeJohCbICMUVwr0DvZcOnK9u7GmQNmBQLJCgORxkneqRmAs 0BFmDi0bW9E72PPda/BikwWi0OEHkNR14MrewsTAZF+lAAWZEH6LUCwUkUlntrS1tiG5IYlEc6Lc jYjSYuncngtdhakbM5dXlhgTNEMYLqB9q49MKgsPjTBXntVgkDNIgmI1VY2Q7QzgJ9rx++ci3ofz iBYiiELQEUAyhB/D29M3Zy+uIkDIhGYvgeKvIkbHxz6Tevzq6ut+ANh9fldetMn80OzZVVdgLFjB Q0tpEz68jcB4ifx3pQeictVXIEETnBPCKMLEwBIZAPJD767V/ETGwsjzYYiC6vzEP9asLo3SGuQv AAAAAElFTkSuQmCC""" ), ), "file2": ( "award_star_bronze_1.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLhZNNSFRRFIC/N++9eWMzhkl/ ZJqFMQMRFvTvImkXSdKiVRAURBRRW1eZA9EqaNOiFlZEtQxKyrJwUS0K+qEQzaTE/AtLHR3Hmffu vafFNINDWGdz7z2c7+Nyzr2WiFAIffaMBDW1+B0diAgYgxiDiCDG4DU1QfcLos+fWAXGYUGIUsXi AliUFER+sBAhVCIIVB7QGtEat1oTbcwVz2LMfwR+gPg+oY0bEa3x6sHdUoVdniMUj0M2i/j+PwVJ a2QUu7YWp34D7mqNWdNApD6Ks24dpvcL4gfJRQXevbutjI4lGRzCS9iYukPo5dvxVqWQvn6k/2uy oudd60LGEhG43VBGyI4j2ADZ7vDJ8DZ9Img4hw4cvO/3UZ1vH3p7lrWRLwGVneD4y6G84NaOYSoT VYIFIiAGvXI3OWctJv0TW03jZb5gZSfzl9YBpMcIzUwdzQsuVR9EyR3TeCqm6w5jZiZQMz8xsxOY zDTi50AMVngJNgrnUweRbwMPiLpHrOJDOl9Vh6HD7GyO52qa0VPj6MwUJpNC5mYQS/DUJLH3zzRp 1cqN8YulTUyODBBzt4X6Ou870z2I8ZHsHJLLYNQ8jusQ6+2exJf9BfivKdAymKZiaVdodhBRAagA jIbgzxp20lwb6Vp0jADYkQO6IpHfuoqInSJUVoE2HrpyRQ1tic2LC9p3lSHWPh2rJfL1MeVP2weW vHp8s3ziNZ49i1q6HrR1YHGBNnt1dG2Z++gC4TdvrqNkK1eHj7ljQ/ujHx6NyPw8BFIiKPmNpKar 7P7xb/zyT9P+o7OYvzzYSUt8U+TzxytodixEfgN3CFlQMNAcMgAAAABJRU5ErkJggg==""" ), ), }, "forms": {"text": u"blafasel öäü"}, } browser_test_cases["webkit3-2png1txt"] = { "data": b64d( """ LS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5amRTRmhjQVJrOGZ5R055Ng0KQ29udGVudC1EaXNwb3Np dGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlMSI7IGZpbGVuYW1lPSJndGstYXBwbHkucG5nIg0K Q29udGVudC1UeXBlOiBpbWFnZS9wbmcNCg0KiVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACN iR0NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUA d3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANnSURBVDiNldJ9aJVVHAfw7znPuS/PvW4405WbLWfbsBuN bramq5Tp7mLqIFPXINlwpAitaCAPjWKgBdXzR2TBpEZoadAyCVGndttCFNxqLXORK7x3y704NlzX zfs8d89znuf0R/fKk03xHvjCOZxzPpzzO4cIIZBuC6nsGYmRrwFMWVw0hxV+PDVH0gVDKvNSRgZf rm5+QCISOi58pY1MXhm1uHg+rPDfabqnoxJpKQ2snf/gwgKY3ut4pfodX/lTGwokRt4AgLTAkMoK 3cz7enVJg/fyTCdGE/3gwsTo+LBu2+J82qDE6IEXyrd7YvYwbpgjyPOtQHTikvhz+NKgsNGWFhhS WU3uwqWPBx9aRwfjPTCFgXx5JY50tumWKbaFFS7uGQypLINKZH/tukb/kN6DSSOCFfO3oqu/3biZ iH0ZVvjF1Np7AiVG31sdXO/P8GfhqtaLbE8BqOlBZ++xuMXFbudaljxBDnNJHbZlFwF407bFh6kr hFRW7Jcztlc9Uee5HD+DaWsCTy/YgbaOvZpl2Y1hhU87QVLxvpQpMfpzfeXuZfmLA/Rw1wdaZOS3 Pm7aNQDGJUZ/qatqKs5etIj03TiKQv8aaFOWOHRm30+nm4zS229DmVs6Ulm6OW/50iD9G1Hsqnrb t2lNwyoXYwMAPnk4N1D4aO4qEtW6wagHeZ4SfNP1mW6Zdt1c5WEE8Lll5qKCQbdiGIh/h+JlK6Wi xcHM4z2fb9tUtkOO6hdw3Yzi2axdON33xaxuzLSGFf7HXCA1Dav+5Nn2Kyd7DyYK5bXw0QWIJM4j 7rqGmvKd8gwZw5D+I3K8jyGhmzj366lpi4uWOz0gEUIgpDKPxGjr/VlLanZubJknXLMYiH8Pjccw K26C27Oouu8tfHysWbs6HnkxrPATdwVTLaSyzW63+8BLzzX6H1lSSrtjBzFpRPBkZi0mrk3Z7Z2t P5xqMiruhP0PTKL5EqMnSgKr87eUvSqPGf3Ipsux53CDpie0QFjhf90NhBDiVlJ1LaqmcqXq2l/7 aU7826E94rWjQb3iXbYXgAzAC8ADwI1//zF1OkQIAUIIBSAlc6tfpkjr52XTj4SFi937eP3MmDAB 2I5YyaT63AmyuVDHmAAQt0FOzARg/aeGhBCS3EjnCBygMwKAnXL+AdDkiZ/xYgR3AAAAAElFTkSu QmCCDQotLS0tLS1XZWJLaXRGb3JtQm91bmRhcnlqZFNGaGNBUms4ZnlHTnk2DQpDb250ZW50LURp c3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImZpbGUyIjsgZmlsZW5hbWU9Imd0ay1uby5wbmci DQpDb250ZW50LVR5cGU6IGltYWdlL3BuZw0KDQqJUE5HDQoaCgAAAA1JSERSAAAAFAAAABQIBgAA AI2JHQ0AAAAEc0JJVAgICAh8CGSIAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAGXRFWHRTb2Z0d2Fy ZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAzVJREFUOI2tlM9rG0cUxz8zu7OzsqhtyTIONDG2g9ue UnIwFEqCwYUeTC+99u5T/4FAKKUEeuh/4FPvOZXiWw3GpRRcGjW0h1KwLLe4juOspJUlS95frwft CkdJbh347o95bz+8mfedVSLC/zncNwUeKnVfw4YD6yncBXCgnsJeBruPRPZf952arPCBUhUL216p tLm0vGxmq1X3rbk5AC6CgE67nTQbjTgaDHauYOtrkfYbgV8o9SHw/crKytR7d+5YDXhzc2hjEBGy OCZutciU4s+nT68ajcYl8MlXIj+9AnygVMXA4draWqVWqaBLJcz09ChLBBGBXHEYImlK0G5zcHDQ juF2UakuyBa2l27dmqqWywxOTpAkIWq1iILgFWVxzOXREZVymaXFxSkL2wVHFw0w1m6urq7asF7H sZa01SINAiQIyIp7q0XaapEEAcp1CZ884Z3VVWus3Xyo1P1xlzVsvL2wYJLTUwhDdBiiHAedL1EV +yxCJoJkGTpJkDAkOj3l5o0b5vD4eAPYd3M7rM+WSq7qdLCAOjtD+z46y1DXgJkIZNmIHUWj3E6H melp14H1cYUZ3J31fZyTE1zA7fVw+n0cERSg8v2RUS5pPqeArNtlZmGBwqtjY+skwYig80lXBCff 5OvANFeSxzIRojge5+j8Uu9dXOD5Pt6o41jAz1W69uznMQ8wgOf79LpdNNTHwBT22r1ebDwPt0h8 DbQAFTADGGvp9PtxCntjYAa7zW43wVpca3HyZZsJaAF0C/k+4vs0wzDJYHcMfCSyHyfJzq/n50NT raKVwhl1H3cCpAsphVut8tvz58M4SXaKn8X4pFzB1lG/P2gOBuhaDYxBJhqR5e8Yg56f53gwoNHr Da9gq+CMz7JSauoz+HgFvr1trX+vXPZKUYSbJCMTA+K6xMYw8Dx+7Pfjw+Fw+Dt8/h38ALwQkeg6 cAaoLcLyp/BlVam1dz3PWdDaqbkjdwVpymmaZn9FUXouUn8M3zyDJvAC+PclYA6dBmpA5SO4dxM+ mIf3fVgCGMLfz+CPf+CXPfgZCIFz4ExEkpeWfH0opZzcKYUsI38nIy5D4BK4kgnAfwLblOaQdQsS AAAAAElFTkSuQmCCDQotLS0tLS1XZWJLaXRGb3JtQm91bmRhcnlqZFNGaGNBUms4ZnlHTnk2DQpD b250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9InRleHQiDQoNCnRoaXMgaXMgYW5v dGhlciB0ZXh0IHdpdGggw7xtbMOkw7x0cw0KLS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5amRTRmhj QVJrOGZ5R055Ni0tDQo=""" ), "boundary": "----WebKitFormBoundaryjdSFhcARk8fyGNy6", "files": { "file1": ( "gtk-apply.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANnSURB VDiNldJ9aJVVHAfw7znPuS/PvW4405WbLWfbsBuNbramq5Tp7mLqIFPXINlwpAitaCAPjWKgBdXz R2TBpEZoadAyCVGndttCFNxqLXORK7x3y704NlzXzfs8d89znuf0R/fKk03xHvjCOZxzPpzzO4cI IZBuC6nsGYmRrwFMWVw0hxV+PDVH0gVDKvNSRgZfrm5+QCISOi58pY1MXhm1uHg+rPDfabqnoxJp KQ2snf/gwgKY3ut4pfodX/lTGwokRt4AgLTAkMoK3cz7enVJg/fyTCdGE/3gwsTo+LBu2+J82qDE 6IEXyrd7YvYwbpgjyPOtQHTikvhz+NKgsNGWFhhSWU3uwqWPBx9aRwfjPTCFgXx5JY50tumWKbaF FS7uGQypLINKZH/tukb/kN6DSSOCFfO3oqu/3biZiH0ZVvjF1Np7AiVG31sdXO/P8GfhqtaLbE8B qOlBZ++xuMXFbudaljxBDnNJHbZlFwF407bFh6krhFRW7Jcztlc9Uee5HD+DaWsCTy/YgbaOvZpl 2Y1hhU87QVLxvpQpMfpzfeXuZfmLA/Rw1wdaZOS3Pm7aNQDGJUZ/qatqKs5etIj03TiKQv8aaFOW OHRm30+nm4zS229DmVs6Ulm6OW/50iD9G1Hsqnrbt2lNwyoXYwMAPnk4N1D4aO4qEtW6wagHeZ4S fNP1mW6Zdt1c5WEE8Lll5qKCQbdiGIh/h+JlK6WixcHM4z2fb9tUtkOO6hdw3Yzi2axdON33xaxu zLSGFf7HXCA1Dav+5Nn2Kyd7DyYK5bXw0QWIJM4j7rqGmvKd8gwZw5D+I3K8jyGhmzj366lpi4uW Oz0gEUIgpDKPxGjr/VlLanZubJknXLMYiH8PjccwK26C27Oouu8tfHysWbs6HnkxrPATdwVTLaSy zW63+8BLzzX6H1lSSrtjBzFpRPBkZi0mrk3Z7Z2tP5xqMiruhP0PTKL5EqMnSgKr87eUvSqPGf3I psux53CDpie0QFjhf90NhBDiVlJ1LaqmcqXq2l/7aU7826E94rWjQb3iXbYXgAzAC8ADwI1//zF1 OkQIAUIIBSAlc6tfpkjr52XTj4SFi937eP3MmDAB2I5YyaT63AmyuVDHmAAQt0FOzARg/aeGhBCS 3EjnCBygMwKAnXL+AdDkiZ/xYgR3AAAAAElFTkSuQmCC""" ), ), "file2": ( "gtk-no.png", "image/png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAM1SURB VDiNrZTPaxtHFMc/M7uzs7KobckyDjQxtoPbnlJyMBRKgsGFHkwvvfbuU/+BQCilBHrof+BT7zmV 4lsNxqUUXBo1tIdSsCy3uI7jrKSVJUveX68H7QpHSW4d+O6PeW8/vJn3nVUiwv853DcFHip1X8OG A+sp3AVwoJ7CXga7j0T2X/edmqzwgVIVC9teqbS5tLxsZqtV9625OQAugoBOu500G404Ggx2rmDr a5H2G4FfKPUh8P3KysrUe3fuWA14c3NoYxARsjgmbrXIlOLPp0+vGo3GJfDJVyI/vQJ8oFTFwOHa 2lqlVqmgSyXM9PQoSwQRgVxxGCJpStBuc3Bw0I7hdlGpLsgWtpdu3ZqqlssMTk6QJCFqtYiC4BVl cczl0RGVcpmlxcUpC9sFRxcNMNZurq6u2rBex7GWtNUiDQIkCMiKe6tF2mqRBAHKdQmfPOGd1VVr rN18qNT9cZc1bLy9sGCS01MIQ3QYohwHnS9RFfssQiaCZBk6SZAwJDo95eaNG+bw+HgD2HdzO6zP lkqu6nSwgDo7Q/s+OstQ14CZCGTZiB1Fo9xOh5npadeB9XGFGdyd9X2ckxNcwO31cPp9HBEUoPL9 kVEuaT6ngKzbZWZhgcKrY2PrJMGIoPNJVwQn3+TrwDRXkscyEaI4Hufo/FLvXVzg+T7eqONYwM9V uvbs5zEPMIDn+/S6XTTUx8AU9tq9Xmw8D7dIfA20ABUwAxhr6fT7cQp7Y2AGu81uN8FaXGtx8mWb CWgBdAv5PuL7NMMwyWB3DHwksh8nyc6v5+dDU62ilcIZdR93AqQLKYVbrfLb8+fDOEl2ip/F+KRc wdZRvz9oDgboWg2MQSYakeXvGIOen+d4MKDR6w2vYKvgjM+yUmrqM/h4Bb69ba1/r1z2SlGEmyQj EwPiusTGMPA8fuz348PhcPg7fP4d/AC8EJHoOnAGqC3C8qfwZVWptXc9z1nQ2qm5I3cFacppmmZ/ RVF6LlJ/DN88gybwAvj3JWAOnQZqQOUjuHcTPpiH931YAhjC38/gj3/glz34GQiBc+BMRJKXlnx9 KKWc3CmFLCN/JyMuQ+ASuJIJwH8C25TmkHULEgAAAABJRU5ErkJggg==""" ), ), }, "forms": {"text": u"this is another text with ümläüts"}, } browser_test_cases["ie6-2png1txt"] = { "data": b64d( """ LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS03ZDkxYjAzYTIwMTI4DQpDb250ZW50LURpc3Bv c2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImZpbGUxIjsgZmlsZW5hbWU9IkM6XFB5dGhvbjI1XHd6 dGVzdFx3ZXJremV1Zy1tYWluXHRlc3RzXG11bHRpcGFydFxmaXJlZm94My0ycG5nMXR4dFxmaWxl MS5wbmciDQpDb250ZW50LVR5cGU6IGltYWdlL3gtcG5nDQoNColQTkcNChoKAAAADUlIRFIAAAAQ AAAAEAgGAAAAH/P/YQAAAARnQU1BAACvyDcFiukAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdl UmVhZHlxyWU8AAABnUlEQVQ4y6VTMWvCQBS+qwEFB10KGaS1P6FDpw7SrVvzAwRRx04VCk4K6iAo DhLXdhFcW9qhZCk4FQoW0gp2U4lQRDAUS4hJmn5Xgg2lsQ198PHu3b3vu5d3L9S2bfIf47wOer1e wzTNtGEYBP48kUjkfsrb8BIAMb1cLovwRfi07wrYzcCr4/1/Am4FzzhzBGZeefR7E7vd7j0Iu4wY jUYDBMfD0dBiMUQfstns3toKkHgF6EgmqqruW6bFiHcsxr70awVu63Q6NiOmUinquwfMdF1f28CV gCRJx0jMAQ1BEFquRn7CbYVCYZVbr9dbnJMohoIh9kViu90WEW9nMpmxu4JyubyF/VEsFiNcgCPy oyxiu7XhCPBzdU4s652VnUccbDabPLyN2C6VSmwdhFgel5DB84AJb64mEUlvmqadTKcv40gkUkUs g1DjeZ7iRsrWgByP71T7/afxYrHIYry/eoBD9mxsaK4VRamFw2EBQknMAWGvRClNTpQJAfkCxFNg Bmiez1ipVA4hdgQcOD/TLfylKIo3vubgL/YBnIw+ioOMLtwAAAAASUVORK5CYIINCi0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tN2Q5MWIwM2EyMDEyOA0KQ29udGVudC1EaXNwb3NpdGlvbjog Zm9ybS1kYXRhOyBuYW1lPSJmaWxlMiI7IGZpbGVuYW1lPSJDOlxQeXRob24yNVx3enRlc3Rcd2Vy a3pldWctbWFpblx0ZXN0c1xtdWx0aXBhcnRcZmlyZWZveDMtMnBuZzF0eHRcZmlsZTIucG5nIg0K Q29udGVudC1UeXBlOiBpbWFnZS94LXBuZw0KDQqJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAA AB/z/2EAAAAEZ0FNQQAAr8g3BYrpAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccll PAAAAlFJREFUGBmlwd1rzXEcwPH353d+51jO5jDZFpnnJNaiUSK5mkJKMYkUSS1RSvwDpnFBkYeY O2p2sZRceCh5mpKnUXZssVaO2Q4Hw9nO+Z3v52O/ldoFF8vrJWbG/5CNB67uXbm65lgma3EzQBVT xanD1FBTzDnUDHMOp8qEWPCroyN1uPVE3Rm/ZkXNqWhR3CsvYiziv7LuFHDGzwbmZTM/GavBwDyG +eaMhm1zGavdjT2EfDMllC84DDA1nIJiqBpOFVcwXMEIPt8l+/wykeIq9pXd49XZ/Tt8zAiJJ4gZ 5gkmhqjgeYKIh4hDM9eJ9j6lomo7iVmL+dY9n+StpuO+U0fIA0wEBCIGKqBqRAwK6dvEcm+Iz1tB 5l0HMclTMqGC4smVCd/UGCECZniAiYCACOT77yM/npCYvYZcbzOx8ULPyyQDWZBcptpTdfwhIiBC yANy6fsUvtwmMWctQx8vItGvRItLiFuGK6nlLN3X2ukVgoARIogIIRGhL3md7IebJOZuYCh1Di8a kB+YSfphO1NqG/g4OJGQZ04JRQABRIT+5A1+pNooW7iO/KcmIjEjNzCD9KMXVGw6T1H5AkyVkK+q /CFAV1szhe+vKchUel+fZlJZjKHMdL49S1K55QLRxDRCakbIT3X3tNSfDOrUOdQptdLE5vpLvG0+ SOeDNsZVVvO9L8WNoa30NTzGVFEl1MIwMTNGO7JnUXBoV72P53h55xo93V0/E1NKV9YebW/nL8TM GK1uVengktnl/rIFs7Borm2wP71zfeOr9/zDb6ZFKM6WU+GQAAAAAElFTkSuQmCCDQotLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLTdkOTFiMDNhMjAxMjgNCkNvbnRlbnQtRGlzcG9zaXRpb246 IGZvcm0tZGF0YTsgbmFtZT0idGV4dCINCg0KaWU2IHN1Y2tzIDotLw0KLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS03ZDkxYjAzYTIwMTI4LS0NCg==""" ), "boundary": "---------------------------7d91b03a20128", "files": { "file1": ( "file1.png", "image/x-png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGdSURBVDjLpVMxa8JAFL6rAQUHXQoZpLU/ oUOnDtKtW/MDBFHHThUKTgrqICgOEtd2EVxb2qFkKTgVChbSCnZTiVBEMBRLiEmafleCDaWxDX3w 8e7dve+7l3cv1LZt8h/jvA56vV7DNM20YRgE/jyRSOR+ytvwEgAxvVwui/BF+LTvCtjNwKvj/X8C bgXPOHMEZl559HsTu93uPQi7jBiNRgMEx8PR0GIxRB+y2eze2gqQeAXoSCaqqu5bpsWIdyzGvvRr BW7rdDo2I6ZSKeq7B8x0XV/bwJWAJEnHSMwBDUEQWq5GfsJthUJhlVuv11uckyiGgiH2RWK73RYR b2cymbG7gnK5vIX9USwWI1yAI/KjLGK7teEI8HN1TizrnZWdRxxsNps8vI3YLpVKbB2EWB6XkMHz gAlvriYRSW+app1Mpy/jSCRSRSyDUON5nuJGytaAHI/vVPv9p/FischivL96gEP2bGxorhVFqYXD YQFCScwBYa9EKU1OlAkB+QLEU2AGaJ7PWKlUDiF2BBw4P9Mt/KUoije+5uAv9gGcjD6Kg4wu3AAA AABJRU5ErkJggg==""" ), ), "file2": ( "file2.png", "image/x-png", b64d( """ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0 U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJRSURBVBgZpcHda81xHMDx9+d3fudYzuYw 2RaZ5yTWolEiuZpCSjGJFEktUUr8A6ZxQZGHmDtqdrGUXHgoeZqSp1F2bLFWjtkOB8PZzvmd7+dj v5XaBRfL6yVmxv+QjQeu7l25uuZYJmtxM0AVU8Wpw9RQU8w51AxzDqfKhFjwq6Mjdbj1RN0Zv2ZF zaloUdwrL2Is4r+y7hRwxs8G5mUzPxmrwcA8hvnmjIZtcxmr3Y09hHwzJZQvOAwwNZyCYqgaThVX MFzBCD7fJfv8MpHiKvaV3ePV2f07fMwIiSeIGeYJJoao4HmCiIeIQzPXifY+paJqO4lZi/nWPZ/k rabjvlNHyANMBAQiBiqgakQMCunbxHJviM9bQeZdBzHJUzKhguLJlQnf1BghAmZ4gImAgAjk++8j P56QmL2GXG8zsfFCz8skA1mQXKbaU3X8ISIgQsgDcun7FL7cJjFnLUMfLyLRr0SLS4hbhiup5Szd 19rpFYKAESKICCERoS95neyHmyTmbmAodQ4vGpAfmEn6YTtTahv4ODiRkGdOCUUAAUSE/uQNfqTa KFu4jvynJiIxIzcwg/SjF1RsOk9R+QJMlZCvqvwhQFdbM4XvrynIVHpfn2ZSWYyhzHS+PUtSueUC 0cQ0QmpGyE9197TUnwzq1DnUKbXSxOb6S7xtPkjngzbGVVbzvS/FjaGt9DU8xlRRJdTCMDEzRjuy Z1FwaFe9j+d4eecaPd1dPxNTSlfWHm1v5y/EzBitblXp4JLZ5f6yBbOwaK5tsD+9c33jq/f8w2+m RSjOllPhkAAAAABJRU5ErkJggg==""" ), ), }, "forms": {"text": u"ie6 sucks :-/"}, } class TestWerkzeugExamples(BaseMultipartTest): def test_werkzeug_examples(self): """Tests multipart parsing against data collected from webbrowsers""" for name in browser_test_cases: self.reset() self.data = BytesIO(browser_test_cases[name]['data']) boundary = browser_test_cases[name]['boundary'] files = browser_test_cases[name]['files'] forms = browser_test_cases[name]['forms'] self.parse('multipart/form-data; boundary=%s'%boundary, clen=-1) for name, file in files.items(): self.assertFile(name, file[0], file[1], file[2]) for name, form in forms.items(): self.assertForm(name, form) python-bottle-0.13.2/test/test_oorouting.py000066400000000000000000000016731470367422500210430ustar00rootroot00000000000000""" Tests & demonstrates various OO approaches to routes """ import unittest import sys if sys.version_info >= (3, 0, 0): from io import BytesIO else: from StringIO import StringIO as BytesIO __author__ = 'atc' from bottle import Bottle, request, tob, BaseRequest class TestRouter(object): """ A test class for wrapping routes to test certain OO scenarios """ app = Bottle() @app.post("/route1/") def route_1(self, msg): body = request.body.readline() return {'msg': msg, 'len': len(body)} class TestRoutes(unittest.TestCase): def test_route1(self): body = "abc" request.environ['CONTENT_LENGTH'] = str(len(tob(body))) request.environ['wsgi.input'] = BytesIO() request.environ['wsgi.input'].write(tob(body)) request.environ['wsgi.input'].seek(0) result = TestRouter().route_1("bob") self.assertEqual(result, dict(msg="bob", len=3)) python-bottle-0.13.2/test/test_outputfilter.py000077500000000000000000000142321470367422500215620ustar00rootroot00000000000000# -*- coding: utf-8 -*- '''Everything returned by Bottle()._cast() MUST be WSGI compatiple.''' import unittest import bottle from bottle import tob, touni from .tools import ServerTestBase, tobs, warn USING_UJSON = True try: import ujson except ImportError: USING_UJSON = False class TestOutputFilter(ServerTestBase): ''' Tests for WSGI functionality, routing and output casting (decorators) ''' def test_bytes(self): self.app.route('/')(lambda: tob('test')) self.assertBody('test') def test_bytearray(self): self.app.route('/')(lambda: map(tob, ['t', 'e', 'st'])) self.assertBody('test') def test_tuple(self): self.app.route('/')(lambda: ('t', 'e', 'st')) self.assertBody('test') def test_emptylist(self): self.app.route('/')(lambda: []) self.assertBody('') def test_none(self): self.app.route('/')(lambda: None) self.assertBody('') def test_illegal(self): self.app.route('/')(lambda: 1234) self.assertStatus(500) self.assertInBody('Unhandled exception') def test_error(self): bottle.debug(True) self.app.route('/')(lambda: 1/0) self.assertStatus(500) self.assertInBody('ZeroDivisionError') def test_fatal_error(self): @self.app.route('/') def test(): raise KeyboardInterrupt() self.assertRaises(KeyboardInterrupt, self.assertStatus, 500) def test_file(self): self.app.route('/')(lambda: tobs('test')) self.assertBody('test') def test_unicode(self): self.app.route('/')(lambda: touni('äöüß')) self.assertBody(touni('äöüß').encode('utf8')) self.app.route('/')(lambda: [touni('äö'), touni('üß')]) self.assertBody(touni('äöüß').encode('utf8')) @self.app.route('/') def test5(): bottle.response.content_type='text/html; charset=iso-8859-15' return touni('äöüß') self.assertBody(touni('äöüß').encode('iso-8859-15')) @self.app.route('/') def test5(): bottle.response.content_type='text/html' return touni('äöüß') self.assertBody(touni('äöüß').encode('utf8')) def test_json(self): self.app.route('/')(lambda: {'a': 1}) self.assertBody(bottle.json_dumps({'a': 1})) self.assertHeader('Content-Type','application/json') @unittest.skipIf(USING_UJSON, 'ujson do not throw exception in serialize') def test_json_serialization_error(self): """ Verify that 500 errors serializing dictionaries don't return content-type application/json """ self.app.route('/')(lambda: {'a': set()}) self.assertStatus(500) self.assertHeader('Content-Type','text/html; charset=UTF-8') def test_json_HTTPResponse(self): self.app.route('/')(lambda: bottle.HTTPResponse({'a': 1}, 500)) self.assertBody(bottle.json_dumps({'a': 1})) self.assertHeader('Content-Type','application/json') def test_json_HTTPError(self): self.app.error(400)(lambda e: e.body) self.app.route('/')(lambda: bottle.HTTPError(400, {'a': 1})) self.assertBody(bottle.json_dumps({'a': 1})) self.assertHeader('Content-Type','application/json') def test_generator_callback(self): @self.app.route('/') def test(): bottle.response.headers['Test-Header'] = 'test' yield 'foo' self.assertBody('foo') self.assertHeader('Test-Header', 'test') def test_empty_generator_callback(self): @self.app.route('/') def test(): yield bottle.response.headers['Test-Header'] = 'test' self.assertBody('') self.assertHeader('Test-Header', 'test') def test_error_in_generator_callback(self): @self.app.route('/') def test(): yield 1/0 self.assertStatus(500) self.assertInBody('ZeroDivisionError') def test_fatal_error_in_generator_callback(self): @self.app.route('/') def test(): yield raise KeyboardInterrupt() self.assertRaises(KeyboardInterrupt, self.assertStatus, 500) def test_httperror_in_generator_callback(self): @self.app.route('/') def test(): yield bottle.abort(404, 'teststring') self.assertInBody('teststring') self.assertInBody('404 Not Found') self.assertStatus(404) def test_httpresponse_in_generator_callback(self): @self.app.route('/') def test(): yield bottle.HTTPResponse('test') self.assertBody('test') def test_unicode_generator_callback(self): @self.app.route('/') def test(): yield touni('äöüß') self.assertBody(touni('äöüß').encode('utf8')) def test_invalid_generator_callback(self): @self.app.route('/') def test(): yield 1234 self.assertStatus(500) self.assertInBody('Unsupported response type') def test_iterator_with_close(self): class MyIter(object): def __init__(self, data): self.data = data self.closed = False def close(self): self.closed = True def __iter__(self): return iter(self.data) byte_iter = MyIter([tob('abc'), tob('def')]) unicode_iter = MyIter([touni('abc'), touni('def')]) for test_iter in (byte_iter, unicode_iter): @self.app.route('/') def test(): return test_iter self.assertInBody('abcdef') self.assertTrue(byte_iter.closed) def test_cookie(self): """ WSGI: Cookies """ @bottle.route('/cookie') def test(): bottle.response.set_cookie('b', 'b') bottle.response.set_cookie('c', 'c', path='/') return 'hello' try: c = self.urlopen('/cookie')['header'].get_all('Set-Cookie', '') except: c = self.urlopen('/cookie')['header'].get('Set-Cookie', '').split(',') c = [x.strip() for x in c] self.assertTrue('b=b' in c) self.assertTrue('c=c; Path=/' in c) python-bottle-0.13.2/test/test_plugins.py000066400000000000000000000165461470367422500205040ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest from . import tools from bottle import HTTPResponse, HTTPError, json_dumps class MyPlugin(object): def __init__(self): self.app = None self.add_args = {} self.add_content = '' def setup(self, app): self.app = app def apply(self, func, config): def wrapper(*a, **ka): ka.update(self.add_args) self.lastcall = func, a, ka return ''.join(func(*a, **ka)) + self.add_content return wrapper def my_decorator(func): def wrapper(*a, **ka): return list(func(*a, **ka))[-1] class TestPluginManagement(tools.ServerTestBase): def verify_installed(self, plugin, otype, **config): self.assertEqual(type(plugin), otype) self.assertEqual(plugin.config, config) self.assertEqual(plugin.app, self.app) self.assertTrue(plugin in self.app.plugins) def test_install_plugin(self): plugin = MyPlugin() installed = self.app.install(plugin) self.assertEqual(plugin, installed) self.assertTrue(plugin in self.app.plugins) def test_install_decorator(self): installed = self.app.install(my_decorator) self.assertEqual(my_decorator, installed) self.assertTrue(my_decorator in self.app.plugins) def test_install_non_plugin(self): self.assertRaises(TypeError, self.app.install, 'I am not a plugin') def test_uninstall_by_instance(self): plugin = self.app.install(MyPlugin()) plugin2 = self.app.install(MyPlugin()) self.app.uninstall(plugin) self.assertTrue(plugin not in self.app.plugins) self.assertTrue(plugin2 in self.app.plugins) def test_uninstall_by_type(self): plugin = self.app.install(MyPlugin()) plugin2 = self.app.install(MyPlugin()) self.app.uninstall(MyPlugin) self.assertTrue(plugin not in self.app.plugins) self.assertTrue(plugin2 not in self.app.plugins) def test_uninstall_by_name(self): plugin = self.app.install(MyPlugin()) plugin2 = self.app.install(MyPlugin()) plugin.name = 'myplugin' self.app.uninstall('myplugin') self.assertTrue(plugin not in self.app.plugins) self.assertTrue(plugin2 in self.app.plugins) def test_uninstall_all(self): plugin = self.app.install(MyPlugin()) plugin2 = self.app.install(MyPlugin()) self.app.uninstall(True) self.assertFalse(self.app.plugins) def test_route_plugin(self): plugin = MyPlugin() plugin.add_content = ';foo' @self.app.route('/a') @self.app.route('/b', apply=[plugin]) def a(): return 'plugin' self.assertBody('plugin', '/a') self.assertBody('plugin;foo', '/b') def test_plugin_oder(self): self.app.install(MyPlugin()).add_content = ';global-1' self.app.install(MyPlugin()).add_content = ';global-2' l1 = MyPlugin() l1.add_content = ';local-1' l2 = MyPlugin() l2.add_content = ';local-2' @self.app.route('/a') @self.app.route('/b', apply=[l1, l2]) def a(): return 'plugin' self.assertBody('plugin;global-2;global-1', '/a') self.assertBody('plugin;local-2;local-1;global-2;global-1', '/b') def test_skip_by_instance(self): g1 = self.app.install(MyPlugin()) g1.add_content = ';global-1' g2 = self.app.install(MyPlugin()) g2.add_content = ';global-2' l1 = MyPlugin() l1.add_content = ';local-1' l2 = MyPlugin() l2.add_content = ';local-2' @self.app.route('/a', skip=[g2, l2]) @self.app.route('/b', apply=[l1, l2], skip=[g2, l2]) def a(): return 'plugin' self.assertBody('plugin;global-1', '/a') self.assertBody('plugin;local-1;global-1', '/b') def test_skip_by_class(self): g1 = self.app.install(MyPlugin()) g1.add_content = ';global-1' @self.app.route('/a') @self.app.route('/b', skip=[MyPlugin]) def a(): return 'plugin' self.assertBody('plugin;global-1', '/a') self.assertBody('plugin', '/b') def test_skip_by_name(self): g1 = self.app.install(MyPlugin()) g1.add_content = ';global-1' g1.name = 'test' @self.app.route('/a') @self.app.route('/b', skip=['test']) def a(): return 'plugin' self.assertBody('plugin;global-1', '/a') self.assertBody('plugin', '/b') def test_skip_all(self): g1 = self.app.install(MyPlugin()) g1.add_content = ';global-1' @self.app.route('/a') @self.app.route('/b', skip=[True]) def a(): return 'plugin' self.assertBody('plugin;global-1', '/a') self.assertBody('plugin', '/b') def test_skip_nonlist(self): g1 = self.app.install(MyPlugin()) g1.add_content = ';global-1' @self.app.route('/a') @self.app.route('/b', skip=g1) def a(): return 'plugin' self.assertBody('plugin;global-1', '/a') self.assertBody('plugin', '/b') def test_json_plugin_catches_httpresponse(self): @self.app.get('/return') def _(): return HTTPResponse({'test': 'ko'}, 402) @self.app.get('/raise') def _(): raise HTTPResponse({'test': 'ko2'}, 402) self.assertBody(json_dumps({'test': 'ko'}), '/return') self.assertBody(json_dumps({'test': 'ko2'}), '/raise') class TestPluginAPI(tools.ServerTestBase): def setUp(self): super(TestPluginAPI, self).setUp() @self.app.route('/', test='plugin.cfg') def test(**args): return ', '.join('%s:%s' % (k,v) for k,v in args.items()) def test_callable(self): def plugin(func): def wrapper(*a, **ka): return func(test='me', *a, **ka) + '; tail' return wrapper self.app.install(plugin) self.assertBody('test:me; tail', '/') def test_apply(self): class Plugin(object): def apply(self, func, route): def wrapper(*a, **ka): return func(test=route.config['test'], *a, **ka) + '; tail' return wrapper def __call__(self, func): raise AssertionError("Plugins must not be called "\ "if they implement 'apply'") self.app.install(Plugin()) self.assertBody('test:plugin.cfg; tail', '/') def test_instance_method_wrapper(self): class Plugin(object): api=2 def apply(self, callback, route): return self.b def b(self): return "Hello" self.app.install(Plugin()) self.assertBody('Hello', '/') def test_setup(self): class Plugin(object): def __call__(self, func): return func def setup(self, app): self.app = app plugin = self.app.install(Plugin()) self.assertEqual(getattr(plugin, 'app', None), self.app) def test_close(self): class Plugin(object): def __call__(self, func): return func def close(self): self.closed = True plugin = self.app.install(Plugin()) plugin2 = self.app.install(Plugin()) self.app.uninstall(plugin) self.assertTrue(getattr(plugin, 'closed', False)) self.app.close() self.assertTrue(getattr(plugin2, 'closed', False)) python-bottle-0.13.2/test/test_resources.py000066400000000000000000000050161470367422500210230ustar00rootroot00000000000000from bottle import ResourceManager import os.path import unittest class TestResourceManager(unittest.TestCase): def test_path_normalize(self): tests = ('/foo/bar/', '/foo/bar/baz', '/foo/baz/../bar/blub') for test in tests: rm = ResourceManager() rm.add_path(test) self.assertEqual(rm.path, ['/foo/bar/']) def test_path_create(self): import tempfile, shutil tempdir = tempfile.mkdtemp() try: rm = ResourceManager() exists = rm.add_path('./test/', base=tempdir) self.assertEqual(exists, False) exists = rm.add_path('./test2/', base=tempdir, create=True) self.assertEqual(exists, True) finally: shutil.rmtree(tempdir) def test_path_absolutize(self): tests = ('./foo/bar/', './foo/bar/baz', './foo/baz/../bar/blub') abspath = os.path.abspath('./foo/bar/') + os.sep for test in tests: rm = ResourceManager() rm.add_path(test) self.assertEqual(rm.path, [abspath]) for test in tests: rm = ResourceManager() rm.add_path(test[2:]) self.assertEqual(rm.path, [abspath]) def test_path_unique(self): tests = ('/foo/bar/', '/foo/bar/baz', '/foo/baz/../bar/blub') rm = ResourceManager() [rm.add_path(test) for test in tests] self.assertEqual(rm.path, ['/foo/bar/']) def test_root_path(self): tests = ('/foo/bar/', '/foo/bar/baz', '/foo/baz/../bar/blub') for test in tests: rm = ResourceManager() rm.add_path('./baz/', test) self.assertEqual(rm.path, ['/foo/bar/baz/']) for test in tests: rm = ResourceManager() rm.add_path('baz/', test) self.assertEqual(rm.path, ['/foo/bar/baz/']) def test_path_order(self): rm = ResourceManager() rm.add_path('/middle/') rm.add_path('/first/', index=0) rm.add_path('/last/') self.assertEqual(rm.path, ['/first/', '/middle/', '/last/']) def test_get(self): rm = ResourceManager() rm.add_path('/first/') rm.add_path(__file__) rm.add_path('/last/') self.assertEqual(None, rm.lookup('notexist.txt')) self.assertEqual(__file__, rm.lookup(os.path.basename(__file__))) def test_open(self): rm = ResourceManager() rm.add_path(__file__) fp = rm.open(__file__) self.assertEqual(fp.read(), open(__file__).read()) python-bottle-0.13.2/test/test_route.py000066400000000000000000000044131470367422500201470ustar00rootroot00000000000000import unittest import bottle from .tools import api from bottle import _re_flatten class TestReFlatten(unittest.TestCase): def test_re_flatten(self): self.assertEqual(_re_flatten(r"(?:aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"(aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"aaa)(_bbb)"), 'aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"aaa(_bbb)"), 'aaa(?:_bbb)') self.assertEqual(_re_flatten(r"aaa_bbb"), 'aaa_bbb') class TestRoute(unittest.TestCase): @api('0.12') def test_callback_inspection(self): def x(a, b): pass def d(f): def w(): return f() return w route = bottle.Route(bottle.Bottle(), None, None, d(x)) self.assertEqual(route.get_undecorated_callback(), x) self.assertEqual(set(route.get_callback_args()), set(['a', 'b'])) def d2(foo): def d(f): def w(): return f() return w return d route = bottle.Route(bottle.Bottle(), None, None, d2('foo')(x)) self.assertEqual(route.get_undecorated_callback(), x) self.assertEqual(set(route.get_callback_args()), set(['a', 'b'])) def test_callback_inspection_multiple_args(self): # decorator with argument, modifying kwargs def d2(f="1"): def d(fn): def w(*args, **kwargs): # modification of kwargs WITH the decorator argument # is necessary requirement for the error kwargs["a"] = f return fn(*args, **kwargs) return w return d @d2(f='foo') def x(a, b): return route = bottle.Route(bottle.Bottle(), None, None, x) # triggers the "TypeError: 'foo' is not a Python function" self.assertEqual(set(route.get_callback_args()), set(['a', 'b'])) if bottle.py3k: def test_callback_inspection_newsig(self): env = {} eval(compile('def foo(a, *, b=5): pass', '', 'exec'), env, env) route = bottle.Route(bottle.Bottle(), None, None, env['foo']) self.assertEqual(set(route.get_callback_args()), set(['a', 'b'])) python-bottle-0.13.2/test/test_router.py000077500000000000000000000150551470367422500203400ustar00rootroot00000000000000# -*- coding: utf-8 -*- import unittest import bottle import warnings class TestRouter(unittest.TestCase): CGI = False def setUp(self): self.r = bottle.Router() def add(self, path, target, method='GET', **ka): with warnings.catch_warnings() as r: warnings.simplefilter("ignore") self.r.add(path, method, target, **ka) def match(self, path, method='GET'): env = {'PATH_INFO': path, 'REQUEST_METHOD': method} if self.CGI: env['wsgi.run_once'] = 'true' return self.r.match(env) def assertMatches(self, rule, url, method='GET', **args): self.add(rule, rule, method) target, urlargs = self.match(url, method) self.assertEqual(rule, target) self.assertEqual(args, urlargs) def testBasic(self): self.assertMatches('/static', '/static') self.assertMatches('/\\:its/:#.+#/:test/:name#[a-z]+#/', '/:its/a/cruel/world/', test='cruel', name='world') self.assertMatches('/:test', '/test', test='test') # No tail self.assertMatches(':test/', 'test/', test='test') # No head self.assertMatches('/:test/', '/test/', test='test') # Middle self.assertMatches(':test', 'test', test='test') # Full wildcard self.assertMatches('/:#anon#/match', '/anon/match') # Anon wildcards self.assertRaises(bottle.HTTPError, self.match, '//no/m/at/ch/') def testNewSyntax(self): self.assertMatches('/static', '/static') self.assertMatches('/\\/<:re:.+>///', '//a/cruel/world/', test='cruel', name='world') self.assertMatches('/', '/test', test='test') # No tail self.assertMatches('/', 'test/', test='test') # No head self.assertMatches('//', '/test/', test='test') # Middle self.assertMatches('', 'test', test='test') # Full wildcard self.assertMatches('/<:re:anon>/match', '/anon/match') # Anon wildcards self.assertRaises(bottle.HTTPError, self.match, '//no/m/at/ch/') def testUnicode(self): self.assertMatches('/uni/', '/uni/瓶', x='瓶') def testValueErrorInFilter(self): self.r.add_filter('test', lambda x: ('.*', int, int)) self.assertMatches('/int/', '/int/5', i=5) # No tail self.assertRaises(bottle.HTTPError, self.match, '/int/noint') def testIntFilter(self): self.assertMatches('/object/', '/object/567', id=567) self.assertRaises(bottle.HTTPError, self.match, '/object/abc') def testFloatFilter(self): self.assertMatches('/object/', '/object/1', id=1) self.assertMatches('/object/', '/object/1.1', id=1.1) self.assertMatches('/object/', '/object/.1', id=0.1) self.assertMatches('/object/', '/object/1.', id=1) self.assertRaises(bottle.HTTPError, self.match, '/object/abc') self.assertRaises(bottle.HTTPError, self.match, '/object/') self.assertRaises(bottle.HTTPError, self.match, '/object/.') def testPathFilter(self): self.assertMatches('//:f', '/a/b', id='a', f='b') self.assertMatches('/', '/a', id='a') def testWildcardNames(self): self.assertMatches('/alpha/:abc', '/alpha/alpha', abc='alpha') self.assertMatches('/alnum/:md5', '/alnum/sha1', md5='sha1') def testParentheses(self): self.assertMatches('/func(:param)', '/func(foo)', param='foo') self.assertMatches('/func2(:param#(foo|bar)#)', '/func2(foo)', param='foo') self.assertMatches('/func2(:param#(foo|bar)#)', '/func2(bar)', param='bar') self.assertRaises(bottle.HTTPError, self.match, '/func2(baz)') def testErrorInPattern(self): self.assertRaises(Exception, self.assertMatches, '/:bug#(#/', '/foo/') self.assertRaises(Exception, self.assertMatches, '/<:re:(>/', '/foo/') def testBuild(self): add, build = self.add, self.r.build add('/:test/:name#[a-z]+#/', 'handler', name='testroute') url = build('testroute', test='hello', name='world') self.assertEqual('/hello/world/', url) url = build('testroute', test='hello', name='world', q='value') self.assertEqual('/hello/world/?q=value', url) # RouteBuildError: Missing URL argument: 'test' self.assertRaises(bottle.RouteBuildError, build, 'test') def testBuildAnon(self): add, build = self.add, self.r.build add('/anon/:#.#', 'handler', name='anonroute') url = build('anonroute', 'hello') self.assertEqual('/anon/hello', url) url = build('anonroute', 'hello', q='value') self.assertEqual('/anon/hello?q=value', url) # RouteBuildError: Missing URL argument: anon0. self.assertRaises(bottle.RouteBuildError, build, 'anonroute') def testBuildFilter(self): add, build = self.add, self.r.build add('/int/<:int>', 'handler', name='introute') url = build('introute', '5') self.assertEqual('/int/5', url) # RouteBuildError: Missing URL argument: anon0. self.assertRaises(ValueError, build, 'introute', 'hello') def test_dynamic_before_static_any(self): ''' Static ANY routes have lower priority than dynamic GET routes. ''' self.add('/foo', 'foo', 'ANY') self.assertEqual(self.match('/foo')[0], 'foo') self.add('/<:>', 'bar', 'GET') self.assertEqual(self.match('/foo')[0], 'bar') def test_any_static_before_dynamic(self): ''' Static ANY routes have higher priority than dynamic ANY routes. ''' self.add('/<:>', 'bar', 'ANY') self.assertEqual(self.match('/foo')[0], 'bar') self.add('/foo', 'foo', 'ANY') self.assertEqual(self.match('/foo')[0], 'foo') def test_dynamic_any_if_method_exists(self): ''' Check dynamic ANY routes if the matching method is known, but not matched.''' self.add('/bar<:>', 'bar', 'GET') self.assertEqual(self.match('/barx')[0], 'bar') self.add('/foo<:>', 'foo', 'ANY') self.assertEqual(self.match('/foox')[0], 'foo') def test_lots_of_routes(self): n = bottle.Router._MAX_GROUPS_PER_PATTERN+10 for i in range(n): self.add('/<:>/'+str(i), str(i), 'GET') self.assertEqual(self.match('/foo/'+str(n-1))[0], str(n-1)) class TestRouterInCGIMode(TestRouter): ''' Makes no sense since the default route does not optimize CGI anymore.''' CGI = True python-bottle-0.13.2/test/test_securecookies.py000066400000000000000000000033411470367422500216530ustar00rootroot00000000000000#coding: utf-8 import unittest import bottle from bottle import tob, touni from .tools import api class TestSignedCookies(unittest.TestCase): def setUp(self): self.data = touni('υηι¢σ∂є') self.secret = tob('secret') bottle.app.push() bottle.response.bind() def tear_down(self): bottle.app.pop() def get_pairs(self): for k, v in bottle.response.headerlist: if k == 'Set-Cookie': key, value = v.split(';')[0].split('=', 1) yield key.lower().strip(), value.strip() def set_pairs(self, pairs): header = ','.join(['%s=%s' % (k, v) for k, v in pairs]) bottle.request.bind({'HTTP_COOKIE': header}) def testValid(self): bottle.response.set_cookie('key', self.data, secret=self.secret) pairs = self.get_pairs() self.set_pairs(pairs) result = bottle.request.get_cookie('key', secret=self.secret) self.assertEqual(self.data, result) def testWrongKey(self): bottle.response.set_cookie('key', self.data, secret=self.secret) pairs = self.get_pairs() self.set_pairs([(k + 'xxx', v) for (k, v) in pairs]) result = bottle.request.get_cookie('key', secret=self.secret) self.assertEqual(None, result) class TestSignedCookiesWithPickle(TestSignedCookies): def setUp(self): super(TestSignedCookiesWithPickle, self).setUp() self.data = dict(a=5, b=touni('υηι¢σ∂є'), c=[1,2,3,4,tob('bytestring')]) @api("0.9", "0.13") def testValid(self): super(TestSignedCookiesWithPickle, self).testValid() @api("0.9", "0.13") def testWrongKey(self): super(TestSignedCookiesWithPickle, self).testWrongKey() python-bottle-0.13.2/test/test_sendfile.py000077500000000000000000000154371470367422500206150ustar00rootroot00000000000000import unittest from bottle import static_file, request, response, parse_date, parse_range_header, Bottle, tob import bottle import wsgiref.util import os import tempfile import time basename = os.path.basename(__file__) root = os.path.dirname(__file__) basename2 = os.path.basename(bottle.__file__) root2 = os.path.dirname(bottle.__file__) weekday_full = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] weekday_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] month_abbr = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] class TestDateParser(unittest.TestCase): def test_rfc1123(self): """DateParser: RFC 1123 format""" ts = time.time() rs = bottle.http_date(ts) self.assertEqual(int(ts), int(parse_date(rs))) def test_rfc850(self): """DateParser: RFC 850 format""" ts = time.time() t = time.gmtime(ts) rs = time.strftime("%%s, %d-%%s-%y %H:%M:%S GMT", t) % (weekday_full[t.tm_wday], month_abbr[t.tm_mon]) self.assertEqual(int(ts), int(parse_date(rs))) def test_asctime(self): """DateParser: asctime format""" ts = time.time() t = time.gmtime(ts) rs = time.strftime("%%s %%s %d %H:%M:%S %Y", t) % (weekday_abbr[t.tm_wday], month_abbr[t.tm_mon]) self.assertEqual(int(ts), int(parse_date(rs))) def test_bad(self): """DateParser: Bad format""" self.assertEqual(None, parse_date('Bad 123')) class TestSendFile(unittest.TestCase): def setUp(self): e = dict() wsgiref.util.setup_testing_defaults(e) b = Bottle() request.bind(e) response.bind() def test_valid(self): """ SendFile: Valid requests""" out = static_file(basename, root=root) self.assertEqual(open(__file__,'rb').read(), out.body.read()) def test_invalid(self): """ SendFile: Invalid requests""" self.assertEqual(404, static_file('not/a/file', root=root).status_code) f = static_file(os.path.join('./../', basename), root='./views/') self.assertEqual(403, f.status_code) def test_file_not_readable(self): if os.geteuid() == 0: return # Root can read anything try: fp, fn = tempfile.mkstemp() os.chmod(fn, 0) self.assertEqual(403, static_file(fn, root='/').status_code) finally: os.close(fp) os.unlink(fn) def test_mime(self): """ SendFile: Mime Guessing""" f = static_file(basename, root=root) self.assertTrue(f.headers['Content-Type'].split(';')[0] in ('application/x-python-code', 'text/x-python')) f = static_file(basename, root=root, mimetype='some/type') self.assertEqual('some/type', f.headers['Content-Type']) f = static_file(basename, root=root, mimetype='text/foo') self.assertEqual('text/foo; charset=UTF-8', f.headers['Content-Type']) f = static_file(basename, root=root, mimetype='text/foo', charset='latin1') self.assertEqual('text/foo; charset=latin1', f.headers['Content-Type']) def test_mime_gzip(self): """ SendFile: Mime Guessing""" try: fp, fn = tempfile.mkstemp(suffix=".txt.gz") f = static_file(fn, root='/') self.assertTrue(f.headers['Content-Type'][0] in ('application/gzip')) self.assertFalse('Content-Encoding' in f.headers) finally: os.close(fp) os.unlink(fn) def test_ims(self): """ SendFile: If-Modified-Since""" request.environ['HTTP_IF_MODIFIED_SINCE'] = bottle.http_date(time.time()) res = static_file(basename, root=root) self.assertEqual(304, res.status_code) self.assertEqual(int(os.stat(__file__).st_mtime), parse_date(res.headers['Last-Modified'])) self.assertAlmostEqual(int(time.time()), parse_date(res.headers['Date'])) request.environ['HTTP_IF_MODIFIED_SINCE'] = bottle.http_date(100) self.assertEqual(open(__file__,'rb').read(), static_file(basename, root=root).body.read()) def test_ims_empty(self): """ SendFile: Empty If-Modified-Since""" request.environ['HTTP_IF_MODIFIED_SINCE'] = '' self.assertEqual(open(__file__, 'rb').read(), static_file(basename, root=root).body.read()) def test_etag(self): """ SendFile: If-Modified-Since""" res = static_file(basename, root=root) self.assertTrue('ETag' in res.headers) self.assertEqual(200, res.status_code) etag = res.headers['ETag'] request.environ['HTTP_IF_NONE_MATCH'] = etag res = static_file(basename, root=root) self.assertTrue('ETag' in res.headers) self.assertEqual(etag, res.headers['ETag']) self.assertEqual(304, res.status_code) request.environ['HTTP_IF_NONE_MATCH'] = etag res = static_file(basename2, root=root2) self.assertTrue('ETag' in res.headers) self.assertNotEqual(etag, res.headers['ETag']) self.assertEqual(200, res.status_code) def test_download(self): """ SendFile: Download as attachment """ f = static_file(basename, root=root, download="foo.mp3") self.assertEqual('audio/mpeg', f.headers['Content-Type']) f = static_file(basename, root=root, download=True) self.assertEqual('attachment; filename="%s"' % basename, f.headers['Content-Disposition']) request.environ['HTTP_IF_MODIFIED_SINCE'] = bottle.http_date(100) f = static_file(basename, root=root) self.assertEqual(open(__file__,'rb').read(), f.body.read()) def test_range(self): request.environ['HTTP_RANGE'] = 'bytes=10-25,-80' f = static_file(basename, root=root) c = open(__file__, 'rb'); c.seek(10) self.assertEqual(c.read(16), tob('').join(f.body)) self.assertEqual('bytes 10-25/%d' % len(open(__file__, 'rb').read()), f.headers['Content-Range']) self.assertEqual('bytes', f.headers['Accept-Ranges']) def test_range_parser(self): r = lambda rs: list(parse_range_header(rs, 100)) self.assertEqual([(90, 100)], r('bytes=-10')) self.assertEqual([(10, 100)], r('bytes=10-')) self.assertEqual([(5, 11)], r('bytes=5-10')) self.assertEqual([(10, 100), (90, 100), (5, 11)], r('bytes=10-,-10,5-10')) def test_custom_headers(self): """ SendFile: Custom headers """ headers = {'X-Custom-Header': 'test-value'} headers_orig = headers.copy() res = static_file(basename, root=root, headers=headers) self.assertTrue('X-Custom-Header' in res.headers) self.assertEqual('test-value', res.headers['X-Custom-Header']) # Check the passed in headers dict isn't modified. self.assertEqual(headers_orig, headers) python-bottle-0.13.2/test/test_stpl.py000077500000000000000000000325661470367422500200100ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import unittest from bottle import SimpleTemplate, TemplateError, view, template, touni, tob, html_quote import re, os import traceback from .tools import chdir class TestSimpleTemplate(unittest.TestCase): def assertRenders(self, tpl, to, *args, **vars): if isinstance(tpl, str): tpl = SimpleTemplate(tpl, lookup=[os.path.join(os.path.dirname(__file__), 'views')]) self.assertEqual(touni(to), tpl.render(*args, **vars)) def test_string(self): """ Templates: Parse string""" self.assertRenders('start {{var}} end', 'start var end', var='var') def test_self_as_variable_name(self): self.assertRenders('start {{self}} end', 'start var end', {'self':'var'}) def test_file(self): with chdir(__file__): t = SimpleTemplate(name='./views/stpl_simple.tpl', lookup=['.']) self.assertRenders(t, 'start var end\n', var='var') def test_name(self): with chdir(__file__): t = SimpleTemplate(name='stpl_simple', lookup=['./views/']) self.assertRenders(t, 'start var end\n', var='var') def test_unicode(self): self.assertRenders('start {{var}} end', 'start äöü end', var=touni('äöü')) self.assertRenders('start {{var}} end', 'start äöü end', var=tob('äöü')) def test_unicode_code(self): """ Templates: utf8 code in file""" with chdir(__file__): t = SimpleTemplate(name='./views/stpl_unicode.tpl', lookup=['.']) self.assertRenders(t, 'start ñç äöü end\n', var=touni('äöü')) def test_import(self): """ Templates: import statement""" t = '%from base64 import b64encode\nstart {{b64encode(var.encode("ascii") if hasattr(var, "encode") else var)}} end' self.assertRenders(t, 'start dmFy end', var='var') def test_data(self): """ Templates: Data representation """ t = SimpleTemplate('<{{var}}>') self.assertRenders('<{{var}}>', '', var=True) self.assertRenders('<{{var}}>', '', var=False) self.assertRenders('<{{var}}>', '<>', var=None) self.assertRenders('<{{var}}>', '<0>', var=0) self.assertRenders('<{{var}}>', '<5>', var=5) self.assertRenders('<{{var}}>', '', var=tob('b')) self.assertRenders('<{{var}}>', '<1.0>', var=1.0) self.assertRenders('<{{var}}>', '<[1, 2]>', var=[1,2]) def test_htmlutils_quote(self): self.assertEqual('"<' "\\>"', html_quote('<\'\r\n\t"\\>')); def test_escape(self): self.assertRenders('<{{var}}>', '', var='b') self.assertRenders('<{{var}}>', '<<&>>',var='<&>') def test_noescape(self): self.assertRenders('<{{!var}}>', '', var='b') self.assertRenders('<{{!var}}>', '<<&>>', var='<&>') def test_noescape_setting(self): t = SimpleTemplate('<{{var}}>', noescape=True) self.assertRenders(t, '', var='b') self.assertRenders(t, '<<&>>', var='<&>') t = SimpleTemplate('<{{!var}}>', noescape=True) self.assertRenders(t, '', var='b') self.assertRenders(t, '<<&>>', var='<&>') def test_blocks(self): """ Templates: Code blocks and loops """ t = "start\n%for i in l:\n{{i}} \n%end\nend" self.assertRenders(t, 'start\n1 \n2 \n3 \nend', l=[1,2,3]) self.assertRenders(t, 'start\nend', l=[]) t = "start\n%if i:\n{{i}} \n%end\nend" self.assertRenders(t, 'start\nTrue \nend', i=True) self.assertRenders(t, 'start\nend', i=False) def test_elsebug(self): ''' Whirespace between block keyword and colon is allowed ''' self.assertRenders("%if 1:\nyes\n%else:\nno\n%end\n", "yes\n") self.assertRenders("%if 1:\nyes\n%else :\nno\n%end\n", "yes\n") def test_commentbug(self): ''' A "#" sign within an string is not a comment ''' self.assertRenders("%if '#':\nyes\n%end\n", "yes\n") def test_multiline(self): ''' Block statements with non-terminating newlines ''' self.assertRenders("%if 1\\\n%and 1:\nyes\n%end\n", "yes\n") def test_newline_in_parameterlist(self): ''' Block statements with non-terminating newlines in list ''' self.assertRenders("%a=[1,\n%2]\n{{len(a)}}", "2") def test_dedentbug(self): ''' One-Line dednet blocks should not change indention ''' t = '%if x: a="if"\n%else: a="else"\n%end\n{{a}}' self.assertRenders(t, "if", x=True) self.assertRenders(t, "else", x=False) t = '%if x:\n%a="if"\n%else: a="else"\n%end\n{{a}}' self.assertRenders(t, "if", x=True) self.assertRenders(t, "else", x=False) t = SimpleTemplate('%if x: a="if"\n%else: a="else"\n%end') self.assertRaises(NameError, t.render) def test_onelinebugs(self): ''' One-Line blocks should not change indention ''' t = '%if x:\n%a=1\n%end\n{{a}}' self.assertRenders(t, "1", x=True) t = '%if x: a=1; end\n{{a}}' self.assertRenders(t, "1", x=True) t = '%if x:\n%a=1\n%else:\n%a=2\n%end\n{{a}}' self.assertRenders(t, "1", x=True) self.assertRenders(t, "2", x=False) t = '%if x: a=1\n%else:\n%a=2\n%end\n{{a}}' self.assertRenders(t, "1", x=True) self.assertRenders(t, "2", x=False) t = '%if x:\n%a=1\n%else: a=2; end\n{{a}}' self.assertRenders(t, "1", x=True) self.assertRenders(t, "2", x=False) t = '%if x: a=1\n%else: a=2; end\n{{a}}' self.assertRenders(t, "1", x=True) self.assertRenders(t, "2", x=False) def test_onelineblocks(self): """ Templates: one line code blocks """ t = "start\n%a=''\n%for i in l: a += str(i); end\n{{a}}\nend" self.assertRenders(t, 'start\n123\nend', l=[1,2,3]) self.assertRenders(t, 'start\n\nend', l=[]) def test_escaped_codelines(self): self.assertRenders('\\% test', '% test') self.assertRenders('\\%% test', '%% test') self.assertRenders(' \\% test', ' % test') def test_nobreak(self): """ Templates: Nobreak statements""" self.assertRenders("start\\\\\n%pass\nend", 'startend') def test_nonobreak(self): """ Templates: Escaped nobreak statements""" self.assertRenders("start\\\\\n\\\\\n%pass\nend", 'start\\\\\nend') def test_include(self): """ Templates: Include statements""" with chdir(__file__): t = SimpleTemplate(name='stpl_include', lookup=['./views/']) self.assertRenders(t, 'before\nstart var end\nafter\n', var='var') def test_rebase(self): """ Templates: %rebase and method passing """ with chdir(__file__): t = SimpleTemplate(name='stpl_t2main', lookup=['./views/']) result='+base+\n+main+\n!1234!\n+include+\n-main-\n+include+\n-base-\n' self.assertRenders(t, result, content='1234') def test_get(self): self.assertRenders('{{get("x", "default")}}', '1234', x='1234') self.assertRenders('{{get("x", "default")}}', 'default') def test_setdefault(self): t = '%setdefault("x", "default")\n{{x}}' self.assertRenders(t, '1234', x='1234') self.assertRenders(t, 'default') def test_defnied(self): self.assertRenders('{{x if defined("x") else "no"}}', 'yes', x='yes') self.assertRenders('{{x if defined("x") else "no"}}', 'no') def test_notfound(self): """ Templates: Unavailable templates""" self.assertRaises(TemplateError, SimpleTemplate, name="abcdef", lookup=['.']) def test_error(self): """ Templates: Exceptions""" self.assertRaises(SyntaxError, lambda: SimpleTemplate('%for badsyntax').co) self.assertRaises(IndexError, SimpleTemplate('{{i[5]}}', lookup=['.']).render, i=[0]) def test_winbreaks(self): """ Templates: Test windows line breaks """ self.assertRenders('%var+=1\r\n{{var}}\r\n', '6\r\n', var=5) def test_winbreaks_end_bug(self): d = { 'test': [ 1, 2, 3 ] } self.assertRenders('%for i in test:\n{{i}}\n%end\n', '1\n2\n3\n', **d) self.assertRenders('%for i in test:\n{{i}}\r\n%end\n', '1\r\n2\r\n3\r\n', **d) self.assertRenders('%for i in test:\r\n{{i}}\n%end\r\n', '1\n2\n3\n', **d) self.assertRenders('%for i in test:\r\n{{i}}\r\n%end\r\n', '1\r\n2\r\n3\r\n', **d) def test_commentonly(self): """ Templates: Commentd should behave like code-lines (e.g. flush text-lines) """ t = SimpleTemplate('...\n%#test\n...') self.assertNotEqual('#test', t.code.splitlines()[0]) def test_template_shortcut(self): result = template('start {{var}} end', var='middle') self.assertEqual(touni('start middle end'), result) def test_view_decorator(self): @view('start {{var}} end') def test(): return dict(var='middle') self.assertEqual(touni('start middle end'), test()) def test_view_decorator_issue_407(self): with chdir(__file__): @view('stpl_no_vars') def test(): pass self.assertEqual(touni('hihi'), test()) @view('aaa {{x}}', x='bbb') def test2(): pass self.assertEqual(touni('aaa bbb'), test2()) def test_global_config(self): SimpleTemplate.global_config('meh', 1) t = SimpleTemplate('anything') self.assertEqual(touni('anything'), t.render()) def test_bug_no_whitespace_before_stmt(self): self.assertRenders('\n{{var}}', '\nx', var='x') def test_bug_block_keywords_eat_prefixed_code(self): ''' #595: Everything before an 'if' statement is removed, resulting in SyntaxError. ''' tpl = "% m = 'x' if True else 'y'\n{{m}}" self.assertRenders(tpl, 'x') class TestSTPLDir(unittest.TestCase): def fix_ident(self, string): lines = string.splitlines(True) if not lines: return string if not lines[0].strip(): lines.pop(0) whitespace = re.match('([ \t]*)', lines[0]).group(0) if not whitespace: return string for i in range(len(lines)): lines[i] = lines[i][len(whitespace):] return lines[0][:0].join(lines) def assertRenders(self, source, result, syntax=None, *args, **vars): source = self.fix_ident(source) result = self.fix_ident(result) tpl = SimpleTemplate(source, syntax=syntax) try: tpl.co self.assertEqual(touni(result), tpl.render(*args, **vars)) except SyntaxError: self.fail('Syntax error in template:\n%s\n\nTemplate code:\n##########\n%s\n##########' % (traceback.format_exc(), tpl.code)) def test_multiline_block(self): source = ''' <% a = 5 b = 6 c = 7 %> {{a+b+c}} '''; result = ''' 18 ''' self.assertRenders(source, result) source_wineol = '<% a = 5\r\nb = 6\r\nc = 7\r\n%>\r\n{{a+b+c}}' result_wineol = '18' self.assertRenders(source_wineol, result_wineol) def test_multiline_ignore_eob_in_string(self): source = ''' <% x=5 # a comment y = '%>' # a string # this is still code # lets end this %> {{x}}{{!y}} '''; result = ''' 5%> ''' self.assertRenders(source, result) def test_multiline_find_eob_in_comments(self): source = ''' <% # a comment # %> ignore because not end of line # this is still code x=5 # lets end this here %> {{x}} '''; result = ''' 5 ''' self.assertRenders(source, result) def test_multiline_indention(self): source = ''' <% if True: a = 2 else: a = 0 end %> {{a}} '''; result = ''' 2 ''' self.assertRenders(source, result) def test_multiline_eob_after_end(self): source = ''' <% if True: a = 2 end %> {{a}} '''; result = ''' 2 ''' self.assertRenders(source, result) def test_multiline_eob_in_single_line_code(self): # eob must be a valid python expression to allow this test. source = ''' cline eob=5; eob xxx '''; result = ''' xxx ''' self.assertRenders(source, result, syntax='sob eob cline foo bar') def test_multiline_strings_in_code_line(self): source = ''' % a = """line 1 line 2""" {{a}} '''; result = ''' line 1 line 2 ''' self.assertRenders(source, result) def test_multiline_comprehensions_in_code_line(self): self.assertRenders(source=''' % a = [ % (i + 1) % for i in range(5) % if i%2 == 0 % ] {{a}} ''', result=''' [1, 3, 5] ''') def test_end_keyword_on_same_line(self): self.assertRenders(''' % if 1: % 1; end foo ''', ''' foo ''') python-bottle-0.13.2/test/test_wsgi.py000077500000000000000000000414761470367422500177770ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir from bottle import tob, touni, HTTPResponse class TestWsgi(ServerTestBase): ''' Tests for WSGI functionality, routing and output casting (decorators) ''' def test_get(self): """ WSGI: GET routes""" @bottle.route('/') def test(): return 'test' self.assertStatus(404, '/not/found') self.assertStatus(405, '/', post="var=value") self.assertBody('test', '/') def test_post(self): """ WSGI: POST routes""" @bottle.route('/', method='POST') def test(): return 'test' self.assertStatus(404, '/not/found') self.assertStatus(405, '/') self.assertBody('test', '/', post="var=value") def test_headget(self): """ WSGI: HEAD routes and GET fallback""" @bottle.route('/get') def test(): return 'test' @bottle.route('/head', method='HEAD') def test2(): return 'test' # GET -> HEAD self.assertStatus(405, '/head') # HEAD -> HEAD self.assertStatus(200, '/head', method='HEAD') self.assertBody('', '/head', method='HEAD') # HEAD -> GET self.assertStatus(200, '/get', method='HEAD') self.assertBody('', '/get', method='HEAD') def test_request_attrs(self): """ WSGI: POST routes""" @bottle.route('/') def test(): self.assertEqual(bottle.request.app, bottle.default_app()) self.assertEqual(bottle.request.route, bottle.default_app().routes[0]) return 'foo' self.assertBody('foo', '/') def get204(self): """ 204 responses must not return some entity headers """ bad = ('content-length', 'content-type') for h in bad: bottle.response.set_header(h, 'foo') bottle.status = 204 for h, v in bottle.response.headerlist: self.assertFalse(h.lower() in bad, "Header %s not deleted" % h) def get304(self): """ 304 responses must not return entity headers """ bad = ('allow', 'content-encoding', 'content-language', 'content-length', 'content-md5', 'content-range', 'content-type', 'last-modified') # + c-location, expires? for h in bad: bottle.response.set_header(h, 'foo') bottle.status = 304 for h, v in bottle.response.headerlist: self.assertFalse(h.lower() in bad, "Header %s not deleted" % h) def test_anymethod(self): self.assertStatus(404, '/any') @bottle.route('/any', method='ANY') def test2(): return 'test' self.assertStatus(200, '/any', method='HEAD') self.assertBody('test', '/any', method='GET') self.assertBody('test', '/any', method='POST') self.assertBody('test', '/any', method='DELETE') @bottle.route('/any', method='GET') def test2(): return 'test2' self.assertBody('test2', '/any', method='GET') @bottle.route('/any', method='POST') def test2(): return 'test3' self.assertBody('test3', '/any', method='POST') self.assertBody('test', '/any', method='DELETE') def test_500(self): """ WSGI: Exceptions within handler code (HTTP 500) """ @bottle.route('/') def test(): return 1/0 self.assertStatus(500, '/') def test_500_unicode(self): @bottle.route('/') def test(): raise Exception(touni('Unicode äöüß message.')) self.assertStatus(500, '/') def test_utf8_url(self): """ WSGI: UTF-8 Characters in the URL """ @bottle.route('/my-öäü/') def test(string): return string self.assertBody(tob('urf8-öäü'), '/my-öäü/urf8-öäü') def test_utf8_header(self): header = 'öäü' if bottle.py3k: header = header.encode('utf8').decode('latin1') @bottle.route('/test') def test(): h = bottle.request.get_header('X-Test') self.assertEqual(h, 'öäü') bottle.response.set_header('X-Test', h) self.assertHeader('X-Test', header, '/test', env={'HTTP_X_TEST': header}) def test_utf8_404(self): self.assertStatus(404, '/not-found/urf8-öäü') def test_401(self): """ WSGI: abort(401, '') (HTTP 401) """ @bottle.route('/') def test(): bottle.abort(401) self.assertStatus(401, '/') @bottle.error(401) def err(e): bottle.response.status = 200 return str(type(e)) self.assertStatus(200, '/') self.assertBody("",'/') def test_303(self): """ WSGI: redirect (HTTP 303) """ @bottle.route('/') def test(): bottle.redirect('/yes') @bottle.route('/one') def test2(): bottle.redirect('/yes',305) env = {'SERVER_PROTOCOL':'HTTP/1.1'} self.assertStatus(303, '/', env=env) self.assertHeader('Location', 'http://127.0.0.1/yes', '/', env=env) env = {'SERVER_PROTOCOL':'HTTP/1.0'} self.assertStatus(302, '/', env=env) self.assertHeader('Location', 'http://127.0.0.1/yes', '/', env=env) self.assertStatus(305, '/one', env=env) self.assertHeader('Location', 'http://127.0.0.1/yes', '/one', env=env) def test_generator_callback(self): @bottle.route('/yield') def test(): bottle.response.headers['Test-Header'] = 'test' yield 'foo' @bottle.route('/yield_nothing') def test2(): yield bottle.response.headers['Test-Header'] = 'test' self.assertBody('foo', '/yield') self.assertHeader('Test-Header', 'test', '/yield') self.assertBody('', '/yield_nothing') self.assertHeader('Test-Header', 'test', '/yield_nothing') def test_cookie(self): """ WSGI: Cookies """ @bottle.route('/cookie') def test(): bottle.response.set_cookie('b', 'b') bottle.response.set_cookie('c', 'c', path='/') return 'hello' try: c = self.urlopen('/cookie')['header'].get_all('Set-Cookie', '') except: c = self.urlopen('/cookie')['header'].get('Set-Cookie', '').split(',') c = [x.strip() for x in c] self.assertTrue('b=b' in c) self.assertTrue('c=c; Path=/' in c) class TestErrorHandling(ServerTestBase): def test_error_routing(self): @bottle.route("/") def throw_error(code): bottle.abort(code) # Decorator syntax @bottle.error(500) def catch_500(err): return err.status_line # Decorator syntax (unusual/custom error codes) @bottle.error(999) def catch_999(err): return err.status_line # Callback argument syntax def catch_404(err): return err.status_line bottle.error(404, callback=catch_404) self.assertBody("404 Not Found", '/not_found') self.assertBody("500 Internal Server Error", '/500') self.assertBody("999 Unknown", '/999') class TestRouteDecorator(ServerTestBase): def test_decorators(self): def foo(): return bottle.request.method bottle.get('/')(foo) bottle.post('/')(foo) bottle.put('/')(foo) bottle.delete('/')(foo) for verb in 'GET POST PUT DELETE'.split(): self.assertBody(verb, '/', method=verb) def test_single_path(self): @bottle.route('/a') def test(): return 'ok' self.assertBody('ok', '/a') self.assertStatus(404, '/b') def test_path_list(self): @bottle.route(['/a','/b']) def test(): return 'ok' self.assertBody('ok', '/a') self.assertBody('ok', '/b') self.assertStatus(404, '/c') def test_no_path(self): @bottle.route() def test(x=5): return str(x) self.assertBody('5', '/test') self.assertBody('6', '/test/6') def test_no_params_at_all(self): @bottle.route def test(x=5): return str(x) self.assertBody('5', '/test') self.assertBody('6', '/test/6') def test_method(self): @bottle.route(method='gEt') def test(): return 'ok' self.assertBody('ok', '/test', method='GET') self.assertStatus(200, '/test', method='HEAD') self.assertStatus(405, '/test', method='PUT') def test_method_list(self): @bottle.route(method=['GET','post']) def test(): return 'ok' self.assertBody('ok', '/test', method='GET') self.assertBody('ok', '/test', method='POST') self.assertStatus(405, '/test', method='PUT') def test_apply(self): def revdec(func): def wrapper(*a, **ka): return reversed(func(*a, **ka)) return wrapper @bottle.route('/nodec') @bottle.route('/dec', apply=revdec) def test(): return '1', '2' self.assertBody('21', '/dec') self.assertBody('12', '/nodec') def test_apply_list(self): def revdec(func): def wrapper(*a, **ka): return reversed(func(*a, **ka)) return wrapper def titledec(func): def wrapper(*a, **ka): return ''.join(func(*a, **ka)).title() return wrapper @bottle.route('/revtitle', apply=[revdec, titledec]) @bottle.route('/titlerev', apply=[titledec, revdec]) def test(): return 'a', 'b', 'c' self.assertBody('cbA', '/revtitle') self.assertBody('Cba', '/titlerev') def test_hooks(self): @bottle.route() def test(): return bottle.request.environ.get('hooktest','nohooks') @bottle.hook('before_request') def hook(): bottle.request.environ['hooktest'] = 'before' @bottle.hook('after_request') def hook(*args, **kwargs): bottle.response.headers['X-Hook'] = 'after' self.assertBody('before', '/test') self.assertHeader('X-Hook', 'after', '/test') def test_after_request_sees_HTTPError_response(self): """ Issue #671 """ called = [] @bottle.hook('after_request') def after_request(): called.append('after') self.assertEqual(400, bottle.response.status_code) @bottle.get('/') def _get(): called.append("route") bottle.abort(400, 'test') self.urlopen("/") self.assertEqual(["route", "after"], called) def test_after_request_hooks_run_after_exception(self): """ Issue #671 """ called = [] @bottle.hook('before_request') def before_request(): called.append('before') @bottle.hook('after_request') def after_request(): called.append('after') @bottle.get('/') def _get(): called.append("route") 1/0 self.urlopen("/") self.assertEqual(["before", "route", "after"], called) def test_after_request_hooks_run_after_exception_in_before_hook(self): """ Issue #671 """ called = [] @bottle.hook('before_request') def before_request(): called.append('before') 1 / 0 @bottle.hook('after_request') def after_request(): called.append('after') @bottle.get('/') def _get(): called.append("route") self.urlopen("/") self.assertEqual(["before", "after"], called) def test_after_request_hooks_may_rise_response_exception(self): """ Issue #671 """ called = [] @bottle.hook('after_request') def after_request(): called.append('after') bottle.abort(400, "hook_content") @bottle.get('/') def _get(): called.append("route") return "XXX" self.assertInBody("hook_content", "/") self.assertEqual(["route", "after"], called) def test_after_response_hook_can_set_headers(self): """ Issue #1125 """ @bottle.route() def test1(): return "test" @bottle.route() def test2(): return HTTPResponse("test", 200) @bottle.route() def test3(): raise HTTPResponse("test", 200) @bottle.hook('after_request') def hook(): bottle.response.headers["X-Hook"] = 'works' for route in ("/test1", "/test2", "/test3"): self.assertBody('test', route) self.assertHeader('X-Hook', 'works', route) def test_template(self): @bottle.route(template='test {{a}} {{b}}') def test(): return dict(a=5, b=6) self.assertBody('test 5 6', '/test') def test_template_opts(self): @bottle.route(template=('test {{a}} {{b}}', {'b': 6})) def test(): return dict(a=5) self.assertBody('test 5 6', '/test') def test_name(self): @bottle.route(name='foo') def test(x=5): return 'ok' self.assertEqual('/test/6', bottle.url('foo', x=6)) def test_callback(self): def test(x=5): return str(x) rv = bottle.route(callback=test) self.assertBody('5', '/test') self.assertBody('6', '/test/6') self.assertEqual(rv, test) class TestDecorators(ServerTestBase): ''' Tests Decorators ''' def test_view(self): """ WSGI: Test view-decorator (should override autojson) """ with chdir(__file__): @bottle.route('/tpl') @bottle.view('stpl_t2main') def test(): return dict(content='1234') result = '+base+\n+main+\n!1234!\n+include+\n-main-\n+include+\n-base-\n' self.assertHeader('Content-Type', 'text/html; charset=UTF-8', '/tpl') self.assertBody(result, '/tpl') def test_view_error(self): """ WSGI: Test if view-decorator reacts on non-dict return values correctly.""" @bottle.route('/tpl') @bottle.view('stpl_t2main') def test(): return bottle.HTTPError(401, 'The cake is a lie!') self.assertInBody('The cake is a lie!', '/tpl') self.assertInBody('401 Unauthorized', '/tpl') self.assertStatus(401, '/tpl') def test_truncate_body(self): """ WSGI: Some HTTP status codes must not be used with a response-body """ @bottle.route('/test/') def test(code): bottle.response.status = int(code) return 'Some body content' self.assertBody('Some body content', '/test/200') self.assertBody('', '/test/100') self.assertBody('', '/test/101') self.assertBody('', '/test/204') self.assertBody('', '/test/304') def test_routebuild(self): """ WSGI: Test route builder """ def foo(): pass bottle.route('/a//c', name='named')(foo) bottle.request.environ['SCRIPT_NAME'] = '' self.assertEqual('/a/xxx/c', bottle.url('named', b='xxx')) self.assertEqual('/a/xxx/c', bottle.app().get_url('named', b='xxx')) bottle.request.environ['SCRIPT_NAME'] = '/app' self.assertEqual('/app/a/xxx/c', bottle.url('named', b='xxx')) bottle.request.environ['SCRIPT_NAME'] = '/app/' self.assertEqual('/app/a/xxx/c', bottle.url('named', b='xxx')) bottle.request.environ['SCRIPT_NAME'] = 'app/' self.assertEqual('/app/a/xxx/c', bottle.url('named', b='xxx')) def test_autoroute(self): app = bottle.Bottle() def a(): pass def b(x): pass def c(x, y): pass def d(x, y=5): pass def e(x=5, y=6): pass self.assertEqual(['/a'],list(bottle.yieldroutes(a))) self.assertEqual(['/b/'],list(bottle.yieldroutes(b))) self.assertEqual(['/c//'],list(bottle.yieldroutes(c))) self.assertEqual(['/d/','/d//'],list(bottle.yieldroutes(d))) self.assertEqual(['/e','/e/','/e//'],list(bottle.yieldroutes(e))) class TestAppShortcuts(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) def testWithStatement(self): default = bottle.default_app() inner_app = bottle.Bottle() self.assertEqual(default, bottle.default_app()) with inner_app: self.assertEqual(inner_app, bottle.default_app()) self.assertEqual(default, bottle.default_app()) def assertWraps(self, test, other): self.assertEqual(test.__doc__, other.__doc__) def test_module_shortcuts(self): for name in '''route get post put delete error mount hook install uninstall'''.split(): short = getattr(bottle, name) original = getattr(bottle.app(), name) self.assertWraps(short, original) def test_module_shortcuts_with_different_name(self): self.assertWraps(bottle.url, bottle.app().get_url) python-bottle-0.13.2/test/tools.py000077500000000000000000000140621470367422500171160ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import with_statement import os import bottle import sys import unittest import wsgiref import wsgiref.util import wsgiref.validate import warnings import mimetypes import uuid from bottle import tob, tonat, BytesIO, py3k, unicode def warn(msg): sys.stderr.write('WARNING: %s\n' % msg.strip()) def tobs(data): ''' Transforms bytes or unicode into a byte stream. ''' return BytesIO(tob(data)) class chdir(object): def __init__(self, dir): if os.path.isfile(dir): dir = os.path.dirname(dir) self.wd = os.path.abspath(dir) self.old = os.path.abspath('.') def __enter__(self): os.chdir(self.wd) def __exit__(self, exc_type, exc_val, tb): os.chdir(self.old) class assertWarn(object): def __init__(self, text): self.searchtext = text def __call__(self, func): def wrapper(*a, **ka): with warnings.catch_warnings(record=True) as wr: warnings.simplefilter("always") out = func(*a, **ka) messages = [repr(w.message) for w in wr] for msg in messages: if self.searchtext in msg: return out raise AssertionError("Could not find phrase %r in any warning messaged: %r" % (self.searchtext, messages)) return wrapper def api(introduced, deprecated=None, removed=None): current = tuple(map(int, bottle.__version__.split('-')[0].split('.'))) introduced = tuple(map(int, introduced.split('.'))) deprecated = tuple(map(int, deprecated.split('.'))) if deprecated else (99,99) removed = tuple(map(int, removed.split('.'))) if removed else (99,100) assert introduced < deprecated < removed def decorator(func): if current < introduced: return None elif current < deprecated: return func elif current < removed: func.__doc__ = '(deprecated) ' + (func.__doc__ or '') return assertWarn('DeprecationWarning')(func) else: return None return decorator def wsgistr(s): if py3k: return s.encode('utf8').decode('latin1') else: return s class ServerTestBase(unittest.TestCase): def setUp(self): ''' Create a new Bottle app set it as default_app ''' self.port = 8080 self.host = 'localhost' self.app = bottle.app.push() self.wsgiapp = wsgiref.validate.validator(self.app) def urlopen(self, path, method='GET', post='', env=None): result = {'code':0, 'status':'error', 'header':{}, 'body':tob('')} def start_response(status, header, exc_info=None): result['code'] = int(status.split()[0]) result['status'] = status.split(None, 1)[-1] for name, value in header: name = name.title() if name in result['header']: result['header'][name] += ', ' + value else: result['header'][name] = value env = env if env else {} wsgiref.util.setup_testing_defaults(env) env['REQUEST_METHOD'] = wsgistr(method.upper().strip()) env['PATH_INFO'] = wsgistr(path) env['QUERY_STRING'] = wsgistr('') if post: env['REQUEST_METHOD'] = 'POST' env['CONTENT_LENGTH'] = str(len(tob(post))) env['wsgi.input'].write(tob(post)) env['wsgi.input'].seek(0) response = self.wsgiapp(env, start_response) for part in response: try: result['body'] += part except TypeError: raise TypeError('WSGI app yielded non-byte object %s', type(part)) if hasattr(response, 'close'): response.close() del response return result def postmultipart(self, path, fields, files): env = multipart_environ(fields, files) return self.urlopen(path, method='POST', env=env) def tearDown(self): bottle.app.pop() def assertStatus(self, code, route='/', **kargs): self.assertEqual(code, self.urlopen(route, **kargs)['code']) def assertBody(self, body, route='/', **kargs): self.assertEqual(tob(body), self.urlopen(route, **kargs)['body']) def assertInBody(self, body, route='/', **kargs): result = self.urlopen(route, **kargs)['body'] if tob(body) not in result: self.fail('The search pattern "%s" is not included in body:\n%s' % (body, result)) def assertHeader(self, name, value, route='/', **kargs): self.assertEqual(value, self.urlopen(route, **kargs)['header'].get(name)) def assertHeaderAny(self, name, route='/', **kargs): self.assertTrue(self.urlopen(route, **kargs)['header'].get(name, None)) def assertInError(self, search, route='/', **kargs): bottle.request.environ['wsgi.errors'].errors.seek(0) err = bottle.request.environ['wsgi.errors'].errors.read() if search not in err: self.fail('The search pattern "%s" is not included in wsgi.error: %s' % (search, err)) def multipart_environ(fields, files): boundary = 'lowerUPPER-1234' env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE': 'multipart/form-data; boundary='+boundary} wsgiref.util.setup_testing_defaults(env) boundary = '--' + boundary body = '' for name, value in fields: body += boundary + '\r\n' body += 'Content-Disposition: form-data; name="%s"\r\n\r\n' % name body += value + '\r\n' for name, filename, content in files: mimetype = str(mimetypes.guess_type(filename)[0]) or 'application/octet-stream' body += boundary + '\r\n' body += 'Content-Disposition: file; name="%s"; filename="%s"\r\n' % \ (name, filename) body += 'Content-Type: %s\r\n\r\n' % mimetype body += content + '\r\n' body += boundary + '--\r\n' if isinstance(body, unicode): body = body.encode('utf8') env['CONTENT_LENGTH'] = str(len(body)) env['wsgi.input'].write(body) env['wsgi.input'].seek(0) return env python-bottle-0.13.2/test/views/000077500000000000000000000000001470367422500165335ustar00rootroot00000000000000python-bottle-0.13.2/test/views/jinja2_base.tpl000066400000000000000000000000531470367422500214210ustar00rootroot00000000000000begin {% block content %}{% endblock %} endpython-bottle-0.13.2/test/views/jinja2_inherit.tpl000066400000000000000000000001001470367422500221420ustar00rootroot00000000000000{% extends "jinja2_base" %} {% block content %}abc{% endblock %}python-bottle-0.13.2/test/views/jinja2_simple.tpl000066400000000000000000000000211470367422500217730ustar00rootroot00000000000000start {{var}} endpython-bottle-0.13.2/test/views/mako_base.tpl000066400000000000000000000000211470367422500211660ustar00rootroot00000000000000o${self.body()}o python-bottle-0.13.2/test/views/mako_inherit.tpl000066400000000000000000000000521470367422500217220ustar00rootroot00000000000000<%inherit file="mako_base.tpl"/> c${var}c python-bottle-0.13.2/test/views/mako_simple.tpl000066400000000000000000000000211470367422500215450ustar00rootroot00000000000000start ${var} end python-bottle-0.13.2/test/views/stpl_include.tpl000066400000000000000000000000561470367422500217420ustar00rootroot00000000000000before %include('stpl_simple', var=var) after python-bottle-0.13.2/test/views/stpl_no_vars.tpl000066400000000000000000000000041470367422500217570ustar00rootroot00000000000000hihipython-bottle-0.13.2/test/views/stpl_simple.tpl000066400000000000000000000000221470367422500216010ustar00rootroot00000000000000start {{var}} end python-bottle-0.13.2/test/views/stpl_t2base.tpl000066400000000000000000000001231470367422500214720ustar00rootroot00000000000000%test('base') {{base}}\\ %_ = include('stpl_t2inc', test=test) %_['test2']('base') python-bottle-0.13.2/test/views/stpl_t2inc.tpl000066400000000000000000000000611470367422500213320ustar00rootroot00000000000000%test('include') %def test2(var): -{{var}}- %end python-bottle-0.13.2/test/views/stpl_t2main.tpl000066400000000000000000000002271470367422500215110ustar00rootroot00000000000000%def test(var): +{{var}}+ %end %rebase('stpl_t2base', test=test) %test('main') !{{content}}! %_ = include('stpl_t2inc', test=test) %_['test2']('main') python-bottle-0.13.2/test/views/stpl_unicode.tpl000066400000000000000000000000351470367422500217420ustar00rootroot00000000000000start {{"ñç"}} {{var}} end python-bottle-0.13.2/tox.ini000066400000000000000000000004221470367422500157300ustar00rootroot00000000000000[tox] envlist = py27,py36,py37,py38,py39,py27-most [testenv] deps=Mako jinja2 commands={envpython} -m unittest discover sitepackages=False [testenv:py27-most] basepython=python2.7 deps=Mako jinja2 eventlet cherrypy paste twisted tornado