troubleshootingfaq

Quick tip: If $placeholder is really calling a function, say from an imported python file of your own making, then make sure that the function you are calling returns a value rather than prints. Otherwise your output will be delayed until the template has printed and things will be out of order.


This might be something obvious to those more familiar with WebWare?, but I spent a day on it so I figured I'd point it out here...in trying to get some modifications to the sample site going, my created pure Python servlet couldn't access any of the web transaction objects. WebWare? doesn't get involved until it calls awake. That is, during __init__, anything from Cheetah is just operating with the dummy servlet class, so you can't get at the transaction information. It's not until awake() gets called that the Servlet springs into life as a WebWare? servlet subclass and you can do initilization. This is sort of in the docs in the discussion of the awake method, but not really explicitly spelled out that you can't init things servlet type things from __init__ (you can of course read the source to discover this).

-- RenePijlman - 20 Nov 2003


$varExists(var) doesn't work for local (#set) variables.

Tavis Rudd told me:

"It checks to see if a variable is in the searchList, but can't check for local variables that are created with #set."

The solution is to use has_key, like so:

#if $locals().has_key('gumby') something

[never used a wiki so I apologize if I'm screwing everything up ]

-- NormanJHarmanJr - 25 Nov 2002


When the data contains Unicode strings, you may get the following exception:

Unicode related error: ASCII encoding error: ordinal not in
range(128)
Traceback (innermost last):
[...]
File "C:\Python\Python22\Lib\site-packages\Cheetah\Template.py",
line 45, in respond
  # More intra-package imports ...
File "C:\Python\Python22\Lib\site-packages\Cheetah\Filters.py",
line 106, in filter
                     return str(val)

The solution is to use a custom filter that encodes Unicode strings. There is an example in the CheetahRecipes.

-- RenePijlman - 20 Nov 2003


I'm using Cheetah 0.9.15 to generate a large static website. My application creates thousands of files in this way:

template = Template(templateFile, searchList)
content = template.respond()
# write content to file and close file

When I run this code I see the python process consuming an ever growing amount of memory (I see this in the "Mem usage" column in the Windows task manager and the SZ column of ps -l on Linux).

Looking at the methods of the Template class I noticed a promising method called shutdown(). And indeed, when I add:

template.shutdown()

... to the code above, memory usage remains low and constant.

At the time of writing, template.shutdown() was not documented in the Users' Guide.

-- RenePijlman - 25 Nov 2003


When installing on Windows, the cheetah and cheetah-compile scripts are installed to %PYTHON_HOME%\Scripts (where %PYTHON_HOME% is the path to your python installation).

These scripts fail to run on windows, even if this directory is in your PATH, since they have no file extension. Renaming them to have a ".py" extension allows them to run from the command line, as per the documentation.

I'm not sure how this effects the cheetah unit tests, but there were several of the "insignificant" errors listed on the installation guide. My installation seems to work correctly otherwise.