[Twisted-web] Re: NevowSite and renderString (was: really beginner example)

Alex Levy mesozoic at polynode.com
Mon Apr 5 14:10:11 MDT 2004


On Mon, 2004-04-05 at 14:24, Ellers wrote:
> > Why in particular don't you want to use NevowSite? You don't need to
> > subclass NevowSite, it can be used as-is (see the attached example).
> 
> thats a good question.
> 
> Primarily my logic is that I shouldn't "have" to use a NevowSite. The
> twisted framework is, well, quite a heavy framework as it is. I have
> my existing (admittedly somewhat lame) resource.Resource subclasses,
> and I felt that I "should" be able to use Nevow without having to do
> everything its way (ie using NevowSite).
> 
> Hope that doesn't sound too militant... I guess I figure Nevow sounds
> like a great opportunity for a cool API, but I'm hoping I don't have
> to use it as a heavyweight framework. Where the difference between API
> and framework is how locked in I am to do my code "its way".

Have you tried using NevowSite, but giving it one of your custom
resources instead of a nevow.rend.Page instance? I'm not sure whether
that will work or not, but I don't see why it shouldn't. NevowSite is
just a subclass of t.w.server.Site, which you need anyways.

The main thing about NevowSite is that it converts everything to
inevow.IResource instead of t.w.resource.IResource. This means support
for both "old" resources, like yours, and for Nevow's own resources. So
you're getting more by usingi t, and there's very little additional
overhead.

> Nifty trick with the deferred and the gotRenderedPage() callback. I'm
> still having trouble getting my mind around deferred so thats helpful.

You'll see deferreds all over Twisted. They're very useful, sometimes
essential, in a framework where you don't always know everything at
once.

> Can you expand a bit on how the remember() calls are helpful? 

They're essential. Normally they get called in Page.renderHTTP, but they
aren't there in renderString. 

(Anyone, is this a bug? Is there a reason they're not in renderString?)

-- 
Alex Levy
WWW: http://mesozoic.geecs.org

"Never let your sense of morals prevent you from doing what is right."
-- Salvor Hardin, Isaac Asimov's _Foundation_

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://pyramid.twistedmatrix.com/pipermail/twisted-web/attachments/20040405/1c624548/attachment.bin


More information about the Twisted-web mailing list