Home arrow Zope arrow ZPT Basics (part 1)

ZPT Basics (part 1)

Contrary to what you might think, DTML isn't the only programming language available to you in Zope. Take a look at Zope Page Templates (ZPT), a template-based alternative that makes it easier for designers and developers to collaborate on Zope application development.

TABLE OF CONTENTS:
  1. ZPT Basics (part 1)
  2. The Power Of Three
  3. Practical Magic
  4. Anatomy Lesson
  5. Putting It All In Context
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 23
September 18, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Not too long ago, I introduced you to something called DTML, the Document Template Markup Language. I defined it as HTML on steroids, and spent lots of time and bandwidth showing you how it could be used to build complex Zope applications.

DTML isn't the only thing Zope has going for it, though. Over the next few pages, I'm going to introduce you to a brand-spanking-new creature from the Zope stable. It's called Zope Page Templates, or ZPT, and it's rapidly overtaking DTML as the de-facto standard for developing applications in Zope.

The Zope Web site is pretty wordy when it comes to describing ZPT. It defines ZPT as "a consistent, XML compliant, markup language [which] embed[s] all logic in namespaced attributes ...and provide[s] a means to supply prototypical content to give the presentation designer a sense of context." Or, to put it in simpler terms, ZPT allows Web developers greater flexibility in separating an application's presentation layer from the business logic that drives it, thereby making it possible to easily update one without disrupting the other.

I'm going to show you how in the following pages. Before I begin, though, make sure that you have a working copy of Zope and ZPT (this tutorial uses Zope 2.5.0, which comes with ZPT built in), and can log in to the Zope management interface. In case you can't, drop by http://www.zope.org/, get yourself set up and come back when you're ready to roll.{mospagebreak title=The Right Choice} Let's start with a very basic, but important, question: why use ZPT when you can use DTML?

There are a couple of reasons why you might prefer to use ZPT instead of DTML. First, DTML isn't really all that friendly, even to developers who are used to wading in the muddy waters of open-source programming languages. The language comes with numerous idiosyncrasies, which can be both annoying and confusing to developers. For example, the result value obtained from a DTML variable often depends on the manner in which it is accessed, and the connectivity between DTML and Python can often leave you confused and desperately searching for a Python programmer to help you get unstuck.

In addition to the technical problems with DTML, it's also not perfect when it comes to separating business logic from interface code. Since DTML documents contain both HTML code and DTML commands, interface designers and developers must collaborate closely with each other whenever a change needs to be made to the interface or processing sequences within a DTML document. Obviously, this means more time and effort to implement changes.

ZPT attempts to resolve this last problem by using templates to separate presentation and layout information from program code. This two-tiered approach affords both developers and designers a fair degree of independence when it comes to maintaining a Zope application, and can substantially reduce the time and effort required in the post-release phases of a development project.

Does this mean DTML is now redundant? No, not really. ZPT should not be considered a replacement for DTML; rather, it should be treated as an alternative to DTML. There still are some things that can be handled only using DTML - sending mail, managing sequences, batching and so on. If you're planning on working with Zope, you're going to need to keep your DTML skills current. It's just that you now have a little more choice.

 
 
>>> More Zope Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ZOPE ARTICLES

- Creating Zope Products
- Plone Content Types With Archetypes
- Flat User Management in Zope
- Creating Basic Zope Applications
- Getting started with Zope for Linux and Sola...
- ZPT Basics (part 4)
- ZPT Basics (part 3)
- ZPT Basics (part 2)
- ZPT Basics (part 1)
- Exception Handling In DTML
- DTML Basics (part 4)
- DTML Basics (part 3)
- DTML Basics (part 2)
- DTML Basics (part 1)
- Using Zope With Apache

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: