• Business posts
  • Technology posts
  • Company site
  • SubscribeRSS

Userland templates for Plone – template engine abstraction layer for Python

Posted on November 9, 2008  by Mikko Ohtamaa
Filed Under Plone (old), python, zope
Tags: cheetah, content rules, django, email, engine, kupu, metal, Plone (old), python, security, tal, tales, template, zope

I have been working with collective.easytemplate product which allows users to use template tags on various places on Plone site. Currently supporting

  • Kupu
  • Outgoing email actions (Content rules ones)

The users can place ${title}, ${object_url} and other template in the edit mode. These variables which are directly mapped from Archetypes fields when the content is viewed/sent. Also, one can register custom snippet generators like $list_folder_content.

I hope Easy Template to cover some more actions in the future. I have noted PloneFormGen and Singing & Dancing product authors that we could add some mixed in functionality together.

Currently Easy Template uses Cheetah template backend. Cheetah is not Zope security friendly and exposing templated actions should be allowed only to trusted members. I am not huge fan of Plone’s TAL template language which is based on XML attributes and thus suitable only be used in XML context – this language is aimed only for hardcore hackers and software designers and ordinary folk really cannot wrap their minds around it.

Because I am not sure which will be the chosen template backend in the future I chose to abstract the template engine layer away. I created collective.templateengines product. It is a bunch of Zope interfaces and utility functions to abstract away common template actions like

  • Applying a template
  • Adding a template context variables
  • Registering custom template tags

Currently collective.templateengines supports Cheetah and Django templates.

So, dear audience, what do you think of all this? What template engine would you suggest which would be Kupu friendly – you can edit the template language in WYSIWYG editor? Do you see any other usages for collective.templateengines? Which other projects could adopt template engine abstraction layer?

 

Other posts by Mikko Ohtamaa

 

Comments

6 Responses to “Userland templates for Plone – template engine abstraction layer for Python”

  1. Martin Aspeli on November 10th, 2008 1:18 am
    Gravatar

    I’m not sure I’m reading this correctly, but if you’re talking about writing templates through the web with Kupu, then I don’t think that’s a use case Plone really should cater for by default.

    The only use case I think could make sense, would be simple variable substitutions. In this case, string.Template probably makes sense – I certainly wouldn’t invent a whole pagetemplate abstraction library.

    However, I think a better solution would be to use HTML markers, e.g. . These would be transformed on page rendering to insert the appropriate values.

    Martin

     
  2. Mikko Ohtamaa on November 10th, 2008 1:20 am
    Gravatar

    > writing templates through the web

    It’s about using templates in Kupu.

     
  3. Jon Stahl on November 10th, 2008 3:38 am
    Gravatar

    I can definitely see some use cases (mainly involving PloneFormGen or S&D, as Mikko suggests) for doing simple variable substitutions in Kupu.

    e.g. on a Thank You page, the user would like to write the page in Kupu but be able to stick in form variables.

     
  4. Malthe on November 10th, 2008 1:33 pm
    Gravatar

    Right, “string.Template“ is fast and simple and it could be used lazily, such that values would only be computed when requested.

     
  5. Mikko Ohtamaa on November 10th, 2008 3:16 pm
    Gravatar

    You can use string.Template as a backend. But you still need to have a way to map context object to template variables.

    I have found out that simple strings are not enough in real life. I wouldn’t have gone through to make this exercise just for fun.

     
  6. Petri Savolainen on November 13th, 2008 1:44 pm
    Gravatar

    If you’re talking about userland variable substitution a’la mailmerge in ms word, why not just simply write a new portal transform?

     

Leave a Reply




  • About

    Twinapex Blog is the voice of mobile and Internet experts. We tell tales about our exciting life in the world where communication methods convergence and you can access whatever information you wish, wherever, on whichever device you want.

    If you find us interesting and talented and you are looking for developers, please contact us and we might just be able to help you.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution 3.0 Unported License.

  • Recently Written

  • PyDev, Python and system default Unicode encoding problem
  • Creating a drag’n’drop basket with jQueryUI
  • Mobile browser wars: Nokia microB vs. Firefox Fennec
  • Profiling PostgreSQL database
  • It will be damn big, and damn fast…
  • Black Friday was not sad for mobile commerce
  • Nokia N900, sports tracking and geotagging
  • PhoneGap ported on N900 (Maemo)
  • Do you really think 160 chars tells the story?
  • Installing Python Imaging Library (PIL) under virtualenv or buildout
  • Tags

  • aggregator analytics android api buildout c++ cms comic debug debugging developer django documentation eclipse extjs failure html iphone javascript jquery language linux mobile multilingual nokia php plone Plone (old) pys60 python release rss s60 seo series 60 setuptools sql subclipse symbian ubuntu usability virtualenv web web development zope
  • Monthly Archives

  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • February 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
 
© Twinapex Oy 2010 Log in