Re: Request subclassing

Matt Patterson <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
On 9 Nov 2005, at 14:59, David Binger wrote:

> On Nov 9, 2005, at 6:26 AM, Matt Patterson wrote:
>
>> Did anyone have any thoughts about this (approach more than patch,  
>> I suppose). The issues around it (amount of extra complexity  
>> needed to graft on request context stuff at the moment, for one)  
>> are becoming more pressing here at work, and I'd appreciate your  
>> opinions. The original message is here: http://mail.mems- 
>> exchange.org/durusmail/quixote-users/5265/

I've reordered things a bit below to avoid tripping over my feet.

> The patch seems to offer two more ways of doing what seems to be
> the same thing: either by a keyword argument or by overriding the
> create_request() method.  Do we need more options?

I think we do.

> The caller of process_request (the driver) can supply
> an instance of the subclass of HTTPRequest that the application
> requires.

I think that messing with the driver scripts is a Bad Idea,  
particularly if (as I will be at work) you're wanting to deploy  
multiple quixote apps onto a server. Messing with the driver scripts  
seems like going in at the wrong level. (I'm not 100% but I think  
that a WSGI-like environment adds weight to that argument.) If I'm  
deploying my app to run on an app server I don't want to have to  
redeploy bits that feel like part of the app server too...

> If you would prefer to customize the Publisher instead of
> the driver, your application's subclass of Publisher
> could do this:
>
>     def process_request(self, request):
>         request.__class__ = MyHTTPRequest
> 	return Publisher.process_request(self, request)

Unless I'm being dense (and hey, that's not unknown...) doing this  
means that you miss the opportunity to do something with the  
Request's __init__ method, which seems like a fairly major loss to me.

So, I think that my proposal provides a better separated way to do  
something I think is important. The keyword option allows people to  
use a different Request without subclassing Publisher, and I'm not  
convinced that that's essential.

I'd be perfectly happy to force people to subclass Publisher to make  
it happen and just add create_request() as a method.

Thanks,

Matt

-- 
   Matt Patterson | Design & Code
   <[email protected]> | http://www.emdash.co.uk/
   <[email protected]> | http://www.reprocessed.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.