[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Basic Zope Objects
Sat, 31 Aug 2002 03:45:22 -0400
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/BasicObject.stx#2-80
As you've seen DTML Methods are a useful tool for presentation and
quick scripting, but eventually you're going to want to power of a
fully expressive programming language, and that's where *Scripts*
% twalter - Apr. 20, 2002 7:59 pm:
As a beginner, I needed more information here so that later I would make index_html a DTML Method rather than
a Document. From an earlier comment, it sounds like the differences are in a later chapter. Just add a
sentence that says, to get the folder objects, you need to use a DTML Method rather than a DTML Document. Specifically,
I was tripped in the "Creating Basic Zope Applications" chapter, creating the navigation Method. It did not
easily occur to me that it might be due to this differentiation.
% Anonymous User - June 5, 2002 4:31 pm:
I'm still waiting for the "Why are they different." definition. This book would be much more usefull if there
were some explaination of WHY things are rather than "cause i said so" descriptions offered so far.
% Anonymous User - Aug. 31, 2002 3:45 am:
One additional basic and obvious difference that has not been mentioned here: DTML documents have a property
sheet; DTML methods do not.
A DTML document is intended to be a fairly complete and autonomous object, whereas a DTML method is primarily
intended to be referenced from other objects, providing a means for other objects to use some functionality
provided by the method.
To put it in a slightly more advanced way, most of the DTML variables available to a DTML document refer to
that document or its properties, whereas the same variables in a DTML method more often refer to the document
which is using the method at the time, not the method itself.
Note that at the most basic level DTML documents and methods behave in an identical manner -- it's only when
you start doing tricks with DTML markup that the differences become apparent. So which to use? If all you're
doing is dishing up static HTML (with or without standard_html_header type substitutions), it really doesn't
matter -- indeed, you would do well to consider using a Page Template instead, or even a File if the content
is completely static. In other cases the differences described above should guide you: use DTML documents for
things which have properties, and DTML methods for things which form a component of something else.