HTML Templates (Sitemesh/Tiles concept) in Python

Discussion in 'Python' started by Suren, Oct 23, 2006.

  1. Suren

    Suren Guest

    Hello,

    I am a newbie to python and web development. I am part of a fairly
    simple project and we are trying to identify an efficient way to design
    our html pages. The technologies at our disposal are javascript, html
    and python for now.

    Our pages bear a very standard look. Here is what it looks like.

    --------------------------------------------------
    BANNER
    --------------------------------------------------
    | -l1 | <- -> Logout
    | -l2 |---------------------------------------
    | -l3 |
    | -l4 | CONTENT
    | -l5 |---------------------------------------
    | | COPYRIGHT
    -------------------------------------------------

    l1 through l5 are links that basically target the content page and fill
    in. Each page via that link has a python reference to go gather
    appropriate data for the content page. We are using frames to do the
    banner.html, menu.html (the links page) and the content page.

    For the content page, how can we decorate it on top with the back/front
    buttons and logout buttons and botton with a copyright in every page.
    It seems error prone as well as bad design to scatter this logic in
    each content page. Is there a template logic like Sitemesh or Tiles
    concept that can decorate a desired page just before show time?

    Any other tips to help life easier are appreciated.
     
    Suren, Oct 23, 2006
    #1
    1. Advertising

  2. Suren wrote:
    > Hello,
    >
    > I am a newbie to python and web development. I am part of a fairly
    > simple project and we are trying to identify an efficient way to design
    > our html pages. The technologies at our disposal are javascript, html
    > and python for now.


    Python with ? CGI ? FastCGI ? mod_python ? Other ?


    > Our pages bear a very standard look. Here is what it looks like.
    >

    (snip)

    > l1 through l5 are links that basically target the content page and fill
    > in. Each page via that link has a python reference to go gather
    > appropriate data for the content page. We are using frames to do the
    > banner.html, menu.html (the links page) and the content page.


    You shouldn't - unless this is an internal web-based application, not a
    public site. Since your dynamically generating the pages, there's no
    gain using frames - but there are huge drawbacks, for the programmers as
    well as for the visitors.

    > For the content page, how can we decorate it on top with the back/front
    > buttons and logout buttons and botton with a copyright in every page.
    > It seems error prone as well as bad design to scatter this logic in
    > each content page. Is there a template logic like Sitemesh or Tiles
    > concept that can decorate a desired page just before show time?


    There are lot of web templating engines in Python, and most of them
    provide some way to either "extend" an existing template (to fill-in
    page-specific stuffs) or to do server-side-includes-like inclusion of
    common parts. Google for Genshi, Jinja, SimpleTAL, Mighty, Cheetah...

    > Any other tips to help life easier are appreciated.


    Have you considered using one of the existing python web development
    libraries/frameworks? Like Pylons, Turbogears, Django, Spyce, Karigell,
    etc, etc, etc, etc...

    My 2 cents...
    --
    bruno desthuilliers
    python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
    p in ''.split('@')])"
     
    Bruno Desthuilliers, Oct 23, 2006
    #2
    1. Advertising

  3. Suren

    Suren Guest


    > Python with ? CGI ? FastCGI ? mod_python ? Other ?


    We are using mod_python and SSI. We are inheriting some legacy code
    that we do not want to mess with at all.

    > You shouldn't - unless this is an internal web-based application, not a
    > public site. Since your dynamically generating the pages, there's no
    > gain using frames - but there are huge drawbacks, for the programmers as
    > well as for the visitors.


    Although not an internal site, this site is going to be in a controlled
    environment. Only a handful of people may access the website.

    > There are lot of web templating engines in Python, and most of them
    > provide some way to either "extend" an existing template (to fill-in
    > page-specific stuffs) or to do server-side-includes-like inclusion of
    > common parts. Google for Genshi, Jinja, SimpleTAL, Mighty, Cheetah...


    I will look at these and see it works.

    >
    > > Any other tips to help life easier are appreciated.

    >
    > Have you considered using one of the existing python web development
    > libraries/frameworks? Like Pylons, Turbogears, Django, Spyce, Karigell,
    > etc, etc, etc, etc...
    >
    > My 2 cents...


    We have not considered a framework coz the legacy code base has not
    included one. We are living in the same source structure and did not
    want to introduce a newer dependency. I hope we can find a
    non-intrusive library/framework that does its job.


    Thanks.
     
    Suren, Oct 23, 2006
    #3
  4. Suren a écrit :

    > > Python with ? CGI ? FastCGI ? mod_python ? Other ?

    >
    > We are using mod_python and SSI.
    >
    > We are inheriting some legacy code
    > that we do not want to mess with at all.


    Ok.

    > > You shouldn't - unless this is an internal web-based application, not a
    > > public site. Since your dynamically generating the pages, there's no
    > > gain using frames - but there are huge drawbacks, for the programmers as
    > > well as for the visitors.

    >
    > Although not an internal site, this site is going to be in a controlled
    > environment. Only a handful of people may access the website.


    So the drawbacks of frames may not be a definitive show-stopper.
    Anyway, and unless going thru useless complications, frames still have
    at least 2 big problems : you cannot bookmark pages, and you cannot be
    sure the use will see the effective content thru the "framed" page.
    The main use case for frames is (was ?) to avoid duplicating the same
    set of common elements (menus, header, footer etc) on each and evry
    page of a site. With dynamic page generation and template systems, this
    is no more a problem, so I see very few reasons to still use them.

    (snip)

    > >
    > > > Any other tips to help life easier are appreciated.

    > >
    > > Have you considered using one of the existing python web development
    > > libraries/frameworks? Like Pylons, Turbogears, Django, Spyce, Karigell,
    > > etc, etc, etc, etc...
    > >

    > We have not considered a framework coz the legacy code base has not
    > included one. We are living in the same source structure and did not
    > want to introduce a newer dependency. I hope we can find a
    > non-intrusive library/framework that does its job.


    Hard to tell what would be more appropriate without knowledge of the
    existing code base and architecture... Anyway, both Jinja and Genshi
    are relatively easy to setup and get started with. Mighty is a much
    more complex and powerful beast (it's almost a whole web-components
    framework by itsef).

    My 2 cents
     
    bruno de chez modulix en face, Oct 23, 2006
    #4
  5. Suren

    Guest

    Suren wrote:
    > > Python with ? CGI ? FastCGI ? mod_python ? Other ?

    >
    > We are using mod_python and SSI. We are inheriting some legacy code
    > that we do not want to mess with at all.


    If you are already using SSI for basic page composition using 'include
    virtual', it may be of interest for you to know that upcoming
    mod_python 3.3 supports use of Python code directly with SSI. For
    details see:


    http://www.dscpl.com.au/wiki/ModPython/Articles/BasicsOfServerSideIncludes

    To use this feature now, you would have to use latest mod_python code
    base out of Subversion repository though. We are just tidying up last
    few issues for 3.3, so code is more than usable at this point.

    There is an example in the article about how the new feature can be
    used for adding header, footers etc.

    Graham
     
    , Oct 24, 2006
    #5
  6. Suren

    metaperl Guest

    Suren wrote:


    > It seems error prone as well as bad design to scatter this logic in
    > each content page. Is there a template logic like Sitemesh or Tiles
    > concept that can decorate a desired page just before show time?
    >


    Suren, you are looking for push-style templating. I list a number of
    alternatives here:
    http://www.livingcosmos.org/Members/sundevil/software-engineering/push-style-templating-systems/view

    I use meld3 personally, but Templess looks pretty good and Webstring
    also. Depends on your tastes.
     
    metaperl, Oct 24, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Sobol

    Sitemesh-like templating system for .NET?

    Steve Sobol, Mar 29, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    526
    Steve Sobol
    Mar 29, 2006
  2. Rich M
    Replies:
    0
    Views:
    2,060
    Rich M
    Mar 5, 2004
  3. Steve Sobol
    Replies:
    0
    Views:
    498
    Steve Sobol
    Mar 28, 2006
  4. OTB

    Sitemesh : replace logo

    OTB, Dec 20, 2006, in forum: Java
    Replies:
    2
    Views:
    358
    Steven J. Sobol
    Dec 20, 2006
  5. Zaza
    Replies:
    0
    Views:
    628
Loading...

Share This Page