On 9/3/09 6:19 PM, Iain Duncan wrote:
> On Thu, 2009-09-03 at 18:15 -0400, Chris McDonough wrote:
>> Using request parameters in model code is technically unsupported.    In the 
>> bfg
>> "mindset", models need no access to the request environment.  But please 
>> check
>> out the "repoze.bfg.threadlocal" module.  (Please read the comment relating 
>> to
>> "get_current_request").  Then decide what you want to do.
>
> That's what I thought, which makes sense to me for the bfg way from what
> I understand. But then I got stuck at middleware, does it not also seem
> reasonable that a model might want to interact with middleware?

Not in the out-of-the-box behavior of BFG.  Whether the data comes from 
middleware or from a user's browser, model *traversal* code (__getitem__) 
shouldn't need access to the request.  Or at least that's a design decision.

If it really does (which I think it probably really doesn't in 99.99% of 
cases), 
a different "traverser" should be plugged in.  For example, QuantumBuster 
(built 
on BFG) replaces the default BFG traverser with a custom one in a more or less 
"approved" way for other reasons (unrelated to the need to access request 
variables in model traversal code).

> In this
> instance for example, the choice of db url string is made by middleware.
> But maybe that needs to be pushed out into get_root.

get_root seems like a good place to check for that.

- C
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to