Ian Bicking: the old part of his blog

Comment

ISession and other various interfaces are in a separate module, I just directly wrote the interface name for verbosity needs ;)

In this specific case the interface is used just like a name.

def remember(self, adapter, interface=None):
"""Remember an object that implements some interfaces.
Later, calls to .locate which are passed an interface implemented
by this object will return this object.

If the 'interface' argument is supplied, this object will only
be remembered for this interface, and not any of
the other interfaces it implements.
"""
if interface is None:
interfaceList = megaGetInterfaces(adapter)
if not interfaceList:
interfaceList = [dataqual]
else:
interfaceList = [qual(interface)]
if self._remembrances is None:
self._remembrances = {}
for interface in interfaceList:
self._remembrances[interface] = adapter
return self

This is the specific context.remember() implementation inside Nevow. So Adaptation doesn't come into play with this example although it may seems at first glance. This is also why ISession(context) is not a way of having the session object from the context, since providing ISession with context would require context providing also IRequest, IHand and a lot more (user needed also) interfaces, which can't be done, also, you would end up with a huge context class that provides a method for every method of a request/session/so_on. As you can see, instead, interfaces are rather a key inside a dict.

context.someData = data

could have been used actually, but since context.someData is not namespaced you can have some collisions (remember that using context.remember() you give the user the possibility to remember all the objects he needs to, so I can have some collisions).

HTH, I should post more on my blog actually... :P
Comment on Dealing with Context
by Valentino Volonghi