Ian Bicking: the old part of his blog

Comment

I'm a big Nevow fan (I also wrote some recipes about Nevow in the Cookbook). By design Nevow passes 2 arguments to its methods:

a context, which represents the current object space state

a data argument, which contains the return value from the data_* method.

Using the context you can pretty much do anything, also remembering objects with a precise interface that can be retrieved later, here is a little example of how this would work:

class Page(rend.Page):
def render_stuff(self, context, data):
context.remember(data, ISomeData)

Which can be retrieved later with:

class SecondPage(rend.Page):
def render_otherStuff(self, context, data):
my_data = context.locate(ISomeData)

In the context is stored every information about the connection, like the request object:

request = context.locate(IRequest)

Also the Session is there:

session = context.locate(ISession)

and the current processed tag from the template:

context.tag

I think this is the most complete implementation of 'passing a context around'.
Comment on Dealing with Context
by Valentino Volonghi