Discussion:
[Moin-devel] dependencies[] for macros
Jim Clark
2005-04-20 13:14:01 UTC
Permalink
Just an update on my caching question - I think I've found the answer,
but would be curious if there are alternative/better methods.

1. In the macro header, use the line

Dependencies = ["time"]

This forces a recalculation with each call of the macro.


2. Inside the macro call do this:

from MoinMoin import caching, wikiutil

cache = caching.CacheEntry(self.macro.request, 'RSS',
wikiutil.quoteWikinameFS(self.args['url']))
# if cached entry is from within the last hour, use it.
if (time.time() - cache.mtime() < 3600):
return cache.content()

#else, do feed parsing, generate HTML ...

cache.update(html)

Cheers,

Jim


-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
Alexander Schremmer
2005-04-21 20:19:54 UTC
Permalink
Post by Jim Clark
Just an update on my caching question - I think I've found the answer,
but would be curious if there are alternative/better methods.
No, there are not. The dependency system currently just differentiates two
cases: cachable or not. In Moin 1.4, there might be a better persistency
layer.
Your solution is perfectly suitable to do it like you want.

Kind regards,
Alexander



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

Loading...