store/retrieve objects in files
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 3 Oct 2005 19:04:41 +0000 (19:04 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 3 Oct 2005 19:04:41 +0000 (19:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1888 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.xul

index f39e28b..1b57759 100644 (file)
@@ -25,21 +25,28 @@ OpenILS.data = function (mw,G) {
 
        function a_get(obj,i) { return [i, obj[i]]; }  // funkiness with loops and closures
 
-       for (var i in this._cacheable_fm_objects) {
-               var classname = a_get(this._cacheable_fm_objects,i)[0];
-               var data = a_get(this._cacheable_fm_objects,i)[1];
+       JSAN.use('util.file');
+
+       function gen_fm_retrieval_func(classname,data) {
                var app = data[0]; var method = data[1]; var params = data[2];
-               this.chain.push(
-                       function() {
-                               try {
-                                       obj.list[classname] = obj.G.network.request( app, method, params);
-                                       // store an offline copy
-                               } catch(E) {
-                                       // try offline
-                               }
-                               //obj.hash[classname] = convert_object_list_to_hash( obj.list[classname] );
+               return function () {
+                       try {
+                               obj.list[classname] = obj.G.network.request( app, method, params);
+                               // store an offline copy
+                               var file = new util.file( obj.mw, obj.G, classname );
+                               file.set_object( obj.list[classname] );
+
+                       } catch(E) {
+                               // try offline
                        }
-               );
+                       //obj.hash[classname] = convert_object_list_to_hash( obj.list[classname] );
+               }
+       }
+
+       obj.G.error.sdump('D_DEBUG','_cacheable_fm_objects = ' + js2JSON(this._cacheable_fm_objects) + '\n');
+
+       for (var i in this._cacheable_fm_objects) {
+               this.chain.push( gen_fm_retrieval_func(i,this._cacheable_fm_objects[i]) );
        }
 
        /*
index 6cce151..0ab0342 100644 (file)
 
        <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
        <!-- BEHAVIOR -->
+       <script type="text/javascript">var myPackageDir = 'evergreen'; var IAMXUL = true;</script>
        <script type="text/javascript" src="../OpenILS/util/utils.js"></script>
        <script type="text/javascript" src="../OpenILS/util/md5.js"></script>
        <script type="text/javascript" src="../OpenILS/util/JSON.js"></script>
        <script type="text/javascript" src="../OpenILS/util/fmall.js"></script>
        <script type="text/javascript" src="../OpenILS/util/fmgen.js"></script>
-       <script type="text/javascript">var IAMXUL = true;</script>
        <script type="text/javascript" src="../OpenILS/util/RemoteRequest.js"></script>
        <script type="text/javascript" src="../OpenILS/util/OrgTree.js"></script>
        <script type="text/javascript" src="../OpenILS/util/org_utils.js"></script>