472,119 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Compile Cheetah Template on Windows

Newbie here....

I have been able to successful pull info from a MySQL DB, get the
results and output them in an HTML format using Cheetah to the screen
using IDLE. I am doing this on a Windows Laptop, running WinXP,
Python 2.5 and the latest version of Cheetah.

I have two questions:
1. How and where do you compile Cheetah templates in Windows? The
command in the docs is cheetah compile a, however, I believe that this
is for Linux. This does nothing in a DOS Prompt. Please provide the
info for this command in Windows.

2. How do I output the HTML to a file? I tried the following:

FILE = open(filename, "wt")
FILE.writelines(output)
FILE.close()

I get an error though that states that writelines() requires an
interable argument

Thnx for any assistance!

B

Nov 24 '07 #1
1 2974
brianrpsgt1 <br*******@cox.netwrote:
>
I have been able to successful pull info from a MySQL DB, get the
results and output them in an HTML format using Cheetah to the screen
using IDLE. I am doing this on a Windows Laptop, running WinXP,
Python 2.5 and the latest version of Cheetah.

I have two questions:
1. How and where do you compile Cheetah templates in Windows? The
command in the docs is cheetah compile a, however, I believe that this
is for Linux. This does nothing in a DOS Prompt. Please provide the
info for this command in Windows.
The Cheetah installation should have created scripts called "cheetah" and
"cheetah-compile" in your Python25\Scripts directory. The issue you have
is that they aren't on your path.

One answer is to copy Python25\Scripts\cheetah to \Windows\cheetah.py and
Python25\Scripts\cheetah-compile to \Windows\cheetah-compile.py. Then you
can type "cheetah.py compile xxx" or "cheetah-compile.py xxx".

However, you don't have to compile them in advance. You can do "from
Cheetah.Template import Template" and compile them on the fly, with
tmpl = Template( file='page.tmpl' )
>2. How do I output the HTML to a file? I tried the following:

FILE = open(filename, "wt")
FILE.writelines(output)
FILE.close()

I get an error though that states that writelines() requires an
interable argument
Just use FILE.write( output ).
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Charlotte | last post: by
3 posts views Thread by wolfgang.lipp | last post: by
reply views Thread by ajay.padala | last post: by
1 post views Thread by chun ping wang | last post: by
4 posts views Thread by Paolo Pantaleo | last post: by
2 posts views Thread by Sai Krishna M | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.