SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler 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

Mais conteúdo relacionado

Semelhante a 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
 
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
 
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XML
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XMLOSCON 2008: Mashing Up Voice and the Web Using Open Source and XML
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XMLDan York
 
OSGi Users' Forum Meeting 4 - 19 Jan 2010
OSGi Users' Forum Meeting 4 - 19 Jan 2010OSGi Users' Forum Meeting 4 - 19 Jan 2010
OSGi Users' Forum Meeting 4 - 19 Jan 2010mfrancis
 

Semelhante a 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
 
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
 
"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
 
Python Orientation
Python OrientationPython Orientation
Python Orientation
 
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XML
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XMLOSCON 2008: Mashing Up Voice and the Web Using Open Source and XML
OSCON 2008: Mashing Up Voice and the Web Using Open Source and XML
 
OSGi Users' Forum Meeting 4 - 19 Jan 2010
OSGi Users' Forum Meeting 4 - 19 Jan 2010OSGi Users' Forum Meeting 4 - 19 Jan 2010
OSGi Users' Forum Meeting 4 - 19 Jan 2010
 

Mais de 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
 

Mais de 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)
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

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