Index: trunk/zoo-project/HISTORY.txt
===================================================================
--- trunk/zoo-project/HISTORY.txt	(revision 960)
+++ trunk/zoo-project/HISTORY.txt	(revision 961)
@@ -1,3 +1,6 @@
 Version 1.8.0-dev
+  * Produce value string only when memory=load for Python support.
+  * Make local files uris usable when cache is used
+  * Make GDAL/prilfe service usable in case memory=protect 
   * Add Dockerfile and docker-compose environment with pgbouncer, see #177
   * Add documentation on how to use asyncrhonous execution using the Javascript
Index: trunk/zoo-project/zoo-kernel/caching.c
===================================================================
--- trunk/zoo-project/zoo-kernel/caching.c	(revision 960)
+++ trunk/zoo-project/zoo-kernel/caching.c	(revision 961)
@@ -403,5 +403,5 @@
   if(strncasecmp(request,"file://",7)==0){
     char* tmpStr=zStrdup(request+7);
-    fprintf(stderr,"**** %s %d %s \n",__FILE__,__LINE__,tmpStr);
+    setMapInMaps(conf,"lenv",tmpStr,"local");
     return tmpStr;
   }
@@ -709,30 +709,33 @@
       unlockFile(*m,lck);
     }
-    cached[strlen(cached)-1]='m';
-    s=zStat(cached, &f_status);
-    if(s==0){
-      zooLock* lck=lockFile(*m,cached,'r');
-      if(lck==NULL)
-	return -1;
-      mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1));
-      FILE* f=fopen(cached,"rb");
-      fread(mimeType,f_status.st_size,1,f);
-      mimeType[f_status.st_size]=0;
-      fclose(f);
-      unlockFile(*m,lck);
-    }
-    cached[strlen(cached)-1]='p';
-    s=zStat(cached, &f_status);
-    if(s==0){
-      zooLock* lck=lockFile(*m,cached,'r');
-      if(lck==NULL)
-	return -1;
-      origin=(char*)malloc(sizeof(char)*(f_status.st_size+1));
-      FILE* f=fopen(cached,"rb");
-      fread(origin,f_status.st_size,1,f);
-      mimeType[f_status.st_size]=0;
-      fclose(f);
-      unlockFile(*m,lck);
-    }
+    map* isLocalFile=getMapFromMaps(*m,"lenv",cached);
+    if(isLocalFile==NULL){
+      cached[strlen(cached)-1]='m';
+      s=zStat(cached, &f_status);
+      if(s==0){
+	zooLock* lck=lockFile(*m,cached,'r');
+	if(lck==NULL)
+	  return -1;
+	mimeType=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+	FILE* f=fopen(cached,"rb");
+	fread(mimeType,f_status.st_size,1,f);
+	mimeType[f_status.st_size]=0;
+	fclose(f);
+	unlockFile(*m,lck);
+      }
+      cached[strlen(cached)-1]='p';
+      s=zStat(cached, &f_status);
+      if(s==0){
+	zooLock* lck=lockFile(*m,cached,'r');
+	if(lck==NULL)
+	  return -1;
+	origin=(char*)malloc(sizeof(char)*(f_status.st_size+1));
+	FILE* f=fopen(cached,"rb");
+	fread(origin,f_status.st_size,1,f);
+	mimeType[f_status.st_size]=0;
+	fclose(f);
+	unlockFile(*m,lck);
+      }
+    }    
   }else{    
     addRequestToQueue(m,hInternet,url,true);
Index: trunk/zoo-project/zoo-kernel/main_conf_read.y
===================================================================
--- trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 960)
+++ trunk/zoo-project/zoo-kernel/main_conf_read.y	(revision 961)
@@ -162,4 +162,6 @@
     freeMap(&current_content);
     free(current_content);
+  }else{
+    current_maps->next=NULL;
   }
   if(curr_key!=NULL){
Index: trunk/zoo-project/zoo-kernel/server_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/server_internal.c	(revision 960)
+++ trunk/zoo-project/zoo-kernel/server_internal.c	(revision 961)
@@ -373,9 +373,7 @@
     return ;
   }
-  fseek(file, 0, SEEK_END);
   zStatStruct f_status;
   int s=zStat(filename, &f_status);
   sprintf(rsize,"%lld",f_status.st_size);
-  rewind(file);
   if(getMap(content,"storage")==NULL){
     map* memUse=getMapFromMaps(m,"main","memory");
@@ -390,4 +388,5 @@
       if(tmpMap1->value==NULL){
 	setMapInMaps(m,"lenv","message","Unable to allocate the memory required to read the produced file.");
+	return;
       }
       fread(&tmpMap1->value,1,f_status.st_size,file);
@@ -395,6 +394,7 @@
     }
   }
-  fclose(file);  
-  addToMap(content,"size",rsize);
+  fclose(file);
+  if(content!=NULL)
+    addToMap(content,"size",rsize);
 }
 
Index: trunk/zoo-project/zoo-kernel/service.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service.c	(revision 960)
+++ trunk/zoo-project/zoo-kernel/service.c	(revision 961)
@@ -328,9 +328,12 @@
     fprintf(stderr,"freeMap\n");
 #endif
-    free(_cursor->name);
-    free(_cursor->value);
+    if(_cursor->name!=NULL)
+      free(_cursor->name);
+    if(_cursor->value!=NULL)
+      free(_cursor->value);
     if(_cursor->next!=NULL){
       freeMap(&_cursor->next);
-      free(_cursor->next);
+      if(_cursor->next!=NULL)
+	free(_cursor->next);
     }
   }
@@ -825,7 +828,7 @@
     else{
       maps* tmp1=getMaps(*mo,tmp->name);
-      while(_cursor->next!=NULL)
-	_cursor=_cursor->next;
       if(tmp1==NULL){
+	while(_cursor->next!=NULL)
+	  _cursor=_cursor->next;
 	_cursor->next=dupMaps(&tmp);
 	if(tmp->child!=NULL)
Index: trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 960)
+++ trunk/zoo-project/zoo-kernel/service_internal_python.c	(revision 961)
@@ -468,5 +468,5 @@
   while(tmp!=NULL){
     PyObject* name=PyString_FromString(tmp->name);
-    if(strcasecmp(tmp->name,"value")==0) {
+    if(strcasecmp(tmp->name,"value")==0 && strlen(tmp->value)>0) {
       if(isArray!=NULL){
 	map* len=getMap(tmp,"length");
Index: trunk/zoo-project/zoo-services/gdal/profile/service.c
===================================================================
--- trunk/zoo-project/zoo-services/gdal/profile/service.c	(revision 960)
+++ trunk/zoo-project/zoo-services/gdal/profile/service.c	(revision 961)
@@ -35,4 +35,7 @@
 #include "cpl_conv.h"
 #include "ogr_api.h"
+#if GDAL_VERSION_MAJOR >= 2
+#include <gdal_priv.h>
+#endif
 
 #ifdef ZOO_SERVICE
@@ -87,6 +90,49 @@
 	  GDALComputeRasterMinMax( hBand, TRUE, adfMinMax );
 #ifdef ZOO_SERVICE
+	OGRGeometryH geometry=NULL;
+	// Verify if there is a cache file for this input, use it if available
+	tmp1=getMapFromMaps(inputs,"Geometry","cache_file");
+	if(tmp1!=NULL){
+#if GDAL_VERSION_MAJOR >= 2
+	  char* pszDataSource=strdup(tmp1->value);
+	  GDALDatasetH poDS
+	    = GDALOpenEx( pszDataSource,
+			  GDAL_OF_READONLY | GDAL_OF_VECTOR,
+			  NULL, NULL, NULL );
+#endif
+	  for( int iLayer = 0; iLayer < OGR_DS_GetLayerCount(poDS) ;
+	       iLayer++ )
+	    {
+	      OGRLayerH        poLayer = OGR_DS_GetLayer(poDS,iLayer);
+
+	      if( poLayer == NULL )
+		{
+		  fprintf( stderr, "FAILURE: Couldn't fetch advertised layer %d!\n",
+			   iLayer );
+		  char tmp[1024];
+		  sprintf(tmp,"Couldn't fetch advertised layer %d!",iLayer);
+		  setMapInMaps(conf,"lenv","message",tmp);
+		  return SERVICE_FAILED;
+		}
+	      OGRFeatureH  poFeature;
+	      int         nFeaturesInTransaction = 0;
+	      int fCount=0;
+	      OGR_L_ResetReading(poLayer);
+	      while( TRUE )
+		{
+		  poFeature = OGR_L_GetNextFeature(poLayer);
+		  if( poFeature == NULL ){
+	            break;
+		  }
+		  geometry=OGR_G_Clone(OGR_F_GetGeometryRef(poFeature));
+		  OGR_F_Destroy( poFeature );
+		}
+	      
+	    }
+	}
+	else{
 	  tmp1=getMapFromMaps(inputs,"Geometry","value");
-	  OGRGeometryH geometry=OGR_G_CreateGeometryFromJson(tmp1->value);
+	  geometry=OGR_G_CreateGeometryFromJson(tmp1->value);
+	}
 #else
 	  OGRGeometryH geometry=OGR_G_CreateGeometryFromJson(argv[2]);
