durusmail: quixote-users: Re: A toy Nevow implementation
A toy Nevow implementation
2004-01-15
2004-01-15
2004-01-15
2004-01-15
Debug syntax errors in PTL (was: A toy Nevow implementation)
2004-01-15
Debug syntax errors in PTL (was: A toy Nevowimplementation)
2004-01-15
Debug syntax errors in PTL (was: A toy Nevowimplementation)
2004-01-16
Jason E. Sibre (2 parts)
Debug syntax errors in PTL
2004-01-22
Debug syntax errors in PTL
2004-01-18
2004-01-18
2004-01-15
Re: A toy Nevow implementation
2004-01-16
2004-01-19
Re: A toy Nevow implementation
2004-01-19
Re: A toy Nevow implementation
2004-01-19
2004-01-19
2004-01-19
2004-01-19
2004-01-19
2004-01-19
2004-01-19
2004-01-19
2004-01-20
2004-01-20
2004-01-20
2004-01-20
2004-01-21
2004-01-20
Re: A toy Nevow implementation
Graham Fawcett
2004-01-16
Thanks to all who responded to my post about Nevow. I wanted to add a
few comments to the discussion.

Thanks to Jon for the htmlgen (Lisp) reference. I think I'd seen htmlgen
before; a surprisingly similar look and feel (though I'm sure a veteran
Lisper would tell that me similarities are inevitable, since Python is
merely a Lisp derivative. ;-)


Jason Sibre wrote:

> I can't see a good reason to saddle myself with yet another
> syntax which in the end, serves primarily to abstract away (or is it
> obfuscate?) the HTML I'm already very familiar with.

That's a hard one to argue against. ;-)  The "one, and preferably only
one way to do it" philosophy has definitely not governed the explosion
of Web templating solutions available for Python. PTL, of course, is the
only really good one. ;-)

 From what I've seen so far, PTL and the Nevow expression style are
orthogonal. I guess it wouldn't be a matter of dropping PTL, but merely
a decision whether to use Nevow expressions in PTL. The choice is nice
to have, I think.


Matt Goodall wrote:

> Any keyword arguments that begin with an underscore have the
> underscore removed before the tag is renderer. So, no workaround
> needed just do this:
>
> p(_class='jones', id='smith')['hello']

Thanks for all the useful information on Nevow, Matt. It was a pleasant
surprise to find a Nevow afficionado on this list!

I was going to play the '_class' trick, but I remembered a similar idea
being shot down on this list, I think in the context of the htmltag()
function. (Some people spell it '_class', others 'klass', still others
hate the pseudo-naming scheme altogether, and want dicts instead.) I
chose to avoid that can of worms.

If Nevow-in-Quixote becomes more than a toy, we'll have to decide
whether we want to stay in sync with the official Nevow implementation,
or just take the idea and run with it ourselves. My guess is that we
would do the latter, especially given the size of (and design choices
made in) the original implementation.

I feel a bit guilty about taking someone else's idea while it's under
active development, and suggesting a radical fork right off the bat. Ah,
well, hopefully the Nevow team would take this imitation as a sincere
form of flattery.


AMK wrote:

> That's pretty cute.  What are the pros and cons of this vs. PTL?
>
> * Full Nevow seems aimed at improving performance by pre-generating the
>   document, but this means you need support for callouts.
>   I'm not sure this optimization is worthwhile; is gluing together HTML
>   strings the bottleneck in any real applications?
> * No need to remember to write ending tags.  Advantage: Nevow.
> * I'll bet you could make the classes enforce validity by checking
>   the child tags (so body[input()] would raise an exception).

That last one is a /very/ neat idea. I hadn't thought about validity
enforcement, but you're right, I'm sure this code could be adapted to do
just that. That's a constraint I could learn to love!


>>They also use interfaces and component adaptation to adapt various Python
>>> types to Nevow "renderables", a very Twisted thing to do.
>
> Sigh.  To rephrase Peter Gutmann [1], whenever someone thinks they need to
> write some complicated new component model, their computer speakers should
> generate some sort of penis-shaped sound wave and plunge it repeatedly into
> their skulls until they achieve enlightenment.

Hilarious! I've gotta remember that. (And your point is well taken.)


> I'd suggest taking the idea without using the Twisted implementation.
> Twisted's Nevow is LGPL'ed, for a start.  More importantly, the
> tags/stan/renderer modules are 552 lines of code + another 450 for
> twisted.python.component; Graham's implementation is roughly 80 or so lines,
> which would make it much easier to debug problems.

Works for me. I was careful not to study Nevow's source, mainly to make
the exercise more fun; but I can assure there's no borrowed code, so I
think the licensing issue is moot.


> Do we need a public CVS/Subversion repository to serve as a Quixote sandbox
> for things like this?

I think that's an excellent idea. We should probably use the Wiki you
set up too, to add general documentation and examples for our sandbox
projects.


* * * * *

To sum up, I think this Nevow-like thing I wrote is worth playing with,
and I intend to do so, real soon now. I hope that others will too, and
that we can continue discussion about it for a while longer.

-- Graham



reply