Author: reebalazs
Date: Sat Jan  3 02:42:43 2009
New Revision: 60768

Modified:
   kukit/kukit.js/trunk/kukit/serveraction.js
Log:
Clean up terrible mess in serveraction.py, left there by previous merge.
Also add a non-initializing ServerActionBase class, for reuse in plugins.

Modified: kukit/kukit.js/trunk/kukit/serveraction.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/serveraction.js  (original)
+++ kukit/kukit.js/trunk/kukit/serveraction.js  Sat Jan  3 02:42:43 2009
@@ -21,7 +21,9 @@
 
 var sa = this;
 
-sa.ServerAction = function() {
+// ServerActionBase is a non-initialize version of ServerAction
+// this enables to subclass it or reuse its methods
+sa.ServerActionBase = function() {
 
 this.initialize = function(name, oper) {
     this.oper = oper;
@@ -29,36 +31,6 @@
     if (typeof(this.url) == 'undefined') {
         this.url = name;
     }
-
-    this.calculateAbsoluteURL = function(url) {
-        // Append slash to the end of the url, this helps with certain
-        // webframeworks like Django
-        if (!url.match(RegExp('\/$'))) {
-            url += '/';
-        }
-
-        //
-        // If the url is an absolute path, it is used
-        //
-        // If the url is not an absolute path, it is put at the end of the 
context
-        // url.
-        //
-        // example: url='@theview/getName',
-        //          context='http://your.site.com/portal/folder/object'
-        //
-        //     
result='http://your.site.com/portal/folder/object/@@theview/getName'
-        //
-        if (url.match(RegExp('/^https?:\/\//')) || url.match(RegExp('^\/'))) {
-            return url;
-        } 
-
-        var result = kukit.engine.baseUrl;
-        if (!result.match(RegExp('\/$'))) {
-            result += '/';
-        }
-
-        return result + url;
-    };
     this.url = this.calculateAbsoluteURL(this.url);
     this.notifyServer();
 };
@@ -210,7 +182,7 @@
             }
             commandstags = kukit.dom.getNsTags(dom, 'commands');
             if (commandstags.length != 1) {
-                // no good, maybe better luck with it as html payload
+                // no good
                 dom = null;
             }
         }
@@ -304,8 +276,7 @@
 ;;;             }
             throw kukit.err.responseParsingError(kukit.E);
         }
-    };
-
+    }
     if (dom == null) {
         // this should not happen
 ;;;     kukit.E = 'Neither xml nor html payload.';
@@ -365,7 +336,12 @@
         // TODO figure out something?
     }
 };
-this.initialize.apply(this, arguments);
+
+};
+
+sa.ServerAction = function() {
+    this.initialize.apply(this, arguments);
 };
+sa.ServerAction.prototype = new sa.ServerActionBase();
 
 }();                              /// MODULE END
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to