2008/6/8 Kent Johnson <[EMAIL PROTECTED]>: > On Sun, Jun 8, 2008 at 6:46 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote: >> I am moving a website from php to python gradually. The first step is >> replacing the page headers and footers. > > I'm not sure how you plan to do this. PHP programs are embedded into > web pages. Python web programs output the contents of the web page. > This is pretty different.
Very little of the pages are PHP, most is HTML. I understand that Python can be used as a web scripting language, so I assume that Python can be run in Apache from a page with an .html extension. Is this not the case, with an .httaccess directive? >> Currently, each page begins >> with <?php include "header.php"; ?> which contains the <head> porton >> of the html and the html code to present the website name and logo. >> Each page ends with <?php include"footer.php"; ?> which includes a >> footer note and the closing body and html tags. Of course this is a >> generalization, but the point is that I need to do something similar >> in Python. Python discourages the use of includes > > Python doesn't have anything that functions like an include to > incorporate a literal block of text from an external file. I guess you > could call that discouragement.... Could I do something similar with a function? Something like printHeader() and I would define that function in a class? >> , and I would like to >> know why so that I can either rethink my page strategy, or decide to >> go against the 'recommended practices'. > > You should probably find a Python template package that uses syntax > similar to PHP. There is a comparison of three modern template > packages here: > http://lucumr.pocoo.org/cogitations/2008/01/01/python-template-engine-comparison/ > > A more complete list is here: > http://wiki.python.org/moin/Templating?highlight=%28genshi%29 Thanks, I will go through those. > If your website is complex you might also want to consider a full web > framework such as Django or TurboGears. Since half the reason for the website to exist is for me to learn to program (just for fun) then I would rather not use an existing framework. Thanks for the suggestion, though. Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor