473,626 Members | 3,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTML Templates (Sitemesh/Tiles concept) in Python

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.

Oct 23 '06 #1
5 2208
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 'o****@xiludom. gro'.split('@')])"
Oct 23 '06 #2
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.

Oct 23 '06 #3

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

Oct 23 '06 #4
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

Oct 23 '06 #5

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.

Oct 24 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2354
by: Dave Smithz | last post by:
Hi, Summary: Best way to divide out the HTML and PHP in some code I inherited. How can I keep the HTML files separate? Full Details: I've now been working two weeks on PHP / MySQL code I inherited and the client is a happy bunny. This was my first crash course outing with PHP, but with basic PERL experience found it fairly easy to pick up and used the code
0
1370
by: Carlos Ribeiro | last post by:
Hello all, While studying some of the templating systems available for Python, I've come up with an idea to implement templates using decorators. The following code snippet runs in Python 2.3; a few 2.4 only extensions are shown as comments. Please note that I have shamelessly copied the trim function from PEP 257, because it's needed to have the strings properly formatted. ============================
13
2382
by: Michele Simionato | last post by:
What is the recommended way of generating HTML from Python? I know of HTMLGen and of few recipes in the Cookbook, but is there something which is more or less standard? Also, are there plans to include a module for HTML generation in the standard library? I really would like to see some standardization in this area. Michele Simionato
7
2153
by: Hansan | last post by:
Hi all, I hope you have time to help me out a little. My problem is that I want to combine some python code I have made with some html templates, I found a tutorial at dev shed: http://devshed.spunge.org/Server_Side/Python/CGI/page6.html and : http://devshed.spunge.org/Server_Side/Python/CGI/page5.html and tried to do it like they do, but it doesn't work. I used the same code they use for making the two display functions and the same...
3
2610
by: db | last post by:
Hello all, I hope this is the correct newsgroup for this question. Does anybody know how I can write a html-header with python(cgi)? The problem is, I have a few html templates in which I have a header e.g: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>
18
4958
by: pkassianidis | last post by:
Hello everybody, I am in the process of writing my very first web application in Python, and I need a way to generate dynamic HTML pages with data from a database. I have to say I am overwhelmed by the plethora of different frameworks, templating engines, HTML generation tools etc that exist. After some thought I decided to leave the various frameworks aside for the
4
2329
by: Andrew Taylor | last post by:
I've been struggling for a long time with HTML_Quickform from PEAR. The concept is ideal, but, the implementation is (IMHO) a bit of a kludge. As a developer I want a quick and easy way to generate/validate/process forms without hand hacking HTML, however, I also want it to be easy to do! The HTML_Quickform method seems to require more work than it should and whenever you start getting really complicated forms, the hassle starts to...
104
4552
by: JohnQ | last post by:
Well apparently not since one can step thru template code with a debugger. But if I was willing to make the concession on debugging, templates would be strictly a precompiler thing? I have a feeling the answer I'm going to get back will be "no, because templates have taken on a life of their own since their original conception and now also affect compiler implementation" (read: not good, IMO. John
26
231
by: puzzlecracker | last post by:
Team, C++ has been around since 1986, why templates are still regarded is a new feature by most compiler vendors and not fully supported (for example export feature). Look at other popular languages -- say Java, CSharp --and templates , also known as generics, are fully implemented and supported in latest releases. Yes, in C++ they are implemented differently, yet not better. Then why C++ is so lagging behind. Can't we get ourself...
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.