[open-ils-commits] r17941 - trunk/Open-ILS/web/js/dojo/openils (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Sep 23 20:15:32 EDT 2010


Author: senator
Date: 2010-09-23 20:15:31 -0400 (Thu, 23 Sep 2010)
New Revision: 17941

Modified:
   trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
Log:
Re-commit miker's PermaCrud changes, just a tad more nicer ;-)


Modified: trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-23 23:50:20 UTC (rev 17940)
+++ trunk/Open-ILS/web/js/dojo/openils/PermaCrud.js	2010-09-24 00:15:31 UTC (rev 17941)
@@ -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