From d4befa9d74b2207f35d7c0f2ba97fe9e2e10d821 Mon Sep 17 00:00:00 2001 From: senator Date: Fri, 24 Sep 2010 00:15:31 +0000 Subject: [PATCH] Re-commit miker's PermaCrud changes, just a tad more nicer ;-) git-svn-id: svn://svn.open-ils.org/ILS/trunk@17941 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/PermaCrud.js | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/dojo/openils/PermaCrud.js b/Open-ILS/web/js/dojo/openils/PermaCrud.js index 834c6cd8d..5bc6d3905 100644 --- a/Open-ILS/web/js/dojo/openils/PermaCrud.js +++ b/Open-ILS/web/js/dojo/openils/PermaCrud.js @@ -66,7 +66,41 @@ if(!dojo._hasResource["openils.PermaCrud"]) { return false; } }, - + + _session_request : function ( args /* hash */, commitOnComplete /* set to true, else no */ ) { + + var me = this; + var endstyle = 'rollback'; + var aopts = dojo.mixin({}, args); + args = aopts; + if (commitOnComplete) endstyle = 'commit'; + + if (me.authoritative) { + if (!me.connected) me.connect(); + if (args.timeout && !args.oncomplete && !args.onresponse) { // pure sync call + args.oncomplete = function (r) { + me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth()); + me.session.disconnect(); + me.disconnect(); + }; + } else if (args.oncomplete) { // there's an oncomplete, fire that, and then end the transaction + var orig_oncomplete = args.oncomplete; + args.oncomplete = function (r) { + var ret; + try { + ret = orig_oncomplete(r); + } finally { + me.session.request('open-ils.pcrud.transaction.' + endstyle, me.auth()); + me.session.disconnect(); + me.disconnect(); + } + return ret; + }; + } + me.session.request('open-ils.pcrud.transaction.begin', me.auth()); + } + return me.session.request( args ); + }, retrieve : function ( fm_class /* Fieldmapper class hint */, id /* Fieldmapper object primary key value */, opts /* Option hash */) { if(!opts) opts = {}; -- 2.11.0