Problem combining python code and html
Fredrik Lundh
fredrik at pythonware.com
Wed May 11 13:11:35 EDT 2005
Hansan wrote:
> I used the same code they use for making the two display functions and the
> same template for the html form. I even tried using the form template they
> use too, but it still dosnt work. I will now show how the functions and
> templates look like.
>
> The two display functions are:
> def Display(Content):
> TemplateHandle = open(TemplateFile, "r")
> TemplateInput = TemplateHandle.read()
> TemplateHandle.close()
> BadTemplateException = "There was a problem with the HTML template."
> SubResult = re.subn("<!-- *** INSERT CONTENT HERE *** -->",
> Content,TemplateInput)
re.subn takes a regular expression, in which certain characters have
special meanings. for example, in
<!-- *** INSERT JWZ QUOTE HERE *** -->
"*" is reserved character, which means "repeat preceeding expression".
so "***" means repeating a repeated repeat, which makes very little
sense, which is why the RE engine complains.
changing
> SubResult = re.subn("<!-- *** INSERT CONTENT HERE *** -->",
> Content,TemplateInput)
SubResult = TemplateInput.replace(
"<!-- *** INSERT CONTENT HERE *** -->",
Content
)
should work better.
</F>
More information about the Python-list
mailing list