[Twisted-web] Add segmentsResolved method to inevow.IResource
matt at pollenation.net
Thu Sep 9 17:53:20 MDT 2004
Please ignore the last message, I hit send by accident.
On Wed, 2004-09-08 at 16:59 -0400, James Y Knight wrote:
> On Sep 8, 2004, at 7:05 AM, Matt Goodall wrote:
> > I propose that we add one more method to the IResource API - a "hook"
> > method that is called when the final segment has been located, i.e.
> > there are no more path segments to process. The IResource definition of
> > the method would look something like:
> > def segmentsResolved(self, ctx):
> > pass
> Why is this different/easier to support/cleaner than returning a
> resource from renderHTTP?
Because the method would be part of the resource location process and
nothing to do with rendering. It's supposed to return a resource whereas
renderHTTP is supposed to render the page.
After a little more thought, a better name might be something like
finalizeLocateChild and it should probably always return a resource, not
> Instead of:
> C1.locateChild, C2.locateChild, C2.renderHTTP, C3.renderHTTP
> we'll have:
> C1.locateChild, C2.locateChild, C2.segmentsResolved,
> C3.segmentsResolved, C3.renderHTTP.
> I don't see why that's a big difference?
I'm not really talking about t.web/Nevow, I'm talking about application
code where clarity is important. Personally, I don't think returning a
resource from renderHTTP makes much sense. Nevow's just located the resource
and asked the resource to render itself, only it doesn't and returns a
new resource instead.
The problem with this is that it adds a new method to a wonderfully simply
interface and in the vast majority of cases the method would just
"return self". That puts me off the idea somewhat.
More information about the Twisted-web