[Zope-CMF] Emulating <dtml-var... In a CMF document

Carlson, Christopher W. Christopher.W.Carlson@saint-gobain.com
Tue, 12 Mar 2002 09:23:07 -0500


Thanks!  You've certainly given me a lot to think about.

As a followup question, I have this: The only place I've used this
particular call is in index_html at the root of my site.  If I create a DTML
document, it (obviously) doesn't include any of the skin.  What's the
appropriate way to create a one-off index_html document that plays well with
a CMF site?

--- Chris

-----Original Message-----
From: Tres Seaver [mailto:tseaver@ZOPE.COM] 
Sent: Tuesday, March 12, 2002 7:50 AM
To: Carlson, Christopher W.
Cc: 'zope-cmf@zope.org'
Subject: Re: [Zope-CMF] Emulating <dtml-var... In a CMF document


On Mon, 11 Mar 2002, Carlson, Christopher W. wrote:

> I'm trying to migrate a web site from a DTML-based, home-grown mess to CMF
> (using the Plone skin, specifically), and am stumped.
> 
> I have a Python script which randomly selects a picture from a collection
of
> photo albums, and I use it on my old site by invoking: <dtml-var
> expr="randompic()">
> 
> I haven't found a convenient way to do the same thing from within a CMF
> document, using either the HTML or STX setting.  Can it be done?

The CMF makes a sharp distinction between "content" and "software";
the standard Document content type in the CMF is "pure" content, with
no scripting possible (by design).

It is possible to create a wrapper for an existing Zope object
(such as DTMLDocument) to make it "play nice" inside the CMF;  this
sounds more like what you are asking for.  For example, you can create
a FactoryTypeInformation object in your types tool with the following
properties:

  ID:  DTML Document  # the space is important
  Meta type: DTML Document
  Icon: document_icon.gif
  Product name: OFSP
  Factory method in product:  manage_addDTMLDocument
  Initial view name: dtmldocument_edit_form

You would then flesh out the type by adding CMF-ized edit form,
view method, etc. to its actions, and writing them as skins.  A
more robust implementation would create a new content type, deriving
from DTMLDocument, and adding on the extra mechanism (e.g., the
'getIcon' method) expected by the CMF.  Such an approach is
workable for ZPT, as well.

Note that allowing mixing content and scripting implies a much
greater level of trust in your authors than "pure" content;  if
this is not problematic for you, then please experiment (and feel
free to contribute your solution!)

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.org


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests