On Jul 18, 7:21 pm, "Mark Ramm" <[EMAIL PROTECTED]> wrote:
> Seems like this is a discussion to move to trunk :)
>
> Yea, it all depends on the size of the controller object.

It all depends on the size/complexity of the controller's __init__
method.  Instantiating a class isn't particular expensive, considering
everything else that's going on during a request.  The default
controller class basically doesn't do anything during instantiation.

Early on I believe Pylons didn't instantiate the controller for each
request, but I convinced them to change it because it didn't really
have any point.  You don't save any significant work by reusing an
instance, and you make other things harder.  E.g., the controller has
a self.start_response attribute, that points to the start_response
callback that was passed in.  That is necessarily per-request.  You
could store it elsewhere, but you'd be recreating all the same
overheads but in a less elegant manner.  Similarly in my own code, I
occassionally often find it handy to set an attribute in __before__,
and using it in the action.

The result is basically the servlet model, but Pylons calls them
controllers which is fine because "servlet" has too much baggage
anyway.

  Ian


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to