[Tutor] Python equiv to PHP "include" ?
Kent Johnson
kent37 at tds.net
Fri Sep 30 03:10:31 CEST 2005
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 template. 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 at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list