[open-ils-commits] r17942 - branches/rel_2_0/Open-ILS/web/js/dojo/openils (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Sep 23 20:16:13 EDT 2010


Author: senator
Date: 2010-09-23 20:16:12 -0400 (Thu, 23 Sep 2010)
New Revision: 17942

Modified:
   branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud.js
Log:
Backport r17941 from trunk: miker's permacrud authoritative search


Modified: branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud.js
===================================================================
--- branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-24 00:15:31 UTC (rev 17941)
+++ branches/rel_2_0/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-24 00:16:12 UTC (rev 17942)
@@ -66,8 +66,42 @@
                 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 = {};
             var req_hash = dojo.mixin(



More information about the open-ils-commits mailing list