SlideShare a Scribd company logo

An introduction to Zope Page Templates and their use outside of Zope (+Audio)

This document discusses Zope Page Templates (ZPT), which is an implementation of the Template Attribute Language (TAL). ZPT allows separating presentation from logic by using XML/TAL data and templates to generate XHTML or other formats. Some key features of TAL mentioned include making well-formed XHTML easy, optional tag omission, conditional inclusion, and internationalization support. The document provides examples of basic template usage and more advanced features like macros.

1 of 29
Download to read offline
Zope Page Templates
  file:///home/pptfactory/temp/20090701114008/stencil.jpg




                                                                An introduction to Zope Page Templates
                                                                and their use outside of Zope

                                                                Matt Hamilton
                                                                matth@netsight.co.uk




30th June 2009                                              Europython 2009, Birmingham, UK          1
Who Am I
 Technical Director of Netsight
      Web development firm in Bristol, UK




 10 years experience with Zope/Plone
 More of an integrator than core developer
      I get involved in all those sticky projects of merging
         Plone in with other systems in an enterprise

30th June 2009         Europython 2009, Birmingham, UK         2
The Irony of this talk...

   Most of it was taken from a talk
             on PHPTAL!

                                                                          Thanks to Kornel Lesiński who did a
                 file:///home/pptfactory/temp/20090701114008/kornel.jpg




                                                                          talk on it at the Web Standards
                                                                          conference 2008 in London




30th June 2009                                                              Europython 2009, Birmingham, UK     3
What is ZPT/TAL


                 TAL – Template Attribute Language
                   ZPT – Zope Page Templates



                 ZPT = an implementation of TAL



30th June 2009            Europython 2009, Birmingham, UK   4
Zope?! I don't DO Zope!
                 file:///home/pptfactory/temp/20090701114008/2512086374_5da1610fc9.jpg




30th June 2009                                                                           Europython 2009, Birmingham, UK   5
TAL is a standard (sort of)


 Official specification
 http://wiki.zope.org/ZPT/TAL


 Multiple implementations
 http://en.wikipedia.org/wiki/Template_Attribute_Language




30th June 2009       Europython 2009, Birmingham, UK        6
The Idea of Templating

                                              XML/TAL
                 Data
                                              Template



                              ZPT




                           XHTML


30th June 2009          Europython 2009, Birmingham, UK   7
The Idea of Templating

                                 XML/TAL
          Data
                                 Template



                  ZPT



                                   or                or         not   Plain
                 XHTML                    XML             RSS
                                                                      text


30th June 2009          Europython 2009, Birmingham, UK                   8
Why use templates?

      Separate Presentation and Logic
      Keeping code clean
      Multiple presentations of same data (RSS,
       JSON, REST, XML)




30th June 2009     Europython 2009, Birmingham, UK   9
But, why TAL?


      <ul>
        % for name in row:
            <li>${name}</li>
        % endfor
      </ul>



30th June 2009   Europython 2009, Birmingham, UK   10
But, why TAL?
     <ul>
       % for name in row:
           <li>${name}</li>
       % endfor
    </ul>



      <ul>
        <li tal:repeat=”name row”
            tal:content=”name” />
      </ul>

30th June 2009     Europython 2009, Birmingham, UK   11
But, why TAL?

      <ul>
        <li tal:repeat=”name row”
            tal:content=”name”>
        Dummy data
        </li>
      </ul>


30th June 2009   Europython 2009, Birmingham, UK   12
But, why TAL?

      <ul>
        <li tal:repeat=”name row”
            tal:content=”name”>
        Dummy data
        </li>
      </ul>


30th June 2009   Europython 2009, Birmingham, UK   13
Makes well-formed XHTML
easy
      <ul>
        <li>
        % if foo = 'bar':
             ${name}
        </li>                                      Nesting
        % endif                                    Error!
      </ul>


30th June 2009   Europython 2009, Birmingham, UK             14
Makes well-formed XHTML
easy

  <ul>
    <li
tal:condition=”python:foo='bar'”
tal:content=”name” />
  </ul>



30th June 2009   Europython 2009, Birmingham, UK   15
Makes well-formed XHTML
easy


           Ensures that you close all elements
            and quote attributes
           Escapes all ampersands by default &
            -> &amp;



30th June 2009       Europython 2009, Birmingham, UK   16
So, how do I use it?


Create virtualenv
     % virtualenv zptdemo

Install zope.pagetemplate in virtualenv
     % cd zptdemo
     % bin/easy_install zope.pagetemplate



30th June 2009     Europython 2009, Birmingham, UK   17
So, how do I use it?
In mycode.py:
from zope.pagetemplate.pagetemplatefile 
    import PageTemplateFile

my_pt = PageTemplateFile('mytemplate.pt')
context = {'row': ['apple',
                   'banana',
                   'carrot'],
           'foo':'bar'}

print my_pt.pt_render(namespace=context)


30th June 2009   Europython 2009, Birmingham, UK   18
So, how do I use it?
In mytemplate.py:
<html>
<body>
<h1>Hello World</h1>

<div tal:condition=”python:foo == 'bar'”>
<ul>
<li tal:repeat="item rows" tal:content="item" />
</ul>
</div>

</body>
</html>
30th June 2009   Europython 2009, Birmingham, UK   19
So, how do I use it?
End result:
<html>
<body>
<h1>Hello World</h1>

<ul>
<li>apple</li>
<li>banana</li>
<li>carrot</li>
</ul>
</div>

</body>
</html>
30th June 2009    Europython 2009, Birmingham, UK   20
Some TAL niceties



<a href=”href” tal:omit-tag=”not:href”>
   Optionally linked text
</a>

                 Omit the tag if there is href variable
                           evaluates false

30th June 2009             Europython 2009, Birmingham, UK   21
Some TAL niceties


<title tal:content=”page/title |
               site/title | default”>
  My Website
</title>

                 If there is no page title or site title,
                       then use the default text

30th June 2009             Europython 2009, Birmingham, UK   22
Some TAL niceties


<option tal:repeat=”c countries”
        tal:content=”c”
        tal:attributes=”selected
                   python:c==’UK’” />

                 Create an option for each country,
                  and if the UK then set selected

30th June 2009           Europython 2009, Birmingham, UK   23
Some advanced features
                 file:///home/pptfactory/temp/20090701114008/ninja.jpg




                                                 ( but not too many )

30th June 2009                                                           Europython 2009, Birmingham, UK   24
METAL macros
A master template:

<html metal:define-macro=”main”>
  <head><title>My Site</title></head>
  <body>
    <div metal:define-slot=”body”>
      Dummy body
    </div>
  </body>
</html>

30th June 2009   Europython 2009, Birmingham, UK   25
METAL macros
A sub-template for a page:

<html metal:use-macro=
              ”template/macros/main”>
  <head><title>My Site</title></head>
  <body>
    <div metal:fill-slot=”body”>
      This is my real body text
    </div>
  </body>
</html>
30th June 2009   Europython 2009, Birmingham, UK   26
METAL macros



Internationalisation:

<h1 i18n:translate=””>Some text</h1>




30th June 2009    Europython 2009, Birmingham, UK   27
Questions?
                    matth@netsight.co.uk




30th June 2009   Europython 2009, Birmingham, UK   28
We are looking for Developers!

 Come chat to me
 or
 drop an email to

  careers@netsight.co.uk




30th June 2009   Europython 2009, Birmingham, UK   29

Recommended

Lipstick On a Pig (+Audio)
Lipstick On a Pig (+Audio)Lipstick On a Pig (+Audio)
Lipstick On a Pig (+Audio)Matt Hamilton
 
Plone: Event Driven Programming
Plone: Event Driven ProgrammingPlone: Event Driven Programming
Plone: Event Driven ProgrammingMatt Hamilton
 
The Flexibility of Open Source: A Case Study of a large Corporate Intranet
The Flexibility of Open Source: A Case Study of a large Corporate IntranetThe Flexibility of Open Source: A Case Study of a large Corporate Intranet
The Flexibility of Open Source: A Case Study of a large Corporate IntranetMatt Hamilton
 
Adventures in Wonderland - A Plone Developer's Year in iOS
Adventures in Wonderland - A Plone Developer's Year in iOSAdventures in Wonderland - A Plone Developer's Year in iOS
Adventures in Wonderland - A Plone Developer's Year in iOSMatt Hamilton
 
Plone and Sharepoint
Plone and SharepointPlone and Sharepoint
Plone and SharepointMatt Hamilton
 
A Journey Through Open Source
A Journey Through Open SourceA Journey Through Open Source
A Journey Through Open SourceMatt Hamilton
 
Plone Intranet talk at Plone Open Garden 2014, Sorrento
Plone Intranet talk at Plone Open Garden 2014, SorrentoPlone Intranet talk at Plone Open Garden 2014, Sorrento
Plone Intranet talk at Plone Open Garden 2014, SorrentoMatt Hamilton
 
BathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneBathCamp #32 - CMS Smackdown! - Plone
BathCamp #32 - CMS Smackdown! - PloneMatt Hamilton
 

More Related Content

Similar to An introduction to Zope Page Templates and their use outside of Zope (+Audio)

Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code GenerationJonathan Musset
 
Html and visual fox pro
Html and visual fox proHtml and visual fox pro
Html and visual fox proMike Feltman
 
Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)Justin Miller
 
GemStone Update
GemStone UpdateGemStone Update
GemStone UpdateESUG
 
Bugtracking on the Web 2.5
Bugtracking on the Web 2.5Bugtracking on the Web 2.5
Bugtracking on the Web 2.5olberger
 
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume LaforgeGaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume LaforgeGuillaume Laforge
 
Bpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/SymposiumBpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/SymposiumAntoine Toulme
 
Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia Magnolia
 
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie LermanUsing Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie LermanJulie Lerman
 
CS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: SimulationCS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: SimulationWei Tsang Ooi
 
Symfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo PragueSymfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo PraguePavel Campr
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"Stephen Donner
 
Une décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogèneUne décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogèneRoberto Mazzoni
 
Methods to test an e-learning Web application.
Methods to test an e-learning Web application.Methods to test an e-learning Web application.
Methods to test an e-learning Web application.telss09
 
Importing/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactoryImporting/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactoryFrancisco Gonzalez-Longatt
 

Similar to An introduction to Zope Page Templates and their use outside of Zope (+Audio) (20)

Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code Generation
 
Html and visual fox pro
Html and visual fox proHtml and visual fox pro
Html and visual fox pro
 
Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)Beyond The Web: Drupal Meets The Desktop (And Mobile)
Beyond The Web: Drupal Meets The Desktop (And Mobile)
 
GemStone Update
GemStone UpdateGemStone Update
GemStone Update
 
Bugtracking on the Web 2.5
Bugtracking on the Web 2.5Bugtracking on the Web 2.5
Bugtracking on the Web 2.5
 
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume LaforgeGaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
Gaelyk quickie - GR8Conf Europe 2010 - Guillaume Laforge
 
Usdin XML for Standards
Usdin XML for StandardsUsdin XML for Standards
Usdin XML for Standards
 
Bpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/SymposiumBpmn 2.0 Eclipse OMG/Symposium
Bpmn 2.0 Eclipse OMG/Symposium
 
Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia Migrating Belgium's Largest Telecommunication Company to Magnolia
Migrating Belgium's Largest Telecommunication Company to Magnolia
 
The Ins And Outs Of Capture
The Ins And Outs Of CaptureThe Ins And Outs Of Capture
The Ins And Outs Of Capture
 
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie LermanUsing Entity Framework's New POCO Features: Part 1, by Julie Lerman
Using Entity Framework's New POCO Features: Part 1, by Julie Lerman
 
CS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: SimulationCS5229 09/10 Lecture 6: Simulation
CS5229 09/10 Lecture 6: Simulation
 
Module01
Module01Module01
Module01
 
Symfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo PragueSymfony - modern technology in practice, Webexpo Prague
Symfony - modern technology in practice, Webexpo Prague
 
Spring Integration
Spring IntegrationSpring Integration
Spring Integration
 
"How Mozilla Uses Selenium"
"How Mozilla Uses Selenium""How Mozilla Uses Selenium"
"How Mozilla Uses Selenium"
 
Une décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogèneUne décision intelligente dans un environnement hétérogène
Une décision intelligente dans un environnement hétérogène
 
Methods to test an e-learning Web application.
Methods to test an e-learning Web application.Methods to test an e-learning Web application.
Methods to test an e-learning Web application.
 
Importing/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactoryImporting/Exporting a project using DIgSILENT PowerFactory
Importing/Exporting a project using DIgSILENT PowerFactory
 
Mwml
MwmlMwml
Mwml
 

More from Matt Hamilton

Ceci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial NetworksCeci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial NetworksMatt Hamilton
 
Ceci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning StoriesCeci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning StoriesMatt Hamilton
 
Intro to Machine Learning and AI
Intro to Machine Learning and AIIntro to Machine Learning and AI
Intro to Machine Learning and AIMatt Hamilton
 
Open Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the EnterpriseOpen Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the EnterpriseMatt Hamilton
 
Supercharge Your Career with Open Source
Supercharge Your Career with Open SourceSupercharge Your Career with Open Source
Supercharge Your Career with Open SourceMatt Hamilton
 
How to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication SystemHow to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication SystemMatt Hamilton
 
Plone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy GrailPlone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy GrailMatt Hamilton
 
Mistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-LaunchMistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-LaunchMatt Hamilton
 
Plone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a ProductPlone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a ProductMatt Hamilton
 
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)Matt Hamilton
 
The Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public SectorThe Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public SectorMatt Hamilton
 
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)Matt Hamilton
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Matt Hamilton
 
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...Matt Hamilton
 
NextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case StudyNextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case StudyMatt Hamilton
 
Open Source and Content Management (+audio)
Open Source and Content Management (+audio)Open Source and Content Management (+audio)
Open Source and Content Management (+audio)Matt Hamilton
 

More from Matt Hamilton (16)

Ceci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial NetworksCeci n’est pas un canard - Machine Learning and Generative Adversarial Networks
Ceci n’est pas un canard - Machine Learning and Generative Adversarial Networks
 
Ceci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning StoriesCeci N'est Pas Un Canard – and Other Machine Learning Stories
Ceci N'est Pas Un Canard – and Other Machine Learning Stories
 
Intro to Machine Learning and AI
Intro to Machine Learning and AIIntro to Machine Learning and AI
Intro to Machine Learning and AI
 
Open Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the EnterpriseOpen Source, The Natural Fit for Content Management in the Enterprise
Open Source, The Natural Fit for Content Management in the Enterprise
 
Supercharge Your Career with Open Source
Supercharge Your Career with Open SourceSupercharge Your Career with Open Source
Supercharge Your Career with Open Source
 
How to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication SystemHow to get started with the Pluggable Authentication System
How to get started with the Pluggable Authentication System
 
Plone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy GrailPlone and Single-Sign On - Active Directory and the Holy Grail
Plone and Single-Sign On - Active Directory and the Holy Grail
 
Mistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-LaunchMistakes Made and Lessons Learnt Scaling Plone post-Launch
Mistakes Made and Lessons Learnt Scaling Plone post-Launch
 
Plone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a ProductPlone Symposium East 2011 Keynote: Plone, A Solution not a Product
Plone Symposium East 2011 Keynote: Plone, A Solution not a Product
 
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
Mountain Tops to Archipelagos - The People Behind Plone (+AUDIO)
 
The Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public SectorThe Flexibility of Open Source - Plone in the Public Sector
The Flexibility of Open Source - Plone in the Public Sector
 
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
Plone - Revised Roadmap: Plone 3,4,5 and beyond - Dutch Plone Users Day (+AUDIO)
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009
 
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
Kent Connects: Harnessing Open Source for Shared Services and Partnership Wor...
 
NextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case StudyNextGen Roadshow Bmex Case Study
NextGen Roadshow Bmex Case Study
 
Open Source and Content Management (+audio)
Open Source and Content Management (+audio)Open Source and Content Management (+audio)
Open Source and Content Management (+audio)
 

Recently uploaded

Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...ShapeBlue
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...MichaelBenis1
 
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarThousandEyes
 
AI-Plugins-Planners-Persona-SemanticKernel.pptx
AI-Plugins-Planners-Persona-SemanticKernel.pptxAI-Plugins-Planners-Persona-SemanticKernel.pptx
AI-Plugins-Planners-Persona-SemanticKernel.pptxUdaiappa Ramachandran
 
eXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionseXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionsElanthirayan Madhavan
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...BookNet Canada
 
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUG
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUGBoosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUG
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUGRick Ossendrijver
 
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider Lecture
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider LectureMuleSoft Online Meetup Group - B2B Crash Course: PM Insider Lecture
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider LectureManik S Magar
 
iOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingeriOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingerssuser9354ce
 
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...2toLead Limited
 
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlueCloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlueShapeBlue
 
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...DianaGray10
 
PrismCRM-RealEstate-SalesCRM_byCode5Company
PrismCRM-RealEstate-SalesCRM_byCode5CompanyPrismCRM-RealEstate-SalesCRM_byCode5Company
PrismCRM-RealEstate-SalesCRM_byCode5CompanyMustafa Kuğu
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueShapeBlue
 
Geospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & EsriGeospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & EsriSafe Software
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsScyllaDB
 
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)Jay Zhao
 
Communities, networking and developer culture
Communities, networking and developer cultureCommunities, networking and developer culture
Communities, networking and developer cultureRavi Sanghani
 
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...SearchNorwich
 

Recently uploaded (20)

Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
Elevating Cloud Infrastructure with Object Storage, DRS, VM Scheduling, and D...
 
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...National Institute of Standards and Technology (NIST) Cybersecurity Framework...
National Institute of Standards and Technology (NIST) Cybersecurity Framework...
 
AMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes WebinarAMER Introduction to ThousandEyes Webinar
AMER Introduction to ThousandEyes Webinar
 
AI-Plugins-Planners-Persona-SemanticKernel.pptx
AI-Plugins-Planners-Persona-SemanticKernel.pptxAI-Plugins-Planners-Persona-SemanticKernel.pptx
AI-Plugins-Planners-Persona-SemanticKernel.pptx
 
eXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductionseXtended Reality(XR) Basic introductions
eXtended Reality(XR) Basic introductions
 
Sue Loth: Job Search Strategies using personal connections
Sue Loth: Job Search Strategies using personal connectionsSue Loth: Job Search Strategies using personal connections
Sue Loth: Job Search Strategies using personal connections
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
 
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUG
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUGBoosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUG
Boosting Developer Effectiveness with a Java platform team 1.4 - ArnhemJUG
 
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider Lecture
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider LectureMuleSoft Online Meetup Group - B2B Crash Course: PM Insider Lecture
MuleSoft Online Meetup Group - B2B Crash Course: PM Insider Lecture
 
iOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostingeriOncologi_Pitch Deck_2024 slide show for hostinger
iOncologi_Pitch Deck_2024 slide show for hostinger
 
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
Microsoft x 2toLead Webinar Session 1 - How Employee Communication and Connec...
 
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlueCloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
CloudStack Authentication Methods – Harikrishna Patnala, ShapeBlue
 
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...Building Bridges:  Merging RPA Processes, UiPath Apps, and Data Service to bu...
Building Bridges: Merging RPA Processes, UiPath Apps, and Data Service to bu...
 
PrismCRM-RealEstate-SalesCRM_byCode5Company
PrismCRM-RealEstate-SalesCRM_byCode5CompanyPrismCRM-RealEstate-SalesCRM_byCode5Company
PrismCRM-RealEstate-SalesCRM_byCode5Company
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
 
Geospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & EsriGeospatial Synergy: Amplifying Efficiency with FME & Esri
Geospatial Synergy: Amplifying Efficiency with FME & Esri
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & Pitfalls
 
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)
Leonis Insights: The State of AI (7 trends for 2023 and 7 predictions for 2024)
 
Communities, networking and developer culture
Communities, networking and developer cultureCommunities, networking and developer culture
Communities, networking and developer culture
 
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...
ChatGPT's Code Interpreter: Your secret weapon for SEO automation success - S...
 

An introduction to Zope Page Templates and their use outside of Zope (+Audio)

  • 1. Zope Page Templates file:///home/pptfactory/temp/20090701114008/stencil.jpg An introduction to Zope Page Templates and their use outside of Zope Matt Hamilton matth@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 1
  • 2. Who Am I Technical Director of Netsight Web development firm in Bristol, UK 10 years experience with Zope/Plone More of an integrator than core developer I get involved in all those sticky projects of merging Plone in with other systems in an enterprise 30th June 2009 Europython 2009, Birmingham, UK 2
  • 3. The Irony of this talk... Most of it was taken from a talk on PHPTAL! Thanks to Kornel Lesiński who did a file:///home/pptfactory/temp/20090701114008/kornel.jpg talk on it at the Web Standards conference 2008 in London 30th June 2009 Europython 2009, Birmingham, UK 3
  • 4. What is ZPT/TAL TAL – Template Attribute Language ZPT – Zope Page Templates ZPT = an implementation of TAL 30th June 2009 Europython 2009, Birmingham, UK 4
  • 5. Zope?! I don't DO Zope! file:///home/pptfactory/temp/20090701114008/2512086374_5da1610fc9.jpg 30th June 2009 Europython 2009, Birmingham, UK 5
  • 6. TAL is a standard (sort of) Official specification http://wiki.zope.org/ZPT/TAL Multiple implementations http://en.wikipedia.org/wiki/Template_Attribute_Language 30th June 2009 Europython 2009, Birmingham, UK 6
  • 7. The Idea of Templating XML/TAL Data Template ZPT XHTML 30th June 2009 Europython 2009, Birmingham, UK 7
  • 8. The Idea of Templating XML/TAL Data Template ZPT or or not Plain XHTML XML RSS text 30th June 2009 Europython 2009, Birmingham, UK 8
  • 9. Why use templates? Separate Presentation and Logic Keeping code clean Multiple presentations of same data (RSS, JSON, REST, XML) 30th June 2009 Europython 2009, Birmingham, UK 9
  • 10. But, why TAL? <ul> % for name in row: <li>${name}</li> % endfor </ul> 30th June 2009 Europython 2009, Birmingham, UK 10
  • 11. But, why TAL? <ul> % for name in row: <li>${name}</li> % endfor </ul> <ul> <li tal:repeat=”name row” tal:content=”name” /> </ul> 30th June 2009 Europython 2009, Birmingham, UK 11
  • 12. But, why TAL? <ul> <li tal:repeat=”name row” tal:content=”name”> Dummy data </li> </ul> 30th June 2009 Europython 2009, Birmingham, UK 12
  • 13. But, why TAL? <ul> <li tal:repeat=”name row” tal:content=”name”> Dummy data </li> </ul> 30th June 2009 Europython 2009, Birmingham, UK 13
  • 14. Makes well-formed XHTML easy <ul> <li> % if foo = 'bar': ${name} </li> Nesting % endif Error! </ul> 30th June 2009 Europython 2009, Birmingham, UK 14
  • 15. Makes well-formed XHTML easy <ul> <li tal:condition=”python:foo='bar'” tal:content=”name” /> </ul> 30th June 2009 Europython 2009, Birmingham, UK 15
  • 16. Makes well-formed XHTML easy Ensures that you close all elements and quote attributes Escapes all ampersands by default & -> &amp; 30th June 2009 Europython 2009, Birmingham, UK 16
  • 17. So, how do I use it? Create virtualenv % virtualenv zptdemo Install zope.pagetemplate in virtualenv % cd zptdemo % bin/easy_install zope.pagetemplate 30th June 2009 Europython 2009, Birmingham, UK 17
  • 18. So, how do I use it? In mycode.py: from zope.pagetemplate.pagetemplatefile import PageTemplateFile my_pt = PageTemplateFile('mytemplate.pt') context = {'row': ['apple', 'banana', 'carrot'], 'foo':'bar'} print my_pt.pt_render(namespace=context) 30th June 2009 Europython 2009, Birmingham, UK 18
  • 19. So, how do I use it? In mytemplate.py: <html> <body> <h1>Hello World</h1> <div tal:condition=”python:foo == 'bar'”> <ul> <li tal:repeat="item rows" tal:content="item" /> </ul> </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 19
  • 20. So, how do I use it? End result: <html> <body> <h1>Hello World</h1> <ul> <li>apple</li> <li>banana</li> <li>carrot</li> </ul> </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 20
  • 21. Some TAL niceties <a href=”href” tal:omit-tag=”not:href”> Optionally linked text </a> Omit the tag if there is href variable evaluates false 30th June 2009 Europython 2009, Birmingham, UK 21
  • 22. Some TAL niceties <title tal:content=”page/title | site/title | default”> My Website </title> If there is no page title or site title, then use the default text 30th June 2009 Europython 2009, Birmingham, UK 22
  • 23. Some TAL niceties <option tal:repeat=”c countries” tal:content=”c” tal:attributes=”selected python:c==’UK’” /> Create an option for each country, and if the UK then set selected 30th June 2009 Europython 2009, Birmingham, UK 23
  • 24. Some advanced features file:///home/pptfactory/temp/20090701114008/ninja.jpg ( but not too many ) 30th June 2009 Europython 2009, Birmingham, UK 24
  • 25. METAL macros A master template: <html metal:define-macro=”main”> <head><title>My Site</title></head> <body> <div metal:define-slot=”body”> Dummy body </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 25
  • 26. METAL macros A sub-template for a page: <html metal:use-macro= ”template/macros/main”> <head><title>My Site</title></head> <body> <div metal:fill-slot=”body”> This is my real body text </div> </body> </html> 30th June 2009 Europython 2009, Birmingham, UK 26
  • 27. METAL macros Internationalisation: <h1 i18n:translate=””>Some text</h1> 30th June 2009 Europython 2009, Birmingham, UK 27
  • 28. Questions? matth@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 28
  • 29. We are looking for Developers! Come chat to me or drop an email to careers@netsight.co.uk 30th June 2009 Europython 2009, Birmingham, UK 29