[open-ils-commits] r7525 - in trunk/Open-ILS/xul/staff_client:
chrome/content/OpenILS chrome/content/main
chrome/content/util server/circ server/main server/patron
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Jul 5 17:20:24 EDT 2007
Author: phasefx
Date: 2007-07-05 17:16:30 -0400 (Thu, 05 Jul 2007)
New Revision: 7525
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
trunk/Open-ILS/xul/staff_client/chrome/content/util/network.js
trunk/Open-ILS/xul/staff_client/server/circ/checkout.js
trunk/Open-ILS/xul/staff_client/server/main/data.xul
trunk/Open-ILS/xul/staff_client/server/patron/display.js
trunk/Open-ILS/xul/staff_client/server/patron/info_notes.xul
trunk/Open-ILS/xul/staff_client/server/patron/summary.js
trunk/Open-ILS/xul/staff_client/server/patron/util.js
Log:
I'm ripping the experimental network caching out of trunk; I want to start over in an separate branch
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -14,7 +14,6 @@
'list' : {},
'hash' : {},
'tree' : {},
- 'cached_request' : {},
'temp' : '',
@@ -448,13 +447,6 @@
obj.error.sdump_levels.D_SES_RESULT = level;
convert();
obj.data_progress('Retrieved list for ' + classname + ' objects. ');
- // if cacheable, store an offline copy
- /* FIXME -- we're going to revisit caching and do it differently
- if (cacheable) {
- var file = new util.file( classname );
- file.set_object( obj.list[classname] );
- }
- */
} catch(E) {
// if cacheable, try offline
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/constants.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -70,7 +70,7 @@
'FM_AHR_ID_LIST_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.id_list.retrieve', 'secure' : false },
'FM_AHR_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.on_shelf.retrieve' },
'FM_AHR_ID_LIST_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', 'secure' : false },
- 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count' },
+ 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count', 'cacheable' : true, 'ttl' : 60000 },
'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' },
'FM_AHR_UPDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update' },
'FM_AHR_RESET' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.reset' },
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/network.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/network.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/network.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -16,17 +16,15 @@
'NETWORK_FAILURE' : null,
'simple_request' : function(method_id,params,f,override_params) {
+ //var obj = this;
+ //var sparams = js2JSON(params);
+ //obj.error.sdump('D_SES','simple_request '+ method_id +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ // '\noverride_params = ' + override_params + '\n');
if (typeof api[method_id] == 'undefined') throw( 'Method not found for ' + method_id );
var secure = true; if (typeof api[method_id].secure != 'undefined') secure = api[method_id].secure;
return this.request(api[method_id].app,api[method_id].method,params,f,override_params,{ 'secure' : secure, 'method_id' : method_id });
},
- 'cached_request' : function(method_id,params,f,override_params) {
- if (typeof api[method_id] == 'undefined') throw( 'Method not found for ' + method_id );
- var secure = true; if (typeof api[method_id].secure != 'undefined') secure = api[method_id].secure;
- return this.request(api[method_id].app,api[method_id].method,params,f,override_params,{ 'secure' : secure, 'want_cached' : true, 'method_id' : method_id });
- },
-
'get_result' : function (req) {
var obj = this;
var result;
@@ -47,69 +45,23 @@
return result;
},
- 'is_cacheable' : function(method_id) {
- return (api[method_id].cacheable);
- },
-
'request' : function (app,name,params,f,override_params,_params) {
var obj = this;
+
+ //var sparams = js2JSON(params);
+ //obj.error.sdump('D_SES','request '+ app + ' ' + name +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ // '\noverride_params = ' + override_params + '\n_params = ' + _params + '\n');
try {
- if (_params && _params.want_cached) if ( this.is_cacheable(_params.method_id) ) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var key = (app + '+' + name + '+' + js2JSON(params)).replace(/\./g,'_');
- var x = data.cached_request[key];
- if (x) {
- obj.error.sdump('D_CACHE','Cached request found for key = \n' + key + '\n' + js2JSON(x) + '\n');
- switch(x.status) {
- case 'pending' :
- if ( Number(new Date()) - Number(x.status_time) > 60000 ) break; // if pending request is taking too long
- if (f) { // Setup a self-destroying observer on the pending request to handle this request
- obj.error.sdump('D_CACHE','Cached request pending, adding watch to handle current asynchronous request. key = \n' + key + '\n');
- var id = data.observers.add('cached_request.'+key+'.status',function(p,o,n) {
- obj.error.sdump('D_OBSERVERS','Entering watch function for key = \n' + key + '\np = ' + p + '\no = ' + js2JSON(o) + '\nn = ' + js2JSON(n) + '\nx = ' + js2JSON(x) + '\n');
- if (n == 'complete') {
- obj.error.sdump('D_CACHE','Cached request completed for key = \n' + key + '\nNow calling a previous async request watching this one.\n');
- f( { 'getResultObject' : function() { return JSON2js( js2JSON( x.request ) ); } } );
- setTimeout( function() { try { data.observers.remove(id); } catch(E) { alert(E); } }, 0 );
- }
- return n;
- }
- );
- return null;
- } else {
- obj.error.sdump('D_CACHE','Pending request and synchronous request collision with key = \n' + key + '\nFalling through...\n');
- }
- break;
- case 'complete' :
- if ( Number( new Date() ) < x.expire_time ) {
- if (f) {
- obj.error.sdump('D_CACHE','Cached request found completed, handling asynchronous request now. key = \n' + key + '\n');
- f( { 'getResultObject' : function() { return JSON2js( js2JSON( x.request ) ); } } );
- return null;
- } else {
- obj.error.sdump('D_CACHE','Cached request found completed, key = \n' + key + '\nreturning value =\n' + x.request + '\n');
- return JSON2js( js2JSON( x.request ) ); // FIXME -- cloning the object is a workaround, otherwise instanceOf somehow silently fails
- }
- } else {
- obj.error.sdump('D_CACHE','Cached request found completed, however, it has expired. key = \n' + key + '\nFalling through...\n');
- }
- break;
- }
+ var request = this._request(app,name,params,f,override_params,_params);
+ if (request) {
+ return this.get_result(request);
} else {
- obj.error.sdump('D_CACHE','Cached request not found for key = \n' + key + '\n');
+ return null;
}
- }
-
- var request = this._request(app,name,params,f,override_params,_params);
- if (request) {
- return this.get_result(request);
- } else {
- return null;
- }
-
+
} catch(E) {
alert(E);
}
@@ -119,20 +71,10 @@
var obj = this;
try {
var sparams = js2JSON(params);
- obj.error.sdump('D_SES','request '+app+' '+name+' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ obj.error.sdump('D_SES','_request '+app+' '+name+' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
'\noverride_params = ' + override_params + '\n_params = ' + _params +
'\nResult #' + (++obj.link_id) + ( f ? ' asynced' : ' synced' ) );
- var key; var x; var data;
- if (_params && obj.is_cacheable(_params.method_id)) {
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.init({'via':'stash'});
- key = (app + '+' + name + '+' + js2JSON(params)).replace(/\./g,'_');
- data.cached_request[key] = { 'test' : 'test', 'status' : 'pending', 'status_time' : Number(new Date()) };
- data.stash('cached_request');
- x = data.cached_request[key];
- obj.error.sdump('D_CACHE','Current request is cacheable, setting pending status for key = \n' + key + '\nUpdating cache with ' + js2JSON(x) + '\n');
- }
-
var request = new RemoteRequest( app, name );
if (_params && _params.secure) {
request.setSecure(true);
@@ -159,12 +101,6 @@
req = obj.rerequest_on_override(app,name,params,req,override_params,_params);
}
req = obj.check_for_offline(app,name,params,req,override_params,_params);
- if (_params && obj.is_cacheable(_params.method_id)) {
- x.request = obj.get_result(req);
- x.status = 'complete'; x.status_time = Number(new Date()); x.expire_time = Number(x.status_time) + api[_params.method_id].ttl;
- data.stash('cached_request');
- obj.error.sdump('D_CACHE','Previously pending cached request is now complete for key = \n' + key + '\nUpdating cache with ' + js2JSON(x) + '\n');
- }
f(req);
obj.NETWORK_FAILURE = null;
} catch(E) {
@@ -201,12 +137,6 @@
}
request = obj.check_for_offline(app,name,params,request,override_params,_params);
obj.NETWORK_FAILURE = null;
- if (_params && obj.is_cacheable(_params.method_id)) {
- x.request = result;
- x.status = 'complete'; x.status_time = Number(new Date()); x.expire_time = Number(x.status_time) + api[_params.method_id].ttl;
- data.stash('cached_request');
- obj.error.sdump('D_CACHE','Previously pending cached request is now complete for key = \n' + key + '\nUpdating cache with ' + js2JSON(x) + '\n');
- }
return request;
}
Modified: trunk/Open-ILS/xul/staff_client/server/circ/checkout.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/circ/checkout.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/circ/checkout.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -232,7 +232,7 @@
this.check_disable();
- var robj = obj.network.cached_request(
+ var robj = obj.network.simple_request(
'FM_CIRC_COUNT_RETRIEVE_VIA_USER',
[ ses(), obj.patron_id ]
);
Modified: trunk/Open-ILS/xul/staff_client/server/main/data.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/main/data.xul 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/main/data.xul 2007-07-05 21:16:30 UTC (rev 7525)
@@ -190,24 +190,8 @@
g.data.stash('session');
g.data.on_complete = function () {
- g.data.stash('list','hash','tree','temp','cached_request');
+ g.data.stash('list','hash','tree','temp');
- setInterval(
- function() {
- try {
- var remove_me = [];
- var n = Number( new Date() );
- for (var i in g.data.cached_request) {
- if (g.data.cached_request[i].expire_time < n && g.data.cached_request[i].status != 'pending') remove_me.push(i);
- }
- dump('trimming ' + remove_me.length + ' requests from cache\n');
- for (var i in remove_me) delete g.data.cached_request[i];
- } catch(E) {
- alert(E);
- }
- }, 180000
- );
-
g.data._debug_stash();
document.getElementById('iframe').setAttribute(
Modified: trunk/Open-ILS/xul/staff_client/server/patron/display.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/display.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/patron/display.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -589,7 +589,6 @@
'refresh_all' : function() {
var obj = this;
- obj.OpenILS.data.cached_request = {}; obj.OpenILS.data.stash('cached_request'); /* FIXME - do a more selective purging here */
obj.controller.view.patron_name.setAttribute(
'value','Retrieving...'
);
Modified: trunk/Open-ILS/xul/staff_client/server/patron/info_notes.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/info_notes.xul 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/patron/info_notes.xul 2007-07-05 21:16:30 UTC (rev 7525)
@@ -71,7 +71,7 @@
g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
g.new_note = false;
} else {
- g.notes = g.network.cached_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
+ g.notes = g.network.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : g.patron_id } ]).reverse();
}
}
Modified: trunk/Open-ILS/xul/staff_client/server/patron/summary.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/summary.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/patron/summary.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -127,7 +127,7 @@
function(e) {
return function() {
e.setAttribute('value','...');
- obj.network.cached_request(
+ obj.network.simple_request(
'FM_MOUS_RETRIEVE',
[ ses(), obj.patron.id() ],
function(req) {
@@ -171,7 +171,7 @@
var e4 = document.getElementById( 'patron_long_overdue' ); if (e4) e4.setAttribute('value','...');
var e5 = document.getElementById( 'patron_lost' ); if (e5) e5.setAttribute('value','...');
var e6 = document.getElementById( 'patron_noncat' ); if (e6) e6.setAttribute('value','...');
- obj.network.cached_request(
+ obj.network.simple_request(
'FM_CIRC_COUNT_RETRIEVE_VIA_USER',
[ ses(), obj.patron.id() ],
function(req) {
Modified: trunk/Open-ILS/xul/staff_client/server/patron/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/util.js 2007-07-05 20:46:15 UTC (rev 7524)
+++ trunk/Open-ILS/xul/staff_client/server/patron/util.js 2007-07-05 21:16:30 UTC (rev 7525)
@@ -472,7 +472,7 @@
patron.util.retrieve_au_via_id = function(session, id, f) {
JSAN.use('util.network');
var network = new util.network();
- var patron_obj = network.cached_request(
+ var patron_obj = network.simple_request(
'FM_AU_RETRIEVE_VIA_ID',
[ session, id ],
f
@@ -483,7 +483,7 @@
patron.util.retrieve_name_via_id = function(session, id) {
JSAN.use('util.network');
var network = new util.network();
- var parts = network.cached_request(
+ var parts = network.simple_request(
'BLOB_AU_PARTS_RETRIEVE',
[ session, id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]
);
@@ -493,7 +493,7 @@
patron.util.retrieve_fleshed_au_via_id = function(session, id) {
JSAN.use('util.network');
var network = new util.network();
- var patron_obj = network.cached_request(
+ var patron_obj = network.simple_request(
'FM_AU_FLESHED_RETRIEVE_VIA_ID',
[ session, id ]
);
@@ -504,7 +504,7 @@
patron.util.retrieve_fleshed_au_via_barcode = function(session, id) {
JSAN.use('util.network');
var network = new util.network();
- var patron_obj = network.cached_request(
+ var patron_obj = network.simple_request(
'FM_AU_RETRIEVE_VIA_BARCODE',
[ session, id ]
);
@@ -546,10 +546,10 @@
removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
JSAN.use('util.network'); var net = new util.network();
- net.cached_request('FM_MOUS_RETRIEVE',[ ses(), patron.id() ], function(req) {
+ net.simple_request('FM_MOUS_RETRIEVE',[ ses(), patron.id() ], function(req) {
if (req.getResultObject().balance_owed() > 0) addCSSClass(document.documentElement,'PATRON_HAS_BILLS');
});
- net.cached_request('FM_CIRC_COUNT_RETRIEVE_VIA_USER',[ ses(), patron.id() ], function(req) {
+ net.simple_request('FM_CIRC_COUNT_RETRIEVE_VIA_USER',[ ses(), patron.id() ], function(req) {
try {
var co = req.getResultObject();
if (co.overdue > 0 || co.long_overdue > 0) addCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
@@ -557,7 +557,7 @@
alert(E);
}
});
- net.cached_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : patron.id() } ], function(req) {
+ net.simple_request('FM_AUN_RETRIEVE_ALL',[ ses(), { 'patronid' : patron.id() } ], function(req) {
var notes = req.getResultObject();
if (notes.length > 0) addCSSClass(document.documentElement,'PATRON_HAS_NOTES');
});
More information about the open-ils-commits
mailing list