[Tutor] separating logic from html in web apps

dman dman@dman.ddts.net
Wed, 29 May 2002 16:39:41 -0500


--LZvS9be/3tNcYl/X
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, May 29, 2002 at 10:26:21AM -0800, Chris Lott wrote:
=2E..
| Yes... this is what I already do in PHP. I keep most of my code
| and functions in exsternal files, including them as needed.
| However I can't do this in Python (so far) because I don't know
| of a templating system where I can put ANY code in my HTML,

Zope's TAL (which is also available separate from zope)
Python Server Pages (PSP)
Quixote

| so I have to spit out all of the HTML from my Python scripts.

That's one way, if you want to use the python parser for your
"templates".  You could create a template parser (and with it your own
template language) for expanding various constructs (eg loops and
variables) embedded in HTML.  That's all a template is, anyways --
some data with special markers, the markers are replaced by a
processor and the result is spit out.  This is what the Zope Page
Template (TAL) authors did.

| I guess
| I need to look for some kind of templating system,

Yeah, go do that!  :-)

| though it
| seems like many python people build web apps just fine without
| them,

Sure some do.  PHP people do the same thing.  And Perl people.  And C
people.  You can even use ASM or raw machine code to write CGI
"scripts".  I recommended using tools that provide as high-level a
view of the system as possible.

| which is what I am trying to understand. I think :)

HTH,
-D

--=20

In his heart a man plans his course,
but the Lord determines his steps.
        Proverbs 16:9
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg


--LZvS9be/3tNcYl/X
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjz1Sp0ACgkQO8l8XBKTpRQzPgCgipMx6k3SeIWsrP5aDSf6/gBl
FP0An0gPGOfsDOSX8GsExS13xohx4Kbr
=HGMW
-----END PGP SIGNATURE-----

--LZvS9be/3tNcYl/X--