Zope Page Templates
What we have seen so far is very nice for dynamic content generation. But one of the best things about DTML (or any other sophisticated server-side macro language) is the ability to define menus in one document, headers in a second and footers in a third, and then for each page to import them as necessary.
One way to handle this situation is to create three separate templates (menu, header and footer) in the current folder, importing them with TAL expressions such as:
<span tal:replace="container/menu"> menu goes here</span>
TALES looks at the current template's container, retrieves the menu object (which happens to be a page template itself) and inserts its contents into the current document in place of the <span> tag.
Another way to approach DTML's flexibility is with the use of macros. Macros are common in many programming languages and allow us to create functionality that expands at runtime. The ZPT macro language is called METAL, and like TAL and TALES, it is defined and invoked within HTML attributes, placed in the “metal:” XML namespace. METAL macros can define “slots”, or parameters, into which parameter values can be bound. It's easy to imagine how you could create a macro that handles the overall site design, with each document fitting into the slot that this macro provides. Changing the macro definition would effectively change the design of the entire site.
When I first heard about ZPT, I was sure that it was yet another new way to create templates that are incompatible with other techniques and technologies. But over time, I have become convinced that ZPT is indeed a clever and elegant idea, and one that offers advantages to developers and designers alike. Although it is not a complete replacement for DTML, I believe that most of my DTML usage can now be replaced by a combination of TAL, TALES and METAL. I look forward to seeing how these technologies improve over time and how they are integrated more fully into Zope in the coming months and years.
Reuven M. Lerner is a consultant specializing in web/database applications and open-source software. His book, Core Perl, was published in January by Prentice Hall. Reuven lives in Modi'in, Israel, with his wife and daughter.
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
|Pandas||Aug 17, 2016|
|Juniper Systems' Geode||Aug 16, 2016|
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- NVMe over Fabrics Support Coming to the Linux 4.8 Kernel
- New Version of GParted
- All about printf
- Tor 0.2.8.6 Is Released
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide