[Twisted-web] caching branch

Andrea Arcangeli andrea at cpushare.com
Thu Feb 17 21:15:57 MST 2005


The tags.cached keeps working fine in the caching branch (which btw
applied cleanly on top of trunk).

What doesn't work is the rend.Page. I'm very curious to compare the
performance of the caching branch with my previous code that is
currently online already.

Locals
rest	[<listiterator object at 0x56c6fcac>]
item	<generator object at 0x56c6fc8c>
gen	<generator object at 0x56c6fc8c>
/home/andrea/bin/x86_64/python/lib/python2.4/site-packages/nevow/flat/flatstan.py, line 234 in CachedSerializer
232

233

def CachedSerializer(original, context):

234

    cache = ICache(original.scope(context))

235

    cached = cache.get(original.key, original.lifetime)

Locals
original	<cached instance at 1455889540>
context	<WovenContext instance at 1455880172>
Globals
ICache	<MetaInterface nevow.inevow.ICache>
CachedSerializer	<function CachedSerializer at 0x56c63614>

I also suggest to apply this patch to the code or it doesn't even
startup.

--- Nevow/nevow/rend.py.~1~	2005-02-18 04:39:54.208615490 +0100
+++ Nevow/nevow/rend.py	2005-02-18 05:06:15.272641191 +0100
@@ -30,6 +30,7 @@ from nevow import tags
 from nevow import flat
 from nevow.util import log
 from nevow import util
+from nevow import url
 
 import formless
 from formless import iformless
@@ -416,7 +417,7 @@ class Page(Fragment, ConfigurableFactory
         if self.buffered:
             io = StringIO()
             writer = io.write
-            def finisher(result):                
+            def finisher(result):
                 request.write(io.getvalue())
                 finishRequest()
                 return result
@@ -428,7 +429,7 @@ class Page(Fragment, ConfigurableFactory
 
         doc = self.docFactory.load()
         if self.cache:
-            name = url.URL.fromContext(ctx).path
+            name = str(url.URL.fromContext(ctx))
             doc = tags.cached(name, self.lifetime)[doc]
         ctx =  WovenContext(ctx, tags.invisible[doc])
 
@@ -504,7 +505,6 @@ class Page(Fragment, ConfigurableFactory
             else:
                 ## Use the redirectAfterPost url
                 ref = str(redirectAfterPost)
-            from nevow import url
             refpath = url.URL.fromString(ref)
             magicCookie = str(now())
             refpath = refpath.replace('_nevow_carryover_', magicCookie)



More information about the Twisted-web mailing list