[Zope-Moz] Templates anyone?

Rik Hoekstra rik.hoekstra@inghist.nl
Mon, 28 Feb 2000 21:36:24 +0100




Rik Hoekstra wrote:
>
> I'm not sure I understand your differences between components or something
> 'entirely new'.

Well, actually I'm not fully aware of the capabilities of the component
tag -
but from whatever I know, it seems that the problem it would solve would be
a
subset of the problem the 'entirely new' thing can solve. Even if this is
true,
it doesn't mean that the component-tag should be abandoned in favour of  the
'pattern' mechanism I am thinking of. There might be good reasons for both
to
exist.

Few things about the pattern-thingy I have in mind that are different from
the
component tag:
  o  It requires special objects (pattern objects) which define dtml
patterns.
  o  A pattern object is a kind of 'my own' tag. It allows you to group a
      commonly used dtml 'pattern' and then include it anywhere by using
      just one tag.
  o  There are two 'levels of evaluation'. The first level is when a pattern
is
      evaluated into concrete dtml. The second is when the dtml is
evaluated.


Sounds good

>                         Sorry if I'm only intruding upon the discussion,
>  but...

It's great - I like to know what everybody thinks.

> I think Martijn Faassen tried to implement something of the sort with his
> ZFormulator (see at his member page)

From the looks of it ZFormulator does seem similar to what I have in mind
although specific to only html forms. I really need to look deeper into it.

Yes, that's true

> I once thought of adding something similar by using the document template
> 'competitor' in python land, which is HTMLgen (used to be available from
the
> python starship (http://starship.python.net/library - it still is I
checked)
> and even did a test from an external method. That worked quite well, and
> easy. HTMLgen is an object oriented library for producing HTML pages. A
page
> is an object, and so is every tag on it. I never tried to integrate dtml
and
> HTMLgen, though, but it coould be a starting point.

What exactly did you try to do? Was it something like you provide a set of
parameters for creating an html table and the html is generated
automatically?

yes, that was it.


Then it is the same I am thinking of doing with dtml. But I feel doing this
should be easier than writing python and using something like HTMLgen.

Hm, I used HTMLgen before Zope in cgi, and it was not complicated at all. It
involved some python, but then again from a simple external method it will
involve more than (say) three lines or so. All the parameter things are
already there or could be added easily with a subclass.
The big advantage is you get a series of containers with objects which you
can move around and add things to. They are arguably more easy to manage
than template like things that are sequential (if that's English). But then
again, this idea may have drawbacks I'm not aware of.

> SO much for inserting new elements in templates, but what are your
thoughts
> about maintaining/editing such object based pages? Should they be
> rendered/partially rendered. If they're rendered, how do you provide a
> general mechanism that keeps them from being edited? How does the editor
> know where the object boundaries are in a template? How does Zope know
which
> parts to update and which not?

This is related to your earlier post (object based zope editing: which I had
read with great interest).

Good, I wondered whether it ever came through

Again I cannot answer fully, simply because these
things have yet to be thought out.

That's OK, it will bring us further. Actually I only have a faint idea about
how implementation could be accomplished. I read your GUI document at the
ZopeMozilla site and I thought it was going more or less in the same
direction.

But I can say:

o  A 'pattern object' will never be accessed directly by a url. It will only
     be included in another object.
o  A pattern object when 'rendered' produces dtml. Given the same set of
     parameters  a pattern object will always produce the same dtml. So this
     can be done when a document that includes a pattern object is saved.
The
     original document will still contain the 'include' tag. If after this,
the
     page is again edited and saved, this evaluation (pattern->dtml) will be
     repeated.
o  The 'object boundaries' are clearly defined because now a 'pattern
object'
     is included using *one* tag in the document. Previously there would
have
     been a bunch of dtml where now this 'include pattern' tag is used. The
one
     tag is the entire object - it's boundaries are the object boundaries.

Sounds good, useful and doable. Of course this only works for real standard
patterns. You would still be left with custom dtml written by people. On the
other hand, it seems a good idea to move as many dtml out of actual
documents as you can. This would also help in getting different views of
templates.

Did I make sense?

Yep, quite.

Rik