[Tilecache] tilecache refetch configuration

Pavel Iacovlev iacovlev.pavel at gmail.com
Fri Jan 15 12:36:13 EST 2010


I use version Version: 2.10, on Ubuntu 8.04, and I can see this code
in TileCache/Service.py

I have no python knowledge, sorry in advance if I am doing something stupid:

So I added an exception

f options.has_key("TileCacheConfig"):
        configFile = options["TileCacheConfig"]
        lastRead[configFile] = time.time()

        cfgs = cfgs + (configFile,)
        try:
            cfgTime = os.stat(configFile)[8]
            fileChanged = lastRead[configFile] < cfgTime
        except:
            pass
    else:
        configFile = 'default'

    raise Exception("cfgTime : %s, lastRead: %s" % (cfgTime,
lastRead[configFile]))

And I get the following output:
cfgTime : 1263575263, lastRead: 1263576034.86
cfgTime : 1263575263, lastRead: 1263576089.38
After I modified the config file I get:
cfgTime : 1263576110, lastRead: 1263576113.07

So my question is : the date of the config file is compared every time
to the current date and you always get fileChanged = false ?

Here lastRead[configFile] is assigned to current time:
LastRead[configFile] = time.time()

And here it is checked if current date is smaller than file date which
always results into false ?
fileChanged = lastRead[configFile] < cfgTime

On Fri, Jan 15, 2010 at 6:51 PM, Christopher Schmidt
<crschmidt at metacarta.com> wrote:
> On Fri, Jan 15, 2010 at 06:06:11PM +0200, Pavel Iacovlev wrote:
>> My knowledge of phyton is very limited but as I understood correctly
>> this is the line that checks file modification date:
>>
>> cfgs = cfgs + (configFile,)
>> try:
>> cfgTime = os.stat(configFile)[8]
>> fileChanged = lastRead[configFile] < cfgTime
>> except:
>> pass
>
> Are you sure this code is in your TileCache version? It may not
> be in the most recent release.
>
>> I see the code, but I don't get this behavior. I test it like this:
>> 1. Make a WMS request to tilecache
>> 2. Get image as a result
>> 3. Change the layer configuration to an invalid WMS URL, or in general
>> make the config file invalid by adding random text
>> 4. Make the same WMS request
>> 5. And as a result I still get the image, until I reload apache
>>
>> Here is my apache configuration of mod_python maybe it will help:
>>
>> <Directory /home/ue/Projects/yagis-dev/public/tilecache/>
>> # AddHandler cgi-script .cgi
>> # Options +ExecCGI
>>
>> AddHandler python-program .py
>> PythonHandler TileCache.Service
>> PythonPath "['/home/ue/Projects/yagis-dev/public/tilecache/'] + sys.path"
>> PythonOption TileCacheConfig /home/ue/Projects/yagis-dev/configs/tilecache.cfg
>> </Directory>
>>
>> On Fri, Jan 15, 2010 at 5:15 PM, Frederic Junod
>> <frederic.junod at camptocamp.com> wrote:
>> > Hi,
>> >
>> > This job is already done, see:
>> > http://svn.tilecache.org/trunk/tilecache/TileCache/Service.py (function handler)
>> >
>> > The config file is reloaded if needed (based on the file modification date)
>> >
>> > fredj
>> >
>> > On Fri, Jan 15, 2010 at 3:30 PM, Pavel Iacovlev
>> > <iacovlev.pavel at gmail.com> wrote:
>> >> I am using tilecache through apache + mod_python and as I understood
>> >> correctly tilecache loads the tilecache.cfg into the memory to improve
>> >> performance. So to reload the configuration I need to restart apache.
>> >>
>> >> My question: Is there a way to tell tilecache to reload it's
>> >> configuration file without reloading apache ? In my case the
>> >> configuration file is created by a 3rd party app and it be nice to
>> >> call some "script" that tell tilecache to reload it's configuration
>> >> files.
>> >>
>> >> --
>> >> http://iap.md, The future is open
>> >> _______________________________________________
>> >> Tilecache mailing list
>> >> Tilecache at openlayers.org
>> >> http://openlayers.org/mailman/listinfo/tilecache
>> >>
>> >
>> >
>> >
>> > --
>> > Frédéric Junod
>> > Camptocamp SA
>> >
>>
>>
>>
>> --
>> http://iap.md, The future is open
>> _______________________________________________
>> Tilecache mailing list
>> Tilecache at openlayers.org
>> http://openlayers.org/mailman/listinfo/tilecache
>
> --
> Christopher Schmidt
> MetaCarta
>



-- 
http://iap.md, The future is open



More information about the Tilecache mailing list