Changeset 67


Ignore:
Timestamp:
Jan 9, 2011, 8:21:36 PM (14 years ago)
Author:
djay
Message:

Support binary output for Python Services.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/service_internal_python.c

    r63 r67  
    6363  sprintf(pythonpath,"%s:%s",ntmp,python_path);
    6464#endif
    65   //#ifdef DEBUG
     65#ifdef DEBUG
    6666    fprintf(stderr,"PYTHONPATH=%s\n",pythonpath);
    67   //#endif
     67#endif
    6868#ifndef WIN32
    6969  setenv("PYTHONPATH",pythonpath,1);
     
    222222        if(PyDict_SetItem(res,name,value)<0){
    223223          fprintf(stderr,"Unable to parse params...");
     224          Py_DECREF(value);
    224225          exit(1);
    225226        }
     
    230231        if(PyDict_SetItem(res,name,value)<0){
    231232          fprintf(stderr,"Unable to parse params...");
     233          Py_DECREF(value);
    232234          exit(1);
    233235        }
     
    239241      if(PyDict_SetItem(res,name,value)<0){
    240242        fprintf(stderr,"Unable to parse params...");
     243        Py_DECREF(value);
    241244        exit(1);
    242245      }
     
    279282    free(cursor->content);
    280283    free(cursor);
     284    Py_DECREF(value);
     285    Py_DECREF(key);
    281286#ifdef DEBUG
    282287    dumpMaps(res);
     
    293298  int nb=PyList_Size(list);
    294299  int i;
     300  int sizeValue=-1;
     301  for(i=0;i<nb;i++){
     302    PyObject* key=PyList_GetItem(list,i);
     303    if(strcmp(PyString_AsString(key),"size")==0){
     304      PyObject* value=PyDict_GetItem((PyObject*)t,key);
     305      sizeValue=atoi(PyString_AsString(value));
     306      Py_DECREF(value);
     307      Py_DECREF(key);   
     308      break;
     309    }
     310    Py_DECREF(key);   
     311  }
    295312  for(i=0;i<nb;i++){
    296313    PyObject* key=PyList_GetItem(list,i);
     
    300317            PyString_AsString(key),PyString_AsString(value));
    301318#endif
    302     if(res!=NULL)
    303       addToMap(res,PyString_AsString(key),PyString_AsString(value));
    304     else
    305       res=createMap(PyString_AsString(key),PyString_AsString(value));
    306   }
     319    if(sizeValue>=0 && strcmp(PyString_AsString(key),"value")==0){
     320      char *buffer=NULL;//(char*)malloc((sizeValue+1)*sizeof(char));
     321      Py_ssize_t size;
     322      PyString_AsStringAndSize(value,&buffer,&size);
     323      if(res!=NULL){
     324        addToMap(res,PyString_AsString(key),"");
     325      }else{
     326        res=createMap(PyString_AsString(key),"");
     327      }
     328      map* tmpR=getMap(res,"value");
     329      free(tmpR->value);
     330      tmpR->value=(char*)malloc((sizeValue+1)*sizeof(char));
     331      memmove(tmpR->value,buffer,sizeValue*sizeof(char));
     332      tmpR->value[sizeValue]=0;
     333    }else{
     334      if(res!=NULL)
     335        addToMap(res,PyString_AsString(key),PyString_AsString(value));
     336      else
     337        res=createMap(PyString_AsString(key),PyString_AsString(value));
     338    }
     339    Py_DECREF(value);
     340    Py_DECREF(key);
     341  }
     342  Py_DECREF(list);
    307343  return res;
    308344}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png