summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rwxr-xr-xdocs/api.rst29
-rwxr-xr-xdocs/changelog.rst8
-rw-r--r--docs/deployment.rst7
-rwxr-xr-xdocs/index.rst4
-rwxr-xr-xdocs/plugindev.rst2
-rwxr-xr-xdocs/tutorial.rst6
-rw-r--r--docs/tutorial_app.rst22
7 files changed, 40 insertions, 38 deletions
diff --git a/docs/api.rst b/docs/api.rst
index f2c8129..aeb4ff0 100755
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -107,16 +107,6 @@ Exceptions
.. autoexception:: BottleException
:members:
-.. autoexception:: HTTPResponse
- :members:
-
-.. autoexception:: HTTPError
- :members:
-
-.. autoexception:: RouteReset
- :members:
-
-
The :class:`Bottle` Class
@@ -134,18 +124,16 @@ 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.
-You usually don't instantiate :class:`Request` yourself, but use the module-level :data:`bottle.request` instance. This instance is thread-local and refers to the `current` request, or in other words, the request that is currently processed by the request handler in the current context. `Thread locality` means that you can safely use a global instance in a multithreaded environment.
-
.. autoclass:: Request
:members:
-.. autoclass:: LocalRequest
- :members:
-
.. autoclass:: BaseRequest
:members:
+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.
+.. autoclass:: LocalRequest
+ :members:
The :class:`Response` Object
@@ -156,10 +144,19 @@ The :class:`Response` class stores the HTTP status code as well as headers and c
.. autoclass:: Response
:members:
+.. autoclass:: BaseResponse
+ :members:
+
.. autoclass:: LocalResponse
:members:
-.. autoclass:: BaseResponse
+
+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.
+
+.. autoexception:: HTTPResponse
+ :members:
+
+.. autoexception:: HTTPError
:members:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index cda94fd..44a37f4 100755
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -12,10 +12,10 @@ 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 the application.
+* The new :class:`ResourceManager` interface helps locating files bundled with an application.
* Added a server adapter for `waitress <http://docs.pylonsproject.org/projects/waitress/en/latest/>`_.
* 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 that request.
+* 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.
@@ -95,7 +95,7 @@ This release is mostly backward compatible, but some APIs are marked deprecated
Release 0.8
============
-.. rubric:: API changes
+.. rubric:: API changes
These changes may break compatibility with previous versions.
@@ -121,7 +121,7 @@ These changes may break compatibility with previous versions.
.. rubric:: New features
-This is an incomplete list of new features and improved functionality.
+This is an incomplete list of new features and improved functionality.
* 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`.
* 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.
diff --git a/docs/deployment.rst b/docs/deployment.rst
index d97fcb1..7371ac2 100644
--- a/docs/deployment.rst
+++ b/docs/deployment.rst
@@ -14,6 +14,11 @@
.. _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
+
+
.. _tutorial-deployment:
@@ -87,7 +92,7 @@ If there is no adapter for your favorite server or if you need more control over
Apache mod_wsgi
--------------------------------------------------------------------------------
-Instead of running your own HTTP server from within Bottle, you can attach Bottle applications to an `Apache server`_ using mod_wsgi_.
+Instead of running your own HTTP server from within Bottle, you can attach Bottle applications to an `Apache server <apache>`_ using mod_wsgi_.
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.
diff --git a/docs/index.rst b/docs/index.rst
index 9179c4a..1bb081b 100755
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -31,11 +31,11 @@ Bottle is a fast, simple and lightweight WSGI_ micro web-framework for Python_.
::
- from bottle import route, run
+ from bottle import route, run, template
@route('/hello/:name')
def index(name='World'):
- return '<b>Hello %s!</b>' % name
+ return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
diff --git a/docs/plugindev.rst b/docs/plugindev.rst
index 1649149..40da98c 100755
--- a/docs/plugindev.rst
+++ b/docs/plugindev.rst
@@ -31,7 +31,7 @@ Of course, this is just a simplification. Plugins can do a lot more than just de
return body
return wrapper
- bottle.install(stopwatch)
+ install(stopwatch)
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.
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 9c1bccb..9ef531d 100755
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -23,7 +23,7 @@
Tutorial
========
-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 refecence 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 <mailto:bottlepy@googlegroups.com>`_ or visit us in our `IRC channel <http://webchat.freenode.net/?channels=bottlepy>`_.
+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 <mailto:bottlepy@googlegroups.com>`_ or visit us in our `IRC channel <http://webchat.freenode.net/?channels=bottlepy>`_.
.. _installation:
@@ -93,7 +93,7 @@ The `Default Application`
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::
- from bottle import Bottle, run
+ from bottle import Bottle, run, template
app = Bottle()
@@ -124,7 +124,7 @@ The :func:`route` decorator links an URL path to a callback function, and adds a
@route('/')
@route('/hello/<name>')
def greet(name='Stranger'):
- return 'Hello %s, how are you?' % name
+ 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.
diff --git a/docs/tutorial_app.rst b/docs/tutorial_app.rst
index 0a0201d..0b41ee0 100644
--- a/docs/tutorial_app.rst
+++ b/docs/tutorial_app.rst
@@ -250,21 +250,21 @@ The code needs to be extended to::
@route('/new', method='GET')
def new_item():
- if request.GET.get('save','').strip():
+ if request.GET.get('save','').strip():
- new = request.GET.get('task', '').strip()
- conn = sqlite3.connect('todo.db')
- c = conn.cursor()
+ new = request.GET.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
+ c.execute("INSERT INTO todo (task,status) VALUES (?,?)", (new,1))
+ new_id = c.lastrowid
- conn.commit()
- c.close()
+ conn.commit()
+ c.close()
- return '<p>The new task was inserted into the database, the ID is %s</p>' % new_id
- else:
- return template('new_task.tpl')
+ return '<p>The new task was inserted into the database, the ID is %s</p>' % new_id
+ else:
+ return template('new_task.tpl')
``new_task.tpl`` looks like this::