You need to move the line:

       tmpl = Template(file='TestCache.tmpl', searchList=[{'t':t}])
into the __init__ method.
You are basically recreating the template from the file each time the servlet is run.

The caching works within a single cheetah template *instance*

try somthing like



class TestCache(Page):
def __init__(self):
Page.__init__(self)
self.tmpl = Template(file='TestCache.tmpl')


   def writeHTML(self):
       t =  time.strftime('%H:%M:%S', time.localtime(time.time()))
       self.tmpl.t = t
       self.writeln(tmpl)

-Aaron

JZ wrote:

I do not know how to make WebKit & Cheetah to use cache. I am using
mod_webkit csv. CacheServletClasses and CacheServletInstances are set
to 1. My first try was:

TestCache.py:

import time
from WebKit.Page import Page
from Cheetah.Template import Template
class TestCache(Page):
   def writeHTML(self):
       t =  time.strftime('%H:%M:%S', time.localtime(time.time()))
       tmpl = Template(file='TestCache.tmpl', searchList=[{'t':t}])
       self.writeln(tmpl)

TestCache.tmpl:

<html>
<body>
#cache
t=$t
#end cache
</body>
</html>

But it does NOT work because every refresh of the page I get the new
values. It should be the same values if cache works, isn't it? I have
also tried another way:

TestCache.tmpl:

from WebKit.Page import Page
from Cheetah.Template import Template
class TestCache(Page):
   def writeHTML(self):
       tmpl = Template(file='TestCache.tmpl')
       self.writeln(tmpl)

TestCache.tmpl

<html>
<body>
#import time
#cache
#set $t =  time.strftime('%H:%M:%S', time.localtime(time.time()))
t=$t
#end cache
</body>
</html>

Unsuccesfull. :( Nothing was changed.What am I doing wrong??




-- -Aaron http://www.MetroNY.com/ "I don't know what's wrong with my television set. I was getting C-Span and the Home Shopping Network on the same station. I actually bought a congressman." - Bruce Baum





-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to