[Twisted-web] overriding locateChild
Jean-Paul Calderone
exarkun at divmod.com
Wed Jul 29 17:16:35 EDT 2009
On Wed, 29 Jul 2009 17:12:40 -0300, Juanjo Conti <jjconti at gmail.com> wrote:
>I've solved the question asked last week using chidlFactory; i've also
>tried to use locateChild, but each time I tried (in a LivePage) others
>things stopped to work (LivePage makes lots of ajax/comet calls via
>XMLHTTPRequest and that urls requested seems not to be handled
>propitiated).
>
>Are there something I should have in mind when overriding the method
>in this particular class?
LivePage implements locateChild in order to work. If you override this
method, then you're disabling necessary functionality. You need to take
care to call the overridden implementation for the URLs LivePage expects
to be handling.
>
>On the other hand, I've notice the "Sorry, but I couldn't find the
>object you requested." message when I ask (via url) for a page that's
>not in the hierarchy. Is this a 404 error message? How do I override
>it? How do I raise a 404 error from the code?
A 404 is a resource like any other. However, as a special convenience,
you may also return None in place of a resource. In this case, the
ICanHandleNotFound object remembered in the context will have its
renderHTTP_notFound method called to produce the response.
Jean-Paul
More information about the Twisted-web
mailing list