I really like the paste.auth.cookie module, but I have a few questions:
1. This is less important, but why wasn't the old school Cookie module
used instead of constructing the cookie by hand?
2. I need to set the domain of the cookie, but there isn't a way.
This relates slightly to question 1. I can think of many ways to
architect this including:
a) Setup the AuthCookieHandler class so that it can be subclassed
easily. This would involve breaking up the response_hook a little
bit.
b) paste.auth.cookie.AuthCookieHandler could look for a callable in
environ that is used to do some post processing of the cookie.
Right now, I don't see any other options than copying and modifying
the whole module.
3. I'm using Pylons, and I have the AuthCookieHandler installed in my
pipeline like this:
PylonsApp
...
httpexceptions.make_middleware
AuthCookieHandler
ErrorHandler
...
I'm initializing via:
# Setup paste.auth.cookie. Putting it here is perfect because
# redirects still get cookies, but exceptions still get handled.
app = AuthCookieHandler(app,
cookie_name=app_conf['acctmgr_cookie_name'],
secret=app_conf['acctmgr_secret'])
Unfortunately, putting it here *is not* perfect, because I see in my logs:
=================================================================
Exception happened during processing of request from ('127.0.0.1', 43522)
Traceback (most recent call last):
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/httpserver.py",
line 404, in process_request_in_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.4/SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.4/SocketServer.py", line 521, in __init__
self.handle()
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/httpserver.py",
line 325, in handle
BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.4/BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "/usr/lib/python2.4/BaseHTTPServer.py", line 310, in handle_one_request
method()
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/httpserver.py",
line 228, in wsgi_execute
self.wsgi_start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/registry.py",
line 309, in __call__
app_iter = self.application(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/recursive.py",
line 83, in __call__
return CheckForRecursionMiddleware(e.factory(self),
environ)(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/recursive.py",
line 46, in __call__
return self.app(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/errordocument.py",
line 77, in __call__
return self.app(environ, keep_status_start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/recursive.py",
line 81, in __call__
return self.application(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/errordocument.py",
line 181, in __call__
app_iter = self.application(environ, change_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/cascade.py",
line 92, in __call__
return self.apps[-1](environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/evalexception/middleware.py",
line 175, in __call__
return self.respond(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Pylons-0.9.2-py2.4.egg/pylons/error.py",
line 210, in respond
return self.application(environ, start_response)
File
"/usr/lib/python2.4/site-packages/Paste-0.9.8.1-py2.4.egg/paste/auth/cookie.py",
line 249, in __call__
raise AssertionError("AuthCookie already installed!")
AssertionError: AuthCookie already installed!
=================================================================
This happens whenever I do something like "abort(404)" in my code. I
think it has to do with Paste doing another "subrequest". I think the
auth.cookie code is surprised to see the same environ again. I don't
understand where in the pipeline I should put the auth.cookie
middleware so that I don't have this problem. I didn't see any
mention in the docs where I should put it.
Thanks for the code and all your help!
Best Regards,
-jj
--
The one who gets the last laugh isn't the one who did the laughing,
but rather the one who did the writing.
_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users