diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-01-20 19:55:54 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-01-20 19:55:54 +0000 |
| commit | eca67ac2005bcac3b8d14d051e5e800ea36f42a8 (patch) | |
| tree | 0dcac61810cba831bd1d484478781cd76ca2e09f /repoze/bfg/request.py | |
| parent | 32634a8734321d0c61892dd6fd90451d380cf6f9 (diff) | |
| download | pyramid-eca67ac2005bcac3b8d14d051e5e800ea36f42a8.tar.gz pyramid-eca67ac2005bcac3b8d14d051e5e800ea36f42a8.tar.bz2 pyramid-eca67ac2005bcac3b8d14d051e5e800ea36f42a8.zip | |
# We use 'precooked' Request subclasses that correspond to HTTP
# request methods within ``router.py`` when constructing a request
# object rather than using ``alsoProvides`` to attach the proper
# interface to an unsubclassed webob.Request. This pattern is purely
# an optimization (e.g. preventing calls to ``alsoProvides`` means the
# difference between 590 r/s and 690 r/s on a MacBook 2GHz).
Diffstat (limited to 'repoze/bfg/request.py')
| -rw-r--r-- | repoze/bfg/request.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/repoze/bfg/request.py b/repoze/bfg/request.py new file mode 100644 index 000000000..c764a2e9b --- /dev/null +++ b/repoze/bfg/request.py @@ -0,0 +1,38 @@ +from zope.interface import implements +from webob import Request as WebobRequest + +import repoze.bfg.interfaces + +# We use 'precooked' Request subclasses that correspond to HTTP +# request methods within ``router.py`` when constructing a request +# object rather than using ``alsoProvides`` to attach the proper +# interface to an unsubclassed webob.Request. This pattern is purely +# an optimization (e.g. preventing calls to ``alsoProvides`` means the +# difference between 590 r/s and 690 r/s on a MacBook 2GHz). + +class Request(WebobRequest): + implements(repoze.bfg.interfaces.IRequest) + +class GETRequest(WebobRequest): + implements(repoze.bfg.interfaces.IGETRequest) + +class POSTRequest(WebobRequest): + implements(repoze.bfg.interfaces.IPOSTRequest) + +class PUTRequest(WebobRequest): + implements(repoze.bfg.interfaces.IPUTRequest) + +class DELETERequest(WebobRequest): + implements(repoze.bfg.interfaces.IDELETERequest) + +class HEADRequest(WebobRequest): + implements(repoze.bfg.interfaces.IHEADRequest) + +HTTP_METHOD_FACTORIES = { + 'GET':GETRequest, + 'POST':POSTRequest, + 'PUT':PUTRequest, + 'DELETE':DELETERequest, + 'HEAD':HEADRequest, + } + |
