Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > HTML Templates (Sitemesh/Tiles concept) in Python

Reply
Thread Tools

HTML Templates (Sitemesh/Tiles concept) in Python

 
 
Suren
Guest
Posts: n/a
 
      10-23-2006
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.

 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      10-23-2006
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 '(E-Mail Removed)'.split('@')])"
 
Reply With Quote
 
 
 
 
Suren
Guest
Posts: n/a
 
      10-23-2006

> 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.

 
Reply With Quote
 
bruno de chez modulix en face
Guest
Posts: n/a
 
      10-23-2006

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

 
Reply With Quote
 
grahamd@dscpl.com.au
Guest
Posts: n/a
 
      10-23-2006
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/ModPyth...erSideIncludes

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

 
Reply With Quote
 
metaperl
Guest
Posts: n/a
 
      10-24-2006

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/...g-systems/view

I use meld3 personally, but Templess looks pretty good and Webstring
also. Depends on your tastes.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Monster Templates - Question about Submitting Templates Fred HTML 1 09-26-2005 01:09 AM
Templates within templates Tom McCallum C++ 2 08-04-2004 04:44 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM
using templates in templates John Harrison C++ 8 07-31-2003 12:00 PM



Advertisments