Re: [PythonWeb.org] Problems using web.template.
Status: Beta
Brought to you by:
thejimmyg
|
From: James G. <ja...@py...> - 2005-06-23 20:57:30
|
Hi Wayne, I've tested your code on both Python 2.2 and Python 2.4 and it works as it should for me, I couldn't reproduce your error I'm afraid. Cheetah is the most powerful and best supported templating engine that the web modules support so I'd recommend using that instead. The example is at http://www.pythonweb.org/projects/webmodules/doc/0.5.3/html_multipage/lib/example-file-web-template-cheetah.html As for the Internal Server Error on Apache, that is usually caused because you have forgotten to print the HTTP header before the main content. Add the line: print "Content-type: text/html\n\n" after the import web.template line and you should avoid the error. Hope that is of some use! James Wayne Pierce wrote: >I just found PythonWeb and have started working through the examples. >Unfortunately I can't get a simple template working properly, parts of >the HTML disappear or are printed out of order in the final output. > >I have the following files: > >(webtest.py) > >#!/usr/bin/python > >import web.template > >dict = { > 'welcomeMessage': 'Welcome to the test page.', > 'testVar': True, > 'title': 'Example' >} > >print web.template.parse( > type='xyaptu', > file='web-template.tmpl', > dict=dict >) > >(web-template.tmpl) > ><html> > <head> > <title>$title</title> > </head> > > <body> > <p>$welcomeMessage</p> > <py-open code="if testVar:" /> > The variable is: True > <py-clause code="else:" /> > The variable is: False > <py-close/> > </body> ></html> > >When I run 'python webtest.py' from the command line (Fedora 3) I get >the following: > ><html> <head> <title>Example</title> > <body>> <p>Welcome to the test page.</p> > >The variable is: True ></html> </body> > > >Two things happen, </head> disappears and the last two items are >flipped. Running webtest.py through Apache gives me an Internal >Server Error due to malformed headers. > >Does anyone have suggestions on what could be causing this? I am >using Python 2.3.4 with the latest version of PythonWeb. > >Thanks for any help, > >Wayne > > >------------------------------------------------------- >SF.Net email is sponsored by: Discover Easy Linux Migration Strategies >from IBM. Find simple to follow Roadmaps, straightforward articles, >informative Webcasts and more! Get everything you need to get up to >speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click >_______________________________________________ >Lemon-webmodules mailing list >Lem...@li... >https://lists.sourceforge.net/lists/listinfo/lemon-webmodules > > |