[Zope-PTK] DISCUSS: Changing template construction

Jeffrey P Shell jeffrey@Digicool.com
Fri, 25 Feb 2000 09:20:37 -0500


on 2/24/2000 11:33 PM, Christopher Petrilli at petrilli@digicool.com wrote::

> On 2/24/00 6:47 PM, Kevin Dangoor at kid@kendermedia.com wrote:
> 
>> 
>> I like this proposal. I think it does simplify things. (Boy, people who are
>> new to Zope after the PTK comes out will have nifty sites up and running
>> really quickly :)
>> 
>> One comment: if the template attribute of the <dtml-template> tag can take
>> an expression, this will also make for an easy way to do skins. (And you
>> don't even have to wait for the browsers to support CSS properly)

If someone else wants to deal with expression support and all the issues
related to it, they can.  The tag I wrote does::

 Snarfs up its inner contents (block contents)

 Pushes them onto the namespace (the multidict) bound to the "insertas"
attribute (default is "component-contents"),

 Returns the DTML Method from the "insertas" attribute without even
rendering it (the DTML engine seems to take care of this).

 And does a "finally: md._pop(1)" to pop the block contents off the
namespace stack.

I've done "skins" by writing Python methods in the class I'm writing this in
(not to be confused with web base PythonMethods) that change the template
value in the call, ala

 return self.registrationForm(self, REQUEST,
  my_cool_template=self.manageTemplate)

Without a more thought out model-view-controller/presenter paradigm in
place, I've been quite happy with doing this.  The current project I'm
experimenting with this in is an entirely disk based Python product where I
have some more liberty to apply some design and construction techniques
borrowed from some Openstep-ish conventions.

> Jeffrey and I talked about this a lot yesterday, and here's (pardon I've not
> used it, just written on a whiteboard, but Jffrey will no doubt correct me,
> when he stops playing with MacOS X DP3 :-)....
> 
> Here's the format we talked about:
> 
> <dtml-component template="component_template_name" insertAs="content">
> ...
> ...
> ...
> </dtml-component>
> 
> Here's some reasoning...
> 
> * The reason he changed to <dtml-component> from <dtml-template> is that
> you're not really describing a template, you're describing a component
> rendered USING a template.  On further thought this seems more self evident.

Right.  And this doesn't have to be full page -- you could have other little
components on the page.

> * No "name" attribute.  There's also no "shortcuts".  You must spell out all
> attributes and their options.  Theoretically, there could be other things
> for a <dtml-component> instead of templates... i.e. widgets?

Yep.  no shortcuts == easier (theoretically) to get Golive, Alpha, and
Dreamweaver to handle things easier.  And this tag was really written so
that I could work with my preferred editors a bit easier.  I'm also thinking
of adding an optional "id" attribute whose only purpose might be for XML-ish
parsing.

> * There is a default "insertAs" attribute, 'template_contents'.  You don't
> have to specify.

component-contents.

> * Should there be a default 'template'?  We don't know :-)

I don't know if there should, I just prefer spelling it out.  Shortcuts now
== headaches later.  And I like the possibility of just marking a section of
DTML/HTML and identifying it as a component and being able to extract it
somewhere else (such as a *gulp* "wizard").

-- 
Jeffrey P Shell, jeffrey@Digicool.com
http://www.zope.org/