On 12/23/05, Jason Chu <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 23, 2005 at 11:42:23AM -0500, Kevin Dangoor wrote:
> > I don't really mock the cherrypy package for testing. I just toss in a
> > fake request. Adding a self.request reference to the controller seems
> > reasonable for convenience's sake. Can you open a ticket for that?
> > (http://trac.turbogears.org)
>
> I hadn't thought about this till now, what's the implication in
> multi-threaded environments? If two requests can be executing at the same
> time, cherrypy.request will always point to request for that thread, but
> will self.request?
Don't worry, I *had* thought about this :)
cherrypy.request is a "thread local proxy". __getattr__ and
__setattr__ call through to threadlocal variables, essentially. So, if
we set self.request to cherrypy.request, it *should* be a reference to
the proxy object which will ensure that you're getting the correct
data for the thread.
> Also, currently, my sub-controllers don't extend the RootController. In
> theory, they don't have to, unless this change goes through.
You'd subclass controllers.Controller, but only if you want to use
these features. If you don't care, you don't have to subclass
Controller. (RootController should only be used at the top of an
application, and is used as a marker for determining where url("/")
should go)
Kevin