'Set up the KML cache, should be done once per request'

def __init__(self, all_layers, init=True):

    super(LayerKML, self).__init__(all_layers)
    request = current.request
    cachepath = os.path.join(request.folder, 'uploads', 'gis_cache')
    if os.path.exists(cachepath):
        cacheable = os.access(cachepath, os.W_OK)
    else:
        try:
            os.mkdir(cachepath)
        except OSError as os_error:
            current.log.error(('GIS:    KML    layers    cannot    be    cached:    %s    %s' % (cachepath, os_error)))
            cacheable = False
        else:
            cacheable = True
    LayerKML.cachetable = current.s3db.gis_cache2
    LayerKML.cacheable = cacheable
    LayerKML.cachepath = cachepath
