[Zope] Re: using ImageTag_Hotfix
Danny William Adair
danny@adair.net
Sat, 20 Oct 2001 11:23:27 +1300
On Saturday 20 October 2001 05:20, marc lindahl wrote:
> ...
> this is the stuff to use an external RAMcache. The idea is that you would
> have one RAMcache on your site to cache your calculated thumbnails.
> Architecturally, that's usually what you'd want. The part I dont' know is,
> how could you get any newly created image to connect to this RAMCache
> automatically? Right now, it seems to work if you create the image and the
> RAMcache and associate it manually via the ZMI, but what a pain! I wish I
> knew how to do this within the product - e.g. associate the 'class' with
> the RAMcache....
Without knowing the answer in detail...
_Everything_ you can do with the ZMI you can do in DTML (because that's what
it is). Just go to the ZMI page that does what you want, and look what
function is being called. Somewhere in your Zope installation you will find
the corresponding DTML _file_ (this time it's
lib/python/OFS/dtml/cmassoc.dtml), and see what's happening there. I was able
to do lots of things by simply copying the function calls from ZMI pages...
I don't know exactly what you want you want to do in detail, but this file
should bring lots of enlightnment...
I never looked into CacheManagers in detail, but it looks as if a call to
ZCacheManager_locate finds associated objects, and a call to
ZCacheManager_setAssociations actually establishes the associations. (that's
the methods being called from the form)
Searching for these function names brought me to lib/python/OFS/Cache.py:
def ZCacheManager_setAssociations(self, props=None, REQUEST=None):
'''Associates and un-associates cacheable objects with this
cache manager.
'''
These two files should actually be all you need to mimick the ZMI's behavior.
The right call to myRAMCache.ZCacheManager_setAssociations is probably what
does the trick (doing that whenever you create an image object, maybe some
ZClass derived from ZImage that has this call in its constructor ("add"
method)). What you would need to gather up is what sort of information
ZCacheManager_setAssociations expects in "props" and "REQUEST", which in your
case will probably be a very small subset of what you find in the ZMI's dtml
file.
hth,
and sorry for not providing a copy&paste answer,
I just don't know enough about ZCacheManagers,
Danny