[Twisted-web] Context?
User Paolino
paolo_veronelli at libero.it
Tue May 3 03:20:51 MDT 2005
gerardo arnaez wrote:
>Hello all.
>
>I have slowly been working my way through the nevow examples
>I have start look at the base classes to understand what is going on,
>but Im still stuck on what "context" is supposed to mean
>in say (self, context,data)
>I understand self, and understand data,
>but dont understand the function or what the argument *context* is doing?
>
>I have been going thought the examples and it is just not clear.
>
>Any enlightening insight would be much appreciated
>
>
>
#The context in which the rendering is happening.
#Apart from very useful information you can already get from it:
from nevow.inevow import IRequest
from nevow import rend
class Rendering(rend.Fragment):
def render_try(self,context,data):
argumentsOfRquest=IRequest(context).args
.....
#you can pass your own to it
from nevow import compy
class IContent(compy.Interface):
pass
class Another(rend.Fragment):
def render_try(self,context,data):
content="this is something I want all the methods in this rendering
process to get known about"
context.remember(content,IContent)
......
# all the rendering methods called after that can retrieve the 'content'
from context with IContent(context)
Probably there are more useful things context is supposed to be used for
.....
Ciao
More information about the Twisted-web
mailing list