[Twisted-web] Re: Remembering things in context from a Realm

Donovan Preston dp at ulaluma.com
Tue Sep 28 09:06:56 MDT 2004


On Sep 28, 2004, at 10:20 AM, Alex Levy wrote:

> This is what I'd expected to do -- instead of just returning a regular
> resource, return an EverythingLivesInsideHereResource (with a more
> suitable name) that contains everything the site needs to pass down to
> the resources.
>
> Still, passing the context through the entire resource chain will let 
> me
> cut out a _lot_ of cruft from [Paya]go. Kudos! :)

That was the point and the expected result. Glad it is going to work as 
desired ;-)

Perhaps that resource should be nevow proper? Riffing off what mg did:

class RememberWrapper:
     __implements__ = inevow.IResource,

     def __init__(self, resource, remember):
         self.resource = resource
         self.remember = remember

     def locateChild(self, ctx, segments):
         for interface, adapter in self.remember:
             ctx.remember(adapter, interface)
         return self.resource, segments

     def renderHTTP(self, ctx):
         for interface, adapter in self.remember:
             ctx.remember(adapter, interface)
         return self.resource.renderHTTP(ctx)

dp




More information about the Twisted-web mailing list