From gotcha at codespeak.net Wed Dec 17 18:48:22 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 17 Dec 2008 18:48:22 +0100 (CET) Subject: [KSS-checkins] r60551 - kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit Message-ID: <20081217174822.1B2241684B6@codespeak.net> Author: gotcha Date: Wed Dec 17 18:48:21 2008 New Revision: 60551 Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js Log: remove last reference to schema Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js Wed Dec 17 18:48:21 2008 @@ -62,7 +62,7 @@ }; this.register = function(name, commandClass) { - var actions = kukit.plugins.schema.actions; + var actions = kukit.plugins.actions; var attrib = actions.getItemFactory(name); this._register(name, commandClass, attrib); }; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js Wed Dec 17 18:48:21 2008 @@ -28,20 +28,17 @@ * The order in which they are loaded is irrelevant, provided they * load after registries.js. * - * Managing the schema - * ------------------- + * Managing the registrar + * ---------------------- * * When various javascript code is loaded, it can set up the - * schema for the registry it handles. For example, during the + * registrar for the registry it handles. For example, during the * loading of javascript, plugin code set up its registry, other code * sets up services it provides or depends on. * * The registries are managed by name in a collection of registries. - * Before accessing the schema of any registry, it needs to + * Before accessing the registrar of any registry, it needs to * be initialized at one of the names registries object. - * This may be happen several times, but at - * least once it has been done before the schema is looked up from - * code. * * This is the only dependency what we have for the order of the code. * Ewerywhere else, order is independent. This means that if all @@ -50,25 +47,9 @@ * case of the plugins), then the order of these javascripts is * arbitrary for registries to work. * - * In the initialization the registry name and the item factory - * need to be supplied as parameters. - * - * registries.initializeRegistry('myregistry', MyFactoryClass); - * - * After this the registrar object can be looked up with: - * - * var registrar = registries.schema.myregistry; - * - * Or the schema of an attribute can be looked up, and various methods - * can be called on it. This depends on what the attribute class - * actually implements. - * - * var factory = registries.schema.myregistry.getItemFactory('mykey'); - * factory.doWhateverTheFactoryImplements(blah); - * * This concludes everything we can do, before binding the registry. * Binding freezes the factorization of items in the registrar and - * allows its direct use, without the schema. For the binding, a + * allows its direct use. For the binding, a * singleton registry object has to be provided. The items are * bound on this registry. * From gotcha at codespeak.net Thu Dec 18 13:27:10 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 18 Dec 2008 13:27:10 +0100 (CET) Subject: [KSS-checkins] r60564 - in kukit/kukit.js/branch/gotcha-simplify-service-layer: 3rd_party doc kukit Message-ID: <20081218122710.5D6B7168005@codespeak.net> Author: gotcha Date: Thu Dec 18 13:27:08 2008 New Revision: 60564 Added: kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/base2-dom-fp-20080312.js - copied unchanged from r60551, kukit/kukit.js/trunk/3rd_party/base2-dom-fp-20080312.js kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/base2-dom-fp.js - copied unchanged from r60551, kukit/kukit.js/trunk/3rd_party/base2-dom-fp.js Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/cssQuery-compat.js kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/sarissa.js kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/dom.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/errors.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/forms.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/oper.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/plugin.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/serveraction.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/tokenizer.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/utils.js Log: trunk changes : merge -r 53859:60016 http://codespeak.net/svn/kukit/kukit.js/trunk Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/cssQuery-compat.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/cssQuery-compat.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/cssQuery-compat.js Thu Dec 18 13:27:08 2008 @@ -5,24 +5,49 @@ * want to use cssQuery. * * When both cssQuery and base2 are present, this code does nothing. - * When cssQuery is missing, this code defines a compatibility cssQuery - * function that actually reuses base2 for querying. + * When cssQuery is missing at the time this code is loaded, + * it defines a compatibility cssQuery function that actually reuses + * base2 for querying. * */ +// Check that cssQuery is missing originally. +// If it is present, do not redefine it. if (typeof(window.cssQuery) == 'undefined') { // Define the compatibility layer. - window.cssQuery = function(selector, element) { - if (typeof(element) == 'undefined') { - // if parameter is not given, we need to use document. - element = document; + window.cssQuery = function _cssQueryStub(selector, element) { + // This stub checks which base2 api to use. + // It only runs once and also returns the result. + // + // Base2 legacy version: matchAll has to be used + // Base2 recent version: querySelectorAll has to be used + var _USE_BASE2_LEGACY = (typeof(base2.DOM.Document.querySelectorAll) == 'undefined'); + var f; + if (! _USE_BASE2_LEGACY) { + f = function(selector, element) { + return base2.DOM.Document.querySelectorAll(element, selector); + }; + } else { + f = function(selector, element) { + return base2.DOM.Document.matchAll(element, selector); + }; } - var results = base2.DOM.Document.matchAll(element, selector); - var nodes = []; - for(var i = 0; i < results.length; i++) { - nodes.push(results.item(i)); - } - return nodes; + // redefine the function with its final version + window.cssQuery = function cssQuery(selector, element) { + if (typeof(element) == 'undefined') { + // if parameter is not given, we need to use document. + element = document; + } + var results = f(selector, element); + var nodes = []; + for(var i = 0; i < results.length; i++) { + nodes.push(results.item(i)); + } + return nodes; + }; + // since we are in the stub, we need to use + // the newly redefined function + return window.cssQuery(selector, element); }; }; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/sarissa.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/sarissa.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/3rd_party/sarissa.js Thu Dec 18 13:27:08 2008 @@ -10,13 +10,8 @@ * ==================================================================== * Licence * ==================================================================== - * Sarissa is free software distributed under the GNU GPL version 2 (see gpl.txt) or higher, - * GNU LGPL version 2.1 (see lgpl.txt) or higher and Apache Software License 2.0 or higher - * (see asl.txt). This means you can choose one of the three and use that if you like. If - * you make modifications under the ASL, i would appreciate it if you submitted those. - * In case your copy of Sarissa does not include the license texts, you may find - * them online in various formats at http://www.gnu.org and - * http://www.apache.org. + * Sarissa is free software distributed under the GNU GPL version 2 + * Other licenses are also available, see http://dev.abiss.gr/sarissa/ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt Thu Dec 18 13:27:08 2008 @@ -6,7 +6,12 @@ - ... - - Add global registries. +MISSING, PLEASE MERGE! - Add improved demos + (insertions in tbody is not included : that demo is + still broken in IE6) + [gotcha] + + - Add a general registry for interfaces. Add service layers. @@ -43,14 +48,47 @@ two places and considered as two broken selectors. [ree] - - - refactor the value provider registry to use + - Refactor the value provider registry to use a single registry in place of 3. This will enable to define value providers that recieve non-string parameters like a node selection. [ree] + - Fix or improve calculateAbsoluteURL to handle absolute + and relative urls correctly, as well as get rid of the + double slash (//) issue. + It also satisfies the tests kss_url_param and + kss_url_param_multiprop, that now work as intended, + with previous workaround removed. + [ree] + + - Replaced license header of third-party sarissa.js + to workaround the license detection of ohloh. + sarissa.js is redistributed under GNU GPL v2 + as previously. + [ree] + + - Fix cssQuery-compat.js to use newest base2 api. + [ree] + + - Fix a typo that caused an exception instead of + logging an error message, this happened when + an action was regitered twice with the same name. + [ree] + +kukit.js - 1.4 Released 2008-04-21 + + - Updated base2-dom-fp.js with newest version. + [ree] + + - fix setKssAttribute action and command + (closes bug 8048 from plone.org) + [gotcha] + + - fix action-cancel + [gotcha] + - disabled input values should not be submitted with the form [gotcha] @@ -58,8 +96,6 @@ This fixes breakage on FireFox 3. [ree] -kukit.js - 1.4dev Unreleased - - Remove previously deprecated form() and currentForm() value providers from normal action parameters (remark: they should @@ -83,11 +119,6 @@ - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) and on IE. - - - Fix multiple selection form fields - marshalling on Safari - (fixes #22 in kssproject) - and on IE. [ree] - Fix error fallback handling Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js Thu Dec 18 13:27:08 2008 @@ -34,7 +34,7 @@ ;;; if (typeof(func) == 'undefined') { ;;; kukit.e = '[func] argument is mandatory when registering an action'; ;;; kukit.e += ' [ActionRegistry.register].'; -;;; throw new Error(kukit.E); +;;; throw new Error(kukit.e); ;;; } var actions = kukit.registrars.actions; actions.getItemFactory(name).register({actionFunc: func}); Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/dom.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/dom.js Thu Dec 18 13:27:08 2008 @@ -269,7 +269,7 @@ dom.setKssAttribute = function(node, attrname, value) { // Sets a given kss attribute on the namespace var fullName = _kssAttrNamespace + ':' + attrname; - dom.setAttribute(node, fullName); + dom.setAttribute(node, fullName, value); }; /* @@ -358,7 +358,7 @@ function(node, attrname, recurseParents, getter) { return dom.locateMarkup(node, recurseParents, getter, attrname).value; -} +}; /* * From http://xkr.us/articles/dom/iframe-document/ Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/errors.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/errors.js Thu Dec 18 13:27:08 2008 @@ -224,7 +224,7 @@ ;;; // this error protects and annotates all errors that ;;; // happen during KssRuleProcessor.parse. ;;; err.kssParsingError = function(e, url){ -;;; var kw = {url: url} +;;; var kw = {url: url}; ;;; var message = 'Error parsing KSS at ' + url; ;;; return setErrorInfo(e, 'KssParsingError', message, kw); ;;; }; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/forms.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/forms.js Thu Dec 18 13:27:08 2008 @@ -132,7 +132,7 @@ this.initialize = function(target) { this.target = target; -} +}; this.queryForm = function() { // Find the form that contains the target node. Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js Thu Dec 18 13:27:08 2008 @@ -324,7 +324,7 @@ ;;; } // set it var action = this.actions.getOrCreateAction(value.txt, valuesByReturnType); - if (actionType == 'X' && action.type == null) { + if (actionType == 'X' && action.type != null) { // action-cancel, and the action existed already in the same block: // we delete it straight ahead this.actions.deleteAction(value.txt); @@ -512,7 +512,7 @@ this.process = function() { // For multivalue only - this.values = [] + this.values = []; // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; this.txt = ''; @@ -944,10 +944,10 @@ return new kssp.MethodArgs(this.cursor, kssp.openParent) }, "'": function() { - return new kssp.StringInSelector(this.cursor, kssp.quote) + return new kssp.StringInSelector(this.cursor, kssp.quote); }, '"': function() { - return new kssp.String2InSelector(this.cursor, kssp.dquote) + return new kssp.String2InSelector(this.cursor, kssp.dquote); }, ",": _mkReturnToken(kssp.comma), "{": _emitAndReturn, @@ -1115,7 +1115,7 @@ kssp.KssSelector = kukit.tk.mkParser('kssselector', { ":": function() { return [new kssp.colon(this.cursor), - new kssp.EventValue(this.cursor)] + new kssp.EventValue(this.cursor)]; }, "{": _emitAndReturn, "\/\*": _returnComment Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/oper.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/oper.js Thu Dec 18 13:27:08 2008 @@ -254,7 +254,7 @@ if (this.eventRule) { // if it has actions, the answer is yes if (this.eventRule.actions.hasActions()) - return true + return true; // if we have a default action, we will return true in any case // because we may want to call it. // The reason for this check is, that a default action is also Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/plugin.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/plugin.js Thu Dec 18 13:27:08 2008 @@ -1013,11 +1013,11 @@ } } if (parms.allnodes) { - binder.__continueEvent_allNodes__(parms.name, + binder.continueEventAllNodes(parms.name, actionParameters); } else { // execution happens on the orignode - binder.__continueEvent__(parms.name, oper.orignode, + binder.continueEvent(parms.name, oper.orignode, actionParameters); } }); Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/serveraction.js Thu Dec 18 13:27:08 2008 @@ -63,24 +63,40 @@ this.notifyServer(); }; +/* + * calculateAbsoluteURL + * + * Makes absolute site url + * - if starts with http:// https:// : no change + * - if starts with /: interprets absolute from domain + * - otherwise: relative to current context + */ this.calculateAbsoluteURL = function(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?:\/\//'))) { + // XXX packer breaks on following regexp constant, + // so it must be quoted + if (url.match(RegExp("/^https?:\/\//"))) { + // absolute already return url; - } else { - var result = kukit.engine.baseUrl + url; - return result; } + var absoluteMatch = url.match(RegExp(/^(\/)(.*)/)); + var path = kukit.engine.baseUrl; + if (absoluteMatch) { + // relative to domain + var base = path.match(RegExp(/^(.*:\/\/[^\/]*)(\/?)/))[1]; + // base is like: http://foo.bar without trailing / + url = base + url; + return url; + } + // final case: relative to current url + // (paranoia: add an / to the path *only* if it is + // *not* there) + // XXX packer breaks on following + // regexp constant, so it must be quoted + if (! path.match(RegExp("/$"))) { + path += '/'; + } + url = path + url; + return url; }; // Backparameters can be used on command execution. @@ -135,8 +151,8 @@ }; this.notifyServer_done = function(domDoc) { -;;; var msg = 'Request readyState = ' + domDoc.readyState + '.'; -;;; kukit.logDebug(msg); +//;;; var msg = 'Request readyState = ' + domDoc.readyState + '.'; +//;;; kukit.logDebug(msg); if (domDoc.readyState == 4) { // notify the queue that we are done var success = this.oper.queueItem.receivedResult(); @@ -288,7 +304,8 @@ ;;; } throw kukit.err.responseParsingError(kukit.E); } - } + }; + if (dom == null) { // this should not happen ;;; kukit.E = 'Neither xml nor html payload.'; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/tokenizer.js Thu Dec 18 13:27:08 2008 @@ -73,7 +73,7 @@ }; this.nextStep = function() { - var table = this.table + var table = this.table; var cursor = this.cursor; // Search for symbol according to table. var best_pos = cursor.text.length; @@ -245,7 +245,7 @@ tk.mkParser = function(symbol, table, _class) { // Poor man's subclassing. f = function(cursor, tokenClass, isTopLevelParser) { - this.table = table + this.table = table; this.cursor = cursor; this.startpos = cursor.pos; this.finished = false; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/utils.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/utils.js Thu Dec 18 13:27:08 2008 @@ -54,7 +54,7 @@ try { kukit.HAVE_SAFARI = navigator.vendor && navigator.vendor.indexOf('Apple') != -1; - kukit.HAVE_IE = eval("_SARISSA_IS_IE"); + kukit.HAVE_IE = eval("_SARISSA_IS_IE"); } catch (e) {} ;;; // Activation of extra logging panel: if necessary @@ -82,7 +82,7 @@ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; -} +}; // a null function that is used for logging kukit._null = function() {}; @@ -162,7 +162,7 @@ ;;; kukit.dom.createCookie(kukit._COOKIE_LOGLEVEL, level); ;;; // re-establish the log handlers, based on this cookie setting ;;; kukit._logger.updateLogLevel(); -} +}; // We want a way of knowing if Firebug is available : // it is very convenient to log a node in Firebug; @@ -192,7 +192,7 @@ ;;; this.logWarning = console.warn; ;;; this.logError = console.error; ;;; this.logFatal = console.error; -;;; } +;;; }; ;;; } ;;; // check whether the logging stuff of MochiKit is available @@ -211,7 +211,7 @@ ;;; this.logWarning = MochiKit.Logging.logWarning; ;;; this.logError = MochiKit.Logging.logError; ;;; this.logFatal = MochiKit.Logging.logFatal; -;;; } +;;; }; ;;; // make convenience url ;;; // javascript:kukit.showLog(); ;;; // instead of the need to say @@ -236,7 +236,7 @@ ;;; this.logWarning = function(str) { console.log('WARNING: '+str); }; ;;; this.logError = function(str) { console.log('ERROR: '+str); }; ;;; this.logFatal = function(str) { console.log('FATAL: '+str); }; -;;; } +;;; }; ;;; } // Initialize the logger with the solution we've just detected From gotcha at codespeak.net Thu Dec 18 13:27:35 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 18 Dec 2008 13:27:35 +0100 (CET) Subject: [KSS-checkins] r60565 - in kukit/kss.core/branch/ree-service-layer-and-refactoring: . docs kss/core/pluginregistry kss/core/pluginregistry/deprecated kss/core/pluginregistry/json kss/core/plugins/core kss/core/plugins/core/demo kss/core/plugins/core/demo/commandaction kss/core/plugins/core/demo/coresyntax kss/core/plugins/core/demo/selenium_tests Message-ID: <20081218122735.600191683D1@codespeak.net> Author: gotcha Date: Thu Dec 18 13:27:34 2008 New Revision: 60565 Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/INTRO.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_kssattr.html Removed: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/deprecated/ Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/NEWS.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/json/utils.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/meta.zcml kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/commands.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/commandaction.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/configure.zcml kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/config.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/configure.zcml kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/demoview.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/protocol.html kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/zopeconfig.py kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/interfaces.py kukit/kss.core/branch/ree-service-layer-and-refactoring/setup.py Log: trunk changes : merge -r 53859:60016 http://codespeak.net/svn/kukit/kss.core/trunk Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt Thu Dec 18 13:27:34 2008 @@ -4,7 +4,52 @@ kss.core - 1.5dev Unreleased - - ... + - Fix or improve calculateAbsoluteURL to handle absolute + and relative urls correctly, as well as get rid of the + double slash (//) issue. + It also satisfies the tests kss_url_param and + kss_url_param_multiprop, that now work as intended, + with previous workaround removed. + [ree] + + - Use the real request in the json logic so skin layers, request parmeters, + etc. are available. + [wichert] + + - Replaced license header of third-party sarissa.js + to workaround the license detection of ohloh. + sarissa.js is redistributed under GNU GPL v2 + as previously. + [ree] + + - Fix cssQuery-compat.js to use newest base2 api. + [ree] + + - Fix a typo that caused an exception instead of + logging an error message, this happened when + an action was regitered twice with the same name. + [ree] + +kss.core - 1.4 Released 2008-04-21 + +MISSING, PLEASE MERGE! - Add improved demos + (insertions in tbody is not included : that demo is + still broken in IE6) + [gotcha] + + - Updated base2-dom-fp.js with newest version. + [ree] + + - Change concatresource to accept resources with + "application/x-javascript" content type only + [ree] + + - fix setKssAttribute action and command + (closes bug 8048 from plone.org) + [gotcha] + + - fix action-cancel + [gotcha] - Updated base2-don-fp.js with newest version. This fixes breakage on FireFox 3. Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/INTRO.txt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/INTRO.txt Thu Dec 18 13:27:34 2008 @@ -0,0 +1,44 @@ + +*********************************** +Kinetic Style Sheets (KSS) kss.core +*********************************** + +KSS is an Ajax framework that allows UI development without writing any +Javascript. It uses style sheets with CSS-compliant syntax to declare and bind +dynamic behaviors in the browser. The engine supports a set of generic DOM-like +commands; they are computed on the server and sent back to manipulate the HTML +page. + +What is KSS? +************ + +KSS is an AJAX framework. KSS has both a client-side Javascript library and +server-side support. + +The client-side Javascript library needs to be included in your page. It +fetches Kinetic style sheets from the server, parses them and binds a set of +action to browser events and/or page elements. It is clean Javascript code that +can peacefully coexist with other clean Javascript librarys like JQuery or +ExtJS. It is about 100k in production mode. You can integrate your own +Javascript code by using its extension mechanism through plugins. + +Server-side code is currently available for Zope (2 and 3, which includes +Plone). The kss.base egg (which is currently in alpha) brings server-side +support to other pythonic platforms, such as: + +* pylons +* django +* grok + +The Javascript client-side code can be used independently of existing +server-side support. In other words, it is usable on platforms where we have +not built server-side support like PHP, Ruby or Java. (If you have interest in +porting KSS to the server environment you use and need help, please contact us +!) + +Homepage +*********** + +More information and documentation can be found on the +`KSS project homepage `_. + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/NEWS.txt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/NEWS.txt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/NEWS.txt Thu Dec 18 13:27:34 2008 @@ -1,4 +1,72 @@ +Deprecated in kss 1.4 +--------------------- + +form() and currentForm() in normal value providers +"""""""""""""""""""""""""""""""""""""""""""""""""" + +currentForm() +''''''''''''' + + +You must change rules that use currentForm() in a normal value provider:: + + action-server: myServerAction; + myServerAction-data: currentForm(); + +to:: + + action-server: myServerAction currentForm(); + +Or, if you want to keep compatibility with kss 1.2:: + + action-server: myServerAction; + myServerAction-kssSubmitForm: currentForm(); + + +form() +'''''' + +Similarly, for form(), you must change the following:: + + action-server: myServerAction; + myServerAction-data: form(); + +to:: + + action-server: myServerAction form(); + +Or, if you want to keep compatibility with kss 1.2:: + + action-server: myServerAction; + myServerAction-kssSubmitForm: form(); + + +Necessary server side changes +''''''''''''''''''''''''''''' + +On the server side, the method that received the form as a dictionary in one +parameter, must define the values directly in the method signature, or access +them from the form directly. + +So the following old code:: + + def method(self, data): + field1 = data['field1'] + field2 = data.get('field2', None) + +must be changed in one of the two ways shown in the following examples:: + + def method(self, field1, field2=None): + ... + +An alternate way is to get them from the request:: + + def method(self): + request = self.request + field1 = request.form['field1'] + field2 = request.form.get('field2', None) + New in kss 1.4 -------------- @@ -9,6 +77,8 @@ and the core plugin, are added. All are checkable from a single click from any browser. +- New and improved demos + - Base2 is used for css selection, instead of the original cssQuery (if present). Significantly faster page load. @@ -95,10 +165,14 @@ - Implement loglevels based on cookies (also backported to 1.2.) -- Other fixes (also backported to 1.2):: +- Other fixes (also backported to 1.2): - Fix error fallback handling - Fix multiple selection form fields marshalling on Safari and IE + - Fix setKssAttribute action and command + + - fix action-cancel + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/json/utils.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/json/utils.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/json/utils.py Thu Dec 18 13:27:34 2008 @@ -5,7 +5,6 @@ import os.path, logging import zope.component as capi from zope.interface import implements, Interface -from zope.publisher.browser import TestRequest from interfaces import IJSONStreamWriteable logger = logging.getLogger('kss.core') @@ -14,19 +13,21 @@ 'Gets the addon javascript files for json' files = [] # Try adding the jsonserver files - request = TestRequest() - try: - # use the files already registered to that concat resource - jsonrpc = capi.getAdapter(request, Interface, 'jsonrpc.js') - except capi.ComponentLookupError: - pass # JSON not present. - else: - # JSON present. - files.extend(jsonrpc.context.context.getPathList()) - # add the json kukit support file - plugins_dir = os.path.split(globals()['__file__'])[0] - files.append(os.path.join(plugins_dir, 'browser', 'jsonkukit.js')) - logger.info('Lazy plugin construction: Installed support for JSON-RPC transport.') + request = getattr(capi.getSiteManager(), 'REQUEST', None) + + if request is not None: + try: + # use the files already registered to that concat resource + jsonrpc = capi.getAdapter(request, Interface, 'jsonrpc.js') + except capi.ComponentLookupError: + pass # JSON not present. + else: + # JSON present. + files.extend(jsonrpc.context.context.getPathList()) + # add the json kukit support file + plugins_dir = os.path.split(globals()['__file__'])[0] + files.append(os.path.join(plugins_dir, 'browser', 'jsonkukit.js')) + logger.info('Lazy plugin construction: Installed support for JSON-RPC transport.') return files class JsonCommandView(object): Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/meta.zcml ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/meta.zcml (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/pluginregistry/meta.zcml Thu Dec 18 13:27:34 2008 @@ -4,9 +4,6 @@ - - - + + + + + + + + + +

header

+ +

action-cancel

+ +
+

Standard case

+
    +
  • with
  • +
  • without
  • +
+
+ +
+

Alias case

+
    +
  • with
  • +
  • without
  • +
+
+ +

logger

+ + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/commandaction.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/commandaction.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/commandaction.py Thu Dec 18 13:27:34 2008 @@ -8,10 +8,6 @@ core.toggleClass(selector, 'selected') return self.render() - def focus(self, id): - self.getCommandSet('core').focus('#' + id) - return self.render() - def addClass(self): core = self.getCommandSet('core') selector = core.getSameNodeSelector() @@ -23,3 +19,29 @@ selector = core.getSameNodeSelector() core.removeClass(selector, 'selected') return self.render() + + #focus + + def focus(self, id): + self.getCommandSet('core').focus('#' + id) + return self.render() + + #action-cancel + + def toCancel(self): + core = self.getCommandSet('core') + core.insertHTMLAsLastChild('#logger', 'action') + return self.render() + + #setKssAttribute + + def echo(self, value): + core = self.getCommandSet('core') + core.insertHTMLAsLastChild('#logger', value) + return self.render() + + def setKssAttribute(self): + core = self.getCommandSet('core') + core.setKssAttribute('#command', 'name', 'value-from-command') + return self.render() + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/configure.zcml ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/configure.zcml (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/configure.zcml Thu Dec 18 13:27:34 2008 @@ -39,6 +39,8 @@ permission="zope.View" /> + + + + + + + + + + + + + + + + + + + Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.kss ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.kss Thu Dec 18 13:27:34 2008 @@ -0,0 +1,28 @@ +.get:click { + action-server: echo; + echo-value: kssAttr('name', true); +} + +#command .set:click { + action-server: setKssAttribute; +} + +#action .set:click { + action-client: setKssAttribute; + setKssAttribute-kssSelector: #action; + setKssAttribute-name: name; + setKssAttribute-value: value-from-action; +} + +/* Log control +*/ + +#log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; +} + +#log-reset a:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; +} Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.pt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/kssattr.pt Thu Dec 18 13:27:34 2008 @@ -0,0 +1,34 @@ + + + + + + + + + + +

header

+ +

setKssAttribute

+ +
+

Command

+

getKssAttr

+

setKssAttr

+
+ +
+

Action

+

getKssAttr

+

setKssAttr

+
+ +
+

Log

+

Reset

+ +
+
+ + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/config.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/config.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/config.py Thu Dec 18 13:27:34 2008 @@ -9,7 +9,6 @@ except ImportError: # no demo package installed return Plugin() - class CoreDemos(Plugin): zope_demos = ( @@ -30,7 +29,9 @@ KSSDemo('', 'Core events', "kss_evt_preventbubbling.html", "Prevent bubbling KSS event parameter"), KSSDemo('', 'Core events', "kss_keyevents.html", "Key events"), KSSDemo('', 'Commands/Actions', "ca_focus.html", "Focus"), - KSSDemo('', 'Commands/Actions', "actions.html", "Toggle case action"), + KSSDemo('', 'Commands/Actions', "actions.html", "Class actions: toggle, add, remove"), + KSSDemo('', 'Commands/Actions', "ca_cancel.html", "action-cancel"), + KSSDemo('', 'Commands/Actions', "ca_kssattr.html", "setKssAttribute"), # XXX this should go to the other plugin wuth all its stuff KSSDemo('Effects', '', "effects.html", "Effects"), ) Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/configure.zcml ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/configure.zcml (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/configure.zcml Thu Dec 18 13:27:34 2008 @@ -545,5 +545,21 @@ permission="zope.View" /> + + + + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.kss ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.kss (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.kss Thu Dec 18 13:27:34 2008 @@ -16,6 +16,6 @@ #button_3:click { action-server: urlMethodAnotherAlias; - urlMethodAnotherAlias-kssUrl: "@@urlMethod3/urlMethod3"; + urlMethodAnotherAlias-kssUrl: "@@urlMethod3"; } Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.pt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.pt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param.pt Thu Dec 18 13:27:34 2008 @@ -42,10 +42,10 @@

Alias URL with @@

- Click the button; it will call @@urlMethod3/urlMethod3 on the server. + Click the button; it will call @@urlMethod3 on the server.
#button_3:click {
     action-server: urlMethodAnotherAlias;
-    urlMethodAnotherAlias-kssUrl: "@@urlMethod3/urlMethod3";
+    urlMethodAnotherAlias-kssUrl: "@@urlMethod3";
 }
Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.kss ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.kss (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.kss Thu Dec 18 13:27:34 2008 @@ -14,7 +14,7 @@ } #button_3:click { - action-server: urlMethodAnotherAlias url("@@urlMethod3/urlMethod3"); + action-server: urlMethodAnotherAlias url("@@urlMethod3"); } #button_4:click { Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.pt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.pt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/coresyntax/kss_url_param_multiprop.pt Thu Dec 18 13:27:34 2008 @@ -41,9 +41,9 @@

Alias URL with @@

- Click the button; it will call @@urlMethod3/urlMethod3 on the server. + Click the button; it will call @@urlMethod3 on the server.
#button_3:click {
-    action-server: urlMethodAnotherAlias url("@@urlMethod3/urlMethod3");
+    action-server: urlMethodAnotherAlias url("@@urlMethod3");
 }
@@ -53,7 +53,7 @@

Alias URL from provider

- Click the button; it will call @@urlMethod3/urlMethod3 on the server. + Click the button; it will call urlMethod3 on the server.
#button_4:click {
     action-server: urlMethodAnotherAlias url(kssAttr(methodname, true));
 }
Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/demoview.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/demoview.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/demoview.py Thu Dec 18 13:27:34 2008 @@ -266,3 +266,12 @@ '#character-attr-output', 'title', 'before ]]> after') return self.render() + def protocolAgrave(self): + self.getCommandSet('core').replaceInnerHTML( + '#named-entity-output', 'à') + return self.render() + + def protocolEacute(self): + self.getCommandSet('core').replaceInnerHTML( + '#named-entity-output', 'é') + return self.render() Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.kss ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.kss (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.kss Thu Dec 18 13:27:34 2008 @@ -56,4 +56,14 @@ #attr-endcdata:click { evt-click-preventdefault: true; action-server: protocolAttributeENDCDATA; +} + +#agrave:click { + evt-click-preventdefault: true; + action-server: protocolAgrave; +} + +#eacute:click { + evt-click-preventdefault: true; + action-server: protocolEacute; } \ No newline at end of file Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.pt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.pt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/protocol.pt Thu Dec 18 13:27:34 2008 @@ -86,6 +86,20 @@ Link which get a title attribute + +

Named entities

+

Named entities should work. The next example demonstrates that + the server can send data with named entities.

+ +
    +
  1. Command with an à
  2. +
  3. Command with a é
  4. +
+ +
+ test data will appear here +
+ Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html Thu Dec 18 13:27:34 2008 @@ -0,0 +1,119 @@ + + + +ca_cancel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ca_cancel
open/demo/ca_cancel.html
assertTextPresentaction-cancel
clickcss=#standard #with
waitForTextloggeraction
assertTextloggeraction
clickcss=#standard #without
waitForTextloggeraction
assertTextloggeraction
clickcss=#standard #with
waitForTextloggeractionaction
assertTextloggeractionaction
clicklog-reset
clickcss=#alias #with
waitForTextloggeraction
assertTextloggeraction
clickcss=#alias #without
waitForTextloggeraction
assertTextloggeraction
clickcss=#alias #with
waitForTextloggeractionaction
assertTextloggeractionaction
+ + Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_kssattr.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_kssattr.html Thu Dec 18 13:27:34 2008 @@ -0,0 +1,99 @@ + + + +ca_kssattr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ca_kssattr
open/demo/ca_kssattr.html
assertTextPresentsetKssAttribute
clickcss=#command .set
waitForAttributecommand at kssattr:namevalue-from-command
assertAttributecommand at kssattr:namevalue-from-command
clickcss=#command .get
waitForTextloggervalue-from-command
assertTextloggervalue-from-command
clicklog-reset
waitForTextNotPresentlogger
assertTextNotPresentlogger
clickcss=#action .set
waitForAttributeaction at kssattr:namevalue-from-action
assertAttributeaction at kssattr:namevalue-from-action
clickcss=#action .get
waitForTextloggervalue-from-action
assertTextloggervalue-from-action
+ + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/protocol.html ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/protocol.html (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/protocol.html Thu Dec 18 13:27:34 2008 @@ -163,6 +163,26 @@ character-attr-output at title before ]]> after + + click + agrave + + + + waitForText + named-entity-output + à + + + click + eacute + + + + waitForText + named-entity-output + é + Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/zopeconfig.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/zopeconfig.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/zopeconfig.py Thu Dec 18 13:27:34 2008 @@ -38,7 +38,9 @@ KSSDemo('', 'Core events', "kss_evt_preventbubbling.html", "Prevent bubbling KSS event parameter"), KSSDemo('', 'Core events', "kss_keyevents.html", "Key events"), KSSDemo('', 'Commands/Actions', "ca_focus.html", "Focus"), - KSSDemo('', 'Commands/Actions', "actions.html", "Toggle case action"), + KSSDemo('', 'Commands/Actions', "actions.html", "Class actions: toggle, add, remove"), + KSSDemo('', 'Commands/Actions', "ca_cancel.html", "action-cancel"), + KSSDemo('', 'Commands/Actions', "ca_kssattr.html", "setKssAttribute"), ) # directories are relative from the location of this .py file Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/interfaces.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/interfaces.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/interfaces.py Thu Dec 18 13:27:34 2008 @@ -33,6 +33,9 @@ def setAttribute(selector, name, value): """Set an attribute on node(s) specified by the selector""" + def setKssAttribute(selector, name, value): + """Set a KSS attribute on node(s) specified by the selector""" + def setStyle(selector, name, value): """Set the style attribute of nodes specified by the selector""" Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/setup.py ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/setup.py (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/setup.py Thu Dec 18 13:27:34 2008 @@ -1,13 +1,27 @@ from setuptools import setup, find_packages -import sys, os +import os version = '1.5' +def read(*rnames): + return open(os.path.join(os.path.dirname(__file__), *rnames)).read() + +long_description = ( + read('docs', 'INTRO.txt') + + '\n' + + 'Recently changed\n' + '**********************\n' + + '\n' + + read('docs', 'NEWS.txt') + + '\n' + + 'Download\n' + '**********************\n' + ) + setup(name='kss.core', version=version, description="KSS (Kinetic Style Sheets) core framework", - long_description="""\ -""", + long_description = long_description, # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers classifiers=[ "Framework :: Zope2", From gotcha at codespeak.net Thu Dec 18 13:33:49 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 18 Dec 2008 13:33:49 +0100 (CET) Subject: [KSS-checkins] r60566 - in kukit/kss.core/branch/ree-service-layer-and-refactoring: docs kss/core/plugins/core/demo/commandaction kss/core/plugins/core/demo/selenium_tests Message-ID: <20081218123349.3C64B168449@codespeak.net> Author: gotcha Date: Thu Dec 18 13:33:48 2008 New Revision: 60566 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.kss kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.pt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html Log: trunk changes : merge -r 60016:60018 http://codespeak.net/svn/kukit/kss.core/trunk Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/docs/HISTORY.txt Thu Dec 18 13:33:48 2008 @@ -4,6 +4,10 @@ kss.core - 1.5dev Unreleased + - Fix the ca_cancel (action-cancel) test that was broken + on IE7 because it contained the same id more times. + [ree] + - Fix or improve calculateAbsoluteURL to handle absolute and relative urls correctly, as well as get rid of the double slash (//) issue. Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.kss ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.kss (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.kss Thu Dec 18 13:33:48 2008 @@ -2,7 +2,7 @@ action-server: cancel; } -#standard #without:click { +#standard .without:click { action-cancel: cancel; } @@ -11,7 +11,7 @@ test-html: action; } -#alias #without:click { +#alias .without:click { action-cancel: test; } Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.pt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.pt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/commandaction/cancel.pt Thu Dec 18 13:33:48 2008 @@ -15,16 +15,16 @@

Standard case

    -
  • with
  • -
  • without
  • +
  • with
  • +
  • without

Alias case

    -
  • with
  • -
  • without
  • +
  • with
  • +
  • without
Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/ca_cancel.html Thu Dec 18 13:33:48 2008 @@ -20,7 +20,7 @@ click - css=#standard #with + css=#standard .with @@ -35,7 +35,7 @@ click - css=#standard #without + css=#standard .without @@ -50,7 +50,7 @@ click - css=#standard #with + css=#standard .with @@ -70,7 +70,7 @@ click - css=#alias #with + css=#alias .with @@ -85,7 +85,7 @@ click - css=#alias #without + css=#alias .without @@ -100,7 +100,7 @@ click - css=#alias #with + css=#alias .with From gotcha at codespeak.net Sun Dec 28 12:56:12 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 28 Dec 2008 12:56:12 +0100 (CET) Subject: [KSS-checkins] r60712 - in kukit/kukit.js/branch/gotcha-simplify-service-layer: doc kukit tests Message-ID: <20081228115612.0EACA1684C2@codespeak.net> Author: gotcha Date: Sun Dec 28 12:56:10 2008 New Revision: 60712 Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kukit.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/tokenizer.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_kssparser.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_tokenizer.js Log: parser should not access global plugins; should be parameter Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/doc/HISTORY.txt Sun Dec 28 12:56:10 2008 @@ -51,7 +51,7 @@ - Refactor the value provider registry to use a single registry in place of 3. This will enable to define value - providers that recieve non-string parameters + providers that receive non-string parameters like a node selection. [ree] Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/kssparser.js Sun Dec 28 12:56:10 2008 @@ -117,7 +117,7 @@ kssp.Document = kukit.tk.mkParser('document', { "\/\*": _returnComment, "{": function() { - return new kssp.Block(this.cursor, kssp.openBrace); + return new kssp.Block(this.cursor, kssp.openBrace, false, this.plugins); } }, _Document @@ -172,7 +172,7 @@ this.parseSelectors = function(key) { // Parse the part in an embedded parser var cursor = new kukit.tk.Cursor(key + ' '); - var parser = new kssp.KssSelectors(cursor, null, true); + var parser = new kssp.KssSelectors(cursor, null, true, this.plugins); var results = []; var hasFullNames = false; for(var eventFullName in this.eventFullNames) { @@ -249,7 +249,7 @@ ;;; allowedReturnTypes = {string: true}; ;;; kukit.E = 'event parameter [' + key + ']'; // global registry is used - var registry = kukit.plugins; + var registry = this.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -303,7 +303,7 @@ ;;; kukit.E = 'action definition [' + key + ']'; // check the rule values // global registry is used - var registry = kukit.plugins; + var registry = this.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -347,7 +347,7 @@ ;;; allowedReturnTypes = {string: true}; ;;; kukit.E = 'Wrong value in action error parameter [' + key + ']'; // global registry is used - var registry = kukit.plugins; + var registry = this.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -376,7 +376,7 @@ // (from check). // // global registry is used - var registry = kukit.plugins; + var registry = this.plugins; var value; var allowedReturnTypes; var noStringRequired = false; @@ -925,7 +925,7 @@ // for MethodArgs, for example, does not produce useful txt. // Instead we take a slice of the original text. var cursor = new kukit.tk.Cursor(context.txt + ' '); - var parser = new kssp.KssSelector(cursor, null, true); + var parser = new kssp.KssSelector(cursor, null, true, this.plugins); this.selectors.push(parser.kssSelector); if (context.nextTokenIndex == this.result.length) break; this.expectToken(context, kssp.comma); @@ -1034,7 +1034,7 @@ css = singleword; } // global registry is used - var registry = kukit.plugins; + var registry = this.plugins; // create the selector. var id = null; var ppid = null; @@ -1128,9 +1128,10 @@ * * Rule processor that interfaces with kukit core */ -kssp.KssRuleProcessor = function(href) { +kssp.KssRuleProcessor = function(href, plugins) { this.initialize = function() { + this.plugins = plugins; this.href = href; this.loaded = false; this.rules = []; @@ -1149,7 +1150,7 @@ ;;; try { //Build a parser and parse the text into it var cursor = new kukit.tk.Cursor(this.txt); - var parser = new kssp.Document(cursor, null, true); + var parser = new kssp.Document(cursor, null, true, this.plugins); // Store event rules in the common list for (var i=0; i Author: gotcha Date: Sun Dec 28 13:23:08 2008 New Revision: 60713 Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Log: bind explicitely Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js Sun Dec 28 13:23:08 2008 @@ -53,16 +53,6 @@ * singleton registry object has to be provided. The items are * bound on this registry. * - * registrar.bindItems(registry); - * - * In most cases, the registry can simply be a normal object. So - * the usual setup what we have a registry for plugins is: - * - * registrar.bindItems({}); - * - * However a registry could have attributes inherited with - * a prototype, and if we want to have this, we could bind the items - * on an object with a different prototype. * * After being bound, the registry set up, * will appear directly accessable from registries. @@ -128,7 +118,7 @@ return factory; }; - this.bindItems = function(registries, registry) { + this.bindItems = function() { // Check if we are finalized. if (this.bound) { ;;; kukit.E = 'Attempt to bind already bound registry ['; @@ -137,6 +127,7 @@ } ;;; kukit.E = 'Binding registry [' + this.registryName + ']'; ;;; kukit.logDebug(kukit.E); + var registry = {}; for (var name in this.factories) { var factory = this.factories[name]; var item = factory.create(); @@ -145,11 +136,9 @@ registry[name] = item; }; }; - // Store the registry itself on the registries - // this means that it can be accessed as registries.registryname - registries[this.registryName] = registry; // Set bound state. this.bound = true; + return registry; }; this.initialize.apply(this, arguments); @@ -439,11 +428,11 @@ reg.finalizeGlobalRegistries = function() { var registrars = kukit.registrars; kukit.plugins = {}; - registrars.events.bindItems(kukit.plugins, {}); - registrars.bindsequences.bindItems(kukit.plugins, {}); - registrars.actions.bindItems(kukit.plugins, {}); - registrars.valueproviders.bindItems(kukit.plugins, {}); - registrars.services.bindItems(kukit, {}); + kukit.plugins.events = registrars.events.bindItems(); + kukit.plugins.bindsequences = registrars.bindsequences.bindItems(); + kukit.plugins.actions = registrars.actions.bindItems(); + kukit.plugins.valueproviders = registrars.valueproviders.bindItems(); + kukit.services = registrars.services.bindItems(); }; // At this point we setup the registries used by kukit, Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Sun Dec 28 13:23:08 2008 @@ -83,13 +83,13 @@ called = []; // // At this point we are also ready to bind the items the registrar. - registrar.bindItems(this.registries, s); + this.dummytest = registrar.bindItems(); // This binds all the items. this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']); called = []; // At the same time it also set up these on the class prototype. - this.assertEquals(this.registries.dummytest.fooItem, 'FUNC fooItem'); - this.assertEquals(this.registries.dummytest.barItem, 'FUNC barItem'); + this.assertEquals(this.dummytest.fooItem, 'FUNC fooItem'); + this.assertEquals(this.dummytest.barItem, 'FUNC barItem'); }; }; /* end RegistriesTestCase */ @@ -150,12 +150,12 @@ getter: function() {return function() {return 'fourth/extra';}}}); // // Now bind the items. - registrar.bindItems(this.registries, s); + this.dummyservice = registrar.bindItems(); // We can call the methods on it, - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); - this.assertEquals(this.registries.dummyservice.second(), 'second/extra'); - this.assertEquals(this.registries.dummyservice.third(), 'third/core'); - this.assertEquals(this.registries.dummyservice.fourth(), 'fourth/extra'); + this.assertEquals(this.dummyservice.first(), 'first/core'); + this.assertEquals(this.dummyservice.second(), 'second/extra'); + this.assertEquals(this.dummyservice.third(), 'third/core'); + this.assertEquals(this.dummyservice.fourth(), 'fourth/extra'); }; this.testChecker = function() { @@ -183,9 +183,9 @@ getter: function() {return function() {return 'first/extra';}}}); // // Now bind the items. - registrar.bindItems(this.registries, s); + this.dummyservice = registrar.bindItems(); // call it - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); + this.assertEquals(this.dummyservice.first(), 'first/core'); // Check that the checker has been called. this.assertEquals(checker_counter, 1); }; @@ -205,9 +205,9 @@ registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); // Now bind the items. - registrar.bindItems(this.registries, s); + this.dummyservice = registrar.bindItems(); // We can call the methods on it, - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); + this.assertEquals(this.dummyservice.first(), 'first/core'); }; this.testFinalizeTwice = function() { @@ -223,10 +223,10 @@ registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); // Now bind all items. - registrar.bindItems(this.registries, s); + registrar.bindItems(); // Bind it again. this.assertThrows(function() { - registrar.bindItems(this.registries, s); + registrar.bindItems(); }, Error); }; @@ -242,7 +242,7 @@ getter: function() {return function() {return 'first/core';}}}); // Now bind all items. this.assertThrows(function() { - registrar.bindItems(this.registries, s); + registrar.bindItems(); }, Error) }; @@ -292,7 +292,7 @@ getter: function() {return function() {return 'first/crap';}}}); // Now bind all items. this.assertThrows(function() { - registrar.bindItems(this.registries, s); + registrar.bindItems(); }, Error); }; @@ -355,13 +355,13 @@ bindMethodName: 'bind'}); // // Now bind all items. - events.bindItems(this.registries, {}); - bindsequences.bindItems(this.registries, {}); + this.dummyevents = events.bindItems(); + this.dummybindsequences = bindsequences.bindItems(); // We can call the methods on it, - this.assertEquals(this.registries.dummyevents.click.defaultActionMethodName, null); - this.assertEquals(this.registries.dummyevents.keydown.defaultActionMethodName, null); - this.assertEquals(this.registries.dummyevents.timeout.defaultActionMethodName, null); - this.assertEquals(this.registries.dummybindsequences.timeout.iterName, 'Each'); + this.assertEquals(this.dummyevents.click.defaultActionMethodName, null); + this.assertEquals(this.dummyevents.keydown.defaultActionMethodName, null); + this.assertEquals(this.dummyevents.timeout.defaultActionMethodName, null); + this.assertEquals(this.dummybindsequences.timeout.iterName, 'Each'); }; this.testPluginNoDoubleReg = function() { @@ -412,12 +412,12 @@ binderClass: MSub, bindMethodName: 'bind'}); // bind - bindsequences.bindItems(this.registries, {}); + this.dummybindsequences = bindsequences.bindItems(); // Check that our classes are set as expected. - this.assertEquals(this.registries.dummybindsequences.click.binderClass, M); - this.assertEquals(this.registries.dummybindsequences.timeout.binderClass, M); - this.assertEquals(this.registries.dummybindsequences.keydown.binderClass, MSub); - this.assertEquals(this.registries.dummybindsequences.keypress.binderClass, MSub); + this.assertEquals(this.dummybindsequences.click.binderClass, M); + this.assertEquals(this.dummybindsequences.timeout.binderClass, M); + this.assertEquals(this.dummybindsequences.keydown.binderClass, MSub); + this.assertEquals(this.dummybindsequences.keypress.binderClass, MSub); // Check that both classes have a class name. this.assert(M.prototype.__className__); this.assert(MSub.prototype.__className__); @@ -433,10 +433,10 @@ // Just call up the factoryr: this will create it with config=null. events.getItemFactory('click'); // bind - events.bindItems(this.registries, {}); + this.dummyevents = events.bindItems(); // Check that click is not defined at all. (in particular, it should not be null or {}.) // Since other code that uses it, depends that if it has a value, it is the real config. - this.assertEquals(typeof(this.registries.dummyevents.click), 'undefined'); + this.assertEquals(typeof(this.dummyevents.click), 'undefined'); }; this.testRegisterPlugins = function() { From gotcha at codespeak.net Sun Dec 28 14:03:47 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 28 Dec 2008 14:03:47 +0100 (CET) Subject: [KSS-checkins] r60714 - in kukit/kukit.js/branch/gotcha-simplify-service-layer: kukit tests Message-ID: <20081228130347.72D5F1684C4@codespeak.net> Author: gotcha Date: Sun Dec 28 14:03:45 2008 New Revision: 60714 Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Log: build instead of bind Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js Sun Dec 28 14:03:45 2008 @@ -47,60 +47,18 @@ * case of the plugins), then the order of these javascripts is * arbitrary for registries to work. * - * This concludes everything we can do, before binding the registry. - * Binding freezes the factorization of items in the registrar and - * allows its direct use. For the binding, a - * singleton registry object has to be provided. The items are - * bound on this registry. + * This concludes everything we can do, before building the registry. * + * plugins.events.click - is an event's registry + * plugins.actions.setAttr - is an action's registry * - * After being bound, the registry set up, - * will appear directly accessable from registries. - * - * registries.myregistry == registry - * - * This will be identical to the registry object we bound to. - * The registry contains our items directly. (not the factory, - * but already the actual item values as returned be the factory's - * getItem method.) - * - * registries.myregistry.mykey == item - * - * After being bound, all named registries can be accessed from - * the registries object, e.g. in the following way: - * - * registries.events.click - is an event's registry - * registries.actions.setAttr - is an action's registry - * - * Kukit sets up the following registries for its own use. The - * binding of these registries is done by kukit at the beginning - * of bootstrap. - * - * Created on the global registries "kukit.plugins": - * - * name purpose attribute class - * ---- ------- --------------- - * events kss event name registry kukit.reg.PluginFactory - * bindsequences kss event binding reg. kukit.reg.BindSequenceFactory - * actions kss action registry kukit.reg.PluginFactory - * valueproviders value provider registry kukit.reg.PluginFactory - * - * Created on the global registries "kukit.service": - * - * name purpose attribute class - * ---- ------- --------------- - * services services kukit.reg.ServiceFactory - * - * - * For more information, see ../tests/test_registries.js . - * */ reg.Registrar = function() { this.initialize = function(registryName, FactoryClass) { this.registryName = registryName; - this.bound = false; + this.built = false; this.factories = {}; this.FactoryClass = FactoryClass; }; @@ -118,14 +76,13 @@ return factory; }; - this.bindItems = function() { - // Check if we are finalized. - if (this.bound) { -;;; kukit.E = 'Attempt to bind already bound registry ['; -;;; kukit.E += this.registryName + ']'; + this.buildRegistry = function() { + if (this.built) { +;;; kukit.E = 'Registry ['; +;;; kukit.E += this.registryName + '] already built !'; throw new Error(kukit.E); } -;;; kukit.E = 'Binding registry [' + this.registryName + ']'; +;;; kukit.E = 'Building registry [' + this.registryName + ']'; ;;; kukit.logDebug(kukit.E); var registry = {}; for (var name in this.factories) { @@ -136,8 +93,7 @@ registry[name] = item; }; }; - // Set bound state. - this.bound = true; + this.built = true; return registry; }; @@ -195,7 +151,7 @@ ;;; if (! config.sourceVersion) { ;;; throw this._makeError(componentName, 'config.sourceVersion'); ;;; } - if (this.registrar.bound) { + if (this.registrar.built) { ;;; kukit.E = 'Attempt to provide implementation to method ['; ;;; kukit.E += this.methodName + '] on already finalized registry ['; ;;; kukit.E += this.registrar.registryName + ']'; @@ -283,9 +239,6 @@ this.initialize = function(registrar, name) { this.registrar = registrar; this.name = name; - // Set the config to undefined, this means that the items - // that were produced but not registered during the configuration, - // will not be bound. this.config = undefined; }; @@ -299,11 +252,6 @@ }; this.create = function() { - // Just return the registered item. - // If register was not called, we will return undefined, - // which means the method will not be bound on the - // registry. This makes sure that if the item is found, - // it will for sure have a value. return this.config; }; @@ -394,7 +342,7 @@ }; reg.cleanRoomFinalize = function(suite) { - // Need to finalize (bind) these registries + // Need to build these registries this.finalizeGlobalRegistries(); }; @@ -428,11 +376,11 @@ reg.finalizeGlobalRegistries = function() { var registrars = kukit.registrars; kukit.plugins = {}; - kukit.plugins.events = registrars.events.bindItems(); - kukit.plugins.bindsequences = registrars.bindsequences.bindItems(); - kukit.plugins.actions = registrars.actions.bindItems(); - kukit.plugins.valueproviders = registrars.valueproviders.bindItems(); - kukit.services = registrars.services.bindItems(); + kukit.plugins.events = registrars.events.buildRegistry(); + kukit.plugins.bindsequences = registrars.bindsequences.buildRegistry(); + kukit.plugins.actions = registrars.actions.buildRegistry(); + kukit.plugins.valueproviders = registrars.valueproviders.buildRegistry(); + kukit.services = registrars.services.buildRegistry(); }; // At this point we setup the registries used by kukit, Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Sun Dec 28 14:03:45 2008 @@ -81,10 +81,7 @@ // Check this.assertListEquals(called, ['doThis', 'doThat']); called = []; - // - // At this point we are also ready to bind the items the registrar. - this.dummytest = registrar.bindItems(); - // This binds all the items. + this.dummytest = registrar.buildRegistry(); this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']); called = []; // At the same time it also set up these on the class prototype. @@ -148,9 +145,7 @@ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'fourth/extra';}}}); - // - // Now bind the items. - this.dummyservice = registrar.bindItems(); + this.dummyservice = registrar.buildRegistry(); // We can call the methods on it, this.assertEquals(this.dummyservice.first(), 'first/core'); this.assertEquals(this.dummyservice.second(), 'second/extra'); @@ -181,9 +176,7 @@ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'first/extra';}}}); - // - // Now bind the items. - this.dummyservice = registrar.bindItems(); + this.dummyservice = registrar.buildRegistry(); // call it this.assertEquals(this.dummyservice.first(), 'first/core'); // Check that the checker has been called. @@ -204,14 +197,13 @@ // Define the method later registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); - // Now bind the items. - this.dummyservice = registrar.bindItems(); + this.dummyservice = registrar.buildRegistry(); // We can call the methods on it, this.assertEquals(this.dummyservice.first(), 'first/core'); }; this.testFinalizeTwice = function() { - // A registrar can only be bound once. + // A registrar can only be built once. var s = {}; var registrar = this.registrars.dummyservice; // Provide the method first @@ -222,11 +214,9 @@ // Define the method later registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); - // Now bind all items. - registrar.bindItems(); - // Bind it again. + registrar.buildRegistry(); this.assertThrows(function() { - registrar.bindItems(); + registrar.buildRegistry(); }, Error); }; @@ -240,9 +230,8 @@ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); - // Now bind all items. this.assertThrows(function() { - registrar.bindItems(); + registrar.buildRegistry(); }, Error) }; @@ -290,9 +279,8 @@ sourceName: 'craplib', sourceVersion: '1.1', getter: function() {return function() {return 'first/crap';}}}); - // Now bind all items. this.assertThrows(function() { - registrar.bindItems(); + registrar.buildRegistry(); }, Error); }; @@ -353,10 +341,8 @@ iterName: 'Each', binderClass: M, bindMethodName: 'bind'}); - // - // Now bind all items. - this.dummyevents = events.bindItems(); - this.dummybindsequences = bindsequences.bindItems(); + this.dummyevents = events.buildRegistry(); + this.dummybindsequences = bindsequences.buildRegistry(); // We can call the methods on it, this.assertEquals(this.dummyevents.click.defaultActionMethodName, null); this.assertEquals(this.dummyevents.keydown.defaultActionMethodName, null); @@ -411,8 +397,7 @@ iterName: 'Each', binderClass: MSub, bindMethodName: 'bind'}); - // bind - this.dummybindsequences = bindsequences.bindItems(); + this.dummybindsequences = bindsequences.buildRegistry(); // Check that our classes are set as expected. this.assertEquals(this.dummybindsequences.click.binderClass, M); this.assertEquals(this.dummybindsequences.timeout.binderClass, M); @@ -425,15 +410,14 @@ this.assertNotEquals(M.prototype.__className__, MSub.prototype.__className__); }; - this.testOnlyRegisteredPluginsCanBeBound = function() { + this.testOnlyRegisteredPluginsCanBeBuilt = function() { // We assure that if an item is produced but it is not registered, - // it will not be bound on the configuration. + // it will not be built on the configuration. var events = this.registrars.dummyevents; var bindsequences = this.registrars.dummybindsequences; // Just call up the factoryr: this will create it with config=null. events.getItemFactory('click'); - // bind - this.dummyevents = events.bindItems(); + this.dummyevents = events.buildRegistry(); // Check that click is not defined at all. (in particular, it should not be null or {}.) // Since other code that uses it, depends that if it has a value, it is the real config. this.assertEquals(typeof(this.dummyevents.click), 'undefined'); From gotcha at codespeak.net Sun Dec 28 22:50:15 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 28 Dec 2008 22:50:15 +0100 (CET) Subject: [KSS-checkins] r60717 - in kukit/kukit.js/branch/gotcha-simplify-service-layer: kukit tests Message-ID: <20081228215015.5120716841A@codespeak.net> Author: gotcha Date: Sun Dec 28 22:50:13 2008 New Revision: 60717 Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/runtests.js kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Log: remove Factory classes; use different Registrars instead Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js Sun Dec 28 22:50:13 2008 @@ -37,7 +37,7 @@ ;;; throw new Error(kukit.e); ;;; } var actions = kukit.registrars.actions; - actions.getItemFactory(name).register({actionFunc: func}); + actions.register(name, {actionFunc: func}); }; this.get = function(name) { Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js Sun Dec 28 22:50:13 2008 @@ -34,50 +34,46 @@ this.registerFromAction = function(srcname, factory, name) { var actions = kukit.registrars.actions; - // + var config = actions.get(srcname); // register a given action as a command, using the given vactor - var action_factory = actions.getItemFactory(srcname); - if (! action_factory.config) { + if (typeof(config) == 'undefined') { ;;; kukit.E = 'undefined client action [' + srcname + '] in CommandRegistry.registerFromAction.'; throw Error(kukit.E); } // Set a command of the required class for the action - var commandClass = factory(action_factory.config.actionFunc); + var commandClass = factory(config.actionFunc); // Allow to set a different name (used for BBB) if (typeof(name) != 'undefined') { // Add the BBB config if there is not // by mirroring the config // this makes sure the _registry below won't fail - actions.getItemFactory(name).register(action_factory.config); + actions.register(name, config); // only declare the command class if it's missing - if (typeof(action_factory.config.commandClass) == 'undefined') { - this._register(name, commandClass, action_factory); + if (typeof(config.commandClass) == 'undefined') { + this._register(name, commandClass, config); } } else { // This is the normal case - just register it - this._register(srcname, commandClass, action_factory); + this._register(srcname, commandClass, config); } }; this.register = function(name, commandClass) { - var actions = kukit.plugins.actions; - var attrib = actions.getItemFactory(name); - this._register(name, commandClass, attrib); + var actions = kukit.registrars.actions; + var config = actions[name]; + this._register(name, commandClass, config); }; -this._register = function(name, commandClass, descriptor) { - if (! descriptor.config) { -;;; kukit.E = 'undefined client action [' + name + '] in CommandRegistry.register.'; - throw Error(kukit.E); - } else if (descriptor.config.commandClass) { +this._register = function(name, commandClass, config) { + if (config.commandClass) { // Do not allow redefinition -;;; kukit.E = 'command [' + name + '] is already defined, in CommandRegistry.register.'; +;;; kukit.E = 'command [' + name + '] has already been registered, in CommandRegistry.register.'; throw Error(kukit.E); } // Store the command class on the config - descriptor.config.commandClass = commandClass; + config.commandClass = commandClass; }; this.get = function(name) { @@ -109,17 +105,6 @@ kukit.commandsGlobalRegistry = new _CommandRegistry(); -/* XXX deprecated methods, to be removed asap */ - -cr.commandRegistry = {}; -cr.commandRegistry.registerFromAction = function(srcname, factory, name) { -;;;var msg = 'Deprecated kukit.cr.commandRegistry.registerFromAction,'; -;;;msg += ' use kukit.commandsGlobalRegistry.registerFromAction instead! ('; -;;;msg += srcname + ')'; -;;;kukit.logWarning(msg); - kukit.commandsGlobalRegistry.registerFromAction(srcname, factory, name); -}; - /* Command factories */ cr.makeCommand = function(selector, name, type, parms, transport) { Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js Sun Dec 28 22:50:13 2008 @@ -79,7 +79,7 @@ namespacedEventNames.push(eventName); // register the event informataion var events = kukit.registrars.events; - events.getItemFactory(eventName).register({ + events.register(eventName, { defaultActionMethodName: defaultActionMethodName, parmTypes: null // missing from this api. }); @@ -88,7 +88,7 @@ // This will specify the set of events that will be bound together, // with the specified iterator var bindsequences = kukit.registrars.bindsequences; - bindsequences.getItemFactory('').register({ + bindsequences.register({ eventNames: namespacedEventNames, iterName: iterName, binderClass: binderClass, Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js Sun Dec 28 22:50:13 2008 @@ -44,7 +44,7 @@ } // Always use the global plugins to get the descriptor. var registry = kukit.registrars[this.name]; - registry.getItemFactory(name).register({providerClass: func, + registry.register(name, {providerClass: func, returnType: returnType}); }; this.initialize.apply(this, arguments); Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js Sun Dec 28 22:50:13 2008 @@ -59,24 +59,16 @@ this.initialize = function(registryName, FactoryClass) { this.registryName = registryName; this.built = false; + this.configs = {}; this.factories = {}; this.FactoryClass = FactoryClass; }; - this.getItemFactory = function(name) { - // create the attribute on demand - var factory = this.factories[name]; - if (typeof(factory) == 'undefined') { - // Use the registry in the instance, to look up the MethodDescriptor class - // for this method name - // - // instantiate the factory - factory = this.factories[name] = new this.FactoryClass(this, name); - } - return factory; + this.get = function(name) { + return this.configs[name]; }; - this.buildRegistry = function() { + this.checkBuilt = function() { if (this.built) { ;;; kukit.E = 'Registry ['; ;;; kukit.E += this.registryName + '] already built !'; @@ -84,17 +76,12 @@ } ;;; kukit.E = 'Building registry [' + this.registryName + ']'; ;;; kukit.logDebug(kukit.E); - var registry = {}; - for (var name in this.factories) { - var factory = this.factories[name]; - var item = factory.create(); - if (typeof(item) != 'undefined') { - // Set the item on the registry - registry[name] = item; - }; - }; this.built = true; - return registry; + }; + + this.buildRegistry = function() { + this.checkBuilt(); + return this.configs; }; this.initialize.apply(this, arguments); @@ -103,84 +90,117 @@ /* - * KSS service layer resource - */ - -reg.ServiceFactory = function() { + * + * class PluginRegistrar + * + * + */ - this.initialize = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.sources = {}; - this.preferredsources = null; +reg.PluginRegistrar = function() { + + this.register = function(name, config) { + if (typeof(this.get(name)) != 'undefined') { +;;; kukit.E = 'Double registration of plugin [' + name; +;;; kukit.E += '] in registry [' + this.registryName + ']'; + throw new Error(kukit.E); + } + this.configs[name] = config; }; -;;; this._makeError = function(componentName, name) { -;;; kukit.E = 'In a call to ' + componentName + ', '; -;;; kukit.E += name + ' must be provided for method ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + ']'; -;;; return new Error(kukit.E); -;;; }; + this.initialize.apply(this, arguments); - this.require = function(config) { -;;; // Diagnose if parameters are all right. -;;; if (! config.preferredSources) { -;;; throw this._makeError('ServiceFactory.require', 'config.getter'); -;;; }; - if (this.preferredSources) { -;;; kukit.E = 'ServiceFactory.require is called twice on ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + ']'; +}; +reg.PluginRegistrar.prototype = new reg.Registrar(); +/* end PluginRegistrar */ + +/* + * + * class BindSequenceRegistrar + * + * + */ + +reg.BindSequenceRegistrar = function() { + + this.register = function(config) { + // This is called on any method descriptors, + // i.e. this is a "class method". + // Register config to all event names individually. + // Take names from the config. + for (var i = 0; i < config.eventNames.length; i++) { + var name = config.eventNames[i]; + this._register(name, config); + } + }; + + this._register = function(name, config) { + if (typeof(this.get(name)) != 'undefined') { +;;; kukit.E = 'Double registration of plugin [' + name; +;;; kukit.E += '] in registry [' + this.registryName + ']'; throw new Error(kukit.E); - }; - this.preferredSources = config.preferredSources; - this.checker = config.checker; - this.fallbackProvider = config.fallbackProvider; + } + kukit.logDebug('Register bind sequence [' + name + ']'); + // check the iterator. +;;; if (! kukit.er.getBindIterator(config.iterName)) { +;;; kukit.E = 'In BindSequenceFactory.register: unknown bind strategy ['; +;;; kukit.E += config.iterName + '].'; +;;; throw new Error(kukit.E); +;;; } + // Decorate binder class. + kukit.er.decorateEventBinderClass(config.binderClass); + + this.configs[name] = config; }; - this.provide = function(config) { -;;; // Diagnose if parameters are all right. -;;; var componentName = 'ServiceFactory.provide'; -;;; if (! config.getter) { -;;; throw this._makeError(componentName, 'config.getter'); -;;; } -;;; if (! config.sourceName) { -;;; throw this._makeError(componentName, 'config.sourceName'); -;;; } -;;; if (! config.sourceVersion) { -;;; throw this._makeError(componentName, 'config.sourceVersion'); -;;; } - if (this.registrar.built) { -;;; kukit.E = 'Attempt to provide implementation to method ['; -;;; kukit.E += this.methodName + '] on already finalized registry ['; -;;; kukit.E += this.registrar.registryName + ']'; - throw new Error(kukit.E); - } else if (typeof(this.sources[config.sourceName]) != 'undefined') { -;;; kukit.E = 'Double registration by [' + config.sourceName + ']['; -;;; kukit.E += providerVersion; -;;; kukit.E += '] of method [' + this.name; -;;; kukit.E += '] in registry [' + this.registrar.registryName + ']'; + this.initialize.apply(this, arguments); + +}; +reg.BindSequenceRegistrar.prototype = new reg.Registrar(); +/* end BindSequenceRegistrar */ + + +/* + * + * class ServiceRegistrar + * + * + */ + +reg.ServiceRegistrar = function() { + + this.register = function(name) { + if (typeof(this.get(name)) != 'undefined') { +;;; kukit.E = 'Double registration of service [' + name; +;;; kukit.E += '] in registry [' + this.registryName + ']'; throw new Error(kukit.E); } - // Store the config - config.methodName = this.name; - this.sources[config.sourceName] = config; + + this.configs[name] = new reg.ServiceConfig(name); + return this.configs[name]; }; - this.create = function() { + this.buildRegistry = function() { + this.checkBuilt(); + var registry = {}; + for (var name in this.configs) { + var config = this.configs[name]; + registry[name] = this.createService(config); + }; + return registry; + }; + + this.createService = function(config) { var func; - if (! this.preferredSources) { -;;; kukit.E = 'Undefined method ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + '], '; -;;; kukit.E += 'but the following were provided:'; -;;; kukit.E += this.sources + ']'; + if (! config.preferredSources) { +;;; kukit.E = 'Method ['; +;;; kukit.E += config.name + '] did not specify its preferred sources'; +;;; kukit.E += 'even though sources were provided:'; +;;; kukit.E += config.sources + ']'; throw new Error(kukit.E); } // loop through all preferred providers - for (var i = 0; i < this.preferredSources.length; i++) { - var item = this.sources[this.preferredSources[i]]; + for (var i = 0; i < config.preferredSources.length; i++) { + var item = config.sources[config.preferredSources[i]]; // Did we have an item? if (typeof(item) == 'undefined') { continue; @@ -196,24 +216,23 @@ } if (! func) { // We raise an error. -;;; kukit.E = 'Could not bind item ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName; -;;; kukit.E += '], because no provider found '; -;;; kukit.E += 'of the following preferences: ['; -;;; kukit.E += this.preferredSources + ']'; +;;; kukit.E = 'Cannot build item ['; +;;; kukit.E += config.name + ']'; +;;; kukit.E += 'because we found no provider '; +;;; kukit.E += 'complying to the following preferences: ['; +;;; kukit.E += config.preferredSources + ']'; throw new Error(kukit.E); } else { // We found the func that we can finalize now. ;;; var msg = 'Using method ['; -;;; msg += this.name + '] from source ['; +;;; msg += config.name + '] from source ['; ;;; msg += item.sourceName + '] version ['; ;;; msg += item.sourceVersion + '].'; ;;; kukit.log(msg); // Return the func, optionally prefixed with a checker. - if (this.checker) { + if (config.checker) { // if there is a checker, merge them together - var self = this; + var self = config; return function() { self.checker.apply(null, arguments); return func.apply(null, arguments); @@ -224,104 +243,78 @@ } } }; - this.initialize.apply(this, arguments); -}; /* end ServiceFactory */ - +}; +reg.ServiceRegistrar.prototype = new reg.Registrar(); +/* end ServiceRegistrar */ /* - * KSS plugin registry + * KSS service layer resource */ -reg.PluginFactory = function() { +reg.ServiceConfig = function() { - this.initialize = function(registrar, name) { - this.registrar = registrar; + this.initialize = function(name) { this.name = name; - this.config = undefined; - }; - - this.register = function(config) { - if (typeof(this.config) != 'undefined') { -;;; kukit.E = 'Double registration of plugin [' + this.name; -;;; kukit.E += '] in registry [' + this.registrar.registryName + ']'; - throw new Error(kukit.E); - } - this.config = config; - }; - - this.create = function() { - return this.config; + this.sources = {}; + this.preferredsources = null; + this.built = false; }; - this.initialize.apply(this, arguments); - -}; /* end PluginFactory */ - -/* - * BindSequenceFactory - * - * We need this factory because we need to - * register the binding of events. This is done by a binding - * class and a set of events that bind together on this - * class, and a binding strategy that defines how binding will - * be called. - * - * The event names arrive in a namespace format (dash-separated), - * formerly we only accepted to register an event set with events - * of the same namespace. This restriction is dropped now. Since it - * may make sense, it can be put back in form of asserts on the - * event names. - */ -reg.BindSequenceFactory = function() { - - this.initialize = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.config = null; - }; +;;; this._makeError = function(componentName, name) { +;;; kukit.E = 'In a call to ' + componentName + ', '; +;;; kukit.E += name + ' must be provided for method ['; +;;; kukit.E += this.name + '].'; +;;; return new Error(kukit.E); +;;; }; - this.register = function(config) { - // This is called on any method descriptors, - // i.e. this is a "class method". - // Register config to all event names individually. - // Take names from the config. - for (var i = 0; i < config.eventNames.length; i++) { - var name = config.eventNames[i]; - this.registrar.getItemFactory(name)._register(config); - } + this.require = function(config) { +;;; // Diagnose if parameters are all right. +;;; if (! config.preferredSources) { +;;; throw this._makeError('ServiceConfig.require', 'config.preferredSources'); +;;; }; + if (this.preferredSources) { +;;; kukit.E = 'ServiceConfig.require is called twice on ['; +;;; kukit.E += this.name + '].'; + throw new Error(kukit.E); + }; + this.preferredSources = config.preferredSources; + this.checker = config.checker; + this.fallbackProvider = config.fallbackProvider; }; - this._register = function(config) { - if (this.config != null) { -;;; kukit.E = 'Double registration of item [' + this.name; -;;; kukit.E += '] in plugin registry [' + this.registrar.registryName + ']'; + this.provide = function(config) { +;;; // Diagnose if parameters are all right. +;;; var componentName = 'ServiceConfig.provide'; +;;; if (! config.getter) { +;;; throw this._makeError(componentName, 'config.getter'); +;;; } +;;; if (! config.sourceName) { +;;; throw this._makeError(componentName, 'config.sourceName'); +;;; } +;;; if (! config.sourceVersion) { +;;; throw this._makeError(componentName, 'config.sourceVersion'); +;;; } + if (this.built) { +;;; kukit.E = 'Attempt to provide implementation to method ['; +;;; kukit.E += this.methodName + '] on already built registry.'; + throw new Error(kukit.E); + } else if (typeof(this.sources[config.sourceName]) != 'undefined') { +;;; kukit.E = 'Double registration by [' + config.sourceName + ']['; +;;; kukit.E += providerVersion; +;;; kukit.E += '] of method [' + this.name + '].'; throw new Error(kukit.E); } - // Do some diagnostics // check the iterator. -;;; if (! kukit.er.getBindIterator(config.iterName)) { -;;; kukit.E = 'In BindSequenceFactory.register: unknown bind strategy ['; -;;; kukit.E += config.iterName + '].'; -;;; throw new Error(kukit.E); -;;; } - - // Decorate binder class. - kukit.er.decorateEventBinderClass(config.binderClass); - - // store the config - this.config = config; - + // Store the config + config.methodName = this.name; + this.sources[config.sourceName] = config; }; - this.create = function() { - // Just return the registered value. - return this.config; - }; this.initialize.apply(this, arguments); -}; /* end BindSequenceFactory */ +}; /* end ServiceConfig */ /* * Global handling of registries in kukit @@ -365,11 +358,11 @@ reg.setupGlobalRegistries = function() { // instantiate registries kukit.registrars = {}; - kukit.registrars.events = new reg.Registrar('events', this.PluginFactory) - kukit.registrars.bindsequences = new reg.Registrar('bindsequences', this.BindSequenceFactory) - kukit.registrars.actions = new reg.Registrar('actions', this.PluginFactory) - kukit.registrars.valueproviders = new reg.Registrar('valueproviders', this.PluginFactory) - kukit.registrars.services = new reg.Registrar('services', this.ServiceFactory) + kukit.registrars.events = new reg.PluginRegistrar('events') + kukit.registrars.bindsequences = new reg.BindSequenceRegistrar('bindsequences') + kukit.registrars.actions = new reg.PluginRegistrar('actions') + kukit.registrars.valueproviders = new reg.PluginRegistrar('valueproviders') + kukit.registrars.services = new reg.ServiceRegistrar('services') }; // Finalize global registries @@ -428,16 +421,15 @@ var itemName = item[1]; var config = item[2]; var registrar = registries[itemType]; - var factory = registrar.getItemFactory(itemName); ;;; // Check that we are in a plugin registry. ;;; // It must have a register method. -;;; if (typeof(factory.register) == 'undefined') { +;;; if (typeof(registrar.register) == 'undefined') { ;;; kukit.E = 'Bad registry name in registerPlugins call ['; ;;; kukit.E += itemType + '], it is not a valid plugin registry.'; ;;; throw new Error(kukit.E); ;;; } // Register it. - factory.register(config); + registrar.register(itemName, config); } }; Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js Sun Dec 28 22:50:13 2008 @@ -85,7 +85,7 @@ }; var registrar = kukit.registrars.valueproviders; -registrar.getItemFactory('passnode').register({ +registrar.register('passnode', { providerClass: sr.PassnodePP, returnType: 'selection'}); // the item now will contain providerClass only, @@ -114,9 +114,9 @@ ;;; throw new Error(kukit.E); ;;; } // Also register the selector param provider - var registrar = kukit.registrars.valueproviders; var providerClass = sr.makeAnySelectorProvider(selectorFunc); - registrar.getItemFactory(name).register({ + var registrar = kukit.registrars.valueproviders; + registrar.register(name, { providerClass: providerClass, selectorFunc: selectorFunc, returnType: 'selection'}); Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js Sun Dec 28 22:50:13 2008 @@ -9,7 +9,9 @@ // kukit's preferences to choose between sources // that implement a given functionality. -services.getItemFactory('cssQuery').require({ +var cssQuery = services.register('cssQuery'); + +cssQuery.require({ preferredSources: ['base2', 'base2-legacy', 'cssQuery'], // a parameter checker common for each implementation checker: function(selector, inNodes) { @@ -24,7 +26,7 @@ // that we can detect ourselves. by inspecting if a given // library is loaded. -services.getItemFactory('cssQuery').provide({ +cssQuery.provide({ sourceName:'cssQuery', sourceVersion: '2.0.2', getter: function() { @@ -53,7 +55,7 @@ return results; }; -services.getItemFactory('cssQuery').provide({ +cssQuery.provide({ sourceName: 'base2-legacy', sourceVersion: '<<20020070816', getter: function() { @@ -73,7 +75,7 @@ }; }}); -services.getItemFactory('cssQuery').provide({ +cssQuery.provide({ sourceName: 'base2', sourceVersion: '0.??', getter: function() { Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/runtests.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/runtests.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/runtests.js Sun Dec 28 22:50:13 2008 @@ -25,7 +25,6 @@ testsuite.registerTest(kukit.KssParserSelectorsTestCase); testsuite.registerTest(kukit.KssParserValueProvidersCheckTestCase); testsuite.registerTest(kukit.KssParserSelectorTestCase); - testsuite.registerTest(kukit.RegistriesTestCase); testsuite.registerTest(kukit.ServiceRegistryTestCase); testsuite.registerTest(kukit.PluginRegistriesTestCase); testsuite.registerTest(kukit.ErrorsTestCase); Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js ============================================================================== --- kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js (original) +++ kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js Sun Dec 28 22:50:13 2008 @@ -21,78 +21,6 @@ var kukit = {}; } -kukit.RegistriesTestCase = function() { - this.name = 'kukit.RegistriesTestCase'; - - var called = []; - - var TestFactory = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.doThis = function() { - called.push("doThis"); - } - this.doThat = function() { - called.push("doThat"); - } - this.create = function() { - var signature = "FUNC " + this.name; - called.push(signature); - return signature; - } - }; - - this.setUp = function() { - // work with our own object, not interfering - // with global object setup in registries.js - this.registrars = {}; - this.registries = {}; - }; - - this.testRegistries = function() { - // We can create a simple method descriptor for an registry we want. - // The method descriptor is managing the method's registration state - called = []; - var registrar = new kukit.reg.Registrar('dummytest', TestFactory); - this.assert(typeof(registrar), 'object'); - // Let's get two items - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - // Ok. Now get the descriptors again... - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - }; - - this.testFinalizeRegistries = function() { - // We have a singleton, called s. - var s = {}; - // We eill create a simple item for a selected registry. - // The factory is managing the item's registration state - called = []; - var registrar = new kukit.reg.Registrar('dummytest', TestFactory); - // Let's get two factories - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - this.dummytest = registrar.buildRegistry(); - this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']); - called = []; - // At the same time it also set up these on the class prototype. - this.assertEquals(this.dummytest.fooItem, 'FUNC fooItem'); - this.assertEquals(this.dummytest.barItem, 'FUNC barItem'); - }; - -}; /* end RegistriesTestCase */ -kukit.RegistriesTestCase.prototype = new kukit.UtilsTestCaseBase(); - - kukit.ServiceRegistryTestCase = function() { this.name = 'kukit.ServiceRegistryTestCase'; @@ -101,7 +29,7 @@ // kukit.service or kukit.plugins. this.registries = {}; this.registrars = {} - this.registrars.dummyservice = new kukit.reg.Registrar('dummyservice', kukit.reg.ServiceFactory); + this.registrars.dummyservice = new kukit.reg.ServiceRegistrar('dummyservice'); }; this.testServiceRegistry = function() { @@ -109,39 +37,43 @@ var s = {}; var registrar = this.registrars.dummyservice; // Requires four methods, thie defines their necessity and preferred providers - registrar.getItemFactory('first').require({ + var first = registrar.register('first'); + first.require({ preferredSources: ['corelib', 'extralib']}); - registrar.getItemFactory('second').require({ + var second = registrar.register('second'); + second.require({ preferredSources: ['extralib', 'corelib']}); - registrar.getItemFactory('third').require({ + var third = registrar.register('third'); + third.require({ preferredSources: ['corelib']}); - registrar.getItemFactory('fourth').require({ + var fourth = registrar.register('fourth'); + fourth.require({ preferredSources: ['extralib']}); // // somewhere else, source "corelib" provides the methods: - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); - registrar.getItemFactory('second').provide({ + second.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'second/core';}}}); - registrar.getItemFactory('third').provide({ + third.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'third/core';}}}); // // somewhere else, source "extras" provides the methods: - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'first/extra';}}}); - registrar.getItemFactory('second').provide({ + second.provide({ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'second/extra';}}}); - registrar.getItemFactory('fourth').provide({ + fourth.provide({ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'fourth/extra';}}}); @@ -161,18 +93,19 @@ // and a counter for the checker var checker_counter = 0; // Define three methods - registrar.getItemFactory('first').require({ + var first = registrar.register('first'); + first.require({ preferredSources: ['corelib', 'extralib'], checker: function() {checker_counter++;}}); // // somewhere else, core provides the methods: - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); // // somewhere else, extras provides the methods: - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'extralib', sourceVersion: '12.4', getter: function() {return function() {return 'first/extra';}}}); @@ -189,13 +122,14 @@ // We have a singleton, called s. var s = {}; var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Provide the method first - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); // Define the method later - registrar.getItemFactory('first').require({ + first.require({ preferredSources: ['corelib', 'extralib']}); this.dummyservice = registrar.buildRegistry(); // We can call the methods on it, @@ -206,13 +140,14 @@ // A registrar can only be built once. var s = {}; var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Provide the method first - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); // Define the method later - registrar.getItemFactory('first').require({ + first.require({ preferredSources: ['corelib', 'extralib']}); registrar.buildRegistry(); this.assertThrows(function() { @@ -225,8 +160,9 @@ // A method is provided but not required. var s = {}; var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Provide the method first - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); @@ -239,14 +175,15 @@ this.testDoubleProvided = function() { // A method cannot be provided twice by the same source. var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Provide the method first - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); // Now provide it for the second time. this.assertThrows(function() { - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'corelib', sourceVersion: '1.1', getter: function() {return function() {return 'first/core';}}}); @@ -257,12 +194,13 @@ this.testDoubleDefined = function() { // A method can only be required once. var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Define the method first - registrar.getItemFactory('first').require({ + first.require({ preferredSources: ['corelib', 'extralib']}); // require it again. this.assertThrows(function() { - registrar.getItemFactory('first').require({ + first.require({ preferredSources: ['corelib', 'extralib']})}, Error); }; @@ -271,11 +209,12 @@ // No preferred provider can be found for a method. var s = {}; var registrar = this.registrars.dummyservice; + var first = registrar.register('first'); // Define the method first - registrar.getItemFactory('first').require({ + first.require({ preferredSources: ['corelib', 'extralib']}); // Someone provides the method, but it's not good. - registrar.getItemFactory('first').provide({ + first.provide({ sourceName: 'craplib', sourceVersion: '1.1', getter: function() {return function() {return 'first/crap';}}}); @@ -297,8 +236,8 @@ // kukit.plugins this.registries = {}; this.registrars = {} - this.registrars.dummyevents = new kukit.reg.Registrar('dummyevents', kukit.reg.PluginFactory); - this.registrars.dummybindsequences = new kukit.reg.Registrar('dummybindsequences', kukit.reg.BindSequenceFactory); + this.registrars.dummyevents = new kukit.reg.PluginRegistrar('dummyevents'); + this.registrars.dummybindsequences = new kukit.reg.BindSequenceRegistrar('dummybindsequences'); }; var M = function() { @@ -308,19 +247,19 @@ var events = this.registrars.dummyevents; var bindsequences = this.registrars.dummybindsequences; // somewhere else, core registers the items: - events.getItemFactory('click').register({ + events.register('click', { name: 'click', defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - events.getItemFactory('keydown').register({ + events.register('keydown', { name: 'keydown', defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - bindsequences.getItemFactory('').register({ + bindsequences.register({ eventNames: ['click', 'keydown'], iterName: 'Each', binderClass: M, @@ -328,7 +267,7 @@ //*/ // // somewhere else, extras registers the items: - events.getItemFactory('timeout').register({ + events.register('timeout', { name: 'timeout', defaultActionMethodName: null, parmtypes: [ @@ -336,7 +275,7 @@ ['renew', 'bool', false]]}); // It needs a bind iterator even though it is a single // sequence. - bindsequences.getItemFactory('').register({ + bindsequences.register({ eventNames: ['timeout'], iterName: 'Each', binderClass: M, @@ -355,7 +294,7 @@ var events = this.registrars.dummyevents; var bindsequences = this.registrars.dummybindsequences; // somewhere a plugin registers an item: - events.getItemFactory('click').register({ + events.register('click', { name: 'click', defaultActionMethodName: null, parmtypes: [ @@ -363,7 +302,7 @@ ['allowBubbling', 'bool', false]]}); // But another registration attempt is harshly punished by an Error. this.assertThrows(function() { - events.getItemFactory('click').register({ + events.register('click', { name: 'click', defaultActionMethodName: null, parmtypes: [ @@ -379,7 +318,7 @@ var bindsequences = this.registrars.dummybindsequences; // somewhere else, core registers the items. // XXX registry name '' is used to call registry level methods - bindsequences.getItemFactory('').register({ + bindsequences.register({ eventNames: ['click', 'timeout'], iterName: 'Each', binderClass: M, @@ -392,7 +331,7 @@ this.bind2 = function(oper) {}; }; MSub.prototype = new M(); - bindsequences.getItemFactory('').register({ + bindsequences.register({ eventNames: ['keydown', 'keypress'], iterName: 'Each', binderClass: MSub, @@ -410,19 +349,6 @@ this.assertNotEquals(M.prototype.__className__, MSub.prototype.__className__); }; - this.testOnlyRegisteredPluginsCanBeBuilt = function() { - // We assure that if an item is produced but it is not registered, - // it will not be built on the configuration. - var events = this.registrars.dummyevents; - var bindsequences = this.registrars.dummybindsequences; - // Just call up the factoryr: this will create it with config=null. - events.getItemFactory('click'); - this.dummyevents = events.buildRegistry(); - // Check that click is not defined at all. (in particular, it should not be null or {}.) - // Since other code that uses it, depends that if it has a value, it is the real config. - this.assertEquals(typeof(this.dummyevents.click), 'undefined'); - }; - this.testRegisterPlugins = function() { // Test registerPlugins method. // @@ -507,7 +433,6 @@ kukit.PluginRegistriesTestCase.prototype = new kukit.UtilsTestCaseBase(); if (typeof(testcase_registry) != 'undefined') { - testcase_registry.registerTestCase(kukit.RegistriesTestCase, 'kukit.RegistriesTestCase'); testcase_registry.registerTestCase(kukit.ServiceRegistryTestCase, 'kukit.ServiceRegistryTestCase'); testcase_registry.registerTestCase(kukit.PluginRegistriesTestCase, 'kukit.PluginRegistriesTestCase'); }