SlideShare a Scribd company logo
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

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 Generation
Jonathan Musset
 
Html and visual fox pro
Html and visual fox proHtml and visual fox pro
Html and visual fox pro
Mike 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 Update
ESUG
 
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
 
Usdin XML for Standards
Usdin XML for StandardsUsdin 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/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 Lerman
Julie 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 Prague
Pavel 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ène
Roberto 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 PowerFactory
Francisco 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 Networks
Matt 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 Stories
Matt Hamilton
 
Intro to Machine Learning and AI
Intro to Machine Learning and AIIntro to Machine Learning and AI
Intro to Machine Learning and AI
Matt 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 Enterprise
Matt Hamilton
 
Supercharge Your Career with Open Source
Supercharge Your Career with Open SourceSupercharge Your Career with Open Source
Supercharge Your Career with Open Source
Matt 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 System
Matt 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 Grail
Matt 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-Launch
Matt 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 Product
Matt 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 Sector
Matt 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 2009
Matt 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 Study
Matt 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

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

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