Problem combining python code and html
Hansan
none
Wed May 11 15:22:16 EDT 2005
Thanks for you reply and Help Fredrik Lundh
The change did remove the error message, and I can see what was wrong.
However there is now a new problem, the only thing that is displayed is one
single character and that is: <
Do you or anyone else have a suggestion to what the cause to this new
problem is ?
Thanks for your time
"Fredrik Lundh" <fredrik at pythonware.com> wrote in message
news:mailman.381.1115831593.29826.python-list at python.org...
> 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