[open-ils-commits] r11749 - trunk/Open-ILS/src/c-apps

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Jan 5 21:20:32 EST 2009


Author: miker
Date: 2009-01-05 21:20:31 -0500 (Mon, 05 Jan 2009)
New Revision: 11749

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
do not fetch from the db for retrieve-type methods (checks are done post-retrieve)

Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-01-06 01:58:22 UTC (rev 11748)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-01-06 02:20:31 UTC (rev 11749)
@@ -861,10 +861,12 @@
     osrfHash* meta = (osrfHash*) ctx->method->userData;
     osrfHash* class = osrfHashGet( meta, "class" );
     char* method_type = strdup( osrfHashGet(meta, "methodtype") );
+    int fetch = 1;
 
     if ( ( *method_type == 's' || *method_type == 'i' ) ) {
         free(method_type);
         method_type = strdup("retrieve");
+        fetch = 0; // don't go to the db for the object for retrieve-type methods
     }
 
     osrfHash* pcrud = osrfHashGet( osrfHashGet(class, "permacrud"), method_type );
@@ -941,27 +943,32 @@
     } else {
 	    osrfLogDebug( OSRF_LOG_MARK, "global-level permissions not required, fetching context org ids" );
 	    char* pkey = osrfHashGet(class, "primarykey");
+        jsonObject *param = NULL;
 
         if (obj->classname) {
             pkey_value = oilsFMGetString( obj, pkey );
+            if (!fetch) param = jsonObjectClone(obj);
 	        osrfLogDebug( OSRF_LOG_MARK, "Object supplied, using primary key value of %s", pkey_value );
         } else {
             pkey_value = jsonObjectToSimpleString( obj );
+            fetch = 1;
 	        osrfLogDebug( OSRF_LOG_MARK, "Object not supplied, using primary key value of %s and retrieving from the database", pkey_value );
         }
 
-        jsonObject* _tmp_params = jsonParseStringFmt("[{\"%s\":\"%s\"}]", pkey, pkey_value);
-   		jsonObject* _list = doFieldmapperSearch(
-            ctx,
-            class,
-            _tmp_params,
-            &err
-        );
+        if (fetch) {
+            jsonObject* _tmp_params = jsonParseStringFmt("[{\"%s\":\"%s\"}]", pkey, pkey_value);
+   	    	jsonObject* _list = doFieldmapperSearch(
+                ctx,
+                class,
+                _tmp_params,
+                &err
+            );
     
-        jsonObject *param = jsonObjectClone(jsonObjectGetIndex(_list, 0));
+           param = jsonObjectClone(jsonObjectGetIndex(_list, 0));
     
-        jsonObjectFree(_tmp_params);
-        jsonObjectFree(_list);
+            jsonObjectFree(_tmp_params);
+            jsonObjectFree(_list);
+        }
 
         if (!param) {
             osrfLogDebug( OSRF_LOG_MARK, "Object not found in the database with primary key %s of %s", pkey, pkey_value );



More information about the open-ils-commits mailing list