Python Webpages
François Pinard
pinard at iro.umontreal.ca
Mon Apr 29 19:02:30 EDT 2002
[Johan Fredrik Øhman]
> > I must admit I have never yet seen a system which integrates HTML and
> > code in the same file without the file ending up an unreadable mess.
> I just thought of great idea: How about using one file and not mix html
> and python code at the same time ?
This is almost exactly what we do. Here is a short but real example
(phone number changed, that's all). This page controls what the user
see if there is a database error, or such things.
<!--: Faire
from Local import commun
config = commun.config()
production = config.getboolean('traiter', 'Production')
adresse = config.get('traiter', 'MailTo')
entretien = os.path.exists('/usr/local/etc/entretien')
:-->
<html>
<head><title>erreur.html</title></head>
<body>
<!--: Si production :-->
<!--: Si entretien :-->
Le système ÉCHO est temporairement non disponible. Veuillez ré-essayer
un peu plus tard en journée. Nous nous excusons de cet inconvénient.
Robert Lachance, SRAM.
<!--: Sinon :-->
Une erreur est survenue lors du traitement de votre requête. Veuillez
contacter madame Louise Groulx ou monsieur Robert Lachance au numéro :
(123) 456-7890.
Vous pouvez, si vous le préférez, envoyer un courriel à l'adresse :
%(adresse)s. Vous devrez alors préciser les circonstances
sous lesquelles l'erreur s'est produite.
<!--: FinSi :-->
<!--: Sinon :-->
Oups! Problème inattendu durant le traitement...
<pre>
%(gros_diagnostic)s
</pre>
<!--: FinSi :-->
</body>
</html>
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list