"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/dev_guide/cache.rst" between
cheetah3-3.1.0.tar.gz and cheetah3-3.2.0.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

cache.rst  (cheetah3-3.1.0):cache.rst  (cheetah3-3.2.0)
Caching placeholders and #cache Caching placeholders and #cache
=============================== ===============================
(cache)
Dynamic placeholder - no cache Dynamic placeholder - no cache
------------------------------ ------------------------------
(cache.dynamic)
The template: The template:
:: ::
Dynamic variable: $voom Dynamic variable: $voom
The command line and the output: The command line and the output:
:: ::
skipping to change at line 37 skipping to change at line 33
write('Dynamic variable: ') write('Dynamic variable: ')
write(filter(VFS(SL,"voom",1))) # generated from '$voom' at line 1, col 20. write(filter(VFS(SL,"voom",1))) # generated from '$voom' at line 1, col 20.
write('\n') write('\n')
Just what we expected, like any other dynamic placeholder. Just what we expected, like any other dynamic placeholder.
Static placeholder Static placeholder
------------------ ------------------
(cache.static)
The template: The template:
:: ::
Cached variable: $*voom Cached variable: $*voom
The command line and output: The command line and output:
:: ::
skipping to change at line 108 skipping to change at line 102
necessary. Clearly, the programmer is trying to stick as close to necessary. Clearly, the programmer is trying to stick as close to
normal (dynamic) workflow as possible. Remember that {write}, even normal (dynamic) workflow as possible. Remember that {write}, even
though it looks like a local function, is actually a method of a though it looks like a local function, is actually a method of a
file-like object. So we create a temporary file-like object to file-like object. So we create a temporary file-like object to
divert the {write} object into, then read the result and stuff it divert the {write} object into, then read the result and stuff it
into the cache. into the cache.
Timed-refresh placeholder Timed-refresh placeholder
------------------------- -------------------------
(cache.timed)
The template: The template:
:: ::
Timed cache: $*.5m*voom Timed cache: $*.5m*voom
The command line and the output: The command line and the output:
:: ::
skipping to change at line 195 skipping to change at line 187
""" """
The docstring tells only that "something" will be refreshed every The docstring tells only that "something" will be refreshed every
60.0 seconds, but doesn't reveal { which} placeholder that is. Only 60.0 seconds, but doesn't reveal { which} placeholder that is. Only
if you know the relative order of the placeholders in the template if you know the relative order of the placeholders in the template
can you figure that out. can you figure that out.
Timed-refresh placeholder with braces Timed-refresh placeholder with braces
------------------------------------- -------------------------------------
(cache.timed.braces)
This example is the same but with the long placeholder syntax. It's This example is the same but with the long placeholder syntax. It's
here because it's a Cheetah FAQ whether to put the cache interval here because it's a Cheetah FAQ whether to put the cache interval
inside or outside the braces. (It's also here so I can look it up inside or outside the braces. (It's also here so I can look it up
because I frequently forget.) The answer is: outside. The braces go because I frequently forget.) The answer is: outside. The braces go
around only the placeholder name (and perhaps some output-filter around only the placeholder name (and perhaps some output-filter
arguments.) arguments.)
The template: The template:
:: ::
skipping to change at line 242 skipping to change at line 232
:: ::
Timed with {}: ${*.5m*voom} Timed with {}: ${*.5m*voom}
``${`` is not a valid placeholder, so it gets treated as ordinary ``${`` is not a valid placeholder, so it gets treated as ordinary
text. text.
#cache #cache
------ ------
(cache.directive)
The template: The template:
:: ::
#cache #cache
This is a cached region. $voom This is a cached region. $voom
#end cache #end cache
The output: The output:
skipping to change at line 289 skipping to change at line 277
17 del cacheCollector 17 del cacheCollector
18 write(self._cacheData['23711421']) 18 write(self._cacheData['23711421'])
19 ## END CACHE REGION 19 ## END CACHE REGION
This is the same as the {$\*voom} example, except that the plain This is the same as the {$\*voom} example, except that the plain
text around the placeholder is inside the second if-block. text around the placeholder is inside the second if-block.
#cache with timer and id #cache with timer and id
------------------------ ------------------------
(cache.directive.timer)
The template: The template:
:: ::
#cache timer='.5m', id='cache1' #cache timer='.5m', id='cache1'
This is a cached region. $voom This is a cached region. $voom
#end cache #end cache
The output: The output:
skipping to change at line 322 skipping to change at line 308
self._cacheIndex['cache1'] = '13925129' self._cacheIndex['cache1'] = '13925129'
self.__cache13925129__refreshTime = currentTime() + 30.0 self.__cache13925129__refreshTime = currentTime() + 30.0
elif currentTime() > self.__cache13925129__refreshTime: elif currentTime() > self.__cache13925129__refreshTime:
self.__cache13925129__refreshTime = currentTime() + 30.0 self.__cache13925129__refreshTime = currentTime() + 30.0
else: else:
RECACHE = False RECACHE = False
#cache with test: expression and method conditions #cache with test: expression and method conditions
-------------------------------------------------- --------------------------------------------------
(cache.directive.test)
The template: The template:
:: ::
#cache test=$isDBUpdated #cache test=$isDBUpdated
This is a cached region. $voom This is a cached region. $voom
#end cache #end cache
(Analysis postponed: bug in Cheetah produces invalid Python.)
The template: The template:
:: ::
#cache id='cache1', test=($isDBUpdated or $someOtherCondition) #cache id='cache1', test=($isDBUpdated or $someOtherCondition)
This is a cached region. $voom This is a cached region. $voom
#end cache #end cache
The output: The output:
 End of changes. 9 change blocks. 
18 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)