ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
[Tutor] Python equiv to PHP "include" ?
by Jay Loden other posts by this author
Sep 29 2005 6:59AM messages near this date
Re: [Tutor] FW: Frustrated Beginner | Re: [Tutor] Python equiv to PHP "include" ?
I've not been able to find an answer to this conundrum anywhere: 

My current website is done in PHP with a setup something like this: 

::PHP TEMPLATE CODE::

include('file.htm')

::PHP TEMPLATE CODE::

This way, I can have PHP embedded in my htm files and it will be processed as 
part of the script. For example, I can have a form that's written in HTML and 
processed in PHP, then simply 'include("form.htm")' and I have a form with 
processing that's ALSO wrapped in my site template. 

I can't figure out how one would approach this in Python (i'm using 
mod_python). There's no equivalent to the "include" function from PHP. I 
can't use import because then Python would try to parse the HTML from the 
imported file. I've looked at stuff like cheetah and PSP, but neither of 
those actually answers the question, which is how can I include dynamic 
content including PHP code directly into an existing script. Even if I 
started using PSP, I still can't "include" a PSP page into the middle of 
another PSP page.

I'm definitely willing to consider any other solution for how I can make a 
form that processes its input but maintains my template code wrapped around 
it, so feel free to point out a "Pythonic" method. I just don't want to 
duplicate the template code, and I can't find a nice neat solution like what 
I've got in PHP.

-Jay
_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Jay Loden
Adam Cripps
Alan G
Jay Loden
Larry Holish
Kent Johnson
Alan G

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved