[Zope] Product event when zope restarts

Casey Duncan cduncan@kaivo.com
Thu, 10 May 2001 08:40:12 -0600


> Jan wrote:
> 
> Hello all!
> 
> I have been developing a Zope Product that basically reads in a file
> and shows it in zope. The problem is that when the file is updated in
> file system, that is not updated in zope. I do not want it to read the
> file every time it is accessed in zope. Refreshing it every time the
> zope restarts seems to be the solution.
> 
> So I was wondering if there is a function that will be executed when
> zope restarts.
> 
> Thanx.

What is the problem with repeatedly reading the file? The OS will cache
it if it is accessed frequently anyway. 

If you must here is what I would do:

Use two volatile variables to store the mod date and the data like:

_v_mod
_v_data

Then stat the file when it is accessed and see if its date differs from
_v_mod (if it has already been accessed). If not, return _v_data.
Otherwise read the file, return the data and store it into _v_data and
the mod date in _v_mod.

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>