[Twisted-web] Re: [Twisted-Python] again on nested sequence
Manlio Perillo
manlio_perillo at libero.it
Mon Jul 17 13:22:10 CDT 2006
Valentino Volonghi aka Dialtone ha scritto:
> On Mon, 17 Jul 2006 15:39:10 -0200, Manlio Perillo
> <manlio_perillo at libero.it> wrote:
>> And what about my first solution?
>> http://twistedmatrix.com/pipermail/twisted-web/2006-July/002813.html
>
> Better, although it rewrites the sequence renderer for more or less the
> same functionality. Not too bad of course but could be avoided with less
> code and more templates (that usually are dealt with by the designer).
>
Not Nevow templates...
Now I'm working with a web designer that knows a little of PHP.
I will report how he will interacts with Nevow templates.
> [...]
> 4) The context makes non trivial understanding what instead should be
> trivial
> because it saves state that is reused later breaking the tracebacks.
>
Indeed, reading the sources, the context handling is the more obscure part.
Nevow is simple in design, I hope that in a future version all the ugly
stuff can go away.
> This are the first 4 reasons that came to mind.
>
>> Ok.
>> But I'm searching a simple solution that is database friendly; that is,
>> where I can map directly database queries to data directives.
>
> Just like everyone else does. Besides that writing a simple function
> like the following:
>
> def mapComments(comments, for_atom=False):
> for comment in comments:
> yield dict(rank=comment[0],
> author=comment[1],
> id=comment[2],
> body=comment[3],
> date=comment[4]
> )
>
> Will give you a dict interface over the comments rows returned from the
> database without losing much performance compared to the situation
> without that functions (also thanks to generators).
>
> Also consider that it's better to put time in creating something that
> makes a specific problem more generic so that an already existing tool
> can be used to solve it rather than creating many different solutions to
> the same problem.
>
>
This is certainly true.
When I have time I will try to refactory the queries.
Thanks and regards Manlio Perillo
More information about the Twisted-web
mailing list