On Mar 21, 3:27 am, Christian Boos <c... neuf.fr> wrote:
> Matt Good wrote:
> > On Mar 18, 4:10 pm, Peter Dimov
<peter.di... calitko.org> wrote:
>
> >> I was thinking, wouldn't it be nice, simple
and straightforward to pass
> >> python objects rather than dictionaries to the
template engine.
>
> > The ticket and wiki pages already do this.
>
> >> Let's take for example the changeset page,
which contains a title, a
> >> message, other properties and a list of file
changes. A file change is
> >> between two nodes and has a type attribute and
a list of content
> >> changes. The nodes have their own attributes
like path and revision. The
> >> template file would know this structure and
would know how to represent
> >> the objects as html content.
>
> > Yeah, the logic for displaying changesets is a bit
complex and could
> > probably use some clean up, though I'd be cautious
about trying to
> > move all of it into the template, since this may
make parts of it more
> > complicated and hard to read than straight Python.
However, if you'd
> > be willing to submit a patch starting some
refactoring on this I'm
> > sure one of the devs will take a look.
>
> The migration to Genshi retained a good part of the
original "HDF"
> compatible data structure needed to fill Clearsilver
templates. Existing
> objects were reused when possible, but no new classes
were created,
> rather dictionaries and lists where kept. Now we should
maybe start to
> create such intermediate objects more liberally,
especially since
> [genshi 510], as that would help to get default/missing
values right (by
> setting them to None in the constructor). That would be
preferable to
> all the defined('...') or get('...') calls introduced
in the templates.
To help with making sure values aren't missing I think it'd
be easier
to use some simple nested functions instead of creating new
classes
just to "hold" data. In Java this is
unfortunately common, but it's
usually a symptom of the language missing some of the data
structures
found in Python, and the nice syntaxes Python has for
generating
them. There may be places that new classes could help, but
I don't
think this should be a standard practice.
-- Matt Good
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Trac Development" group.
To post to this group, send email to trac-dev googlegroups.com
To unsubscribe from this group, send email to
trac-dev-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---
|