-> > Attached is a patch that makes three changes minimally necessary to support
-> > a model for one request/thread, multiple requests per publisher.
->
-> OK, I'm fiddling with your patch now in preparation for checking it in.
-> If you're not on the quixote-checkins list now, you might want to
-> subscribe.
->
-> First, you really *meant* to say "one request/publisher, multiple
-> simultaneous publishers" up there, right? I sure as heck don't see
-> anything that would allow multiple requests per publisher.
Nope. Multiple requests per publisher will now be *possible* with a subclass;
they are not currently, and (unless you want to check in the threaded
subclass code, below) would not be part of the default Quixote distribution.
As to what code I override in a subclass, imagine a subclass of Publisher,
ThreadedPublisher, with the following functions:
---
def get_request(self, request):
id = thread.get_ident()
self.request_dict[id] = request
def get_request(self):
id = thread.get_ident()
return self.request_dict[id]
def clear_request(self):
id = thread.get_ident()
if self.request_dict.has_key(id):
del self.request_dict[id]
--
This lets every 'quixote.get_request()' function return a thread-specific
HTTPRequest object, as opposed to the current mechanism, in which there
is a single, global _request object.
Once these functions are redefined as above, Publisher.publish is re-entrant,
and that's what's needed to make Quixote work in a threaded Web server.
I'm not sure how far to go on; should I write up something longer?
Incidentally, I'd be happy to make a (trivial!) patch to fix the mod_python
problem, but it would only benefit people who want to have multiple publishers
in one process -- not, IMO, a good idea for clarity.
cheers,
--titus