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
Re: [Tutor] Python equiv to PHP "include" ?
by Kent Johnson other posts by this author
Sep 29 2005 6:11PM messages near this date
Re: [Tutor] Python equiv to PHP "include" ? | Re: [Tutor] Python equiv to PHP "include" ?
Jay Loden wrote:
>  Alan, thanks for your responses, they're quite helpful. I suspect the real 
>  problem I'm having is simply trying to switch modes of thinking to CGI style 
>  or mod_python style instead of the PHP style embedded code. 

There are quite a few template engines for Python that allow embedding Python into the templ
ate. One of them is part of mod_python: http://www.onlamp.com/pub/a/python/2004/02/26/python
_server_pages.html

Some others are Myghty and Spyce and the PSP component of WebWare:
http://www.myghty.org/
http://spyce.sourceforge.net/
http://www.webwareforpython.org/Webware/PSP/Docs/index.html

You might find that these have a familiar style.

Kent

>  
>  The whole point of this exercise for me was to decide which language I prefer 
>  for web development and evaluate Python for web work. So far, I've found PHP 
>  much easier to work with and less "clunky" in terms of what I'm trying to do 
>  - but I believe that's very much a function of my thinking being rooted in 
>  the PHP style. 
>  
>  If Im understanding this right...the Pythonic/CGI method for something like 
>  this is to import a template module of some kind, then call methods from that 
>  template to display the template, with other Python code in the middle that 
>  takes care of form processing? 
>  
>  The solution I have now feels smoother, since all I do is put content 
>  into .htm files, then pull them into a template that's basically an html 
>  sandwich. This gives me capability to stick a <?php ?> section into the .htm 
>  file itself - for example a form with some dynamic content/variables - and 
>  then from a user perspective, all they see is a normal html page.  
>  
> From a server side, it's seeing one big PHP script that includes both template 
>  code and form code, but without me needing to write any templating code into 
>  the form itself - instead I just call the form into the template.  With 
>  Python, it seems like this kind of approach is impossible, and it also means 
>  that my form would probably have to have some kind of special extension, like 
>  "form.py" (so the handler knows what to do with it) instead of just being 
>  located at "form.htm" - am I following this all correctly? 
>  
>  Does anyone know of any soup-to-nuts CGI programming examples online for 
>  Python that might make this clearer so I can bug the list less and just read 
>  some example code?
>  
>  -Jay
>  
>  _______________________________________________
>  Tutor maillist  -  Tutor@[...].org
>  http://mail.python.org/mailman/listinfo/tutor
>  
>  

_______________________________________________
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