durusmail: quixote-users: why pass request object to public functions / methods
why pass request object to public functions / methods
why pass request object to public functions / methods
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-03
2005-01-05
2005-01-03
2005-01-03
why pass request object to public functions / methods
Zachery Corbiere
2005-01-01
I'm coming in way late on this, and I'm but a simple newbie Quixote
user.  However, I second Graham's opinion that the request parameter
should be included in the method invocation.  I can also see a case for
hanging the other objects off of it as I believe was done in Quixote
1.x:
   request.session
   request.response
   etc.

Having the request be part of the signature makes it easier to test
your code in isolation by passing in fake requests rather than faking
out get_request() and its friends.  Also, it's been my experience that
magic global state, even hidden behind function calls, ends up causing
grief eventually.

As an aside, the documentation for version 1 notes that you should
usually use request.redirect() instead of response.redirect() b/c the
response doesn't have enough request-specific knowledge to do relative
redirects.  To my mind, there is only ever one response to a request,
so why shouldn't the response have a reference to its corresponding
request.  Indeed, why shouldn't request.redirect() be a synonym of
response.redirect().

The only thing I have to base this opinion on is that that is how I
assumed it worked before I read the documentation.

That notwithstanding, Quixote rocks so far!

--
Zac Corbiere
zcorb@fluidarch.com

reply