[Twisted-web] warning appears after upgrading Nevow

Matt Goodall matt at pollenation.net
Fri Sep 2 01:48:25 MDT 2005


Yun Mao wrote:
> 
> exceptions.UserWarning: All inevow.IResource APIs now take a Context
> object instead of the Request; Please adapt the context to IRequest
> before attempting to access attributes of the request

Wow, you haven't upgraded Nevow for a *long* time! ;-)

> 
> The code looks like: view = request.args.get("view",[''])[0]
> 
> How should I deal with the warning?  Thanks..

Firstly, if the argument to your method is still called 'request' then
change it to 'context', 'ctx', or whatever you like to use.

Then adapt that context to inevow.IRequest and use the adapter object
from there on.

For instance, if you currently have some code that looks like:

    def locateChild(self, request, segments):
        view = request.args.get("view",[''])[0]

Then you should change it to:

    def locateChild(self, context, segments):
        request = inevow.IRequest(context)
        view = request.args.get("view",[''])[0]

Both IResource methods - locateChild and renderHTTP - now take a context
instead of a request so those methods, and any methods called from them,
will now take a context arg too.

Hope this helps.

Cheers, Matt

-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \	       Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.



More information about the Twisted-web mailing list