summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorIan Bicking <ianb@colorstudy.com>2010-04-01 14:31:48 -0500
committerIan Bicking <ianb@colorstudy.com>2010-04-01 14:31:48 -0500
commite230a7874a1ac99e4c073eaf81d638820d836d6d (patch)
tree180fd8f60cdb92f1c44d0c3af3c574f9e0cfaec9 /docs
parentcb0d71678da0b45148c1a15ac86b3d2b3a341634 (diff)
downloadpaste-e230a7874a1ac99e4c073eaf81d638820d836d6d.tar.gz
doc fixups
Diffstat (limited to 'docs')
-rw-r--r--docs/do-it-yourself-framework.txt92
-rw-r--r--docs/future.txt3
-rw-r--r--docs/modules/auth.open_id.txt12
-rw-r--r--docs/modules/wsgilib.txt1
-rw-r--r--docs/news.txt2
5 files changed, 75 insertions, 35 deletions
diff --git a/docs/do-it-yourself-framework.txt b/docs/do-it-yourself-framework.txt
index a11d799..ae77ec0 100644
--- a/docs/do-it-yourself-framework.txt
+++ b/docs/do-it-yourself-framework.txt
@@ -149,6 +149,8 @@ In a typical Python object publisher you translate ``/`` to ``.``. So
``/articles/view?id=5`` turns into ``root.articles.view(id=5)``. We
have to start with some root object, of course, which we'll pass in...
+::
+
class ObjectPublisher(object):
def __init__(self, root):
@@ -300,6 +302,9 @@ Lets's update that::
import threading
webinfo = threading.local()
+ class ObjectPublisher(object):
+ ...
+
def __call__(self, environ, start_response):
webinfo.request = Request(environ)
webinfo.response = Response()
@@ -325,10 +330,10 @@ WSGI Middleware
`Middleware
<http://www.python.org/peps/pep-0333.html#middleware-components-that-play-both-sides>`_
-is where people get a little intimidated by WSGI and Paste.
+is where people get a little intimidated by WSGI and Paste.
What is middleware? Middleware is software that serves as an
-intermediary.
+intermediary.
So lets
@@ -378,6 +383,24 @@ return the response body, but we're skimming bits.
<http://pythonpaste.org/module-paste.wsgilib.html#intercept_output>`_
is a somewhat more thorough implementation of this.
+.. note::
+
+ This, like a lot of parts of this (now fairly old) tutorial is
+ better, more thorough, and easier using `WebOb
+ <http://pythonpaste.org/webob/>`_. This particular example looks
+ like::
+
+ from webob import Request
+
+ class Capitalizer(object):
+ def __init__(self, app):
+ self.app = app
+ def __call__(self, environ, start_response):
+ req = Request(environ)
+ resp = req.get_response(self.app)
+ resp.body = resp.body.upper()
+ return resp(environ, start_response)
+
So here's some code that does something useful, authentication::
class AuthMiddleware(object):
@@ -422,6 +445,43 @@ So here's some code that does something useful, authentication::
</body>
</html>"""]
+.. note::
+
+ Again, here's the same thing with WebOb::
+
+ from webob import Request, Response
+
+ class AuthMiddleware(object):
+ def __init__(self, app):
+ self.app = app
+ def __call__(self, environ, start_response):
+ req = Request(environ)
+ if not self.authorized(req.headers['authorization']):
+ resp = self.auth_required(req)
+ else:
+ resp = self.app
+ return resp(environ, start_response)
+ def authorized(self, header):
+ if not header:
+ return False
+ auth_type, encoded = header.split(None, 1)
+ if not auth_type.lower() == 'basic':
+ return False
+ username, password = encoded.decode('base64').split(':', 1)
+ return self.check_password(username, password)
+ def check_password(self, username, password):
+ return username == password
+ def auth_required(self, req):
+ return Response(status=401, headers={'WWW-Authenticate': 'Basic realm="this realm"'},
+ body="""\
+ <html>
+ <head><title>Authentication Required</title></head>
+ <body>
+ <h1>Authentication Required</h1>
+ If you can't get in, then stay out.
+ </body>
+ </html>""")
+
So, how do we use this?
::
@@ -463,22 +523,16 @@ Easy! But let's make it *more* fancy...
So go make an error now. And hit the little +'s. And type stuff in
to the boxes.
-Configuration
-=============
+Conclusion
+==========
Now that you've created your framework and application (I'm sure it's
-much nicer than the one I've given so far) you might find the manually
-plugging together of some of these pieces a little crude. Well, if
-*you* don't, anyone else who uses your app and wants to install it in
-a different location or configure it differently won't be as happy.
-
-So, we want to separate the application setup from the application
-configuration.
-
-What's Next?
-============
-
-Stay tuned, I'll be talking about configuration (using `Paste Deploy
-<http://pythonpaste.org/deploy/>`_) later, and I hope to give a short
-introduction to packaging and plugins as well. When that happens I'll
-note it on `my blog <http://blog.ianbicking.org>`_.
+much nicer than the one I've given so far). You might keep writing it
+(many people have so far), but even if you don't you should be able to
+recognize these components in other frameworks now, and you'll have a
+better understanding how they probably work under the covers.
+
+Also check out the version of this tutorial written `using WebOb
+<http://pythonpaste.org/webob/do-it-yourself.html>`_. That tutorial
+includes things like **testing** and **pattern-matching dispatch**
+(instead of object publishing).
diff --git a/docs/future.txt b/docs/future.txt
index d058758..697c750 100644
--- a/docs/future.txt
+++ b/docs/future.txt
@@ -4,7 +4,7 @@ The Future Of Paste
Introduction
------------
-Paste has been under development for a while, and has lots of code in it. Too much code! The code is largely decoupled except for some core functions shared by many parts of the code. Those core functions are largely replaced in `WebOb <>`_, and replaced with better implementations.
+Paste has been under development for a while, and has lots of code in it. Too much code! The code is largely decoupled except for some core functions shared by many parts of the code. Those core functions are largely replaced in `WebOb <http://pythonpaste.org/webob/>`_, and replaced with better implementations.
The future of these pieces is to split them into independent packages, and refactor the internal Paste dependencies to rely instead on WebOb.
@@ -106,4 +106,3 @@ paste.debug.debugapp, paste.script.testapp:
paste.progress:
Not sure this works.
-
diff --git a/docs/modules/auth.open_id.txt b/docs/modules/auth.open_id.txt
deleted file mode 100644
index d60af3e..0000000
--- a/docs/modules/auth.open_id.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-:mod:`paste.auth.open_id` -- OpenID authentication
-==================================================
-
-.. automodule:: paste.auth.open_id
-
-Module Contents
----------------
-
-.. comment:
-
- .. autoclass:: AuthOpenIDHandler
- .. autofunction:: make_open_id_middleware
diff --git a/docs/modules/wsgilib.txt b/docs/modules/wsgilib.txt
index 5c443c7..e40d426 100644
--- a/docs/modules/wsgilib.txt
+++ b/docs/modules/wsgilib.txt
@@ -15,5 +15,4 @@ Module Contents
.. autofunction:: raw_interactive
.. autofunction:: interactive
.. autofunction:: dump_environ
-.. autofunction:: capture_stdout
.. autofunction:: intercept_output
diff --git a/docs/news.txt b/docs/news.txt
index 4e8e270..0384bad 100644
--- a/docs/news.txt
+++ b/docs/news.txt
@@ -135,7 +135,7 @@ hg tip
* Make :mod:`paste.debug.prints` compatible with App Engine.
* Fix the ``domain`` keyword in
- :method:`paste.wsgiwrappers.WSGIResponse.delete_cookie`.
+ :meth:`paste.wsgiwrappers.WSGIResponse.delete_cookie`.
1.6.1
-----