AuhKit + Paste + Roundup issue tracker

0 views
Skip to first unread message

Ksenia

unread,
Mar 12, 2008, 5:44:47 PM3/12/08
to AuthKit
Hi,

I am trying to use AuthKit and Roundup issue tracker (http://
roundup.sourceforge.net/) together. It almost work, but I am getting
an exception from Roundup wsgi handler:

Exception happened during processing of request from ('127.0.0.1',
56941)
Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpserver.py", line 1056, in
process_request_in_thread
self.finish_request(request, client_address)
File "/opt/local/lib/python2.5/SocketServer.py", line 254, in
finish_request
self.RequestHandlerClass(request, client_address, self)
File "/opt/local/lib/python2.5/SocketServer.py", line 522, in
__init__
self.handle()
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpserver.py", line 432, in handle
BaseHTTPRequestHandler.handle(self)
File "/opt/local/lib/python2.5/BaseHTTPServer.py", line 316, in
handle
self.handle_one_request()
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpserver.py", line 427, in handle_one_request
self.wsgi_execute()
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/urlmap.py", line 202, in __call__
return app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authenticate/__init__.py", line 324, in __call__
return self.app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authenticate/basic.py", line 126, in __call__
return self.application(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authenticate/multi.py", line 62, in __call__
app_iter = app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authenticate/multi.py", line 32, in app
return self.default(environ, find)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authenticate/__init__.py", line 314, in __call__
return self.app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpexceptions.py", line 632, in __call__
return self.application(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/authorize/wsgi_adaptors.py", line 101, in __call__
return self.permission.check(self.app, environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r147-
py2.5.egg/authkit/permissions.py", line 305, in check
return app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/
wsgi_handler.py", line 57, in __call__
client.main()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 252, in main
self.inner_main()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 381, in inner_main
self.write_html(cgitb.html(i18n=self.translator))
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 934, in write_html
self._socket_op(self.request.wfile.write, content)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 899, in _socket_op
call(*args, **kwargs)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/
wsgi_handler.py", line 21, in write
f = self.request.get_wfile()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/
wsgi_handler.py", line 73, in get_wfile
raise ValueError, 'start_response() not called'
ValueError: start_response() not called



The source code of Roundup wsgi adaptor can be found here:
http://roundup.cvs.sourceforge.net/roundup/roundup/roundup/cgi/wsgi_handler.py?view=markup


My wsgi application script looks like this:

========8<==========
import os
from roundup.cgi.wsgi_handler import RequestDispatcher
import authkit.authenticate
import authkit.authorize
from authkit.permissions import ValidAuthKitUser

def make_app(global_conf, full_stack=True, **app_conf):
permission = ValidAuthKitUser()
tracker_home = os.path.dirname(os.path.abspath(__file__))
app = RequestDispatcher(tracker_home)
app = authkit.authorize.middleware(app, permission)
app = authkit.authenticate.middleware(app, app_conf)
return app
========8<==========

My Paste configuration file:
========8<==========
[composite:main]
use = egg:Paste#urlmap
/ = site
/tickets = tickets

[app:tickets]
use = egg:myticketsapp
authkit.setup.enable = true
authkit.setup.method = basic
authkit.basic.authenticate.user.data = ksenia:secret
authkit.basic.realm = Tickets

[app:site]
# pylons application setup...
========8<==========

Am I doing something wrong? What could be the problem?

Thanks!
Ksenia.

Ksenia

unread,
Mar 13, 2008, 3:56:59 PM3/13/08
to AuthKit
After poking around the trac I believe this is the same problem s
reported by Alberto in this ticket:
http://authkit.org/trac/ticket/41

Ksenia

James Gardner

unread,
Mar 14, 2008, 9:44:49 AM3/14/08
to aut...@googlegroups.com
Hi Ksenia,

Thanks for pointing that out. I've checked in an experimental solution.
Would you mind upgrading to the latest SVN and having a go with it?

Cheers,

James

Ksenia

unread,
Mar 14, 2008, 11:30:02 AM3/14/08
to AuthKit
Hi James,

Fantastic, thank you! It works.

Ksenia.

Ksenia

unread,
Mar 18, 2008, 10:43:23 AM3/18/08
to AuthKit
Hi again,

I've noticed that when certain url's are requested, the application
hangs and I see this error in the terminal:
"AssertionError: Attempt to set headers a second time w/o an exc_info"
(See traceback below)

It happens also when Roundup is serving static files.

Thanks for your help!
Ksenia.

Exception happened during processing of request from ('127.0.0.1',
62429)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/__init__.py", line 324, in __call__
return self.app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/cookie.py", line 395, in __call__
return self.app(environ, cookie_setting_start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/multi.py", line 85, in __call__
app_iter = app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/multi.py", line 55, in app
return self.default(environ, find)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/__init__.py", line 314, in __call__
return self.app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/__init__.py", line 337, in __call__
return self.app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpexceptions.py", line 632, in __call__
return self.application(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authorize/wsgi_adaptors.py", line 101, in __call__
return self.permission.check(self.app, environ, start_response)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/permissions.py", line 305, in check
return app(environ, start_response)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/
wsgi_handler.py", line 57, in __call__
client.main()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 252, in main
self.inner_main()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 381, in inner_main
self.write_html(cgitb.html(i18n=self.translator))
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 922, in write_html
self.header()
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 963, in header
self._socket_op(self.request.start_response, headers, response)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/client.py",
line 899, in _socket_op
call(*args, **kwargs)
File "/opt/local/lib/python2.5/site-packages/roundup/cgi/
wsgi_handler.py", line 69, in start_response
description), headers)
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/multi.py", line 45, in find
exc_info_[0]
File "/opt/local/lib/python2.5/site-packages/AuthKit-0.4.1dev_r150-
py2.5.egg/authkit/authenticate/cookie.py", line 394, in
cookie_setting_start_response
return start_response(status, headers, exc_info)
File "/opt/local/lib/python2.5/site-packages/Paste-1.6.1dev_r7262-
py2.5.egg/paste/httpserver.py", line 166, in wsgi_start_response
assert 0, "Attempt to set headers a second time w/o an exc_info"
AssertionError: Attempt to set headers a second time w/o an exc_info
----------------------------------------

Ksenia

unread,
Mar 26, 2008, 3:53:38 AM3/26/08
to AuthKit
With the hope that this problem might be fixed in the trunk, I've
tried to update AuthKit. But there to a permission problem in the
trunk:

# sudo easy_install -U AuthKit==dev
Password:
Searching for AuthKit==dev
Reading http://pypi.python.org/simple/AuthKit/
Reading http://authkit.org/
Reading http://3aims.com/
Reading http://pylonshq.com/
Best match: AuthKit dev
Downloading http://authkit.org/svn/AuthKit/trunk#egg=AuthKit-dev
error: Can't download http://authkit.org/svn/AuthKit/trunk: 403
Forbidden

Ksenia.

James Gardner

unread,
Mar 26, 2008, 8:05:01 AM3/26/08
to aut...@googlegroups.com
Hi Ksenia,

Sorry, try now.

I'm afraid the original problem you've described could be a little
tricky to track down because we need to know the first time the headers
were set. Did it work before I upgraded the code to return the writeable
from start_response()?

Cheers,

James

Ksenia

unread,
May 20, 2008, 2:53:40 PM5/20/08
to AuthKit
Hi James,

I've found the source of the problem! It had nothing to do with
AuthKit, but with Roundup wsgi handler being not thread-safe. During
simultaneous requests the same request instance was re-used across
several threads with Paste error as a result. I've submitted a patch
to Roundup.
Sorry for the noise :)

Ksenia

On Mar 26, 2:05 pm, James Gardner <ja...@pythonweb.org> wrote:
> Hi Ksenia,
>
> Sorry, try now.
>
> I'm afraid the original problem you've described could be a little
> tricky to track down because we need to know the first time the headers
> were set. Did it work before I upgraded the code to return the writeable
> from start_response()?
>
> Cheers,
>
> James
>
> Ksenia wrote:
> > With the hope that this problem might be fixed in the trunk, I've
> > tried to update AuthKit. But there to a permission problem in the
> > trunk:
>
> > # sudo easy_install -U AuthKit==dev
> > Password:
> > Searching for AuthKit==dev
> > Readinghttp://pypi.python.org/simple/AuthKit/
> > Readinghttp://authkit.org/
> > Readinghttp://3aims.com/
> > Readinghttp://pylonshq.com/
> > Best match: AuthKit dev
> > Downloadinghttp://authkit.org/svn/AuthKit/trunk#egg=AuthKit-dev
> > error: Can't downloadhttp://authkit.org/svn/AuthKit/trunk:403
Reply all
Reply to author
Forward
0 new messages