From gotcha at codespeak.net Sat Dec 1 01:24:24 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 1 Dec 2007 01:24:24 +0100 (CET) Subject: [KSS-checkins] r49235 - in kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo: coreplugin selenium_tests Message-ID: <20071201002424.844F7822C@code0.codespeak.net> Author: gotcha Date: Sat Dec 1 01:24:22 2007 New Revision: 49235 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html Log: improve logging mechanism in order to reuse it in other demos Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss Sat Dec 1 01:24:22 2007 @@ -2,18 +2,18 @@ evt-click-allowbubbling: true; evt-click-preventdefault: true; action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #logEnd; + deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #logEnd; + insertHTMLBefore-kssSelector: #log-end; insertHTMLBefore-html: "containing DIV.

"; } #bubbling-node:click { evt-click-preventdefault: true; action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #logEnd; + deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #logEnd; + insertHTMLBefore-kssSelector: #log-end; insertHTMLBefore-html: "bubbling P.

"; } @@ -21,9 +21,16 @@ evt-click-preventdefault: true; evt-click-preventbubbling: true; action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #logEnd; + deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #logEnd; + insertHTMLBefore-kssSelector: #log-end; insertHTMLBefore-html: "not bubbling P.

"; } +#log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "

"; +} Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt Sat Dec 1 01:24:22 2007 @@ -41,10 +41,11 @@

Log

-

You clicked

+

Reset log

+

You clicked :

-

+

Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html Sat Dec 1 01:24:22 2007 @@ -20,33 +20,63 @@ clickAt - css=div#parent-node + parent-node assertText - css=#logger + logger containing DIV. clickAt - css=p#bubbling-node + log-reset assertText logger - containing DIV. bubbling P. containing DIV. + clickAt - css=p#not-bubbling-node + bubbling-node assertText - css=#logger - containing DIV. bubbling P. containing DIV. not bubbling P. + logger + bubbling P. containing DIV. + + + clickAt + log-reset + + + + assertText + logger + + + + clickAt + not-bubbling-node + + + + assertText + logger + not bubbling P. + + + clickAt + log-reset + + + + assertText + logger + From gotcha at codespeak.net Sat Dec 1 01:24:45 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 1 Dec 2007 01:24:45 +0100 (CET) Subject: [KSS-checkins] r49236 - kukit/kss.demo/trunk/kss/demo/browser Message-ID: <20071201002445.8C9608233@code0.codespeak.net> Author: gotcha Date: Sat Dec 1 01:24:45 2007 New Revision: 49236 Modified: kukit/kss.demo/trunk/kss/demo/browser/demo.css Log: some cosmetics Modified: kukit/kss.demo/trunk/kss/demo/browser/demo.css ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/demo.css (original) +++ kukit/kss.demo/trunk/kss/demo/browser/demo.css Sat Dec 1 01:24:45 2007 @@ -14,7 +14,7 @@ font-size: 80%; } -#global-links ul { +#global-links ul, #log-reset { display: table-row; } @@ -22,7 +22,7 @@ display: table-cell; } -#global-links a { +#global-links a, #log-reset a { display: block; padding: 0.25em; margin: 0.25em; From reebalazs at codespeak.net Sat Dec 1 13:28:04 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sat, 1 Dec 2007 13:28:04 +0100 (CET) Subject: [KSS-checkins] r49244 - in kukit/kss.zope/trunk/kss/zope/concatresource: . compression Message-ID: <20071201122804.71CC18193@code0.codespeak.net> Author: reebalazs Date: Sat Dec 1 13:28:03 2007 New Revision: 49244 Removed: kukit/kss.zope/trunk/kss/zope/concatresource/compression/ Modified: kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py Log: Reuse a little bit more from kss.base. Modified: kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py (original) +++ kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py Sat Dec 1 13:28:03 2007 @@ -9,7 +9,7 @@ from zope.interface import implements from interfaces import IContextFile from fileresource import File -from compression import compress +from kss.base.compression.javascript import compress import time import zope.component as capi from kss.zope.interfaces import IKSSPluginRegistry @@ -53,17 +53,17 @@ def getContents(self): fileslist = self.getFilesList() - assert fileslist, 'Must contain at least one resource.' - result = fileslist[0].getContents() - content_type = result['content_type'] - data = [result['data']] - for subres in fileslist[1:]: + # concatenate the data + data = [] + # We only handle javascript now. + content_type = 'application/x-javascript' + for subres in fileslist: d = subres.getContents() - # all elements must have the same content type. assert d['content_type'] == content_type data.append(d['data']) - result['data'] = '\n'.join(data) - result['compress_level'] = self.compress_level - # Do compression on the result - result['data'] = compress(**result) + # Do javascript compression on the result. + result = dict( + data = compress( '\n'.join(data), self.compress_level), + content_type = content_type, + ) return result From reebalazs at codespeak.net Sat Dec 1 13:28:41 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sat, 1 Dec 2007 13:28:41 +0100 (CET) Subject: [KSS-checkins] r49245 - kukit/kss.zope/trunk/kss/zope/concatresource Message-ID: <20071201122841.1233E8195@code0.codespeak.net> Author: reebalazs Date: Sat Dec 1 13:28:40 2007 New Revision: 49245 Modified: kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py Log: add comment Modified: kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py (original) +++ kukit/kss.zope/trunk/kss/zope/concatresource/concatfileresource.py Sat Dec 1 13:28:40 2007 @@ -59,6 +59,7 @@ content_type = 'application/x-javascript' for subres in fileslist: d = subres.getContents() + # Sub resources must be of the same content type. assert d['content_type'] == content_type data.append(d['data']) # Do javascript compression on the result. From jvloothuis at codespeak.net Sun Dec 2 09:12:02 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 2 Dec 2007 09:12:02 +0100 (CET) Subject: [KSS-checkins] r49262 - in kukit/kss.core/trunk/kss/core/plugins/core/demo: parameterfunction selenium_tests Message-ID: <20071202081202.F29038166@code0.codespeak.net> Author: jvloothuis Date: Sun Dec 2 09:12:02 2007 New Revision: 49262 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/forms.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/pf_forms.html Log: Added an explicit test for multi selection fields. This proves that these work as they should when submitting a full form. To prove this the server side handler returns a sorted list of (key, value) tuples (not a dict since the ordering of that might change between test runs). Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/forms.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/forms.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/forms.pt Sun Dec 2 09:12:02 2007 @@ -182,7 +182,7 @@
Click the button.
- Click me ! + Click me !
value1:
+ listval with multiselect: + recordval: Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py Sun Dec 2 09:12:02 2007 @@ -19,4 +19,5 @@ def submitFullFormIntoRequest(self): # marshall back the repr of this dict. ksscore = self.getCommandSet('core') - ksscore.replaceInnerHTML('#target', repr(self.request.form)) + ksscore.replaceInnerHTML('#target', repr(list(sorted( + self.request.form.items())))) Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/pf_forms.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/pf_forms.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/pf_forms.html Sun Dec 2 09:12:02 2007 @@ -113,6 +113,21 @@ target radio-2 + + click + fullform-current + + + + waitForText + target + [('listval', ['listval1', 'listval2']), ('multiple-select', ['Value 1', 'Value 3']), ('recordsval', [{'a': 'recordval_a_1', 'b': 'recordval_b_1'}, {'a': 'recordval_a_2', 'b': 'recordval_b_2'}]), ('recordval', {'a': 'recordval_a', 'b': 'recordval_b'}), ('value1', 'value1'), ('value2', 'value2')] + + + verifyTextPresent + [('listval', ['listval1', 'listval2']), ('multiple-select', ['Value 1', 'Value 3']), ('recordsval', [{'a': 'recordval_a_1', 'b': 'recordval_b_1'}, {'a': 'recordval_a_2', 'b': 'recordval_b_2'}]), ('recordval', {'a': 'recordval_a', 'b': 'recordval_b'}), ('value1', 'value1'), ('value2', 'value2')] + + From reebalazs at codespeak.net Sun Dec 2 12:53:05 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 12:53:05 +0100 (CET) Subject: [KSS-checkins] r49270 - kukit/kss.zope/trunk/kss/zope Message-ID: <20071202115305.84D998173@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 12:53:05 2007 New Revision: 49270 Modified: kukit/kss.zope/trunk/kss/zope/interfaces.py kukit/kss.zope/trunk/kss/zope/registry.txt Log: Add lookup_selector method to interface, and test Modified: kukit/kss.zope/trunk/kss/zope/interfaces.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/interfaces.py (original) +++ kukit/kss.zope/trunk/kss/zope/interfaces.py Sun Dec 2 12:53:05 2007 @@ -41,6 +41,12 @@ def lookup_commandset(id): '''Return a commandset class for the given id''' + def lookup_selector(id): + '''Return a selector class for the given id. + + Id must follow the namespace-name format, if not in the core. + ''' + class ICommandSet(Interface): 'Methods of this class implement a command set' Modified: kukit/kss.zope/trunk/kss/zope/registry.txt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.txt (original) +++ kukit/kss.zope/trunk/kss/zope/registry.txt Sun Dec 2 12:53:05 2007 @@ -30,6 +30,12 @@ >>> list(registry.plugins()) [('kss-core', )] +Javascript +---------- + +We can also query the javascript for the plugins, both the actual plugin +code, and extra dependencies: + >>> list(registry.javascripts()) ['.../kukit/utils.js', '.../kukit/errors.js', ...] @@ -37,6 +43,10 @@ >>> list(registry.extra_javascripts()) ['.../3rd_party/base2-dom-fp.js', '.../3rd_party/sarissa.js'] + +Commandsets +----------- + The registry can also be used to lookup a commandset. If a commandset is requested which is not available we will get a KeyError. @@ -53,6 +63,14 @@ As you can see it returns a factory (in this case the class) for the commandset. +Selectors +--------- + +A given selector class can be queried as well: + + >>> registry.lookup_selector('css') + + BBB === From jvloothuis at codespeak.net Sun Dec 2 13:41:57 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 2 Dec 2007 13:41:57 +0100 (CET) Subject: [KSS-checkins] r49275 - kukit/kss.base/trunk/kss/base Message-ID: <20071202124157.676748164@code0.codespeak.net> Author: jvloothuis Date: Sun Dec 2 13:41:57 2007 New Revision: 49275 Removed: kukit/kss.base/trunk/kss/base/coreselectors.py Modified: kukit/kss.base/trunk/kss/base/__init__.py kukit/kss.base/trunk/kss/base/commands.py kukit/kss.base/trunk/kss/base/commands.txt kukit/kss.base/trunk/kss/base/config.py kukit/kss.base/trunk/kss/base/corecommands.txt kukit/kss.base/trunk/kss/base/plugin.py kukit/kss.base/trunk/kss/base/plugin.txt kukit/kss.base/trunk/kss/base/registry.py kukit/kss.base/trunk/kss/base/selectors.py kukit/kss.base/trunk/kss/base/selectors.txt Log: Changed the selector registration so that it now supports namespaces for selectors. It still has the shortcuts for the core selectors so this change only affects plugin writers. Modified: kukit/kss.base/trunk/kss/base/__init__.py ============================================================================== --- kukit/kss.base/trunk/kss/base/__init__.py (original) +++ kukit/kss.base/trunk/kss/base/__init__.py Sun Dec 2 13:41:57 2007 @@ -1,2 +1,3 @@ from kss.base.commands import KSSCommands +from kss.base.selectors import selectors from kss.base.plugin import load_plugins Modified: kukit/kss.base/trunk/kss/base/commands.py ============================================================================== --- kukit/kss.base/trunk/kss/base/commands.py (original) +++ kukit/kss.base/trunk/kss/base/commands.py Sun Dec 2 13:41:57 2007 @@ -1,7 +1,7 @@ from xml.sax.saxutils import quoteattr from kss.base.registry import command_set_registry from kss.base.selectors import Selector -from kss.base.coreselectors import css +from kss.base.selectors import css kss_response_header = ''' Modified: kukit/kss.base/trunk/kss/base/commands.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/commands.txt (original) +++ kukit/kss.base/trunk/kss/base/commands.txt Sun Dec 2 13:41:57 2007 @@ -22,7 +22,7 @@ also need to create a selector. In this case we will use the CSS selector. For more information about selectors look at the selector documentation. - >>> from kss.base.coreselectors import css + >>> from kss.base.selectors import css >>> commands.add('replaceHTML', css('#someid'), html='some value') Now we have added a command. The first argument is the name of the action Modified: kukit/kss.base/trunk/kss/base/config.py ============================================================================== --- kukit/kss.base/trunk/kss/base/config.py (original) +++ kukit/kss.base/trunk/kss/base/config.py Sun Dec 2 13:41:57 2007 @@ -2,7 +2,7 @@ from kss.base.plugin import Plugin from kss.base.corecommands import KSSCoreCommands -from kss.base.coreselectors import css, htmlid, samenode, parentnode +from kss.base.selectors import css, htmlid, samenode, parentnode kukit_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'kukit') @@ -46,5 +46,5 @@ 'core': KSSCoreCommands, } - selectors = [css, htmlid, samenode, parentnode] + selectors = {None: [css, htmlid, samenode, parentnode]} Modified: kukit/kss.base/trunk/kss/base/corecommands.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/corecommands.txt (original) +++ kukit/kss.base/trunk/kss/base/corecommands.txt Sun Dec 2 13:41:57 2007 @@ -9,7 +9,7 @@ >>> from kss.base.corecommands import KSSCoreCommands >>> from kss.base import KSSCommands - >>> from kss.base.coreselectors import css + >>> from kss.base.selectors import css >>> commands = KSSCommands() >>> core = KSSCoreCommands(commands) Deleted: /kukit/kss.base/trunk/kss/base/coreselectors.py ============================================================================== --- /kukit/kss.base/trunk/kss/base/coreselectors.py Sun Dec 2 13:41:57 2007 +++ (empty file) @@ -1,17 +0,0 @@ -from kss.base.selectors import Selector - -class css(Selector): - def __init__(self, value): - super(css, self).__init__('css', value) - -class htmlid(Selector): - def __init__(self, value): - super(htmlid, self).__init__('htmlid', value) - -class samenode(Selector): - def __init__(self): - super(samenode, self).__init__('samenode', '') - -class parentnode(Selector): - def __init__(self, value): - super(parentnode, self).__init__('parentnode', value) Modified: kukit/kss.base/trunk/kss/base/plugin.py ============================================================================== --- kukit/kss.base/trunk/kss/base/plugin.py (original) +++ kukit/kss.base/trunk/kss/base/plugin.py Sun Dec 2 13:41:57 2007 @@ -3,7 +3,7 @@ from pkg_resources import iter_entry_points from kss.base.registry import command_set_registry, plugin_registry -from kss.base import selectors as kss_selectors +from kss.base import selectors as selector_registry class Plugin(object): priority = 100 @@ -21,13 +21,22 @@ for name, commandset in self.commandsets.iteritems(): registry.unregister(name) + def _selectors(self): + for name, selectors in self.selectors.iteritems(): + for selector in selectors: + if name is None: + selector_id = selector.__name__ + else: + selector_id = name + '-' + selector.__name__ + yield selector_id, selector + def register_selectors(self): - for selector in self.selectors: - setattr(kss_selectors, selector.__name__, selector) + for id, selector in self._selectors(): + selector_registry.register(id, selector) def unregister_selectors(self): - for selector in self.selectors: - delattr(kss_selectors, selector.__name__) + for id, selector in self._selectors(): + selector_registry.unregister(id) def javascripts_from(path): Modified: kukit/kss.base/trunk/kss/base/plugin.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/plugin.txt (original) +++ kukit/kss.base/trunk/kss/base/plugin.txt Sun Dec 2 13:41:57 2007 @@ -26,7 +26,12 @@ >>> import kss.base >>> from kss.base.corecommands import KSSCoreCommands - >>> from kss.base.coreselectors import css + >>> from kss.base.selectors import Selector + + >>> class silly(Selector): + ... def __init__(self, value): + ... super(silly, self).__init__('example-silly', value) + >>> class ExamplePlugin(Plugin): ... javascripts = [file_below_module(kss.base, @@ -35,7 +40,7 @@ ... commandsets = { ... 'example': KSSCoreCommands, ... } - ... selectors = [css] + ... selectors = {'example': [silly]} As you can see from the lines above the registration has a few things in it. The first thing is registering the Javascripts. All items in @@ -47,8 +52,6 @@ identifiers and the command set factory. When using KSS you would normally use this identifier for the lookup of command sets. -We can also register additional selectors. - If we try the activate our plugin now it will not work. >>> kss.base.load_plugins('kss-testing') @@ -84,6 +87,15 @@ >>> tuple(activated_plugins()) (('kss-testing', ),) + +The additional selector we registered is now available in the selector +registry. It can be looked up based on the class name with the key +from the registrion as the namespace. + + >>> from kss.base import selectors + >>> print selectors['example-silly']('testing') + example-silly('testing') + Finally we will unregister our plugin to clean up. >>> from kss.base.plugin import unload_plugins Modified: kukit/kss.base/trunk/kss/base/registry.py ============================================================================== --- kukit/kss.base/trunk/kss/base/registry.py (original) +++ kukit/kss.base/trunk/kss/base/registry.py Sun Dec 2 13:41:57 2007 @@ -16,5 +16,7 @@ def items(self): return self._items.iteritems() + __getitem__ = get + command_set_registry = Registry() plugin_registry = Registry() Modified: kukit/kss.base/trunk/kss/base/selectors.py ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.py (original) +++ kukit/kss.base/trunk/kss/base/selectors.py Sun Dec 2 13:41:57 2007 @@ -1,3 +1,5 @@ +from kss.base.registry import Registry + class Selector(object): def __init__(self, type, value): self.type = type @@ -5,3 +7,22 @@ def __str__(self): return "%s('%s')" % (self.type, self.value) + +class css(Selector): + def __init__(self, value): + super(css, self).__init__('css', value) + +class htmlid(Selector): + def __init__(self, value): + super(htmlid, self).__init__('htmlid', value) + +class samenode(Selector): + def __init__(self): + super(samenode, self).__init__('samenode', '') + +class parentnode(Selector): + def __init__(self, value): + super(parentnode, self).__init__('parentnode', value) + + +selectors = Registry() Modified: kukit/kss.base/trunk/kss/base/selectors.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.txt (original) +++ kukit/kss.base/trunk/kss/base/selectors.txt Sun Dec 2 13:41:57 2007 @@ -24,7 +24,7 @@ In the core package you can find a few standard selectors. The most basic selectors are the CSS and HTML id selectors. - >>> from kss.base.coreselectors import css, htmlid + >>> from kss.base.selectors import css, htmlid They both need a value to operate on. @@ -44,7 +44,7 @@ in that it selects the same node that was used to call the server action. Also note that it does not accept any arguments. - >>> from kss.base.coreselectors import samenode + >>> from kss.base.selectors import samenode >>> selector = samenode() >>> selector.type 'samenode' @@ -55,7 +55,7 @@ query which only operates on nodes that are the parent (or grandparents). - >>> from kss.base.coreselectors import parentnode + >>> from kss.base.selectors import parentnode >>> selector = parentnode('a') >>> selector.type 'parentnode' From reebalazs at codespeak.net Sun Dec 2 15:42:37 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 15:42:37 +0100 (CET) Subject: [KSS-checkins] r49278 - kukit/kss.base/trunk/kss/base Message-ID: <20071202144237.3417380DA@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 15:42:34 2007 New Revision: 49278 Modified: kukit/kss.base/trunk/kss/base/plugin.txt kukit/kss.base/trunk/kss/base/selectors.py kukit/kss.base/trunk/kss/base/selectors.txt Log: Make selectors have a type on class Modified: kukit/kss.base/trunk/kss/base/plugin.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/plugin.txt (original) +++ kukit/kss.base/trunk/kss/base/plugin.txt Sun Dec 2 15:42:34 2007 @@ -29,8 +29,9 @@ >>> from kss.base.selectors import Selector >>> class silly(Selector): - ... def __init__(self, value): - ... super(silly, self).__init__('example-silly', value) + ... type = 'example-silly' + ... def __init__(self, value): + ... self.value = value >>> class ExamplePlugin(Plugin): Modified: kukit/kss.base/trunk/kss/base/selectors.py ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.py (original) +++ kukit/kss.base/trunk/kss/base/selectors.py Sun Dec 2 15:42:34 2007 @@ -1,28 +1,37 @@ from kss.base.registry import Registry class Selector(object): - def __init__(self, type, value): - self.type = type - self.value = value + """A base for selectors. Plugins that implement this, need + to implement __init__ themselves, and set type as a string. + Currently only the 'type' and 'value' attribute gets marshalled, + but this may change in later implementations. + """ + type = None + value = '' + def __init__(self): + raise Exception, 'Unimplemented' def __str__(self): return "%s('%s')" % (self.type, self.value) class css(Selector): + type = 'css' def __init__(self, value): - super(css, self).__init__('css', value) + self.value = value class htmlid(Selector): + type = 'htmlid' def __init__(self, value): - super(htmlid, self).__init__('htmlid', value) + self.value = value class samenode(Selector): + type = 'samenode' def __init__(self): - super(samenode, self).__init__('samenode', '') + pass class parentnode(Selector): + type = 'parentnode' def __init__(self, value): - super(parentnode, self).__init__('parentnode', value) - + self.value = value selectors = Registry() Modified: kukit/kss.base/trunk/kss/base/selectors.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.txt (original) +++ kukit/kss.base/trunk/kss/base/selectors.txt Sun Dec 2 15:42:34 2007 @@ -2,21 +2,27 @@ ========= The selector is responsible for finding the nodes on which to operate. -Selectors are executed on the client. They need a name and an optional -parameter. +Selectors are executed on the client. Most of them has a single parameter. A base class is provided for all selectors. >>> from kss.base.selectors import Selector - >>> selector = Selector('type', 'value') -The selector now has a type and value property. - - >>> selector.type - 'type' - - >>> selector.value - 'value' +The base class cannot be instantiated in itself. We will show later, +how a plugin can subclass it to create a new selector type and +register it. + + >>> Selector() + Traceback (most recent call last): + ... + Exception: Unimplemented + +XXX Jeroen, I removed the possibility for use an unregistered selector for +two reasons: +1. we need the type present on the class already. +2. There is no code that possibly could use it anyway, so nothing + could break for now. +XXX Please delete this part to acknowledge... Standard selectors ------------------ @@ -26,6 +32,13 @@ >>> from kss.base.selectors import css, htmlid +The selector classes have a type parameter defined on the class. + + >>> css.type + 'css' + >>> htmlid.type + 'htmlid' + They both need a value to operate on. >>> selector = css('div.main a') @@ -45,6 +58,8 @@ action. Also note that it does not accept any arguments. >>> from kss.base.selectors import samenode + >>> samenode.type + 'samenode' >>> selector = samenode() >>> selector.type 'samenode' @@ -56,12 +71,55 @@ grandparents). >>> from kss.base.selectors import parentnode + >>> parentnode.type + 'parentnode' >>> selector = parentnode('a') >>> selector.type 'parentnode' >>> selector.value 'a' +Selectors registered by plugins +------------------------------- + +Suppose a plugin registers a new selector. It must overwrite +type, and __init__ (if it needs to have a value parameter). +The type of the selector should always be in namespace-name +notation. Only the core selectors stand without a namespace. + + >>> from kss.base.selectors import Selector + >>> class MyFunkySelector(Selector): + ... type = 'mynamespace-funky' + ... def __init__(self, value): + ... self.value = value + +We will use this class to create selector instances. In real +life, the plugin would register this class now with the plugin +registry, and the commandset code would look up the class from +the registry. However, we test the registration somewhere +else, and just use the class as it is for now: + + >>> selector_class = MyFunkySelector + +Noe let's instantiate the selector: + + >>> selector = selector_class('Selector value') + +The selector now has a type and value property. + + >>> selector.type + 'mynamespace-funky' + + >>> selector.value + 'Selector value' + +XXX Implementation remark: + + Currently only the "value" property will be considered to + be marshalled to the client. So, selectors must have their + parameter stored as "value" for now. + + String representation --------------------- @@ -69,8 +127,8 @@ !TODO: Fix lower casing of string representation - >>> print Selector('type', 'value') - type('value') + >>> print MyFunkySelector('value') + mynamespace-funky('value') >>> print css('div.content') css('div.content') From reebalazs at codespeak.net Sun Dec 2 15:51:27 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 15:51:27 +0100 (CET) Subject: [KSS-checkins] r49279 - kukit/buildout/kss.zope Message-ID: <20071202145127.36ABE80F6@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 15:51:24 2007 New Revision: 49279 Modified: kukit/buildout/kss.zope/base.cfg Log: Add lookup_selector implementation to registry Modified: kukit/buildout/kss.zope/base.cfg ============================================================================== --- kukit/buildout/kss.zope/base.cfg (original) +++ kukit/buildout/kss.zope/base.cfg Sun Dec 2 15:51:24 2007 @@ -90,6 +90,7 @@ kss.base kss.zope kss.demo + ipdb zcml = Products.CMFPlone From jvloothuis at codespeak.net Sun Dec 2 15:53:48 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 2 Dec 2007 15:53:48 +0100 (CET) Subject: [KSS-checkins] r49281 - kukit/kss.base/trunk/kss/base Message-ID: <20071202145348.6D89680F9@code0.codespeak.net> Author: jvloothuis Date: Sun Dec 2 15:53:46 2007 New Revision: 49281 Modified: kukit/kss.base/trunk/kss/base/selectors.py Log: Added some white space to selectors.py for better readability Modified: kukit/kss.base/trunk/kss/base/selectors.py ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.py (original) +++ kukit/kss.base/trunk/kss/base/selectors.py Sun Dec 2 15:53:46 2007 @@ -9,28 +9,35 @@ """ type = None value = '' + def __init__(self): raise Exception, 'Unimplemented' + def __str__(self): return "%s('%s')" % (self.type, self.value) + class css(Selector): type = 'css' + def __init__(self, value): self.value = value class htmlid(Selector): type = 'htmlid' + def __init__(self, value): self.value = value class samenode(Selector): type = 'samenode' + def __init__(self): pass class parentnode(Selector): type = 'parentnode' + def __init__(self, value): self.value = value From reebalazs at codespeak.net Sun Dec 2 16:03:11 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 16:03:11 +0100 (CET) Subject: [KSS-checkins] r49282 - kukit/buildout/kss.zope Message-ID: <20071202150311.B7192814E@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 16:03:11 2007 New Revision: 49282 Modified: kukit/buildout/kss.zope/base.cfg Log: Oops, wrong commit, please ignore previous log on this file completely. Modified: kukit/buildout/kss.zope/base.cfg ============================================================================== --- kukit/buildout/kss.zope/base.cfg (original) +++ kukit/buildout/kss.zope/base.cfg Sun Dec 2 16:03:11 2007 @@ -90,7 +90,6 @@ kss.base kss.zope kss.demo - ipdb zcml = Products.CMFPlone From reebalazs at codespeak.net Sun Dec 2 16:03:34 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 16:03:34 +0100 (CET) Subject: [KSS-checkins] r49283 - kukit/kss.zope/trunk/kss/zope Message-ID: <20071202150334.0098B814E@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 16:03:34 2007 New Revision: 49283 Modified: kukit/kss.zope/trunk/kss/zope/commandset.py kukit/kss.zope/trunk/kss/zope/registry.py kukit/kss.zope/trunk/kss/zope/registry.txt Log: Add lookup_selector implementation to registry Modified: kukit/kss.zope/trunk/kss/zope/commandset.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/commandset.py (original) +++ kukit/kss.zope/trunk/kss/zope/commandset.py Sun Dec 2 16:03:34 2007 @@ -1,5 +1,5 @@ from zope import interface -from kss.base.coreselectors import htmlid, css +from kss.base.selectors import htmlid, css from kss.base.corecommands import KSSCoreCommands from kss.zope.interfaces import IZopeCommandSet Modified: kukit/kss.zope/trunk/kss/zope/registry.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.py (original) +++ kukit/kss.zope/trunk/kss/zope/registry.py Sun Dec 2 16:03:34 2007 @@ -12,18 +12,29 @@ def __init__(self): self._commandsets = {} - for plugin_id, config in available_plugins(): - self._commandsets.update(config.commandsets) - self._javascripts = [] + self._extra_javascripts = [] + self._selectors = {} + + # Import information from all available plugins, + # and make them availeble on the level of Zope. for id, config in self.plugins(): + # get commandset info + self._commandsets.update(config.commandsets) + # get javascripts info for javascript in config.javascripts: self._javascripts.append(javascript) - - self._extra_javascripts = [] - for id, config in self.plugins(): + # get extra javascripts info for extra_javascript in config.extra_javascripts: self._extra_javascripts.append(extra_javascript) + # get selectors info + # XXX TODO We would really like to use selectors[name] + # lookup directly from kss.base... and then we won't need + # this storage. However kss.base does not offer this + # information, only for activated plugins. + for selectors in config.selectors.itervalues(): + for selector in selectors: + self._selectors[selector.type] = selector def plugins(self): return available_plugins() @@ -39,6 +50,13 @@ commandsets.update(self._commandsets) return commandsets[id] + def lookup_selector(self, id): + # XXX it would be nice to have: + # from kss.base import selectors + # return selectors[id] + # or something similar. + return self._selectors[id] + #============================================= # Stuff needed for compatibility features #============================================= Modified: kukit/kss.zope/trunk/kss/zope/registry.txt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.txt (original) +++ kukit/kss.zope/trunk/kss/zope/registry.txt Sun Dec 2 16:03:34 2007 @@ -69,7 +69,7 @@ A given selector class can be queried as well: >>> registry.lookup_selector('css') - + BBB From jvloothuis at codespeak.net Sun Dec 2 16:04:40 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 2 Dec 2007 16:04:40 +0100 (CET) Subject: [KSS-checkins] r49284 - kukit/kss.base/trunk/kss/base Message-ID: <20071202150440.DB7258150@code0.codespeak.net> Author: jvloothuis Date: Sun Dec 2 16:04:40 2007 New Revision: 49284 Modified: kukit/kss.base/trunk/kss/base/selectors.py kukit/kss.base/trunk/kss/base/selectors.txt Log: Changed exception class for Selector instantition to be more in line with its purpose. Also made some improvements to the texts in the selectors.txt tests Modified: kukit/kss.base/trunk/kss/base/selectors.py ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.py (original) +++ kukit/kss.base/trunk/kss/base/selectors.py Sun Dec 2 16:04:40 2007 @@ -11,7 +11,7 @@ value = '' def __init__(self): - raise Exception, 'Unimplemented' + raise NotImplementedError def __str__(self): return "%s('%s')" % (self.type, self.value) Modified: kukit/kss.base/trunk/kss/base/selectors.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/selectors.txt (original) +++ kukit/kss.base/trunk/kss/base/selectors.txt Sun Dec 2 16:04:40 2007 @@ -15,14 +15,7 @@ >>> Selector() Traceback (most recent call last): ... - Exception: Unimplemented - -XXX Jeroen, I removed the possibility for use an unregistered selector for -two reasons: -1. we need the type present on the class already. -2. There is no code that possibly could use it anyway, so nothing - could break for now. -XXX Please delete this part to acknowledge... + NotImplementedError Standard selectors ------------------ @@ -82,10 +75,9 @@ Selectors registered by plugins ------------------------------- -Suppose a plugin registers a new selector. It must overwrite -type, and __init__ (if it needs to have a value parameter). -The type of the selector should always be in namespace-name -notation. Only the core selectors stand without a namespace. +Suppose a plugin registers a new selector. It must overwrite type, and +__init__. The type of the selector should always be in namespace-name +notation. Only the core selectors can do without a namespace. >>> from kss.base.selectors import Selector >>> class MyFunkySelector(Selector): @@ -99,11 +91,9 @@ the registry. However, we test the registration somewhere else, and just use the class as it is for now: - >>> selector_class = MyFunkySelector - -Noe let's instantiate the selector: +Now let's instantiate the selector: - >>> selector = selector_class('Selector value') + >>> selector = MyFunkySelector('Selector value') The selector now has a type and value property. @@ -113,11 +103,9 @@ >>> selector.value 'Selector value' -XXX Implementation remark: - - Currently only the "value" property will be considered to - be marshalled to the client. So, selectors must have their - parameter stored as "value" for now. +Currently only the "value" property will be marshalled to the +client. Selectors must therefore have their parameter stored as +`value`. String representation @@ -125,8 +113,6 @@ For testing purposes we have a string representation of the selectors. -!TODO: Fix lower casing of string representation - >>> print MyFunkySelector('value') mynamespace-funky('value') From jvloothuis at codespeak.net Sun Dec 2 16:12:19 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 2 Dec 2007 16:12:19 +0100 (CET) Subject: [KSS-checkins] r49285 - kukit/kss.base/trunk/kss/base Message-ID: <20071202151219.2A1728150@code0.codespeak.net> Author: jvloothuis Date: Sun Dec 2 16:12:18 2007 New Revision: 49285 Modified: kukit/kss.base/trunk/kss/base/plugin.txt Log: Added sorting to the plugin test so that it works consistently on all machines (was broken for Balazs) Modified: kukit/kss.base/trunk/kss/base/plugin.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/plugin.txt (original) +++ kukit/kss.base/trunk/kss/base/plugin.txt Sun Dec 2 16:12:18 2007 @@ -117,8 +117,15 @@ iterator of all javascripts from a certain path. >>> from kss.base.plugin import javascripts_from, module_path - >>> javascripts_from(module_path(kss.base)) - [.../kukit/kukit/serveraction.js', ...'.../kukit/kukit/dom.js'...] + >>> scripts = javascripts_from(module_path(kss.base)) + +To test the output we will first sort the scripts (otherwise the test +may fail on different systems). Keep this in mind when creating your +own plugins. If you need a consistent order either sort the output or +use a different way of creating the list of scripts. + + >>> list(sorted(scripts)) + [.../kukit/kukit/dom.js', ..., .../kukit/kukit/serveraction.js', ...] When we try to load from something which is not a directory we will get an error. From reebalazs at codespeak.net Sun Dec 2 17:35:51 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 17:35:51 +0100 (CET) Subject: [KSS-checkins] r49288 - kukit/kss.zope/trunk/kss/core/plugins/core Message-ID: <20071202163551.77B4C8186@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 17:35:51 2007 New Revision: 49288 Removed: kukit/kss.zope/trunk/kss/core/plugins/core/commands.py kukit/kss.zope/trunk/kss/core/plugins/core/interfaces.py Modified: kukit/kss.zope/trunk/kss/core/plugins/core/configure.zcml Log: Remove now unneeded stuff Deleted: /kukit/kss.zope/trunk/kss/core/plugins/core/commands.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/plugins/core/commands.py Sun Dec 2 17:35:51 2007 +++ (empty file) @@ -1,198 +0,0 @@ -from kss.core.selectors import Selector, CssSelector, HtmlIdSelector -from kss.core.selectors import ParentNodeSelector, SameNodeSelector -from kss.core.kssview import CommandSet -from kss.core.deprecated import deprecated, deprecated_warning -from kss.core.parsers import HtmlParser -from kss.core.plugins.core.interfaces import IKSSCoreCommands -from zope.interface import implements - -class KSSCoreCommands(CommandSet): - implements(IKSSCoreCommands) - - def getSelector(self, type, selector): - 'Get a selector of a given type' - return Selector(type, selector) - - def getCssSelector(self, selector): - return CssSelector(selector) - - def getHtmlIdSelector(self, selector): - return HtmlIdSelector(selector) - - def getSameNodeSelector(self): - return SameNodeSelector() - - def getParentNodeSelector(self, selector): - return ParentNodeSelector(selector) - - # XXX the list is not full: maybe complete them? - - def replaceInnerHTML(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('replaceInnerHTML', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def replaceHTML(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('replaceHTML', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def setAttribute(self, selector, name, value): - """ see interfaces.py """ - command = self.commands.addCommand('setAttribute', selector) - data = command.addParam('name', name) - data = command.addParam('value', value) - - def setStyle(self, selector, name, value): - """ see interfaces.py """ - command = self.commands.addCommand('setStyle', selector) - data = command.addParam('name', name) - data = command.addParam('value', value) - - def insertHTMLAfter(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAfter', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLAsFirstChild(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAsFirstChild', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLAsLastChild(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAsLastChild', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLBefore(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLBefore', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def clearChildNodes(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('clearChildNodes', selector) - - def deleteNode(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNode', selector) - - def deleteNodeAfter(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNodeAfter', selector) - - def deleteNodeBefore(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNodeBefore', selector) - - def copyChildNodesFrom(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('copyChildNodesFrom', selector) - data = command.addParam('html_id', id) - - def moveNodeAfter(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('moveNodeAfter', selector) - data = command.addParam('html_id', id) - - def moveNodeBefore(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('moveNodeBefore', selector) - data = command.addParam('html_id', id) - - def copyChildNodesTo(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('copyChildNodesTo', selector) - data = command.addParam('html_id', id) - - def setStateVar(self, varname, value): - """ see interfaces.py """ - command = self.commands.addCommand('setStateVar') - command.addParam('varname', varname) - command.addParam('value', value) - - def triggerEvent(self, name, **kw): - """ see interfaces.py """ - command = self.commands.addCommand('triggerEvent') - command.addParam('name', name) - for key, value in kw.iteritems(): - command.addParam(key, value) - - def toggleClass(self, selector, *arg, **kw): - ##def toggleClass(self, selector, value): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('toggleClass', *arg, **kw) - - command = self.commands.addCommand('toggleClass', selector) - data = command.addParam('value', value) - - def addClass(self, selector, *arg, **kw): - ##def addClass(self, selector, name): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('addClass', *arg, **kw) - - command = self.commands.addCommand('addClass', selector) - data = command.addParam('value', value) - - def removeClass(self, selector, *arg, **kw): - ##def removeClass(self, selector, name): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('removeClass', *arg, **kw) - - command = self.commands.addCommand('removeClass', selector) - data = command.addParam('value', value) - - def focus(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('focus', selector) - - # XXX Deprecated ones - - # BBB until 2007-10-18 - def moveChildrenTo(self, selector, id): - """ see interfaces.py """ - self.copyChildrenTo(selector, id) - self.clearChildren(selector) - moveChildrenTo = deprecated(moveChildrenTo, 'No more supported, use a sequence of copyChildrenTo and clearChildren') - - # BBB until 2007-10-18 - setHtmlAsChild = deprecated(replaceInnerHTML, 'use replaceInnerHTML instead') - addAfter = deprecated(insertHTMLAfter, 'use insertHTMLAfter instead') - clearChildren = deprecated(clearChildNodes, 'use clearChildNodes instead') - removeNode = deprecated(deleteNode, 'use deleteNode instead') - removeNextSibling = deprecated(deleteNodeAfter, 'use deleteNodeAfter instead') - removePreviousSibling = deprecated(deleteNodeBefore, 'use deleteNodeBefore instead') - copyChildrenFrom = deprecated(copyChildNodesFrom, 'use copyChildNodesFrom instead') - copyChildrenTo = deprecated(copyChildNodesTo, 'use copyChildNodesTo instead') - setStatevar = deprecated(setStateVar, 'use setStateVar (capital V) instead') - - # BBB 4 month, until 2007-10-18 - addClassName = deprecated(addClass, 'use addClass instead') - removeClassName = deprecated(removeClass, 'use removeClass instead') - -# BBB 4 month, until 2007-10-18 -def BBB_classParms(commandname, value=None, classname=None, name=None): - if classname: - deprecated_warning(('Deprecated the "classname" parameter in the "%s" command, ' + - 'use "name" instead.') % (commandname ,)) - if not value: - value = classname - if name: - deprecated_warning(('Deprecated the "name" parameter in the "%s" command, ' + - 'use "name" instead.') % (commandname ,)) - if not value: - value = name - if not value: - raise Exception, 'Parameter "value" is mandatory in command "%s"' % (commandname, ) - return value - - # end deprecated Modified: kukit/kss.zope/trunk/kss/core/plugins/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/plugins/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/core/plugins/core/configure.zcml Sun Dec 2 17:35:51 2007 @@ -416,13 +416,7 @@ - + + Deleted: /kukit/kss.zope/trunk/kss/core/plugins/core/interfaces.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/plugins/core/interfaces.py Sun Dec 2 17:35:51 2007 +++ (empty file) @@ -1,96 +0,0 @@ -from zope.interface import Interface - -class IKSSCoreCommands(Interface): - """The core commands""" - - def getSelector(type, selector): - """Return a specific type of selector - - The type can be `css` or `htmlid`. The selector is the value for the - selector.""" - - def getCssSelector(selector): - """Return a CSS selector with selector as the value""" - - def getHtmlIdSelector(selector): - """Return a HTML id selector with selector as the value""" - - def getSameNodeSelector(): - """Return the same node as the value""" - - def getParentNodeSelector(selector): - """Return a all nodes in the parent chain which match the css - selector""" - - def replaceInnerHTML(selector, new_value, withKssSetup='True'): - """Replace the contents of a node (selector) with the new_value""" - - def replaceHTML(selector, new_value, withKssSetup='True'): - """Replace the node itself with new_value - - Node selection is done using the selector argument.""" - - def setAttribute(selector, name, value): - """Set an attribute on node(s) specified by the selector""" - - def setStyle(selector, name, value): - """Set the style attribute of nodes specified by the selector""" - - def insertHTMLAfter(selector, new_value, withKssSetup='True'): - """Insert some HTML after the node indicated by selector""" - - def insertHTMLBefore(selector, new_value, withKssSetup='True'): - """Insert some HTML before the node specified by selector""" - - def insertHTMLAsFirstChild(selector, new_value, withKssSetup='True'): - """Insert some HTML as the first child of the node specified by selector""" - - def insertHTMLAsLastChild(selector, new_value, withKssSetup='True'): - """Insert some HTML as the last child of the node specified by selector""" - - def clearChildNodes(selector): - """Remove all the child nodes from the node specified by selector""" - - def deleteNode(selector): - """Remove the node itself specified by selector""" - - def deleteNodeAfter(selector): - """Remove the node after the node specified by selector""" - - def deleteNodeBefore(selector): - """Remove the node before the node specified by selector""" - - def copyChildNodesFrom(selector, id): - """Copy the child nodes from the node specified by id to the selector node - - The copy operation will clear out all childnodes of selector.""" - - def copyChildNodesTo(selector, id): - """Copy the child nodes from the selector node to the node specified by id - - The copy operation will clear out all childnodes of selector.""" - - def moveNodeAfter(selector, id): - """Move the node indicated by selector to a sibling after id""" - - def setStateVar(varname, value): - """Set a client side kukit variable""" - - def triggerEvent(name, **kw): - """Trigger an event on the client """ - # TODO: explain a bit better what this does - - def toggleClass(selector, value): - """Add/remove a class to/from a node. - - If the class is present it will be removed. Else the class will be - added. """ - - def addClass(selector, value): - """Add a class to a node.""" - - def removeClass(selector, value): - """Remove a class from a node.""" - - def focus(selector): - """Set focus to selected node.""" From reebalazs at codespeak.net Sun Dec 2 17:38:00 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 17:38:00 +0100 (CET) Subject: [KSS-checkins] r49289 - in kukit/kss.zope/trunk/kss/zope: . bbb Message-ID: <20071202163800.C11508186@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 17:38:00 2007 New Revision: 49289 Added: kukit/kss.zope/trunk/kss/zope/bbb/commandset.py kukit/kss.zope/trunk/kss/zope/selectors.py Modified: kukit/kss.zope/trunk/kss/zope/bbb/deprecated.py kukit/kss.zope/trunk/kss/zope/commands.py kukit/kss.zope/trunk/kss/zope/commandset.py kukit/kss.zope/trunk/kss/zope/registry.py kukit/kss.zope/trunk/kss/zope/registry.txt kukit/kss.zope/trunk/kss/zope/view.py Log: Add proper emulation and prepare BBB for selectors. Also impelent the suggested new way. Added: kukit/kss.zope/trunk/kss/zope/bbb/commandset.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/bbb/commandset.py Sun Dec 2 17:38:00 2007 @@ -0,0 +1,35 @@ + +# BBB selector compat wrapper +from kss.zope.commandset import ZopeCommandSet +from kss.base.corecommands import KSSCoreCommands +##from deprecated import deprecated + +when = 'after 2008-08-01' + +class CompatCommandSet(ZopeCommandSet, KSSCoreCommands): + + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use getattr(view.selectors, type)(value) instead', when) + def getSelector(self, selector_type, selector): + 'Get a selector of a given type' + return getattr(self.view.selectors, selector_type)(selector) + + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use view.selectors.css(value) instead', when) + def getCssSelector(self, selector): + return self.view.selectors.css(selector) + + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use view.selectors.htmlid(value) instead', when) + def getHtmlIdSelector(self, selector): + return self.view.selectors.htmlid(selector) + + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use view.selectors.samenode() instead', when) + def getSameNodeSelector(self): + return self.view.selectors.samenode() + + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use view.selectors.parentode(value) instead', when) + def getParentNodeSelector(self, selector): + return self.view.selectors.parentnode(selector) Modified: kukit/kss.zope/trunk/kss/zope/bbb/deprecated.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/bbb/deprecated.py (original) +++ kukit/kss.zope/trunk/kss/zope/bbb/deprecated.py Sun Dec 2 17:38:00 2007 @@ -21,25 +21,29 @@ def deprecated_warning(message): warnings.warn(message, DeprecationWarning, 2) -def deprecated(method, message): - def deprecated_method(self, *args, **kw): - warnings.warn(message, DeprecationWarning, 2) - return method(self, *args, **kw) - return deprecated_method +def deprecated(message, when='any time'): + def f(method): + def deprecated_method(self, *args, **kw): + deprecated_warning(textwrap.dedent('''\ + The method %s is deprecated and will be removed %s, + %s + ''' + % (method.__name__, when, message))) + return method(self, *args, **kw) + return deprecated_method + return f def deprecated_directive(directive, message, when='any time'): def f(method): def deprecated_method(_context, *args, **kw): - warnings.warn(message, DeprecationWarning, 2) - warnings.warn(textwrap.dedent('''\ + deprecated_warning(textwrap.dedent('''\ %s The directive %s is deprecated and will be removed %s, %s ''' - % (_context.info, directive, when, message)), - DeprecationWarning, 2) + % (_context.info, directive, when, message))) return method(_context, *args, **kw) return deprecated_method return f Modified: kukit/kss.zope/trunk/kss/zope/commands.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/commands.py (original) +++ kukit/kss.zope/trunk/kss/zope/commands.py Sun Dec 2 17:38:00 2007 @@ -1,9 +1,7 @@ from zope import component from kss.base import KSSCommands - -from kss.zope.interfaces import IKSSPluginRegistry, IZopeCommandSet -from kss.zope.commandset import CompatCommandSet - +from interfaces import IKSSPluginRegistry, IZopeCommandSet +from bbb.commandset import CompatCommandSet class KSSZopeCommands(KSSCommands): def __init__(self, view, context, request): @@ -26,6 +24,7 @@ return commandset_factory(self) # Add something like this + # XXX XXX This is not working!!!!!!! def addCommand(self, command_name, selector=None, **kw): command = KSSCommand(command_name, selector=selector, **kw) self.append(command) Modified: kukit/kss.zope/trunk/kss/zope/commandset.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/commandset.py (original) +++ kukit/kss.zope/trunk/kss/zope/commandset.py Sun Dec 2 17:38:00 2007 @@ -1,8 +1,5 @@ from zope import interface -from kss.base.selectors import htmlid, css -from kss.base.corecommands import KSSCoreCommands - -from kss.zope.interfaces import IZopeCommandSet +from interfaces import IZopeCommandSet class ZopeCommandSet(object): interface.implements(IZopeCommandSet) @@ -16,11 +13,6 @@ def getCommandSet(self, name): return self.view.getCommandSet(name) -# BBB selector compat wrapper -class CompatCommandSet(ZopeCommandSet, KSSCoreCommands): - - def getHtmlIdSelector(self, value): - return htmlid(value) - - def getCssSelector(self, value): - return css(value) + @property + def selectors(self): + return self.view.selectors Modified: kukit/kss.zope/trunk/kss/zope/registry.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.py (original) +++ kukit/kss.zope/trunk/kss/zope/registry.py Sun Dec 2 17:38:00 2007 @@ -55,7 +55,10 @@ # from kss.base import selectors # return selectors[id] # or something similar. - return self._selectors[id] + try: + return self._selectors[id] + except KeyError, exc: + raise KeyError, 'Selector "%s" is not registered.' % (id, ) #============================================= # Stuff needed for compatibility features Modified: kukit/kss.zope/trunk/kss/zope/registry.txt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.txt (original) +++ kukit/kss.zope/trunk/kss/zope/registry.txt Sun Dec 2 17:38:00 2007 @@ -71,6 +71,13 @@ >>> registry.lookup_selector('css') +A nonexistent selector lookup will give a specific key error: + + >>> registry.lookup_selector('NONEXISTENT') + Traceback (most recent call last): + ... + KeyError: 'Selector "NONEXISTENT" is not registered.' + BBB === Added: kukit/kss.zope/trunk/kss/zope/selectors.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/selectors.py Sun Dec 2 17:38:00 2007 @@ -0,0 +1,19 @@ + +from interfaces import IKSSPluginRegistry +from zope import component as capi + +class SelectorLookup(object): + '''Provide lookup to selectors''' + + __allow_access_to_unprotected_subobjects__ = True + + def __getattribute__(self, selector_type): + registry = capi.getUtility(IKSSPluginRegistry) + try: + return registry.lookup_selector(selector_type) + except KeyError, exc: + # Make sure to give attribute error here. + raise AttributeError, str(exc) + +# Create singleton +selectorLookup = SelectorLookup() Modified: kukit/kss.zope/trunk/kss/zope/view.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/view.py (original) +++ kukit/kss.zope/trunk/kss/zope/view.py Sun Dec 2 17:38:00 2007 @@ -30,12 +30,13 @@ try: from Products.Five import BrowserView + BrowserView = BrowserView # satisfy pyflakes except ImportError: from zope.publisher.browser import BrowserView -from kss.zope.commands import KSSZopeCommands -from kss.zope.interfaces import IKSSView - +from commands import KSSZopeCommands +from interfaces import IKSSView +from selectors import selectorLookup from zope import component, interface, event from zope.interface.adapter import VerifyingAdapterRegistry from zope.component.globalregistry import BaseGlobalComponents @@ -50,7 +51,6 @@ except ImportError: HAS_FIVE_LSM = False - class SiteViewComponents(BaseGlobalComponents): def _init_registries(self): @@ -161,3 +161,13 @@ def getCommandSet(self, name): return getattr(self.commands, name) + + @property + def selectors(self): + """selector lookup object. + Provides selectors by attribute lookup. + + Example: + selector = view.selectors.css('div#id') + """ + return selectorLookup From reebalazs at codespeak.net Sun Dec 2 18:09:16 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 18:09:16 +0100 (CET) Subject: [KSS-checkins] r49290 - kukit/kss.zope/trunk/kss/zope Message-ID: <20071202170916.55F4F818C@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 18:09:15 2007 New Revision: 49290 Modified: kukit/kss.zope/trunk/kss/zope/commands.py Log: Clean up commands, add compatibility for addCommand, addParam Modified: kukit/kss.zope/trunk/kss/zope/commands.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/commands.py (original) +++ kukit/kss.zope/trunk/kss/zope/commands.py Sun Dec 2 18:09:15 2007 @@ -2,6 +2,10 @@ from kss.base import KSSCommands from interfaces import IKSSPluginRegistry, IZopeCommandSet from bbb.commandset import CompatCommandSet +# BBB +from kss.base.selectors import Selector, css +#from bbb.deprecated import deprecated +#when = 'after 2008-08-01' class KSSZopeCommands(KSSCommands): def __init__(self, view, context, request): @@ -23,124 +27,19 @@ else: return commandset_factory(self) - # Add something like this - # XXX XXX This is not working!!!!!!! + ## Don't BBB yet. Uncommenting the next line will activate BBB. + ##@deprecated('use view.commands.add(action, selector **kw)', when) def addCommand(self, command_name, selector=None, **kw): - command = KSSCommand(command_name, selector=selector, **kw) - self.append(command) - return command - -''' -# BBB stuf -class KSSParam: - implements(IKSSParam) - - def __init__(self, name, content=''): - self.name = name - self.content = content - - def force_content_unicode(self): - # Content must be str with ascii encoding, or unicode! - self.content = force_unicode(self.content) - - def getName(self): - return self.name - - def getContent(self): - return self.content - -class KSSCommand: - implements(IKSSCommand) - - def __init__(self, command_name, selector=None, **kw): - try: - checkRegisteredCommand_old(command_name) - except KSSPluginError: - # we expect this is not registered as command, anyway - # so check it as an action. - checkRegisteredCommand(command_name) - else: - # ok. XXX this will be deprecated - # All registerCommand commands are obsolete, by default - import warnings, textwrap - warnings.warn(textwrap.dedent(' - The usage of the kss command "%s" is deprecated' - % (command_name, )), DeprecationWarning, 2) - if selector is not None: - if isinstance(selector, basestring): - # the default selector - given just as a string - self.selector = selector - self.selectorType = '' - else: - checkRegisteredSelector(selector.type) - self.selector = selector.value - self.selectorType = selector.type - else: - self.selector = None - self.selectorType = None - self.name = command_name - self.params = [] - # Add parameters passed in **kw - for key, value in kw.iteritems(): - self.addParam(key, value) - - # -- - # Different parameter conversions - # -- - - # REMARK: with the jsonserver product present, you can - # just send complex data types directly with AddParam - - def addParam(self, name, content=''): - 'Add the param as is' - param = KSSParam(name, content) - self.params.append(param) - return param - - # - # Some helpers - # - - def addUnicodeParam(self, name, content=''): - 'Add the param as unicode' - self.addParam(name, content=content) - - def addStringParam(self, name, content='', encoding='utf'): - 'Add the param as an encoded string, by default UTF-8' - content = unicode(content, 'utf') - self.addParam(name, content=content) - - def addHtmlParam(self, name, content=''): - 'Add the param as an HTML content.' - content = HtmlParser(content)().encode('ascii', 'xmlcharrefreplace') - ##self.addParam(name, content=content) - # add html as cdata! - self.addCdataParam(name, content=content) - - def addXmlParam(self, name, content=''): - 'Add the param as XML content' - content = XmlParser(content)().encode('ascii', 'xmlcharrefreplace') - self.addParam(name, content=content) - - def addCdataParam(self, name, content=''): - 'Add the param as a CDATA node' - content = '' % (content, ) - self.addParam(name, content=content) - - - # -- - # Accessors, not sure if we need them - # -- - - def getName(self): - return self.name - - def getSelector(self): - return self.selector - - def getSelectorType(self): - return self.selectorType - - def getParams(self): - return self.params -''' + self._strip_none_parameters(kw) + + if selector is not None and not isinstance(selector, Selector): + selector = css(selector) + + self.commands.append(CompatCommand(command_name, selector, kw)) + +# Nasty BBB for covering this old usage: +# command = self.addCommand('command_name', 'selector') +# command.addParam('key', 'value') +class CompatCommand(tuple): + def addParam(self, key, value): + self[2][key] = value From reebalazs at codespeak.net Sun Dec 2 18:40:43 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 18:40:43 +0100 (CET) Subject: [KSS-checkins] r49291 - in kukit/kss.zope/trunk: . kss/core kss/core/plugins kss/zope kss/zope/plugins kss/zope/plugins/core kss/zope/plugins/draganddrop Message-ID: <20071202174043.CC274817D@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 18:40:42 2007 New Revision: 49291 Added: kukit/kss.zope/trunk/kss/zope/plugins/ - copied from r49285, kukit/kss.zope/trunk/kss/core/plugins/ kukit/kss.zope/trunk/kss/zope/plugins/core/configure.zcml - copied unchanged from r49288, kukit/kss.zope/trunk/kss/core/plugins/core/configure.zcml Removed: kukit/kss.zope/trunk/kss/core/plugins/ kukit/kss.zope/trunk/kss/zope/plugins/core/commands.py kukit/kss.zope/trunk/kss/zope/plugins/core/interfaces.py kukit/kss.zope/trunk/kss/zope/plugins/draganddrop/ Modified: kukit/kss.zope/trunk/kss/core/configure.zcml kukit/kss.zope/trunk/kss/zope/configure.zcml kukit/kss.zope/trunk/kss/zope/plugins/configure.zcml kukit/kss.zope/trunk/setup.py Log: Move plugins from core to zope, delete draganddrop Modified: kukit/kss.zope/trunk/kss/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/core/configure.zcml Sun Dec 2 18:40:42 2007 @@ -8,7 +8,6 @@ - + + Modified: kukit/kss.zope/trunk/kss/zope/plugins/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/plugins/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/zope/plugins/configure.zcml Sun Dec 2 18:40:42 2007 @@ -2,19 +2,10 @@ xmlns:browser="http://namespaces.zope.org/browser" xmlns:five="http://namespaces.zope.org/five"> - - - - - - Deleted: /kukit/kss.zope/trunk/kss/core/plugins/core/commands.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/plugins/core/commands.py Sun Dec 2 18:40:42 2007 +++ (empty file) @@ -1,198 +0,0 @@ -from kss.core.selectors import Selector, CssSelector, HtmlIdSelector -from kss.core.selectors import ParentNodeSelector, SameNodeSelector -from kss.core.kssview import CommandSet -from kss.core.deprecated import deprecated, deprecated_warning -from kss.core.parsers import HtmlParser -from kss.core.plugins.core.interfaces import IKSSCoreCommands -from zope.interface import implements - -class KSSCoreCommands(CommandSet): - implements(IKSSCoreCommands) - - def getSelector(self, type, selector): - 'Get a selector of a given type' - return Selector(type, selector) - - def getCssSelector(self, selector): - return CssSelector(selector) - - def getHtmlIdSelector(self, selector): - return HtmlIdSelector(selector) - - def getSameNodeSelector(self): - return SameNodeSelector() - - def getParentNodeSelector(self, selector): - return ParentNodeSelector(selector) - - # XXX the list is not full: maybe complete them? - - def replaceInnerHTML(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('replaceInnerHTML', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def replaceHTML(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('replaceHTML', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def setAttribute(self, selector, name, value): - """ see interfaces.py """ - command = self.commands.addCommand('setAttribute', selector) - data = command.addParam('name', name) - data = command.addParam('value', value) - - def setStyle(self, selector, name, value): - """ see interfaces.py """ - command = self.commands.addCommand('setStyle', selector) - data = command.addParam('name', name) - data = command.addParam('value', value) - - def insertHTMLAfter(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAfter', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLAsFirstChild(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAsFirstChild', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLAsLastChild(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLAsLastChild', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def insertHTMLBefore(self, selector, new_value, withKssSetup='True'): - """ see interfaces.py """ - command = self.commands.addCommand('insertHTMLBefore', selector) - data = command.addHtmlParam('html', new_value) - data = command.addParam('withKssSetup', withKssSetup) - - def clearChildNodes(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('clearChildNodes', selector) - - def deleteNode(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNode', selector) - - def deleteNodeAfter(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNodeAfter', selector) - - def deleteNodeBefore(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('deleteNodeBefore', selector) - - def copyChildNodesFrom(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('copyChildNodesFrom', selector) - data = command.addParam('html_id', id) - - def moveNodeAfter(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('moveNodeAfter', selector) - data = command.addParam('html_id', id) - - def moveNodeBefore(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('moveNodeBefore', selector) - data = command.addParam('html_id', id) - - def copyChildNodesTo(self, selector, id): - """ see interfaces.py """ - command = self.commands.addCommand('copyChildNodesTo', selector) - data = command.addParam('html_id', id) - - def setStateVar(self, varname, value): - """ see interfaces.py """ - command = self.commands.addCommand('setStateVar') - command.addParam('varname', varname) - command.addParam('value', value) - - def triggerEvent(self, name, **kw): - """ see interfaces.py """ - command = self.commands.addCommand('triggerEvent') - command.addParam('name', name) - for key, value in kw.iteritems(): - command.addParam(key, value) - - def toggleClass(self, selector, *arg, **kw): - ##def toggleClass(self, selector, value): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('toggleClass', *arg, **kw) - - command = self.commands.addCommand('toggleClass', selector) - data = command.addParam('value', value) - - def addClass(self, selector, *arg, **kw): - ##def addClass(self, selector, name): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('addClass', *arg, **kw) - - command = self.commands.addCommand('addClass', selector) - data = command.addParam('value', value) - - def removeClass(self, selector, *arg, **kw): - ##def removeClass(self, selector, name): - """ see interfaces.py """ - # BBB 4 months, until 2007-10-18 - value = BBB_classParms('removeClass', *arg, **kw) - - command = self.commands.addCommand('removeClass', selector) - data = command.addParam('value', value) - - def focus(self, selector): - """ see interfaces.py """ - command = self.commands.addCommand('focus', selector) - - # XXX Deprecated ones - - # BBB until 2007-10-18 - def moveChildrenTo(self, selector, id): - """ see interfaces.py """ - self.copyChildrenTo(selector, id) - self.clearChildren(selector) - moveChildrenTo = deprecated(moveChildrenTo, 'No more supported, use a sequence of copyChildrenTo and clearChildren') - - # BBB until 2007-10-18 - setHtmlAsChild = deprecated(replaceInnerHTML, 'use replaceInnerHTML instead') - addAfter = deprecated(insertHTMLAfter, 'use insertHTMLAfter instead') - clearChildren = deprecated(clearChildNodes, 'use clearChildNodes instead') - removeNode = deprecated(deleteNode, 'use deleteNode instead') - removeNextSibling = deprecated(deleteNodeAfter, 'use deleteNodeAfter instead') - removePreviousSibling = deprecated(deleteNodeBefore, 'use deleteNodeBefore instead') - copyChildrenFrom = deprecated(copyChildNodesFrom, 'use copyChildNodesFrom instead') - copyChildrenTo = deprecated(copyChildNodesTo, 'use copyChildNodesTo instead') - setStatevar = deprecated(setStateVar, 'use setStateVar (capital V) instead') - - # BBB 4 month, until 2007-10-18 - addClassName = deprecated(addClass, 'use addClass instead') - removeClassName = deprecated(removeClass, 'use removeClass instead') - -# BBB 4 month, until 2007-10-18 -def BBB_classParms(commandname, value=None, classname=None, name=None): - if classname: - deprecated_warning(('Deprecated the "classname" parameter in the "%s" command, ' + - 'use "name" instead.') % (commandname ,)) - if not value: - value = classname - if name: - deprecated_warning(('Deprecated the "name" parameter in the "%s" command, ' + - 'use "name" instead.') % (commandname ,)) - if not value: - value = name - if not value: - raise Exception, 'Parameter "value" is mandatory in command "%s"' % (commandname, ) - return value - - # end deprecated Deleted: /kukit/kss.zope/trunk/kss/core/plugins/core/interfaces.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/plugins/core/interfaces.py Sun Dec 2 18:40:42 2007 +++ (empty file) @@ -1,96 +0,0 @@ -from zope.interface import Interface - -class IKSSCoreCommands(Interface): - """The core commands""" - - def getSelector(type, selector): - """Return a specific type of selector - - The type can be `css` or `htmlid`. The selector is the value for the - selector.""" - - def getCssSelector(selector): - """Return a CSS selector with selector as the value""" - - def getHtmlIdSelector(selector): - """Return a HTML id selector with selector as the value""" - - def getSameNodeSelector(): - """Return the same node as the value""" - - def getParentNodeSelector(selector): - """Return a all nodes in the parent chain which match the css - selector""" - - def replaceInnerHTML(selector, new_value, withKssSetup='True'): - """Replace the contents of a node (selector) with the new_value""" - - def replaceHTML(selector, new_value, withKssSetup='True'): - """Replace the node itself with new_value - - Node selection is done using the selector argument.""" - - def setAttribute(selector, name, value): - """Set an attribute on node(s) specified by the selector""" - - def setStyle(selector, name, value): - """Set the style attribute of nodes specified by the selector""" - - def insertHTMLAfter(selector, new_value, withKssSetup='True'): - """Insert some HTML after the node indicated by selector""" - - def insertHTMLBefore(selector, new_value, withKssSetup='True'): - """Insert some HTML before the node specified by selector""" - - def insertHTMLAsFirstChild(selector, new_value, withKssSetup='True'): - """Insert some HTML as the first child of the node specified by selector""" - - def insertHTMLAsLastChild(selector, new_value, withKssSetup='True'): - """Insert some HTML as the last child of the node specified by selector""" - - def clearChildNodes(selector): - """Remove all the child nodes from the node specified by selector""" - - def deleteNode(selector): - """Remove the node itself specified by selector""" - - def deleteNodeAfter(selector): - """Remove the node after the node specified by selector""" - - def deleteNodeBefore(selector): - """Remove the node before the node specified by selector""" - - def copyChildNodesFrom(selector, id): - """Copy the child nodes from the node specified by id to the selector node - - The copy operation will clear out all childnodes of selector.""" - - def copyChildNodesTo(selector, id): - """Copy the child nodes from the selector node to the node specified by id - - The copy operation will clear out all childnodes of selector.""" - - def moveNodeAfter(selector, id): - """Move the node indicated by selector to a sibling after id""" - - def setStateVar(varname, value): - """Set a client side kukit variable""" - - def triggerEvent(name, **kw): - """Trigger an event on the client """ - # TODO: explain a bit better what this does - - def toggleClass(selector, value): - """Add/remove a class to/from a node. - - If the class is present it will be removed. Else the class will be - added. """ - - def addClass(selector, value): - """Add a class to a node.""" - - def removeClass(selector, value): - """Remove a class from a node.""" - - def focus(selector): - """Set focus to selected node.""" Modified: kukit/kss.zope/trunk/setup.py ============================================================================== --- kukit/kss.zope/trunk/setup.py (original) +++ kukit/kss.zope/trunk/setup.py Sun Dec 2 18:40:42 2007 @@ -1,34 +1,37 @@ from setuptools import setup, find_packages -import sys, os +from textwrap import dedent version = '1.4' -setup(name='kss.zope', - version=version, - description="KSS (Kinetic Style Sheets) core framework", - long_description="""\ -""", - # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ +setup( + name = 'kss.zope', + version = version, + description = "KSS (Kinetic Style Sheets) core framework", + long_description = dedent("""\ + """), + # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers + classifiers = [ "Framework :: Zope2", "Framework :: Zope3", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", ], - keywords='', - author='KSS Project', - author_email='kss-devel at codespeak.net', - url='http://kssproject.org', - license='GPL', - packages=find_packages(exclude=['ez_setup']), - namespace_packages=['kss'], - include_package_data=True, - zip_safe=False, - install_requires=[ - 'kss.base>=dev', - 'setuptools', - ], - entry_points=""" - # -*- Entry points: -*- - """, - ) + keywords = '', + author = 'KSS Project', + author_email = 'kss-devel at codespeak.net', + url = 'http://kssproject.org', + license = 'GPL', + packages = find_packages(exclude=['ez_setup']), + namespace_packages = ['kss'], + include_package_data = True, + zip_safe = False, + install_requires = [ + 'kss.base>=dev', + 'setuptools', + ], + entry_points={ +# 'kss.plugin': [ +# 'core=kss.base.config:KSSCore' +# ], + }, +) From reebalazs at codespeak.net Sun Dec 2 19:33:42 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 19:33:42 +0100 (CET) Subject: [KSS-checkins] r49293 - kukit/kss.base/trunk/kss/base Message-ID: <20071202183342.A5C1B817C@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 19:33:42 2007 New Revision: 49293 Modified: kukit/kss.base/trunk/kss/base/plugin.py Log: Fix default (selectors is a dict now) Modified: kukit/kss.base/trunk/kss/base/plugin.py ============================================================================== --- kukit/kss.base/trunk/kss/base/plugin.py (original) +++ kukit/kss.base/trunk/kss/base/plugin.py Sun Dec 2 19:33:42 2007 @@ -10,7 +10,7 @@ javascripts = () extra_javascripts = () - selectors = () + selectors = {} commandsets = {} def register_commandsets(self, registry): From reebalazs at codespeak.net Sun Dec 2 21:03:52 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 21:03:52 +0100 (CET) Subject: [KSS-checkins] r49296 - in kukit/kss.zope/trunk/kss/zope: . plugins/core plugins/core/demo plugins/core/demo/binderids Message-ID: <20071202200352.AD1078150@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 21:03:52 2007 New Revision: 49296 Added: kukit/kss.zope/trunk/kss/zope/plugins/core/config.py kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/config.py - copied, changed from r49291, kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/zopeconfig.py kukit/kss.zope/trunk/kss/zope/plugins/core/demo/config.py - copied, changed from r49291, kukit/kss.zope/trunk/kss/zope/plugins/core/demo/zopeconfig.py Removed: kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/zopeconfig.py kukit/kss.zope/trunk/kss/zope/plugins/core/demo/zopeconfig.py Modified: kukit/kss.zope/trunk/kss/zope/plugins/core/README kukit/kss.zope/trunk/kss/zope/plugins/core/configure.zcml kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/configure.zcml kukit/kss.zope/trunk/kss/zope/plugins/core/demo/configure.zcml kukit/kss.zope/trunk/kss/zope/registry.py Log: Register demos from plugins Modified: kukit/kss.zope/trunk/kss/zope/plugins/core/README ============================================================================== --- kukit/kss.zope/trunk/kss/zope/plugins/core/README (original) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/README Sun Dec 2 21:03:52 2007 @@ -1,4 +1 @@ -The core plugins have a missing browser directory as -the plugins are included in kukit/kukit.js. - Added: kukit/kss.zope/trunk/kss/zope/plugins/core/config.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/config.py Sun Dec 2 21:03:52 2007 @@ -0,0 +1,48 @@ + +from kss.base.plugin import Plugin +from kss.demo.resource import ( + KSSDemo, + KSSSeleniumTestDirectory, +) + +class KSSCore(Plugin): + '''The KSS core plugin has all the standard functionality''' + + # XXX what is priority? + priority = -1000 + + javascripts = [] + extra_javascripts = [] + commandsets = {} + selectors = {} + + # Zope specific stuff + + zope_demos = ( + KSSDemo('', '', "demos/basic_commands.html", "Change tag content"), + KSSDemo('', '', "demos/two_selects.html", "Two selects"), + KSSDemo('', '', "demos/autoupdate.html", "Auto update"), + KSSDemo('', '', "demos/inline_edit.html", "Inline edit"), + KSSDemo('', '', "demos/cancel_submit.html", "Cancel Submit Click"), + KSSDemo('', '', "demos/tree.html", "Tree"), + KSSDemo('', '', "demos/more_selectors.html", "More complex selectors"), + KSSDemo('', '', "demos/two_select_revisited.html", "Master-slave selects revisited"), + KSSDemo('', '', "demos/form_submit.html", "Form submit"), + KSSDemo('', '', "demos/effects.html", "Effects"), + KSSDemo('', '', "demos/error_handling.html", "Error handling"), + KSSDemo('', '', "demos/preventdefault.html", "Preventdefault (a.k.a. Safari workarounds)"), + KSSDemo('', '', "demos/html_inserts.html", "HTML insertions (Change tag content returns)"), + KSSDemo('', 'Parameter functions', 'demos/pf_forms.html', 'Forms'), + KSSDemo('', 'Selectors', 'demos/selectors.html', 'Parent node selector'), + KSSDemo('', 'Core syntax', "demos/kss_selector_param.html", "Kss selector parameters"), + KSSDemo('', 'Core syntax', "demos/kss_url_param.html", "Kss url parameters"), + KSSDemo('', 'Core events', "demos/kss_evt_preventbubbling.html", "Prevent bubbling KSS event parameter"), + KSSDemo('', 'Core events', "demos/kss_keyevents.html", "Key events"), + KSSDemo('', 'Commands/Actions', "demos/ca_focus.html", "Focus"), + KSSDemo('', 'Commands/Actions', "demos/actions.html", "Toggle case action"), + ) + + # directories are relative from the location of this .py file + selenium_tests = ( + KSSSeleniumTestDirectory('demos/selenium_tests'), + ) Modified: kukit/kss.zope/trunk/kss/zope/plugins/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/zope/plugins/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/configure.zcml Sun Dec 2 21:03:52 2007 @@ -8,415 +8,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Copied: kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/config.py (from r49291, kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/zopeconfig.py) ============================================================================== --- kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/zopeconfig.py (original) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/config.py Sun Dec 2 21:03:52 2007 @@ -1,26 +1,13 @@ -from kss.demo.interfaces import ( - IKSSDemoResource, - IKSSSeleniumTestResource, - ) +from kss.base.plugin import Plugin from kss.demo.resource import ( KSSDemo, KSSSeleniumTestDirectory, ) -from zope.interface import implements - -# Create a mesh of provided interfaces -# This is needed, because an utility must have a single interface. -class IResource(IKSSDemoResource, IKSSSeleniumTestResource): - pass - -# XXX you do not need to change anything above here -# ------------------------------------------------- -class KSSDemos(object): - implements(IResource) +class CoreDemos(Plugin): - demos = ( + zope_demos = ( # List your demos here. # (Second parameter can be a subcategory within the demo if needed.) KSSDemo('', 'Core syntax', 'binderids.html', 'Binder ids'), @@ -28,7 +15,7 @@ ) # directories are relative from the location of this .py file - selenium_tests = ( + zope_selenium_testsuites = ( # if you only have one test directory, you # need not change anything here. KSSSeleniumTestDirectory('selenium_tests'), Modified: kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/demo/binderids/configure.zcml Sun Dec 2 21:03:52 2007 @@ -8,14 +8,6 @@ Set up the demos --> - - - - - - Author: reebalazs Date: Sun Dec 2 21:04:47 2007 New Revision: 49297 Added: kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py Removed: kukit/kss.demo/branch/kss-zope-transition/kss/demo/events.py kukit/kss.demo/branch/kss-zope-transition/kss/demo/kss.demo-meta.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/meta.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/registry.py Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py kukit/kss.demo/branch/kss-zope-transition/kss/demo/configure.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py kukit/kss.demo/branch/kss-zope-transition/kss/demo/tests/test_demoview.py Log: Register demos from plugins Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py Sun Dec 2 21:04:47 2007 @@ -1,9 +1,10 @@ -from kss.demo.interfaces import IKSSDemoRegistry +from kss.zope.interfaces import IKSSPluginRegistry from zope.publisher.interfaces.browser import IBrowserPublisher from zope.publisher.interfaces import NotFound from zope.component import getUtility from zope.interface import implements +from kss.demo.selenium_utils.builder import getSeleniumTestsFromSuite, cookSeleniumTests try: from Products.Five import BrowserView BrowserView # make pyflakes happy @@ -14,8 +15,8 @@ def getSortedDemos(self): """Get demos""" - registry = getUtility(IKSSDemoRegistry) - return registry.getSortedDemos() + registry = getUtility(IKSSPluginRegistry) + return registry.zope_demos() def getDemoGroups(self): """Get demos groupped by plugin_namespace, category""" @@ -89,6 +90,13 @@ into the file seltest_all.pty in the directory of kss.demo.selenium_utils . """ - registry = getUtility(IKSSDemoRegistry) - registry.cookSeleniumTests() - return "Selenium tests cooked OK. (%i)" % (len(registry.selenium_tests), ) + registry = getUtility(IKSSPluginRegistry) + suites = registry.zope_selenium_testsuites() + # Extract filenames from all suites + filenames = [] + for owner_instance, suite in suites: + filenames.extend(getSeleniumTestsFromSuite(owner_instance, suite)) + # Cook them. This will create seltest_all.py. + cookSeleniumTests(filenames) + # We are done. + return "Selenium tests cooked OK. (%i) suites, (%i) files" % (len(suites), len(filenames)) Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/configure.zcml ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/configure.zcml (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/configure.zcml Sun Dec 2 21:04:47 2007 @@ -50,16 +50,4 @@ - - - - - - Deleted: /kukit/kss.demo/branch/kss-zope-transition/kss/demo/events.py ============================================================================== --- /kukit/kss.demo/branch/kss-zope-transition/kss/demo/events.py Sun Dec 2 21:04:47 2007 +++ (empty file) @@ -1,43 +0,0 @@ - -import zope.component -from zope.component.interfaces import ( - IUtilityRegistration, - IRegistrationEvent, - ) -from interfaces import ( - IKSSDemoResource, - IKSSSeleniumTestResource, - IKSSDemoRegistrationEvent, - IKSSDemoRegistryEvent, - IKSSDemoRegistry - ) -from zope.interface import implements - -class KSSDemoRegistrationEvent(object): - """Redispatch of registration for demo resource utilities""" - implements(IKSSDemoRegistrationEvent) - -class KSSDemoRegistryEvent(object): - """Redispatch of registration for demo registry utilities""" - implements(IKSSDemoRegistryEvent) - - at zope.component.adapter(IUtilityRegistration, IRegistrationEvent) -def dispatchRegistration(registration, event): - """When a demo utility is registered, add it to the registry. - When a demo utility is registered, - event handler registered for the particular component registered, - the registration and the event. - """ - component = registration.component - # Only dispatch registration of the interesting utilities. - if IKSSDemoResource.providedBy(component) or \ - IKSSSeleniumTestResource.providedBy(component): - new_event = KSSDemoRegistrationEvent() - handlers = zope.component.subscribers((component, registration, event, new_event), None) - for handler in handlers: - pass # getting them does the work - if IKSSDemoRegistry.providedBy(component): - new_event = KSSDemoRegistryEvent() - handlers = zope.component.subscribers((component, registration, event, new_event), None) - for handler in handlers: - pass # getting them does the work Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py Sun Dec 2 21:04:47 2007 @@ -50,101 +50,3 @@ description=u'Relative directory path, contains *.html selenium tests', required=False, ) - -# -- -# Resource definition interfaces -# -- - -class IKSSDemoResource(Interface): - """An utility that a demo needs to register""" - - # list of IKSSDemo - demos = List( - title=u"demos", - description=u'The ordered list of demos contained in this plugin', - required=True, - ) - -class IKSSSeleniumTestResource(Interface): - """An utility that a demo needs to register""" - - # list of IKSSSeleniumTestDir - selenium_tests = List( - title=u"selenium tests", - description=u'The list of selenium test directories contained in this plugin', - required=True, - ) - -# -- -# The registry itself -# -- - -class IKSSDemoRegistry(Interface): - """Faciliates registration of demos. - - Implementations must look after the IKSSDemoResource - adapters, and use their content to set up themselves. - """ - - def registerDemo(demo): - """Register a demo - - It has the attributes specified in IKSSDemo: - - plugin_namespace - string with the name of the plugin. - Or: "" when it is the core part. - - category - text that will appear as the title of the - category. "" if out of category. - - demo_page - (relative) url of the demo page. This should - traverse on ISimpleContent. - - title - Title of the demo. This also identifies it - for removal. - """ - - def unregisterDemo(demo): - """Unregister the given demo.""" - - def getSortedDemos(): - """Get the (sorted) list of demos""" - -class IKSSSeleniumTestRegistry(Interface): - """Faciliates registration of demos. - - Implementations must look after the IKSSSeleniumTestResource - adapters, and use their content to set up themselves. - """ - - def registerSeleniumTestFile(test_filename): - """Register a selenium test directory - - It test_dir has the "filename" attributes specified in IKSSSeleniumTest. - """ - - def unregisterSeleniumTestFile(test_filename): - """Unregister the given test directory.""" - - def cookSeleniumTests(): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ - -# -- -# Event that gets redispatched, for allowing -# the listeners to filter on component -# -- - -class IKSSDemoRegistrationEvent(Interface): - """Redispatched event for registration of - IKSSDemoRegistration utilities (resources). - """ - -class IKSSDemoRegistryEvent(Interface): - """Redispatched event for registration of - IKSSDemoRegistry utilities. - """ Deleted: /kukit/kss.demo/branch/kss-zope-transition/kss/demo/kss.demo-meta.zcml ============================================================================== --- /kukit/kss.demo/branch/kss-zope-transition/kss/demo/kss.demo-meta.zcml Sun Dec 2 21:04:47 2007 +++ (empty file) @@ -1,3 +0,0 @@ - - - Deleted: /kukit/kss.demo/branch/kss-zope-transition/kss/demo/meta.zcml ============================================================================== --- /kukit/kss.demo/branch/kss-zope-transition/kss/demo/meta.zcml Sun Dec 2 21:04:47 2007 +++ (empty file) @@ -1,6 +0,0 @@ - - - - - Deleted: /kukit/kss.demo/branch/kss-zope-transition/kss/demo/registry.py ============================================================================== --- /kukit/kss.demo/branch/kss-zope-transition/kss/demo/registry.py Sun Dec 2 21:04:47 2007 +++ (empty file) @@ -1,254 +0,0 @@ -from zope.interface import implements -from zope.component import ( - adapter, - getSiteManager, - ) -from interfaces import ( - IKSSDemoRegistry, - IKSSSeleniumTestRegistry, - IKSSDemoResource, - IKSSSeleniumTestResource, - IKSSDemoRegistrationEvent, - IKSSDemoRegistryEvent, - ) -from zope.component.interfaces import ( - IUtilityRegistration, - IRegistered, - IUnregistered, - ) -import sys, os, re, textwrap -from elementtree import HTMLTreeBuilder -from string import Template -import kss.demo.selenium_utils -# shut the mouth of pyflakes -kss.demo.selenium_utils - -# -- -# Registry implementation for use with Zope -# -- - -def getRootDirOfModule(module_name): - return os.path.dirname(sys.modules[module_name].__file__) - -def getRootDirOfClass(cls): - return getRootDirOfModule(cls.__module__) - -def getRootDirOfInstance(obj): - return getRootDirOfClass(obj.__class__) - -# Create a mesh of provided interfaces -# This is needed, because an utility must have a single interface. -class IRegistry(IKSSDemoRegistry, IKSSSeleniumTestRegistry): - pass - -class KSSDemoRegistry(object): - """KSS demo registry. - """ - implements(IRegistry) - - def __init__(self): - # We will set up my handlers to get notified of new plugins - # (works via redispatching by events.py) - site = getSiteManager() - # registry for demos - self.demos_dict = {} - self.demos = [] - self.demos_are_sorted = False - site.registerHandler(self.registerDemosFromPlugin) - site.registerHandler(self.unregisterDemosFromPlugin) - site.registerHandler(self.registerEarlierDemos) - # registry for selenium tests - self.selenium_tests = [] - site.registerHandler(self.registerSeleniumTestsFromPlugin) - site.registerHandler(self.unregisterSeleniumTestsFromPlugin) - # ... the rest of setup will be done from registerEarlierDemos - - @adapter(IKSSDemoRegistry, IUtilityRegistration, IRegistered, IKSSDemoRegistryEvent) - def registerEarlierDemos(self, registry, registration=None, event=None, new_event=None): - """Make sure that the resources registered earlier, are added - (so this is a listener to the registration of myself - which is needed because CA is not ready at time of the __init__) - """ - if registry != self: - # The utility only register on itself. - return - site = getSiteManager() - for name, plugin in site.getUtilitiesFor(IKSSDemoResource): - for demo in plugin.demos: - self.registerDemo(demo) - - @adapter(IKSSDemoResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) - def registerDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None): - """Add a demo collection to the registry. - """ - for demo in plugin.demos: - self.registerDemo(demo) - - @adapter(IKSSDemoResource, IUtilityRegistration, IUnregistered, IKSSDemoRegistrationEvent) - def unregisterDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None): - """Remove a demo collection from the registry. - """ - for demo in plugin.demos: - self.unregisterDemo(demo) - - def registerDemo(self, demo): - """Register a demo - - It has the attributes specified in IKSSDemo: - - plugin_namespace - string with the name of the plugin. - Or: "" when it is the core part. - - category - text that will appear as the title of the - category. "" if out of category. - - demo_page - (relative) url of the demo page. This should - traverse on ISimpleContent. - - title - Title of the demo. This also identifies it - for removal. - """ - key = demo.plugin_namespace, demo.category, demo.page_url - if key in self.demos: - raise Exception, 'The demo for %s has already been registered. Cannot add.' % (key, ) - self.demos_dict[key] = demo - self.demos.append(demo) - self.demos_are_sorted = False - - def unregisterDemo(self, demo): - """Unregister the given demo.""" - key = demo.plugin_namespace, demo.category, demo.demo_page - try: - value = self.demos_dict[key] - except KeyError: - raise Exception, 'The demo for %s is yet unregistered. Cannot remove.' % (key, ) - del self.demos_dict[key] - self.demos.remove(value) - - def getSortedDemos(self): - """Get the (sorted) list of demos""" - if not self.demos_are_sorted: - self.demos.sort(key=lambda demo: ( - demo.plugin_namespace, - demo.category, - )) - self.demos_are_sorted = True - return list(self.demos) - - # -- - # Selenium tests - # -- - - @staticmethod - def _getSeleniumTestsFromPlugin(plugin): - test_filenames = [] - root_dir = getRootDirOfInstance(plugin) - for selenium_test_directory in plugin.selenium_tests: - tests_root_dir = os.path.join(root_dir, selenium_test_directory.test_directory) - for test_filename in os.listdir(tests_root_dir): - if test_filename.lower().endswith('.html') or \ - test_filename.endswith('.htm'): - test_filenames.append(os.path.join(tests_root_dir, test_filename)) - return test_filenames - - @adapter(IKSSSeleniumTestResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) - def registerSeleniumTestsFromPlugin(self, plugin, registration=None, event=None, new_event=None): - """Add a demo collection to the registry. - """ - for test_filename in self._getSeleniumTestsFromPlugin(plugin): - self.registerSeleniumTestFile(test_filename) - - @adapter(IKSSSeleniumTestResource, IUtilityRegistration, IUnregistered, IKSSDemoRegistrationEvent) - def unregisterSeleniumTestsFromPlugin(self, plugin, registration=None, event=None, new_event=None): - """Remove a demo collection from the registry. - """ - for test_filename in self._getSeleniumTestsFromPlugin(plugin): - self.registerSeleniumTestFile(test_filename) - - def registerSeleniumTestFile(self, test_filename): - """Register a selenium test by absolute filename - """ - if test_filename in self.selenium_tests: - raise Exception, 'The selenium test for %s has already been registered. Cannot add.' % (test_filename, ) - self.selenium_tests.append(test_filename) - - def unregisterSeleniumTestFile(self, test_filename): - """Unregister the given selenium test.""" - try: - del self.selenium_tests[test_filename] - except KeyError: - raise Exception, 'The selenium test for %s is yet unregistered. Cannot remove.' % (test_filename, ) - - template = Template(textwrap.dedent('''\ - from seleniumtestcase import SeleniumTestCase - import unittest, time - - class seltest_$testname(SeleniumTestCase): - - $tests - - def test_suite(): - return unittest.makeSuite(seltest_$testname) - - if __name__ == "__main__": - unittest.main() - ''')) - - variable_regexp = re.compile('\$\{(?P\w*)\}') - @classmethod - def formatcommand(cls, command, *args): - if not command: - return '' # Change this to raise an exception? - - arguments = [] - for arg in args: - if not arg: - continue - matched = cls.variable_regexp.match(arg) - if matched is None: - arguments.append('"%s"'%arg) - else: - arguments.append("self.getVar('%s')"%matched.group('varname')) - return 'self.%s(%s)' % (command, ', '.join(arguments)) - - def cookSeleniumTests(self): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ - # Try to open the file for writing. - output_dir = getRootDirOfModule('kss.demo.selenium_utils') - output_filename = os.path.join(output_dir, 'seltest_all.py') - try: - f = open(output_filename, 'wb') - except IOError, exc: - raise IOError, ('Cannot open file "%s" for writing. ' - 'Make sure zope process has write access in directory. ' - '["%s"]') \ - % (output_filename, exc) - - htmlparser = HTMLTreeBuilder.TreeBuilder() - tests = [] - for filename in self.selenium_tests: - tree = HTMLTreeBuilder.parse(filename) - root = tree.getroot() - - try: - testname = root.find('.//title').text - except AttributeError: - continue - commands = [] - for row in root.findall('.//tbody/tr'): - commands.append(self.formatcommand(*[td.text for td in row.findall('td')])) - - testfilename = 'seltest_%s.py' % testname - testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' - tests.append(testbody) - - f.write(self.template.substitute(dict( - testname=testname, - tests='\n'.join(tests), - ))) - f.close() Added: kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py ============================================================================== --- (empty file) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py Sun Dec 2 21:04:47 2007 @@ -0,0 +1,110 @@ + +import sys, os, re, textwrap +from elementtree import HTMLTreeBuilder +from string import Template + +# -- +# This is used to build the seltest_all.py file into the same directory. +# -- + +# root directory finding code +def getRootDirOfModule(module_name): + return os.path.dirname(sys.modules[module_name].__file__) + +def getRootDirOfClass(cls): + return getRootDirOfModule(cls.__module__) + +def getRootDirOfInstance(obj): + return getRootDirOfClass(obj.__class__) + +def getSeleniumTestsFromSuite(owner_instance, suite): + """Get absolute filenames of all tests from the suite. + Suite contains the directory that we need to find. + owner_instance is used for the directory finding, + the suite's directory is traversed relative from that. + """ + test_filenames = [] + # The owner instance is only used to traverse the sute directory + # relative from it. + root_dir = getRootDirOfInstance(owner_instance) + tests_root_dir = os.path.join(root_dir, suite.test_directory) + for test_filename in os.listdir(tests_root_dir): + if test_filename.lower().endswith('.html') or \ + test_filename.endswith('.htm'): + test_filenames.append(os.path.join(tests_root_dir, test_filename)) + return test_filenames + +template = Template(textwrap.dedent('''\ + from seleniumtestcase import SeleniumTestCase + import unittest, time + + class seltest_$testname(SeleniumTestCase): + + $tests + + def test_suite(): + return unittest.makeSuite(seltest_$testname) + + if __name__ == "__main__": + unittest.main() + ''')) + +variable_regexp = re.compile('\$\{(?P\w*)\}') + +def formatcommand(command, *args): + if not command: + return '' # Change this to raise an exception? + + arguments = [] + for arg in args: + if not arg: + continue + matched = variable_regexp.match(arg) + if matched is None: + arguments.append('"%s"'%arg) + else: + arguments.append("self.getVar('%s')"%matched.group('varname')) + return 'self.%s(%s)' % (command, ', '.join(arguments)) + + + +def cookSeleniumTests(filenames): + """Cook selenium tests + """ + # Try to open the file for writing. + output_dir = getRootDirOfModule('kss.demo.selenium_utils') + output_filename = os.path.join(output_dir, 'seltest_all.py') + try: + f = open(output_filename, 'wb') + except IOError, exc: + raise IOError, ('Cannot open file "%s" for writing. ' + 'Make sure zope process has write access in directory. ' + '["%s"]') \ + % (output_filename, exc) + + htmlparser = HTMLTreeBuilder.TreeBuilder() + tests = [] + + # Now, we find all filenames that are inthe suite passed to us. + + for filename in filenames: + tree = HTMLTreeBuilder.parse(filename) + root = tree.getroot() + + try: + testname = root.find('.//title').text + except AttributeError: + continue + commands = [] + for row in root.findall('.//tbody/tr'): + commands.append(formatcommand(*[td.text for td in row.findall('td')])) + + testfilename = 'seltest_%s.py' % testname + testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' + tests.append(testbody) + + f.write(template.substitute(dict( + testname=testname, + tests='\n'.join(tests), + ))) + f.close() Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/tests/test_demoview.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/tests/test_demoview.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/tests/test_demoview.py Sun Dec 2 21:04:47 2007 @@ -36,7 +36,6 @@ class layer(KSSViewTestCase.layer): @classmethod def setUp(cls): - load_config('meta.zcml', package=kss.demo) load_config('configure.zcml', package=kss.demo) def afterSetUp(self): From reebalazs at codespeak.net Sun Dec 2 21:12:33 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 21:12:33 +0100 (CET) Subject: [KSS-checkins] r49299 - kukit/kss.zope/trunk/kss/zope Message-ID: <20071202201233.BEB318150@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 21:12:32 2007 New Revision: 49299 Modified: kukit/kss.zope/trunk/kss/zope/interfaces.py kukit/kss.zope/trunk/kss/zope/registry.txt Log: Add some superfitial tests for the demo registry extensions Modified: kukit/kss.zope/trunk/kss/zope/interfaces.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/interfaces.py (original) +++ kukit/kss.zope/trunk/kss/zope/interfaces.py Sun Dec 2 21:12:32 2007 @@ -47,6 +47,20 @@ Id must follow the namespace-name format, if not in the core. ''' + # -- + # Extensions for kss.demo + # -- + + def zope_demos(id): + """Return list of zope demo desriptors, for kss.demo.""" + + def zope_selenium_testcases(id): + """Return list of selenium test case descriptors, for kss.demo. + + (A descriptor is a tuple of an owner instance used for directory traverse, + and an actual testcase descriptor. Currently specifying a directory.) + """ + class ICommandSet(Interface): 'Methods of this class implement a command set' Modified: kukit/kss.zope/trunk/kss/zope/registry.txt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/registry.txt (original) +++ kukit/kss.zope/trunk/kss/zope/registry.txt Sun Dec 2 21:12:32 2007 @@ -79,6 +79,18 @@ KeyError: 'Selector "NONEXISTENT" is not registered.' +Demos and selenium tests +------------------------ + +We can get the list of demos and selenium test suites from the +registry as well. + + >>> zope_demos = registry.zope_demos() + >>> zope_selenium_testsuites = registry.zope_selenium_testsuites() + +These are for the private usage of kss.demo. We don't test the content +of these further from here. + BBB === From reebalazs at codespeak.net Sun Dec 2 21:24:22 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 21:24:22 +0100 (CET) Subject: [KSS-checkins] r49301 - kukit/kss.zope/trunk Message-ID: <20071202202422.885EE8186@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 21:24:22 2007 New Revision: 49301 Modified: kukit/kss.zope/trunk/setup.py Log: Huh, forgot the entry points for the demos. Modified: kukit/kss.zope/trunk/setup.py ============================================================================== --- kukit/kss.zope/trunk/setup.py (original) +++ kukit/kss.zope/trunk/setup.py Sun Dec 2 21:24:22 2007 @@ -30,8 +30,9 @@ 'setuptools', ], entry_points={ -# 'kss.plugin': [ -# 'core=kss.base.config:KSSCore' -# ], + 'kss.plugin': [ + 'core-demos-1=kss.zope.plugins.core.demo.config:CoreDemos', + 'core-demos-binderids=kss.zope.plugins.core.demo.binderids.config:CoreDemos', + ], }, ) From reebalazs at codespeak.net Sun Dec 2 21:24:54 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 2 Dec 2007 21:24:54 +0100 (CET) Subject: [KSS-checkins] r49302 - in kukit/kss.zope/trunk/kss: core core/pluginregistry zope/bbb Message-ID: <20071202202454.5C97A8187@code0.codespeak.net> Author: reebalazs Date: Sun Dec 2 21:24:54 2007 New Revision: 49302 Removed: kukit/kss.zope/trunk/kss/core/kss.core-meta.zcml kukit/kss.zope/trunk/kss/core/pluginregistry/ Modified: kukit/kss.zope/trunk/kss/core/configure.zcml kukit/kss.zope/trunk/kss/core/meta.zcml kukit/kss.zope/trunk/kss/zope/bbb/configure.py kukit/kss.zope/trunk/kss/zope/bbb/directives.py kukit/kss.zope/trunk/kss/zope/bbb/meta.zcml Log: Move zcml registry for selectors to bbb. Modified: kukit/kss.zope/trunk/kss/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/core/configure.zcml Sun Dec 2 21:24:54 2007 @@ -5,10 +5,6 @@ - - - - Deleted: /kukit/kss.zope/trunk/kss/core/kss.core-meta.zcml ============================================================================== --- /kukit/kss.zope/trunk/kss/core/kss.core-meta.zcml Sun Dec 2 21:24:54 2007 +++ (empty file) @@ -1,3 +0,0 @@ - - - Modified: kukit/kss.zope/trunk/kss/core/meta.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/meta.zcml (original) +++ kukit/kss.zope/trunk/kss/core/meta.zcml Sun Dec 2 21:24:54 2007 @@ -1,8 +1,8 @@ - - - + Modified: kukit/kss.zope/trunk/kss/zope/bbb/configure.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/bbb/configure.py (original) +++ kukit/kss.zope/trunk/kss/zope/bbb/configure.py Sun Dec 2 21:24:54 2007 @@ -26,11 +26,13 @@ registerEventType = registerFor('eventtype') registerAction = registerFor('action') registerParamProvider = registerFor('paramprovider') +registerSelectorType = registerFor('selectortype') # XXX TODO more meaningful messages here? ## Don't BBB yet. Uncommenting the next three lines will activate BBB. ##registerEventType = deprecated_directive('kss:eventtype', 'use python level registry instead', when)(registerEventType) ##registerAction = deprecated_directive('kss:action', 'use python level registry instead', when)(registerAction) ##registerParamProvider = deprecated_directive('kss:paramprovider', 'use python level registry instead', when)(registerParamProvider) +##registerSelectorType = deprecated_directive('kss:selectortype', 'use python level registry instead', when)(registerSelectorType) class BBBKSSRegistrationError(Exception): pass Modified: kukit/kss.zope/trunk/kss/zope/bbb/directives.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/bbb/directives.py (original) +++ kukit/kss.zope/trunk/kss/zope/bbb/directives.py Sun Dec 2 21:24:54 2007 @@ -106,3 +106,18 @@ description=u"The interface that does the adaptation on the view for this set", required=True, ) + +class IRegisterSelectorTypeDirective(Interface): + 'Register a KSS selector type' + + name = TextLine( + title=u"Name", + description=u"The name of the selector type plugin.", + required=True, + ) + + jsfile = Path( + title=u"Javascript file", + description=u"The path of the javascript file that defines the plugin", + required=False, + ) Modified: kukit/kss.zope/trunk/kss/zope/bbb/meta.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/zope/bbb/meta.zcml (original) +++ kukit/kss.zope/trunk/kss/zope/bbb/meta.zcml Sun Dec 2 21:24:54 2007 @@ -27,6 +27,12 @@ handler=".configure.registerCommandSet" /> + + From kukit-checkins at codespeak.net Mon Dec 3 06:34:25 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Mon, 3 Dec 2007 06:34:25 +0100 (CET) Subject: [KSS-checkins] November 77% OFF Message-ID: <20071203193429.6708.qmail@ppp-124.120.48.169.revip2.asianet.co.th> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071203/43268785/attachment.htm From kukit-checkins at codespeak.net Mon Dec 3 06:50:21 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Mon, 3 Dec 2007 06:50:21 +0100 (CET) Subject: [KSS-checkins] November 79% OFF Message-ID: <20071203114906.4666.qmail@is5.chtts.ru> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071203/0b4a0062/attachment.htm From reebalazs at codespeak.net Tue Dec 4 10:12:57 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 4 Dec 2007 10:12:57 +0100 (CET) Subject: [KSS-checkins] r49330 - kukit/kukit.js/branch/ree-binding-improvements/kukit Message-ID: <20071204091257.8A53B817E@code0.codespeak.net> Author: reebalazs Date: Tue Dec 4 10:12:57 2007 New Revision: 49330 Modified: kukit/kukit.js/branch/ree-binding-improvements/kukit/plugin.js Log: Fix insertedNodes logs causing an error Modified: kukit/kukit.js/branch/ree-binding-improvements/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/ree-binding-improvements/kukit/plugin.js (original) +++ kukit/kukit.js/branch/ree-binding-improvements/kukit/plugin.js Tue Dec 4 10:12:57 2007 @@ -630,7 +630,6 @@ } ;;; kukit.logDebug(content.length + ' nodes inserted.'); // update the events for the new nodes - ;;; kukit.logDebug("Inserted nodes length: "+insertedNodes.length); if (oper.parms.withKssSetup) { kukit.engine.setupEvents(content); } @@ -647,7 +646,6 @@ kukit.dom.insertBefore(content, parentNode, toNode); ;;; kukit.logDebug(content.length + ' nodes inserted.'); // update the events for the new nodes - ;;; kukit.logDebug("Inserted nodes length: "+insertedNodes.length); if (oper.parms.withKssSetup) { kukit.engine.setupEvents(content); } @@ -662,7 +660,6 @@ kukit.dom.appendChildren(content, oper.node); ;;; kukit.logDebug(content.length + ' nodes inserted.'); // update the events for the new nodes - ;;; kukit.logDebug("Inserted nodes length: "+insertedNodes.length); if (oper.parms.withKssSetup) { kukit.engine.setupEvents(content); } @@ -683,7 +680,6 @@ } ;;; kukit.logDebug(content.length + ' nodes inserted.'); // update the events for the new nodes - ;;; kukit.logDebug("Inserted nodes length: "+insertedNodes.length); if (oper.parms.withKssSetup) { kukit.engine.setupEvents(content); } From gotcha at codespeak.net Wed Dec 5 01:04:51 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 5 Dec 2007 01:04:51 +0100 (CET) Subject: [KSS-checkins] r49352 - kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser Message-ID: <20071205000451.98EAE8126@codespeak.net> Author: gotcha Date: Wed Dec 5 01:04:50 2007 New Revision: 49352 Modified: kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.css kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.pt Log: improve UI Modified: kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.css Wed Dec 5 01:04:50 2007 @@ -55,13 +55,13 @@ background-color: #880000; } -a.button, -input[type="submit"] { +a.button, .clickable { width: auto; padding: 0.2em; border: 1px solid #FF8888; color: #CC0000; text-decoration: none; + font-size: 80%; } fieldset { @@ -89,26 +89,22 @@ padding : 1em; } -.red { - color: red; -} - -.green { - color: green; +.production, .error { + color: red; } -.error { - color: red; +.production, .development { + font-weight: bold; } .warning { color: orange; } -.info { +.development, .info { color: green; } .debug { color: blue; -} \ No newline at end of file +} Modified: kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.pt ============================================================================== --- kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.pt (original) +++ kukit/kss.core/branch/ree-loglevels/kss/core/pluginregistry/browser/develui.pt Wed Dec 5 01:04:50 2007 @@ -57,42 +57,50 @@ loglevel python: options.get('loglevel', view.getLogLevel()); referer request/referer|request/HTTP_REFERER|nothing"> -

Kss mode setup

+

KSS mode setup

- Current KSS mode is - developmentproduction. + class="production" tal:condition="not: devel_mode">production mode.

-

+

+ The mode is stored in a cookie that is global to the site. +

+

+ It can be overridden by a local utility (eg. ResourceRegistries, in Plone). +

+ +

If you call @@kss_devel_mode/ison on the current context, - you get True if in development mode, False in in production mode. + you will get True in development mode, False in production mode.

-

- Set KSS mode cookie -

-
- Click the button to toggle mode. -
- -
- - - -
-

The cookie is global to the site and may be overridden by a - local utility (eg. ResourceRegistries, in Plone)

+
+

+ Set KSS mode cookie +

+

+ Click the button to toggle mode. +

+ +
+ + + +
+
+ +

+ Back to the referer page. +

KSS log level setup

@@ -102,39 +110,47 @@ tal:content="loglevel">DEBUG.

-
- Logging is only effective in Development mode. -
- -

- Set KSS log level -

+

+ The log level is stored in a cookie that is global to the site. +

+ +

+ Logging is effective only in development mode. +

+
-
- Click the button to set log level. -
- -
- - - -
-
- -
-

The cookie is global to the site.

+
+

+ Set KSS log level +

+

+ Click the button to set log level. +

+ + +
+ + + +
+
+ +
+
-

Back

+

+ Back to the referer page. +

From gotcha at codespeak.net Wed Dec 5 01:06:12 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 5 Dec 2007 01:06:12 +0100 (CET) Subject: [KSS-checkins] r49353 - kukit/kss.core/trunk/kss/core/plugins/core/demo Message-ID: <20071205000612.296EF8126@codespeak.net> Author: gotcha Date: Wed Dec 5 01:06:11 2007 New Revision: 49353 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt Log: update for new protocol Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt Wed Dec 5 01:06:11 2007 @@ -91,19 +91,18 @@ For instance, let's look at the moveToDivContent response.

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:kukit="http://www.kukit.org/commands/1.0"><body>
-<kukit:commands>
-<kukit:command selector="div#copy" name="copyChildNodesTo"
-               selectorType="">
-    <kukit:param name="html_id">demo</kukit:param>
-</kukit:command>
-<kukit:command selector="div#copy" name="clearChildNodes"
-               selectorType="">
-</kukit:command>
-</kukit:commands>
-</body></html>
+   
+<kukit xmlns="http://www.kukit.org/commands/1.0">
+<commands>
+<command selector="div#copy" name="copyChildNodesTo"
+         selectorType="">
+    <param name="html_id">demo</param>
+</command>
+<command selector="div#copy" name="clearChildNodes"
+         selectorType="">
+</command>
+</commands>
+</kukit>
    

The XML specifies two commands to apply to the div#copy node : From gotcha at codespeak.net Wed Dec 5 01:07:32 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 5 Dec 2007 01:07:32 +0100 (CET) Subject: [KSS-checkins] r49354 - in kukit/kss.core/trunk/kss/core: browser plugins/core/demo Message-ID: <20071205000732.CCC378126@codespeak.net> Author: gotcha Date: Wed Dec 5 01:07:32 2007 New Revision: 49354 Modified: kukit/kss.core/trunk/kss/core/browser/kukitresponse.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt Log: fix protocol version Modified: kukit/kss.core/trunk/kss/core/browser/kukitresponse.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/browser/kukitresponse.pt (original) +++ kukit/kss.core/trunk/kss/core/browser/kukitresponse.pt Wed Dec 5 01:07:32 2007 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/basic_commands.pt Wed Dec 5 01:07:32 2007 @@ -92,7 +92,7 @@

    
-<kukit xmlns="http://www.kukit.org/commands/1.0">
+<kukit xmlns="http://www.kukit.org/commands/1.1">
 <commands>
 <command selector="div#copy" name="copyChildNodesTo"
          selectorType="">

From gotcha at codespeak.net  Wed Dec  5 01:08:40 2007
From: gotcha at codespeak.net (gotcha at codespeak.net)
Date: Wed,  5 Dec 2007 01:08:40 +0100 (CET)
Subject: [KSS-checkins] r49355 - kukit/kss.demo/trunk/kss/demo/browser
Message-ID: <20071205000840.EFEC18126@codespeak.net>

Author: gotcha
Date: Wed Dec  5 01:08:40 2007
New Revision: 49355

Modified:
   kukit/kss.demo/trunk/kss/demo/browser/body_macros.pt
Log:
improve demo UI

Modified: kukit/kss.demo/trunk/kss/demo/browser/body_macros.pt
==============================================================================
--- kukit/kss.demo/trunk/kss/demo/browser/body_macros.pt	(original)
+++ kukit/kss.demo/trunk/kss/demo/browser/body_macros.pt	Wed Dec  5 01:08:40 2007
@@ -19,12 +19,12 @@
         

- Kss is in - development - production + KSS is in + development + production mode. - Setup + Setup

From reebalazs at codespeak.net Wed Dec 5 08:38:27 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 08:38:27 +0100 (CET) Subject: [KSS-checkins] r49360 - in kukit/kukit.js/trunk: doc kukit Message-ID: <20071205073827.827CE8115@codespeak.net> Author: reebalazs Date: Wed Dec 5 08:38:26 2007 New Revision: 49360 Modified: kukit/kukit.js/trunk/doc/HISTORY.txt kukit/kukit.js/trunk/kukit/dom.js kukit/kukit.js/trunk/kukit/utils.js Log: Implement loglevels based on cookies. Merge of branch ree-loglevels. Modified: kukit/kukit.js/trunk/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/trunk/doc/HISTORY.txt (original) +++ kukit/kukit.js/trunk/doc/HISTORY.txt Wed Dec 5 08:38:26 2007 @@ -6,6 +6,12 @@ - ... + - Implement loglevels based on cookies + Add cookie handling code to kss.dom + Change logging on FireBug to avoid line info in debug + level messages + [ree] + - Implement event binding based on the ids fetched dynamically from the dom, by value providers. [ree] Modified: kukit/kukit.js/trunk/kukit/dom.js ============================================================================== --- kukit/kukit.js/trunk/kukit/dom.js (original) +++ kukit/kukit.js/trunk/kukit/dom.js Wed Dec 5 08:38:26 2007 @@ -432,5 +432,30 @@ } }; + +/* + * Cookie handling code taken from: + * http://www.quirksmode.org/js/cookies.html + */ + +this.createCookie = function(name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else var expires = ""; + document.cookie = name + "=" + value + expires + "; path=/"; +} + +// we get this from kukit utils.js. We needed an early +// definition there, because logging is needed from the +// very beginning. +this.readCookie = kukit.readCookie; + +this.eraseCookie = function(name) { + createCookie(name, "", -1); +} + }(); /// MODULE END Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Wed Dec 5 08:38:26 2007 @@ -66,6 +66,94 @@ ;;; kukit.logWarning(msg); ;;; }; +/* + * Cookie handling code taken from: + * http://www.quirksmode.org/js/cookies.html + * Cookie handling is in dom.js, but this method + * is needed right here for log handling. + */ + +kukit.readCookie = function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + 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() {}; + +kukit._COOKIE_LOGLEVEL = '__kss_loglevel'; + +// an empty logger +kukit._logger = new function() { + + this.updateLogLevel = function() { +;;; // set default level +;;; this.loglevel = 0; +;;; // read the cookie +;;; var cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; if (cookie) { +;;; // decode it to a numeric level +;;; cookie = cookie.toLowerCase(); +;;; // Cookies are quoted in Zope, for some reason (???) +;;; // ie we get '"VALUE"' here. Let's compensate this. +;;; if (cookie.substr(0, 1) == '"') { +;;; cookie = cookie.substr(1, cookie.length - 2); +;;; } +;;; if (cookie == 'debug') this.loglevel = 0; +;;; if (cookie == 'info') this.loglevel = 1; +;;; if (cookie == 'warning') this.loglevel = 2; +;;; if (cookie == 'error') this.loglevel = 3; +;;; }; + // Call the function that sets up the handlers + this._setupHandlers(); + // Wrap the just set up handlers, to include wrapping +;;; this.logDebug = this._logFilter(this.logDebug, 0); +;;; this.log = this._logFilter(this.log, 1); +;;; this.logWarning = this._logFilter(this.logWarning, 2); +;;; this.logError = this._logFilter(this.logError, 3); +;;; this.logFatal = this._logFilter(this.logFatal, 3); + }; + + // Log filter, for use from the handlers. +;;; this._logFilter = function(f, currentlevel) { +;;; return (currentlevel >= this.loglevel) ? f : kukit._null; +;;; }; + + // This sets up the handlers and allows to set them + // up again with a different cookie setting. + // Will be overwritten by different loggers. + this._setupHandlers = function() { + this.logDebug = kukit._null; + this.log = kukit._null; + this.logWarning = kukit._null; + this.logError = kukit._null; + this.logFatal = kukit._null; + }; +}(); + +// Stub functions that can be used for logging +kukit.logDebug = function(message) {kukit._logger.logDebug(message);}; +kukit.log = function(message) {kukit._logger.log(message);}; +kukit.logWarning = function(message) {kukit._logger.logWarning(message);}; +kukit.logError = function(message) {kukit._logger.logError(message);}; +kukit.logFatal = function(message) {kukit._logger.logFatal(message);}; + +// Function to change the log level from javascript +// level must be one of "DEBUG", "INFO", "WARNING", "ERROR". +// (Small caps are tolerated as well) +kukit.setLogLevel = function(level) { +;;; // Store it in the cookie so that it persists through requests. +;;; 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; // you get a clickable result that brings you to Firebug inspector. @@ -73,74 +161,77 @@ // if (kukit.hasFirebug) { // kukit.log(node); // } -kukit.hasFirebug = false; ;;; // check whether the logging stuff of Firebug is available ;;; kukit.hasFirebug = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; result = result && typeof console.debug != 'undefined'; ;;; result = result && typeof console.error != 'undefined'; ;;; result = result && typeof console.warn != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasFirebug()) { -;;; kukit.log = console.log; -;;; kukit.logDebug = console.debug; -;;; kukit.logFatal = console.error; -;;; kukit.logError = console.error; -;;; kukit.logWarning = console.warn; -;;; kukit.hasFirebug = true; +;;; }(); + +;;; // Set up logging for FireBug +;;; if (kukit.hasFirebug) { +;;; kukit._logger._setupHandlers = function() { +;;; // for debug level we also log as 'info', because we do +;;; // not want FireBug to display line information. +;;; this.logDebug = console.log; +;;; this.log = console.log; +;;; this.logWarning = console.warn; +;;; this.logError = console.error; +;;; this.logFatal = console.error; +;;; } ;;; } ;;; // check whether the logging stuff of MochiKit is available ;;; kukit.hasMochiKit = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof MochiKit != 'undefined'; +;;; var result = typeof MochiKit != 'undefined'; ;;; result = result && typeof MochiKit.Logging != 'undefined'; ;;; result = result && typeof MochiKit.Logging.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasMochiKit()) { -;;; kukit.log = MochiKit.Logging.log; -;;; kukit.logError = MochiKit.Logging.logError; -;;; kukit.logDebug = MochiKit.Logging.logDebug; -;;; kukit.logFatal = MochiKit.Logging.logFatal; -;;; kukit.logWarning = MochiKit.Logging.logWarning; -;;; // make convenience url -;;; // javascript:kukit.showLog(); -;;; // instead of the need to say -;;; // javascript:void(createLoggingPane(true)); -;;; kukit.showLog = function() { -;;; createLoggingPane(true); -;;; }; +;;; }(); + +;;; // Set up logging for MochiKit +;;; if (! kukit.hasFirebug && kukit.hasMochiKit) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = MochiKit.Logging.logDebug; +;;; this.log = MochiKit.Logging.log; +;;; 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 +;;; // javascript:void(createLoggingPane(true)); +;;; kukit.showLog = function() { +;;; createLoggingPane(true); +;;; }; ;;; } ;;; // check whether the logging stuff of Safari is available ;;; kukit.hasSafari = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasSafari()) { -;;; kukit.log = function(str) { console.log('INFO: '+str); }; -;;; kukit.logError = function(str) { console.log('ERROR: '+str); }; -;;; kukit.logDebug = function(str) { console.log('DEBUG: '+str); }; -;;; kukit.logFatal = function(str) { console.log('FATAL: '+str); }; -;;; kukit.logWarning = function(str) { console.log('WARNING: '+str); }; -;;; } +;;; }(); -/* no logging solution available */ -;;; if (typeof kukit.log == 'undefined') { - kukit.log = function(str){}; - kukit.logError = kukit.log; - kukit.logDebug = kukit.log; - kukit.logFatal = kukit.log; - kukit.logWarning = kukit.log; +;;; // Set up logging for Safari +;;; if (! kukit.hasFirebug && ! kukit.hasMochiKit && kukit.hasSafari) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = function(str) { console.log('DEBUG: '+str); }; +;;; this.log = function(str) { console.log('INFO: '+str); }; +;;; 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 +kukit._logger.updateLogLevel(); + // log a startup message ;;; kukit.log('Loading KSS engine.'); From reebalazs at codespeak.net Wed Dec 5 08:42:06 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 08:42:06 +0100 (CET) Subject: [KSS-checkins] r49362 - in kukit/kss.core/trunk: docs kss/core/pluginregistry/browser Message-ID: <20071205074206.F1E8D80AF@codespeak.net> Author: reebalazs Date: Wed Dec 5 08:42:06 2007 New Revision: 49362 Modified: kukit/kss.core/trunk/docs/HISTORY.txt kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.css kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.pt kukit/kss.core/trunk/kss/core/pluginregistry/browser/develview.py Log: Implement loglevels based on cookies. Merge of branch ree-loglevels. Modified: kukit/kss.core/trunk/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/trunk/docs/HISTORY.txt (original) +++ kukit/kss.core/trunk/docs/HISTORY.txt Wed Dec 5 08:42:06 2007 @@ -6,6 +6,10 @@ - ... + - Implement loglevels based on cookies + Add handling of log levels to the kss mode view + [ree] + - Moved the core demos to this package from kss.demo. They are now located under the core plugin. [ree] Modified: kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.css Wed Dec 5 08:42:06 2007 @@ -55,13 +55,13 @@ background-color: #880000; } -a.button, -input[type="submit"] { +a.button, .clickable { width: auto; padding: 0.2em; border: 1px solid #FF8888; color: #CC0000; text-decoration: none; + font-size: 80%; } fieldset { @@ -89,11 +89,22 @@ padding : 1em; } -.red { - color: red; +.production, .error { + color: red; +} + +.production, .development { + font-weight: bold; } -.green { - color: green; +.warning { + color: orange; } +.development, .info { + color: green; +} + +.debug { + color: blue; +} Modified: kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.pt (original) +++ kukit/kss.core/trunk/kss/core/pluginregistry/browser/develui.pt Wed Dec 5 08:42:06 2007 @@ -54,46 +54,103 @@ + loglevel python: options.get('loglevel', view.getLogLevel()); + referer request/referer|request/HTTP_REFERER|nothing"> -

Kss mode setup

+

KSS mode setup

- Current KSS mode is - developmentproduction. + class="production" tal:condition="not: devel_mode">production mode.

-

+

+ The mode is stored in a cookie that is global to the site. +

+

+ It can be overridden by a local utility (eg. ResourceRegistries, in Plone). +

+ +

If you call @@kss_devel_mode/ison on the current context, - you get True if in development mode, False in in production mode. + you will get True in development mode, False in production mode.

-

- Set KSS mode cookie -

-
- Click the button to toggle mode. -
- -
- - - -
-

The cookie is global to the site and may be overridden by a - local utility (eg. ResourceRegistries, in Plone)

+
+

+ Set KSS mode cookie +

+

+ Click the button to toggle mode. +

+ +
+ + + +
+ +
+
+ +

+ Back to the referer page. +

+ +

KSS log level setup

+ +

+ Current KSS log level is + DEBUG. +

+

+ The log level is stored in a cookie that is global to the site. +

+ +

+ Logging is effective only in development mode. +

+ +
+
+

+ Set KSS log level +

+

+ Click the button to set log level. +

+ + +
+ + + +
+
+ +
+ +
-

Back

+

+ Back to the referer page. +

Modified: kukit/kss.core/trunk/kss/core/pluginregistry/browser/develview.py ============================================================================== --- kukit/kss.core/trunk/kss/core/pluginregistry/browser/develview.py (original) +++ kukit/kss.core/trunk/kss/core/pluginregistry/browser/develview.py Wed Dec 5 08:42:06 2007 @@ -11,7 +11,8 @@ from zope.traversing.interfaces import ITraverser from zope.publisher.interfaces import NotFound -COOKIE_NAME = '__kss_devel' +COOKIE_DEVELMODE = '__kss_devel' +COOKIE_LOGLEVEL = '__kss_loglevel' class DevelView(BrowserView): implements(IDevelView) @@ -37,7 +38,7 @@ return self, ('ui', ) # -- - # Accessable methods + # Methods for handling development/production mode # -- def ison(self): @@ -51,7 +52,7 @@ select development mode without the cookie ''' - ison = COOKIE_NAME in self.request.cookies + ison = COOKIE_DEVELMODE in self.request.cookies if not ison: # Check from javascript tool @@ -76,26 +77,51 @@ def set(self): 'Sets development mode cookie' - self.request.response.setCookie(COOKIE_NAME, '1', path='/') + self.request.response.setCookie(COOKIE_DEVELMODE, '1', path='/') def unset(self): 'Unsets development mode cookie' - self.request.response.expireCookie(COOKIE_NAME, path='/') + self.request.response.expireCookie(COOKIE_DEVELMODE, path='/') + + # -- + # Methods for handling loglevel + # -- + + def getLogLevel(self, REQUEST=None): + 'Gets current log level' + loglevel = self.request.cookies.get(COOKIE_LOGLEVEL, 'DEBUG').upper() + return loglevel + + def setLogLevel(self, loglevel): + 'Sets loglevel cookie' + self.request.response.setCookie(COOKIE_LOGLEVEL, loglevel, path='/') + + # -- + # User interface + # -- _ui = ViewPageTemplateFile('develui.pt', content_type='text/html;charset=utf-8') def ui(self): 'User interface for interactive switching' options = {} + # Handle development/production mode if 'devel' in self.request.form: self.set() # setting it also to have immediate effect in the page options['devel_mode'] = True if 'prod' in self.request.form: self.unset() - if COOKIE_NAME in self.request.cookies: + if COOKIE_DEVELMODE in self.request.cookies: # setting it also to have immediate effect in the page options['devel_mode'] = False + # Handle loglevel + if 'loglevel' in self.request.form: + loglevel = self.request.form['loglevel'] + self.setLogLevel(loglevel) + # setting it also to have immediate effect in the page + options['loglevel'] = loglevel + # Return the rendered template return self._ui(**options) def ui_js(self): From kukit-checkins at codespeak.net Wed Dec 5 08:55:13 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Wed, 5 Dec 2007 08:55:13 +0100 (CET) Subject: [KSS-checkins] December 79% OFF Message-ID: <20071205115526.4336.qmail@dsl85-106-64087.ttnet.net.tr> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071205/a766847c/attachment-0001.htm From reebalazs at codespeak.net Wed Dec 5 09:30:38 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 09:30:38 +0100 (CET) Subject: [KSS-checkins] r49363 - kukit/kukit.js/trunk/kukit Message-ID: <20071205083038.61BA6811E@codespeak.net> Author: reebalazs Date: Wed Dec 5 09:30:37 2007 New Revision: 49363 Modified: kukit/kukit.js/trunk/kukit/dom.js Log: After loglevel merge, change style to the closure standard and add missing semicolons. Modified: kukit/kukit.js/trunk/kukit/dom.js ============================================================================== --- kukit/kukit.js/trunk/kukit/dom.js (original) +++ kukit/kukit.js/trunk/kukit/dom.js Wed Dec 5 09:30:37 2007 @@ -438,7 +438,7 @@ * http://www.quirksmode.org/js/cookies.html */ -this.createCookie = function(name, value, days) { +dom.createCookie = function(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); @@ -446,16 +446,16 @@ } else var expires = ""; document.cookie = name + "=" + value + expires + "; path=/"; -} +}; // we get this from kukit utils.js. We needed an early // definition there, because logging is needed from the // very beginning. -this.readCookie = kukit.readCookie; +dom.readCookie = kukit.readCookie; -this.eraseCookie = function(name) { +dom.eraseCookie = function(name) { createCookie(name, "", -1); -} +}; }(); /// MODULE END From reebalazs at codespeak.net Wed Dec 5 10:13:32 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 10:13:32 +0100 (CET) Subject: [KSS-checkins] r49365 - in kukit/kukit.js/branch/1.2: doc kukit Message-ID: <20071205091332.5C5048121@codespeak.net> Author: reebalazs Date: Wed Dec 5 10:13:31 2007 New Revision: 49365 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt kukit/kukit.js/branch/1.2/kukit/dom.js kukit/kukit.js/branch/1.2/kukit/utils.js Log: Implement loglevels based on cookies. Merge from trunk -r49360, -r49363. Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Wed Dec 5 10:13:31 2007 @@ -6,8 +6,18 @@ - ... + - Implement loglevels based on cookies + Add cookie handling code to kss.dom + Change logging on FireBug to avoid line info in debug + level messages + [ree] + kukit.js - 1.2.3 Released 2007-11-08 + - Implement event binding based on the ids fetched + dynamically from the dom, by value providers. + [ree] + kukit.js - 1.2.2 Released 2007-10-05 - Some code for FireKiss Modified: kukit/kukit.js/branch/1.2/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/dom.js (original) +++ kukit/kukit.js/branch/1.2/kukit/dom.js Wed Dec 5 10:13:31 2007 @@ -483,3 +483,27 @@ return tags; }; +/* + * Cookie handling code taken from: + * http://www.quirksmode.org/js/cookies.html + */ + +kukit.dom.createCookie = function(name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else var expires = ""; + document.cookie = name + "=" + value + expires + "; path=/"; +}; + +// we get this from kukit utils.js. We needed an early +// definition there, because logging is needed from the +// very beginning. +kukit.dom.readCookie = kukit.readCookie; + +kukit.dom.eraseCookie = function(name) { + createCookie(name, "", -1); +}; + Modified: kukit/kukit.js/branch/1.2/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/utils.js (original) +++ kukit/kukit.js/branch/1.2/kukit/utils.js Wed Dec 5 10:13:31 2007 @@ -66,6 +66,94 @@ ;;; kukit.logWarning(msg); ;;; }; +/* + * Cookie handling code taken from: + * http://www.quirksmode.org/js/cookies.html + * Cookie handling is in dom.js, but this method + * is needed right here for log handling. + */ + +kukit.readCookie = function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + 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() {}; + +kukit._COOKIE_LOGLEVEL = '__kss_loglevel'; + +// an empty logger +kukit._logger = new function() { + + this.updateLogLevel = function() { +;;; // set default level +;;; this.loglevel = 0; +;;; // read the cookie +;;; var cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; if (cookie) { +;;; // decode it to a numeric level +;;; cookie = cookie.toLowerCase(); +;;; // Cookies are quoted in Zope, for some reason (???) +;;; // ie we get '"VALUE"' here. Let's compensate this. +;;; if (cookie.substr(0, 1) == '"') { +;;; cookie = cookie.substr(1, cookie.length - 2); +;;; } +;;; if (cookie == 'debug') this.loglevel = 0; +;;; if (cookie == 'info') this.loglevel = 1; +;;; if (cookie == 'warning') this.loglevel = 2; +;;; if (cookie == 'error') this.loglevel = 3; +;;; }; + // Call the function that sets up the handlers + this._setupHandlers(); + // Wrap the just set up handlers, to include wrapping +;;; this.logDebug = this._logFilter(this.logDebug, 0); +;;; this.log = this._logFilter(this.log, 1); +;;; this.logWarning = this._logFilter(this.logWarning, 2); +;;; this.logError = this._logFilter(this.logError, 3); +;;; this.logFatal = this._logFilter(this.logFatal, 3); + }; + + // Log filter, for use from the handlers. +;;; this._logFilter = function(f, currentlevel) { +;;; return (currentlevel >= this.loglevel) ? f : kukit._null; +;;; }; + + // This sets up the handlers and allows to set them + // up again with a different cookie setting. + // Will be overwritten by different loggers. + this._setupHandlers = function() { + this.logDebug = kukit._null; + this.log = kukit._null; + this.logWarning = kukit._null; + this.logError = kukit._null; + this.logFatal = kukit._null; + }; +}(); + +// Stub functions that can be used for logging +kukit.logDebug = function(message) {kukit._logger.logDebug(message);}; +kukit.log = function(message) {kukit._logger.log(message);}; +kukit.logWarning = function(message) {kukit._logger.logWarning(message);}; +kukit.logError = function(message) {kukit._logger.logError(message);}; +kukit.logFatal = function(message) {kukit._logger.logFatal(message);}; + +// Function to change the log level from javascript +// level must be one of "DEBUG", "INFO", "WARNING", "ERROR". +// (Small caps are tolerated as well) +kukit.setLogLevel = function(level) { +;;; // Store it in the cookie so that it persists through requests. +;;; 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; // you get a clickable result that brings you to Firebug inspector. @@ -73,74 +161,77 @@ // if (kukit.hasFirebug) { // kukit.log(node); // } -kukit.hasFirebug = false; ;;; // check whether the logging stuff of Firebug is available ;;; kukit.hasFirebug = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; result = result && typeof console.debug != 'undefined'; ;;; result = result && typeof console.error != 'undefined'; ;;; result = result && typeof console.warn != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasFirebug()) { -;;; kukit.log = console.log; -;;; kukit.logDebug = console.debug; -;;; kukit.logFatal = console.error; -;;; kukit.logError = console.error; -;;; kukit.logWarning = console.warn; -;;; kukit.hasFirebug = true; +;;; }(); + +;;; // Set up logging for FireBug +;;; if (kukit.hasFirebug) { +;;; kukit._logger._setupHandlers = function() { +;;; // for debug level we also log as 'info', because we do +;;; // not want FireBug to display line information. +;;; this.logDebug = console.log; +;;; this.log = console.log; +;;; this.logWarning = console.warn; +;;; this.logError = console.error; +;;; this.logFatal = console.error; +;;; } ;;; } ;;; // check whether the logging stuff of MochiKit is available ;;; kukit.hasMochiKit = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof MochiKit != 'undefined'; +;;; var result = typeof MochiKit != 'undefined'; ;;; result = result && typeof MochiKit.Logging != 'undefined'; ;;; result = result && typeof MochiKit.Logging.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasMochiKit()) { -;;; kukit.log = MochiKit.Logging.log; -;;; kukit.logError = MochiKit.Logging.logError; -;;; kukit.logDebug = MochiKit.Logging.logDebug; -;;; kukit.logFatal = MochiKit.Logging.logFatal; -;;; kukit.logWarning = MochiKit.Logging.logWarning; -;;; // make convenience url -;;; // javascript:kukit.showLog(); -;;; // instead of the need to say -;;; // javascript:void(createLoggingPane(true)); -;;; kukit.showLog = function() { -;;; createLoggingPane(true); -;;; }; +;;; }(); + +;;; // Set up logging for MochiKit +;;; if (! kukit.hasFirebug && kukit.hasMochiKit) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = MochiKit.Logging.logDebug; +;;; this.log = MochiKit.Logging.log; +;;; 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 +;;; // javascript:void(createLoggingPane(true)); +;;; kukit.showLog = function() { +;;; createLoggingPane(true); +;;; }; ;;; } ;;; // check whether the logging stuff of Safari is available ;;; kukit.hasSafari = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasSafari()) { -;;; kukit.log = function(str) { console.log('INFO: '+str); }; -;;; kukit.logError = function(str) { console.log('ERROR: '+str); }; -;;; kukit.logDebug = function(str) { console.log('DEBUG: '+str); }; -;;; kukit.logFatal = function(str) { console.log('FATAL: '+str); }; -;;; kukit.logWarning = function(str) { console.log('WARNING: '+str); }; -;;; } +;;; }(); -/* no logging solution available */ -;;; if (typeof kukit.log == 'undefined') { - kukit.log = function(str){}; - kukit.logError = kukit.log; - kukit.logDebug = kukit.log; - kukit.logFatal = kukit.log; - kukit.logWarning = kukit.log; +;;; // Set up logging for Safari +;;; if (! kukit.hasFirebug && ! kukit.hasMochiKit && kukit.hasSafari) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = function(str) { console.log('DEBUG: '+str); }; +;;; this.log = function(str) { console.log('INFO: '+str); }; +;;; 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 +kukit._logger.updateLogLevel(); + // log a startup message ;;; kukit.log('Loading KSS engine.'); From reebalazs at codespeak.net Wed Dec 5 10:14:11 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 10:14:11 +0100 (CET) Subject: [KSS-checkins] r49366 - kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser Message-ID: <20071205091411.D612A8129@codespeak.net> Author: reebalazs Date: Wed Dec 5 10:14:11 2007 New Revision: 49366 Modified: kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.css kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.pt kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develview.py Log: Implement loglevels based on cookies. Backport from trunk -r49362 Modified: kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.css Wed Dec 5 10:14:11 2007 @@ -55,13 +55,13 @@ background-color: #880000; } -a.button, -input[type="submit"] { +a.button, .clickable { width: auto; padding: 0.2em; border: 1px solid #FF8888; color: #CC0000; text-decoration: none; + font-size: 80%; } fieldset { @@ -89,11 +89,22 @@ padding : 1em; } -.red { - color: red; +.production, .error { + color: red; +} + +.production, .development { + font-weight: bold; } -.green { - color: green; +.warning { + color: orange; } +.development, .info { + color: green; +} + +.debug { + color: blue; +} Modified: kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.pt ============================================================================== --- kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.pt (original) +++ kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develui.pt Wed Dec 5 10:14:11 2007 @@ -46,42 +46,104 @@ - + -

Kss development mode browser setup

-
+

KSS mode setup

+

- Different browser side parameters can be set up. -

+ KSS is in developmentproduction mode. +

-

- @@kss_devel_mode/ison on the current context -

+

+ The mode is stored in a cookie that is global to the site. +

+

+ It can be overridden by a local utility (eg. ResourceRegistries, in Plone). +

+ +

+ If you call @@kss_devel_mode/ison on the current context, + you will get True in development mode, False in production mode. +

+ +
+

+ Set KSS mode cookie +

+

+ Click the button to toggle mode. +

+ +
+ + + +
+ +
+
+ +

+ Back to the referer page. +

+ +

KSS log level setup

+

- Kss development mode is - on - off - -

- -

- Set kss development mode cookie -

-

The cookie is global to the site and may be overridden by a - local utility (eg. ResourceRegistries, in Plone)

-
- Click the button here. -
- -
- - -
+ Current KSS log level is + DEBUG. +

+ +

+ The log level is stored in a cookie that is global to the site. +

+ +

+ Logging is effective only in development mode. +

+ +
+
+

+ Set KSS log level +

+

+ Click the button to set log level. +

+ + +
+ + + +
+
+ +
+
+

+ Back to the referer page. +

+ Modified: kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develview.py ============================================================================== --- kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develview.py (original) +++ kukit/kss.core/branch/1.2/kss/core/pluginregistry/browser/develview.py Wed Dec 5 10:14:11 2007 @@ -11,7 +11,8 @@ from zope.traversing.interfaces import ITraverser from zope.publisher.interfaces import NotFound -COOKIE_NAME = '__kss_devel' +COOKIE_DEVELMODE = '__kss_devel' +COOKIE_LOGLEVEL = '__kss_loglevel' class DevelView(BrowserView): implements(IDevelView) @@ -37,7 +38,7 @@ return self, ('ui', ) # -- - # Accessable methods + # Methods for handling development/production mode # -- def ison(self): @@ -51,7 +52,7 @@ select development mode without the cookie ''' - ison = COOKIE_NAME in self.request.cookies + ison = COOKIE_DEVELMODE in self.request.cookies if not ison: # Check from javascript tool @@ -76,26 +77,51 @@ def set(self): 'Sets development mode cookie' - self.request.response.setCookie(COOKIE_NAME, '1', path='/') + self.request.response.setCookie(COOKIE_DEVELMODE, '1', path='/') def unset(self): 'Unsets development mode cookie' - self.request.response.expireCookie(COOKIE_NAME, path='/') + self.request.response.expireCookie(COOKIE_DEVELMODE, path='/') + + # -- + # Methods for handling loglevel + # -- + + def getLogLevel(self, REQUEST=None): + 'Gets current log level' + loglevel = self.request.cookies.get(COOKIE_LOGLEVEL, 'DEBUG').upper() + return loglevel + + def setLogLevel(self, loglevel): + 'Sets loglevel cookie' + self.request.response.setCookie(COOKIE_LOGLEVEL, loglevel, path='/') + + # -- + # User interface + # -- _ui = ViewPageTemplateFile('develui.pt', content_type='text/html;charset=utf-8') def ui(self): 'User interface for interactive switching' options = {} + # Handle development/production mode if 'devel' in self.request.form: self.set() # setting it also to have immediate effect in the page options['devel_mode'] = True if 'prod' in self.request.form: self.unset() - if COOKIE_NAME in self.request.cookies: + if COOKIE_DEVELMODE in self.request.cookies: # setting it also to have immediate effect in the page options['devel_mode'] = False + # Handle loglevel + if 'loglevel' in self.request.form: + loglevel = self.request.form['loglevel'] + self.setLogLevel(loglevel) + # setting it also to have immediate effect in the page + options['loglevel'] = loglevel + # Return the rendered template return self._ui(**options) def ui_js(self): From reebalazs at codespeak.net Wed Dec 5 11:49:46 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 11:49:46 +0100 (CET) Subject: [KSS-checkins] r49372 - kukit/kss.core/trunk/kss/core/plugins/core/demo Message-ID: <20071205104946.11C77168442@codespeak.net> Author: reebalazs Date: Wed Dec 5 11:49:45 2007 New Revision: 49372 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt Log: Fix error demo (contained obsolate kukit-xxx-yyy markup) Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt Wed Dec 5 11:49:45 2007 @@ -38,29 +38,29 @@ on the server.

The buttons in the first row have no error handled.

- - - - -

The buttons in the second row have individual error handlers.

- - - - -

From reebalazs at codespeak.net Wed Dec 5 12:35:39 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 12:35:39 +0100 (CET) Subject: [KSS-checkins] r49373 - kukit/kss.core/trunk/kss/core/plugins/core/demo Message-ID: <20071205113539.A8A81168444@codespeak.net> Author: reebalazs Date: Wed Dec 5 12:35:35 2007 New Revision: 49373 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss Log: Further fix the error demo Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py Wed Dec 5 12:35:35 2007 @@ -155,7 +155,7 @@ if act == 'error': raise Exception, 'We have an error here.' elif act == 'explicit': - raise KssExplicitError, 'Explicit error raised.' + raise KSSExplicitError, 'Explicit error raised.' elif act == 'empty': # Just do nothing, we want to return a response with no commands. # This is valid behaviour, should raise no error, however Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss Wed Dec 5 12:35:35 2007 @@ -24,11 +24,9 @@ */ .handled:click { - errTest-error: executeCommand; - executeCommand-commandSelector: 'update-status'; - executeCommand-commandSelectorType: htmlid; - executeCommand-commandName: replaceInnerHTML; - executeCommand-html: 'Error handler activated.'; + errTest-error: replaceInnerHTML; + replaceInnerHTML-kssSelector: htmlid('update-status'); + replaceInnerHTML-html: 'Error handler activated.'; } /* Spinner control From reebalazs at codespeak.net Wed Dec 5 13:33:55 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 13:33:55 +0100 (CET) Subject: [KSS-checkins] r49377 - kukit/kukit.js/trunk/kukit Message-ID: <20071205123355.DAAEE168473@codespeak.net> Author: reebalazs Date: Wed Dec 5 13:33:55 2007 New Revision: 49377 Modified: kukit/kukit.js/trunk/kukit/commandprocessor.js kukit/kukit.js/trunk/kukit/errors.js kukit/kukit.js/trunk/kukit/kukit.js kukit/kukit.js/trunk/kukit/serveraction.js Log: Fix error handling. Due to excess commenting, the following problems persisted: - error fallback actions were not executed in production mode - explicit error reason (server reason = ) was never displayed (neither in producttion and development mode) - If there is a problem with the kukit response, there is no error signalled in production mode. I still could not solve this last one. At the moment error demo works correctly. Modified: kukit/kukit.js/trunk/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/trunk/kukit/commandprocessor.js (original) +++ kukit/kukit.js/trunk/kukit/commandprocessor.js Wed Dec 5 13:33:55 2007 @@ -41,8 +41,9 @@ // we make sure we execute none of them. var lastcommand = this.commands[this.commands.length-1]; if (lastcommand.name == 'error') { -;;; throw kukit.err.explicitError(lastcommand); - throw new Error(kukit.E); + // We have to throw an explicitError always, since we want + // error fallbacks work both in production and development mode. + throw kukit.err.explicitError(lastcommand); } } }; Modified: kukit/kukit.js/trunk/kukit/errors.js ============================================================================== --- kukit/kukit.js/trunk/kukit/errors.js (original) +++ kukit/kukit.js/trunk/kukit/errors.js Wed Dec 5 13:33:55 2007 @@ -55,67 +55,84 @@ */ -;;; var ErrorAnnotation = function() { -;;; -;;; this.constructError = function(e, name, message, kw) { -;;; if (typeof(kw) == "undefined") { -;;; kw = {}; -;;; } -;;; this.kw = kw; -;;; this.message = name + ': ' + message; -;;; var addMessage = true; -;;; if (!e) { -;;; e = new Error(message); -;;; addMessage = false; -;;; } else if (typeof(e) == "string") { -;;; kukit.E = 'Do not raise string exceptions, as we cannot '; -;;; kukit.E += 'annotate them properly. Use: throw new Error(msg);'; -;;; e = new Error(e); -;;; } -;;; this.previous_info = e.info; -;;; e.name = name; -;;; e.info = this; -;;; if (addMessage) { -;;; var fullMessage = message + ' [' + e.message + ']'; -;;; // for FF, and Safari: -;;; e.message = fullMessage; -;;; // for IE, message is ignored, description is used. -;;; e.description = fullMessage; +var ErrorAnnotation = function() { + + this.constructError = function(e, name, message, kw) { +;;; if (typeof(kw) == "undefined") { +;;; kw = {}; +;;; } + this.kw = kw; +;;; this.message = name + ': ' + message; +;;; var addMessage = true; + if (!e) { +;;; e = new Error(message); +;;; addMessage = false; +;;; } else if (typeof(e) == "string") { +;;; kukit.E = 'Do not raise string exceptions, as we cannot '; +;;; kukit.E += 'annotate them properly. Use: throw new Error(msg);'; + e = new Error(kukit.E); + } +;;; this.previous_info = e.info; + e.name = name; + e.info = this; +;;; if (addMessage) { +;;; var fullMessage = message + ' [' + e.message + ']'; +;;; // for FF, and Safari: +;;; e.message = fullMessage; +;;; // for IE, message is ignored, description is used. +;;; e.description = fullMessage; ;;; } -;;; return e; -;;; }; + return e; + }; ;;; -;;; this._logRecursive = function() { -;;; kukit.logError(this.message); -;;; if (this.previous_info) { -;;; this.previous_info._logRecursive(); -;;; } -;;; }; +;;; this._logRecursive = function() { +;;; kukit.logError(this.message); +;;; if (this.previous_info) { +;;; this.previous_info._logRecursive(); +;;; } +;;; }; ;;; -;;; this.log = function() { -;;; // This is for debugging only, normal error handling -;;; // does not use it. -;;; kukit.logFatal('KSS error, stack information follows:'); -;;; this._logRecursive(); -;;; }; +;;; this.log = function() { +;;; // This is for debugging only, normal error handling +;;; // does not use it. +;;; kukit.logFatal('KSS error, stack information follows:'); +;;; this._logRecursive(); ;;; }; -;;; var setErrorInfo = function(e, name, message, kw) { -;;; return new ErrorAnnotation().constructError(e, name, message, kw); -;;; }; +}; + +var setErrorInfo = function(e, name, message, kw) { + return new ErrorAnnotation().constructError(e, name, message, kw); +}; /* Protects a function */ -;;; err.explicitError = function(errorcommand){ -;;; var kw = {'errorcommand':errorcommand}; -;;; var message = 'Explicit error'; -;;; return setErrorInfo(null, 'ExplicitError', message, kw); -;;; }; - -;;; err.responseParsingError = function(message){ -;;; return setErrorInfo(null, 'ResponseParsingError', message); -;;; }; +/* + * Explicit error represents that the server side action failed and + * we need to handle this with an explicit error action defined from + * kss. + * There are three main cases when this can happen: + * + * 1. In case the server explicitely sent us an error (hence the + * name of this class) the parameter will contain the kss + * command from the payload. + * + * 2. If a payload response parsing error lead us here, then it + * will contain a string of the error message. + * + * 3. If a timeout of the response happened, the parameter will + * contain the text "timeout". + */ +err.explicitError = function(errorcommand){ + var kw = {'errorcommand': errorcommand}; +;;; kukit.E = 'Explicit error'; + return setErrorInfo(null, 'ExplicitError', kukit.E, kw); +}; + +err.responseParsingError = function(message){ + return setErrorInfo(null, 'ResponseParsingError', message); +}; ;;; err.ruleMergeError = function(message){ ;;; return setErrorInfo(null, 'RuleMergeError', message); Modified: kukit/kukit.js/trunk/kukit/kukit.js ============================================================================== --- kukit/kukit.js/trunk/kukit/kukit.js (original) +++ kukit/kukit.js/trunk/kukit/kukit.js Wed Dec 5 13:33:55 2007 @@ -92,7 +92,8 @@ if((nodes[i].type == 'text/css') || (nodes[i].type == 'text/kss')) { res_type = 'kss'; ;;; } else { -;;; throw kukit.err.explicitError("rel type is not text/css or text/kss"); +;;; // Just show this, and go on with the processing. +;;; kukit.logError("rel type is not text/css or text/kss"); } var newRuleLink = new kukit.RuleSheetLink(nodes[i].href, res_type); results[results.length] = newRuleLink; Modified: kukit/kukit.js/trunk/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/trunk/kukit/serveraction.js (original) +++ kukit/kukit.js/trunk/kukit/serveraction.js Wed Dec 5 13:33:55 2007 @@ -111,20 +111,24 @@ if (success) { // catch the errors otherwise won't get logged. // In FF they seem to get swallowed silently. -;;; try { + // We need these both in production and development mode, + // since the erorr fallbacks are activated from processError. + try { // process the results this.processResult(domDoc); -;;; } catch(e) { + } catch(e) { ;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { ;;; throw kukit.err.eventSetupError(e); -;;; } else if (e.name == 'ResponseParsingError') { -;;; this.processError('Response parsing error: ' + e); -;;; } else if (e.name == 'ExplicitError') { -;;; this.processError(e.errorcommand); -;;; } else { -;;; throw e; -;;; } -;;; } +;;; } + if (e.name == 'ResponseParsingError') { +;;; kukit.E = 'Response parsing error: ' + e; + this.processError(kukit.E); + } else if (e.name == 'ExplicitError') { + this.processError(e.info.kw.errorcommand); + } else { + throw e; + } + } } } }; @@ -151,9 +155,8 @@ try { dom = (new DOMParser()).parseFromString(payload, "text/xml"); } catch(e) { -;;; var msg = 'Error parsing X-KSSCOMMANDS header.'; -;;; throw kukit.err.responseParsingError(msg); - throw new Error(kukit.E); +;;; kukit.E = 'Error parsing X-KSSCOMMANDS header.'; + throw kukit.err.responseParsingError(kukit.E); } commandstags = kukit.dom.getNsTags(dom, 'commands'); if (commandstags.length != 1) { @@ -166,21 +169,19 @@ // and log it as reported from the dom // Opera <= 8.5 does not have the parseError attribute, // so check for it first - dom = domDoc.responseXML; -;;; var msg = 'Unknown server error (invalid KSS response, no error'; -;;; msg += ' info received)'; +;;; dom = domDoc.responseXML; +;;; kukit.E = 'Unknown server error (invalid KSS response, no error'; +;;; kukit.E += ' info received)'; ;;; if (dom && dom.parseError && (dom.parseError != 0)) { -;;; msg += ' : ' + Sarissa.getParseErrorText(dom); +;;; kukit.E += ' : ' + Sarissa.getParseErrorText(dom); ;;; } -;;; throw kukit.err.responseParsingError(msg); - throw new Error(kukit.E); + throw kukit.err.responseParsingError(kukit.E); } } if (dom == null) { // this should not happen -;;; var msg = 'Neither xml nor html payload.'; -;;; throw kukit.err.responseParsingError(msg); - throw new Error(kukit.E); +;;; kukit.E = 'Neither xml nor html payload.'; + throw kukit.err.responseParsingError(msg); } // find the commands (atm we don't limit ourselves inside the commandstag) var commands = kukit.dom.getNsTags(dom, 'command'); @@ -207,6 +208,9 @@ ;;; reason = ', client_reason="' + errorcommand + '" '; ;;; } else if (typeof(errorcommand) != 'undefined') { ;;; // a real error command, sent by the server +;;; // as kukit payload. +;;; // this way the server sends whatever message he wants as a parameter +;;; // to the error command. ;;; reason = ', server_reason="' + errorcommand.parms.message + '" '; ;;; } if (error_action) { @@ -221,6 +225,14 @@ ;;; kukit.E = 'Request failed at url ' + this.oper.queueItem.url; ;;; kukit.E += ', rid=' + this.oper.queueItem.rid + reason; ;;; kukit.logError(kukit.E); +;;; return; + // in case of no logging, we would like to throw an error. + // This means user will see something went wrong. + // XXX But: throwing an error on Firefox + // _seems to be ineffective__ + // and throwing the error from IE + // _throws an ugly window, "Uncaught exception" + // TODO figure out something? } -}; +; From reebalazs at codespeak.net Wed Dec 5 14:00:16 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:00:16 +0100 (CET) Subject: [KSS-checkins] r49380 - kukit/kss.demo/branch/1.2/kss/demo Message-ID: <20071205130016.19BC0168481@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:00:16 2007 New Revision: 49380 Modified: kukit/kss.demo/branch/1.2/kss/demo/events.py kukit/kss.demo/branch/1.2/kss/demo/interfaces.py kukit/kss.demo/branch/1.2/kss/demo/registry.py Log: Port back critical bugfix -r47443 from trunk: demo plugins are not loaded (empty screen) depending on zcml loading order. Modified: kukit/kss.demo/branch/1.2/kss/demo/events.py ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/events.py (original) +++ kukit/kss.demo/branch/1.2/kss/demo/events.py Wed Dec 5 14:00:16 2007 @@ -8,13 +8,19 @@ IKSSDemoResource, IKSSSeleniumTestResource, IKSSDemoRegistrationEvent, + IKSSDemoRegistryEvent, + IKSSDemoRegistry ) from zope.interface import implements class KSSDemoRegistrationEvent(object): - """Redispatch of registration for demo utilities""" + """Redispatch of registration for demo resource utilities""" implements(IKSSDemoRegistrationEvent) +class KSSDemoRegistryEvent(object): + """Redispatch of registration for demo registry utilities""" + implements(IKSSDemoRegistryEvent) + @zope.component.adapter(IUtilityRegistration, IRegistrationEvent) def dispatchRegistration(registration, event): """When a demo utility is registered, add it to the registry. @@ -24,9 +30,14 @@ """ component = registration.component # Only dispatch registration of the interesting utilities. - new_event = KSSDemoRegistrationEvent() if IKSSDemoResource.providedBy(component) or \ IKSSSeleniumTestResource.providedBy(component): + new_event = KSSDemoRegistrationEvent() + handlers = zope.component.subscribers((component, registration, event, new_event), None) + for handler in handlers: + pass # getting them does the work + if IKSSDemoRegistry.providedBy(component): + new_event = KSSDemoRegistryEvent() handlers = zope.component.subscribers((component, registration, event, new_event), None) for handler in handlers: pass # getting them does the work Modified: kukit/kss.demo/branch/1.2/kss/demo/interfaces.py ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/interfaces.py (original) +++ kukit/kss.demo/branch/1.2/kss/demo/interfaces.py Wed Dec 5 14:00:16 2007 @@ -140,6 +140,11 @@ # -- class IKSSDemoRegistrationEvent(Interface): - """Redispatched evend for registration of - IKSSPDemoRegistry utilities. + """Redispatched event for registration of + IKSSDemoRegistration utilities (resources). + """ + +class IKSSDemoRegistryEvent(Interface): + """Redispatched event for registration of + IKSSDemoRegistry utilities. """ Modified: kukit/kss.demo/branch/1.2/kss/demo/registry.py ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/registry.py (original) +++ kukit/kss.demo/branch/1.2/kss/demo/registry.py Wed Dec 5 14:00:16 2007 @@ -9,6 +9,7 @@ IKSSDemoResource, IKSSSeleniumTestResource, IKSSDemoRegistrationEvent, + IKSSDemoRegistryEvent, ) from zope.component.interfaces import ( IUtilityRegistration, @@ -55,10 +56,26 @@ self.demos_are_sorted = False site.registerHandler(self.registerDemosFromPlugin) site.registerHandler(self.unregisterDemosFromPlugin) + site.registerHandler(self.registerEarlierDemos) # registry for selenium tests self.selenium_tests = [] site.registerHandler(self.registerSeleniumTestsFromPlugin) site.registerHandler(self.unregisterSeleniumTestsFromPlugin) + # ... the rest of setup will be done from registerEarlierDemos + + @adapter(IKSSDemoRegistry, IUtilityRegistration, IRegistered, IKSSDemoRegistryEvent) + def registerEarlierDemos(self, registry, registration=None, event=None, new_event=None): + """Make sure that the resources registered earlier, are added + (so this is a listener to the registration of myself + which is needed because CA is not ready at time of the __init__) + """ + if registry != self: + # The utility only register on itself. + return + site = getSiteManager() + for name, plugin in site.getUtilitiesFor(IKSSDemoResource): + for demo in plugin.demos: + self.registerDemo(demo) @adapter(IKSSDemoResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) def registerDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None): From reebalazs at codespeak.net Wed Dec 5 14:05:54 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:05:54 +0100 (CET) Subject: [KSS-checkins] r49381 - kukit/kss.core/trunk/kss/core/plugins/core/demo Message-ID: <20071205130554.199F116848D@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:05:54 2007 New Revision: 49381 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss Log: Remove comment from demo that is not needed any more. Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss Wed Dec 5 14:05:54 2007 @@ -18,11 +18,6 @@ } */ -/* The next rule demonstrates that instead of executing a local - action on the originally selected node, we use executeCommand - which execute a given local action on a new set of selected nodes. -*/ - .handled:click { errTest-error: replaceInnerHTML; replaceInnerHTML-kssSelector: htmlid('update-status'); From reebalazs at codespeak.net Wed Dec 5 14:13:33 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:13:33 +0100 (CET) Subject: [KSS-checkins] r49382 - kukit/kss.demo/branch/1.2/kss/demo/demo Message-ID: <20071205131333.49F48168470@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:13:32 2007 New Revision: 49382 Modified: kukit/kss.demo/branch/1.2/kss/demo/demo/demoview.py kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.kss kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.pt Log: Fix error handling demo (backport -r49371:49373 from trunk of kss.core) Modified: kukit/kss.demo/branch/1.2/kss/demo/demo/demoview.py ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/demo/demoview.py (original) +++ kukit/kss.demo/branch/1.2/kss/demo/demo/demoview.py Wed Dec 5 14:13:32 2007 @@ -155,7 +155,7 @@ if act == 'error': raise Exception, 'We have an error here.' elif act == 'explicit': - raise KssExplicitError, 'Explicit error raised.' + raise KSSExplicitError, 'Explicit error raised.' elif act == 'empty': # Just do nothing, we want to return a response with no commands. # This is valid behaviour, should raise no error, however Modified: kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.kss ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.kss (original) +++ kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.kss Wed Dec 5 14:13:32 2007 @@ -18,17 +18,10 @@ } */ -/* The next rule demonstrates that instead of executing a local - action on the originally selected node, we use executeCommand - which execute a given local action on a new set of selected nodes. -*/ - .handled:click { - errTest-error: executeCommand; - executeCommand-commandSelector: 'update-status'; - executeCommand-commandSelectorType: htmlid; - executeCommand-commandName: replaceInnerHTML; - executeCommand-html: 'Error handler activated.'; + errTest-error: replaceInnerHTML; + replaceInnerHTML-kssSelector: htmlid('update-status'); + replaceInnerHTML-html: 'Error handler activated.'; } /* Spinner control Modified: kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.pt ============================================================================== --- kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.pt (original) +++ kukit/kss.demo/branch/1.2/kss/demo/demo/error_handling.pt Wed Dec 5 14:13:32 2007 @@ -34,29 +34,29 @@ on the server.

The buttons in the first row have no error handled.

- - - - -

The buttons in the second row have individual error handlers.

- - - - -

From reebalazs at codespeak.net Wed Dec 5 14:15:24 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:15:24 +0100 (CET) Subject: [KSS-checkins] r49383 - kukit/kukit.js/trunk/doc Message-ID: <20071205131524.151A9168470@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:15:24 2007 New Revision: 49383 Modified: kukit/kukit.js/trunk/doc/HISTORY.txt Log: Add history for previous fix Modified: kukit/kukit.js/trunk/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/trunk/doc/HISTORY.txt (original) +++ kukit/kukit.js/trunk/doc/HISTORY.txt Wed Dec 5 14:15:24 2007 @@ -6,6 +6,9 @@ - ... + - Fix error fallback handling + [ree] + - Implement loglevels based on cookies Add cookie handling code to kss.dom Change logging on FireBug to avoid line info in debug From reebalazs at codespeak.net Wed Dec 5 14:16:41 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:16:41 +0100 (CET) Subject: [KSS-checkins] r49384 - kukit/kss.core/trunk/docs Message-ID: <20071205131641.A621D168470@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:16:40 2007 New Revision: 49384 Modified: kukit/kss.core/trunk/docs/HISTORY.txt Log: Add history for previous fix Modified: kukit/kss.core/trunk/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/trunk/docs/HISTORY.txt (original) +++ kukit/kss.core/trunk/docs/HISTORY.txt Wed Dec 5 14:16:40 2007 @@ -6,6 +6,9 @@ - ... + - Fix error fallback handling + [ree] + - Implement loglevels based on cookies Add handling of log levels to the kss mode view [ree] From reebalazs at codespeak.net Wed Dec 5 14:18:26 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:18:26 +0100 (CET) Subject: [KSS-checkins] r49385 - kukit/kss.demo/branch/1.2/docs Message-ID: <20071205131826.A3554168470@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:18:21 2007 New Revision: 49385 Modified: kukit/kss.demo/branch/1.2/docs/HISTORY.txt Log: Add history for previous commits Modified: kukit/kss.demo/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.demo/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.demo/branch/1.2/docs/HISTORY.txt Wed Dec 5 14:18:21 2007 @@ -6,6 +6,12 @@ - ... + - Fix error demo + [ree] + + - Fix bug in pluggable demos + [ree] + - Implement pluggable demos [ree] From reebalazs at codespeak.net Wed Dec 5 14:52:08 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:52:08 +0100 (CET) Subject: [KSS-checkins] r49386 - in kukit/kukit.js/branch/1.2: doc kukit Message-ID: <20071205135208.37394168486@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:52:05 2007 New Revision: 49386 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt kukit/kukit.js/branch/1.2/kukit/commandprocessor.js kukit/kukit.js/branch/1.2/kukit/errors.js kukit/kukit.js/branch/1.2/kukit/serveraction.js Log: Fix error handling. Due to excess commenting, the following problems persisted: - error fallback actions were not executed in production mode - explicit error reason (server reason = ) was never displayed (neither in producttion and development mode) - If there is a problem with the kukit response, there is no error signalled in production mode. I still could not solve this last one. At the moment error demo works correctly. This is backport of fix -r49377 on trunk. Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Wed Dec 5 14:52:05 2007 @@ -6,6 +6,9 @@ - ... + - Fix error fallback handling + [ree] + - Implement loglevels based on cookies Add cookie handling code to kss.dom Change logging on FireBug to avoid line info in debug Modified: kukit/kukit.js/branch/1.2/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/1.2/kukit/commandprocessor.js Wed Dec 5 14:52:05 2007 @@ -39,8 +39,9 @@ // we make sure we execute none of them. var lastcommand = this.commands[this.commands.length-1]; if (lastcommand.name == 'error') { -;;; kukit.E = new kukit.err.ExplicitError(lastcommand); - throw kukit.E; + // We have to throw an explicitError always, since we want + // error fallbacks work both in production and development mode. + throw new kukit.err.ExplicitError(lastcommand); } } }; Modified: kukit/kukit.js/branch/1.2/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/errors.js (original) +++ kukit/kukit.js/branch/1.2/kukit/errors.js Wed Dec 5 14:52:05 2007 @@ -71,19 +71,19 @@ return exc; }; -;;; // this should be thrown with the error command as parameter -;;; kukit.err.ExplicitError = kukit.err.exceptionFactory('ExplicitError'); -;;; kukit.err.ee = kukit.err.ExplicitError; -;;; kukit.err.ee.prototype.__superinit__ = kukit.err.ee.prototype.__init__; -;;; kukit.err.ee.prototype.__init__ = function(name, errorcommand) { -;;; var message = 'Explicit error'; -;;; var kw = this.__superinit__(name, message); -;;; kw.errorcommand = errorcommand; -;;; return kw; -;;; }; +// this should be thrown with the error command as parameter +kukit.err.ExplicitError = kukit.err.exceptionFactory('ExplicitError'); +kukit.err.ee = kukit.err.ExplicitError; +kukit.err.ee.prototype.__superinit__ = kukit.err.ee.prototype.__init__; +kukit.err.ee.prototype.__init__ = function(name, errorcommand) { + var message = 'Explicit error'; + var kw = this.__superinit__(name, message); + kw.errorcommand = errorcommand; + return kw; +}; -;;; var name = 'ResponseParsingError'; -;;; kukit.err.ResponseParsingError = kukit.err.exceptionFactory(name); +var name = 'ResponseParsingError'; +kukit.err.ResponseParsingError = kukit.err.exceptionFactory(name); ;;; var name = 'CommandExecutionError'; ;;; kukit.err.CommandExecutionError = kukit.err.exceptionFactory(name); Modified: kukit/kukit.js/branch/1.2/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/1.2/kukit/serveraction.js Wed Dec 5 14:52:05 2007 @@ -111,28 +111,35 @@ if (success) { // catch the errors otherwise won't get logged. // In FF they seem to get swallowed silently. -;;; try { + // We need these both in production and development mode, + // since the erorr fallbacks are activated from processError. + try { // process the results this.processResult(domDoc); -;;; } catch(e) { + } catch(e) { ;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { ;;; // Log the message ;;; var msg = 'Error setting up events: ' + e.toString(); ;;; kukit.logFatal(msg); ;;; // just throw it too... ;;; throw msg; -;;; } else if (e.name == 'ResponseParsingError') { -;;; this.processError('Response parsing error: ' + e); -;;; } else if (e.name == 'ExplicitError') { -;;; this.processError(e.errorcommand); +;;; } + if (e.name == 'ResponseParsingError') { +;;; kukit.E = 'Response parsing error: ' + e; + this.processError(kukit.E); + } else if (e.name == 'ExplicitError') { + this.processError(e.errorcommand); ;;; } else { -;;; var msg = 'Unhandled error during command execution: ' + e; -;;; kukit.logError(msg); +;;; kukit.E = 'Unhandled error during command execution: ' + e; +;;; kukit.logError(kukit.E); ;;; // also IE acts foul on thrown errors ;;; // but at least mumbles something +;;; // XXX TODO We should also signal the problem to the user +;;; // in production mode, in this case, see the other comment +;;; // in this file. ;;; throw e; -;;; } -;;; } + } + } } } }; @@ -159,9 +166,8 @@ try { dom = (new DOMParser()).parseFromString(payload, "text/xml"); } catch(e) { -;;; var msg = 'Error parsing X-KSSCOMMANDS header.'; -;;; kukit.E = new kukit.err.ResponseParsingError(msg); - throw kukit.E; +;;; kukit.E = 'Error parsing X-KSSCOMMANDS header.'; + throw new kukit.err.ResponseParsingError(msg); } commandstags = kukit.dom.getNsTags(dom, 'commands'); if (commandstags.length != 1) { @@ -174,21 +180,19 @@ // and log it as reported from the dom // Opera <= 8.5 does not have the parseError attribute, // so check for it first - dom = domDoc.responseXML; -;;; var msg = 'Unknown server error (invalid KSS response, no error'; -;;; msg += ' info received)'; +;;; dom = domDoc.responseXML; +;;; kukit.E = 'Unknown server error (invalid KSS response, no error'; +;;; kukit.E += ' info received)'; ;;; if (dom && dom.parseError && (dom.parseError != 0)) { -;;; msg += ' : ' + Sarissa.getParseErrorText(dom); +;;; kukit.E += ' : ' + Sarissa.getParseErrorText(dom); ;;; } -;;; kukit.E = new kukit.err.ResponseParsingError(msg); - throw kukit.E; + throw new kukit.err.ResponseParsingError(kukit.E); } } if (dom == null) { // this should not happen -;;; var msg = 'Neither xml nor html payload.'; -;;; kukit.E = new kukit.err.ResponseParsingError(msg); - throw kukit.E; +;;; kukit.E = 'Neither xml nor html payload.'; + throw new kukit.err.ResponseParsingError(msg); } // find the commands (atm we don't limit ourselves inside the commandstag) var commands = kukit.dom.getNsTags(dom, 'command'); From reebalazs at codespeak.net Wed Dec 5 14:55:36 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 5 Dec 2007 14:55:36 +0100 (CET) Subject: [KSS-checkins] r49387 - kukit/kss.core/branch/1.2/docs Message-ID: <20071205135536.BDE7D168486@codespeak.net> Author: reebalazs Date: Wed Dec 5 14:55:35 2007 New Revision: 49387 Modified: kukit/kss.core/branch/1.2/docs/HISTORY.txt Log: Add history entries for previous fixes Modified: kukit/kss.core/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/1.2/docs/HISTORY.txt Wed Dec 5 14:55:35 2007 @@ -6,6 +6,13 @@ - ... + - Fix error fallback handling + [ree] + + - Implement loglevels based on cookies + Add handling of log levels to the kss mode view + [ree] + kss.core - 1.2.3 Released 2007-11-08 kss.core - 1.2.2 Released 2007-10-05 From kukit-checkins at codespeak.net Thu Dec 6 08:16:01 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Thu, 6 Dec 2007 08:16:01 +0100 (CET) Subject: [KSS-checkins] December 78% OFF Message-ID: <20071206131604.2550.qmail@ppp85-140-221-253.pppoe.mtu-net.ru> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071206/2e108cc6/attachment.htm From reebalazs at codespeak.net Thu Dec 6 10:20:56 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 6 Dec 2007 10:20:56 +0100 (CET) Subject: [KSS-checkins] r49438 - kukit/kukit.js/trunk/kukit Message-ID: <20071206092056.3868D168514@codespeak.net> Author: reebalazs Date: Thu Dec 6 10:20:55 2007 New Revision: 49438 Modified: kukit/kukit.js/trunk/kukit/serveraction.js Log: Arrrrrrggh. (semicolon missing by mistake) Modified: kukit/kukit.js/trunk/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/trunk/kukit/serveraction.js (original) +++ kukit/kukit.js/trunk/kukit/serveraction.js Thu Dec 6 10:20:55 2007 @@ -234,5 +234,5 @@ // _throws an ugly window, "Uncaught exception" // TODO figure out something? } -; +}; From reebalazs at codespeak.net Thu Dec 6 10:27:30 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 6 Dec 2007 10:27:30 +0100 (CET) Subject: [KSS-checkins] r49439 - kukit/kukit.js/branch/1.2/kukit Message-ID: <20071206092730.97D29168514@codespeak.net> Author: reebalazs Date: Thu Dec 6 10:27:30 2007 New Revision: 49439 Modified: kukit/kukit.js/branch/1.2/kukit/serveraction.js Log: Add missing comment Modified: kukit/kukit.js/branch/1.2/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/1.2/kukit/serveraction.js Thu Dec 6 10:27:30 2007 @@ -233,6 +233,14 @@ ;;; kukit.E = 'Request failed at url ' + this.oper.queueItem.url; ;;; kukit.E += ', rid=' + this.oper.queueItem.rid + reason; ;;; kukit.logError(kukit.E); +;;; return; + // in case of no logging, we would like to throw an error. + // This means user will see something went wrong. + // XXX But: throwing an error on Firefox + // _seems to be ineffective__ + // and throwing the error from IE + // _throws an ugly window, "Uncaught exception" + // TODO figure out something? } }; From reebalazs at codespeak.net Thu Dec 6 11:51:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 6 Dec 2007 11:51:01 +0100 (CET) Subject: [KSS-checkins] r49441 - in kukit/kukit.js/trunk: doc kukit Message-ID: <20071206105101.6FD36168529@codespeak.net> Author: reebalazs Date: Thu Dec 6 11:50:55 2007 New Revision: 49441 Modified: kukit/kukit.js/trunk/doc/HISTORY.txt kukit/kukit.js/trunk/kukit/forms.js Log: Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) Modified: kukit/kukit.js/trunk/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/trunk/doc/HISTORY.txt (original) +++ kukit/kukit.js/trunk/doc/HISTORY.txt Thu Dec 6 11:50:55 2007 @@ -6,6 +6,11 @@ - ... + - Fix multiple selection form fields + marshalling on Safari + (fixes #22 in kssproject) + [ree] + - Fix error fallback handling [ree] Modified: kukit/kukit.js/trunk/kukit/forms.js ============================================================================== --- kukit/kukit.js/trunk/kukit/forms.js (original) +++ kukit/kukit.js/trunk/kukit/forms.js Thu Dec 6 11:50:55 2007 @@ -62,8 +62,11 @@ var elem = new _FormQueryElem(name, value); this.l.push(elem); } + // value.length is for detection of an Array. + // In addition we also check that value.pop is a function else if (typeof(value) == 'object' && - value.constructor.toString().indexOf('Array') != -1) { + typeof(value.length) == 'number' && + typeof(value.pop) == 'function') { // Special marshalling of arrays for (var i=0; i < value.length; i++) { var elem = new _FormQueryElem(name, value[i]); From reebalazs at codespeak.net Thu Dec 6 12:01:34 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 6 Dec 2007 12:01:34 +0100 (CET) Subject: [KSS-checkins] r49442 - in kukit/kukit.js/trunk: doc kukit Message-ID: <20071206110134.D622C168529@codespeak.net> Author: reebalazs Date: Thu Dec 6 12:01:19 2007 New Revision: 49442 Modified: kukit/kukit.js/trunk/doc/HISTORY.txt kukit/kukit.js/trunk/kukit/forms.js Log: Fix multiple selection form fields marshalling on IE dquote> (due to a necessary workaround that was not applied everywhere) Modified: kukit/kukit.js/trunk/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/trunk/doc/HISTORY.txt (original) +++ kukit/kukit.js/trunk/doc/HISTORY.txt Thu Dec 6 12:01:19 2007 @@ -9,6 +9,7 @@ - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) + and on IE. [ree] - Fix error fallback handling Modified: kukit/kukit.js/trunk/kukit/forms.js ============================================================================== --- kukit/kukit.js/trunk/kukit/forms.js (original) +++ kukit/kukit.js/trunk/kukit/forms.js Thu Dec 6 12:01:19 2007 @@ -179,10 +179,9 @@ value=""; } else { var option = element.options[element.selectedIndex]; - value = option.value; - if (value == "") { - value = option.text; - } + // on FF and safari, option.value has the value + // on IE, option.text needs to be used + value = option.value || option.text; } // Now process selects with the multiple option set } else { @@ -190,7 +189,9 @@ for(i=0; i Author: reebalazs Date: Thu Dec 6 12:02:16 2007 New Revision: 49443 Modified: kukit/kss.core/trunk/docs/HISTORY.txt Log: Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) and on IE Modified: kukit/kss.core/trunk/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/trunk/docs/HISTORY.txt (original) +++ kukit/kss.core/trunk/docs/HISTORY.txt Thu Dec 6 12:02:16 2007 @@ -6,6 +6,12 @@ - ... + - Fix multiple selection form fields + marshalling on Safari + (fixes #22 in kssproject) + and on IE. + [ree] + - Fix error fallback handling [ree] From reebalazs at codespeak.net Thu Dec 6 12:11:00 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 6 Dec 2007 12:11:00 +0100 (CET) Subject: [KSS-checkins] r49444 - in kukit/kukit.js/branch/1.2: doc kukit Message-ID: <20071206111100.A1478168525@codespeak.net> Author: reebalazs Date: Thu Dec 6 12:10:55 2007 New Revision: 49444 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt kukit/kukit.js/branch/1.2/kukit/forms.js Log: Backport critical bugfix -r49440:49442 from trunk: Fix multiple selection form fields marshalling on Safari and IE Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Thu Dec 6 12:10:55 2007 @@ -6,6 +6,12 @@ - ... + - Fix multiple selection form fields + marshalling on Safari + (fixes #22 in kssproject) + and on IE. + [ree] + - Fix error fallback handling [ree] Modified: kukit/kukit.js/branch/1.2/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/forms.js (original) +++ kukit/kukit.js/branch/1.2/kukit/forms.js Thu Dec 6 12:10:55 2007 @@ -60,8 +60,11 @@ var elem = new kukit.fo.FormQueryElem(name, value); this.l.push(elem); } + // value.length is for detection of an Array. + // In addition we also check that value.pop is a function else if (typeof(value) == 'object' && - value.constructor.toString().indexOf('Array') != -1) { + typeof(value.length) == 'number' && + typeof(value.pop) == 'function') { // Special marshalling of arrays for (var i=0; i < value.length; i++) { var elem = new kukit.fo.FormQueryElem(name, value[i]); @@ -174,10 +177,9 @@ value=""; } else { var option = element.options[element.selectedIndex]; - value = option.value; - if (value == "") { - value = option.text; - } + // on FF and safari, option.value has the value + // on IE, option.text needs to be used + value = option.value || option.text; } // Now process selects with the multiple option set } else { @@ -185,7 +187,9 @@ for(i=0; i Author: reebalazs Date: Thu Dec 6 12:13:08 2007 New Revision: 49445 Modified: kukit/kss.core/branch/1.2/docs/HISTORY.txt Log: Add history entry for javascript fix Modified: kukit/kss.core/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/1.2/docs/HISTORY.txt Thu Dec 6 12:13:08 2007 @@ -6,6 +6,12 @@ - ... + - Fix multiple selection form fields + marshalling on Safari + (fixes #22 in kssproject) + and on IE. + [ree] + - Fix error fallback handling [ree] From kukit-checkins at codespeak.net Thu Dec 6 13:05:12 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Thu, 6 Dec 2007 13:05:12 +0100 (CET) Subject: [KSS-checkins] December 74% OFF Message-ID: <20071206020656.6664.qmail@AMarseille-157-1-29-39.w90-15.abo.wanadoo.fr> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071206/34efb302/attachment.htm From gotcha at codespeak.net Thu Dec 6 20:59:09 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 20:59:09 +0100 (CET) Subject: [KSS-checkins] r49459 - kukit/kukit.js/tag/1.2.4 Message-ID: <20071206195909.6A066168538@codespeak.net> Author: gotcha Date: Thu Dec 6 20:59:09 2007 New Revision: 49459 Added: kukit/kukit.js/tag/1.2.4/ - copied from r49458, kukit/kukit.js/branch/1.2/ Log: prepare for release From gotcha at codespeak.net Thu Dec 6 21:08:30 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:08:30 +0100 (CET) Subject: [KSS-checkins] r49460 - kukit/kukit.js/tag/1.2.4/doc Message-ID: <20071206200830.3684C168535@codespeak.net> Author: gotcha Date: Thu Dec 6 21:08:27 2007 New Revision: 49460 Modified: kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt Log: release Modified: kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt (original) +++ kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt Thu Dec 6 21:08:27 2007 @@ -6,6 +6,8 @@ - ... +kukit.js - 1.2.4 Released 2007-12-06 + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) From gotcha at codespeak.net Thu Dec 6 21:09:24 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:09:24 +0100 (CET) Subject: [KSS-checkins] r49461 - kukit/kukit.js/branch/1.2/doc Message-ID: <20071206200924.04C99168535@codespeak.net> Author: gotcha Date: Thu Dec 6 21:09:24 2007 New Revision: 49461 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt Log: release Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Thu Dec 6 21:09:24 2007 @@ -6,6 +6,8 @@ - ... +kukit.js - 1.2.4 Released 2007-12-06 + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) From gotcha at codespeak.net Thu Dec 6 21:14:51 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:14:51 +0100 (CET) Subject: [KSS-checkins] r49462 - kukit/kss.concatresource/tag/1.2.4 Message-ID: <20071206201451.EEC4D168535@codespeak.net> Author: gotcha Date: Thu Dec 6 21:14:51 2007 New Revision: 49462 Added: kukit/kss.concatresource/tag/1.2.4/ - copied from r49461, kukit/kss.concatresource/branch/1.2/ Log: prepare for release From jfroche at codespeak.net Thu Dec 6 21:18:16 2007 From: jfroche at codespeak.net (jfroche at codespeak.net) Date: Thu, 6 Dec 2007 21:18:16 +0100 (CET) Subject: [KSS-checkins] r49464 - kukit/kss.core/branch/finish-closures/kss/core Message-ID: <20071206201816.3EFC416854A@codespeak.net> Author: jfroche Date: Thu Dec 6 21:18:15 2007 New Revision: 49464 Modified: kukit/kss.core/branch/finish-closures/kss/core/ (props changed) kukit/kss.core/branch/finish-closures/kss/core/EXTERNALS.TXT Log: use the right branch for kukit Modified: kukit/kss.core/branch/finish-closures/kss/core/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/EXTERNALS.TXT (original) +++ kukit/kss.core/branch/finish-closures/kss/core/EXTERNALS.TXT Thu Dec 6 21:18:15 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/trunk +kukit http://codespeak.net/svn/kukit/kukit.js/branch/finish-closures/ From gotcha at codespeak.net Thu Dec 6 21:18:16 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:18:16 +0100 (CET) Subject: [KSS-checkins] r49463 - in kukit/kss.concatresource/tag/1.2.4: . docs Message-ID: <20071206201816.45693168549@codespeak.net> Author: gotcha Date: Thu Dec 6 21:18:14 2007 New Revision: 49463 Modified: kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt kukit/kss.concatresource/tag/1.2.4/setup.py Log: release Modified: kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt ============================================================================== --- kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt (original) +++ kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt Thu Dec 6 21:18:14 2007 @@ -6,6 +6,8 @@ - ... +kss.concatresource - 1.2.4 Released 2007-12-06 + kss.concatresource - 1.2.3 Released 2007-11-08 kss.concatresource - 1.2.2 Released 2007-10-05 Modified: kukit/kss.concatresource/tag/1.2.4/setup.py ============================================================================== --- kukit/kss.concatresource/tag/1.2.4/setup.py (original) +++ kukit/kss.concatresource/tag/1.2.4/setup.py Thu Dec 6 21:18:14 2007 @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '1.2-dev' +version = '1.2.4' setup(name='concatresource', version=version, From gotcha at codespeak.net Thu Dec 6 21:19:41 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:19:41 +0100 (CET) Subject: [KSS-checkins] r49465 - kukit/kss.concatresource/branch/1.2/docs Message-ID: <20071206201941.95BC1168529@codespeak.net> Author: gotcha Date: Thu Dec 6 21:19:41 2007 New Revision: 49465 Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Log: release Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Thu Dec 6 21:19:41 2007 @@ -6,6 +6,8 @@ - ... +kss.concatresource - 1.2.4 Released 2007-12-06 + kss.concatresource - 1.2.3 Released 2007-11-08 kss.concatresource - 1.2.2 Released 2007-10-05 From gotcha at codespeak.net Thu Dec 6 21:22:34 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:22:34 +0100 (CET) Subject: [KSS-checkins] r49466 - kukit/kss.core/tag/1.2.4 Message-ID: <20071206202234.A3EE516852A@codespeak.net> Author: gotcha Date: Thu Dec 6 21:22:31 2007 New Revision: 49466 Added: kukit/kss.core/tag/1.2.4/ - copied from r49465, kukit/kss.core/branch/1.2/ Log: prepare for release From gotcha at codespeak.net Thu Dec 6 21:29:41 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:29:41 +0100 (CET) Subject: [KSS-checkins] r49467 - in kukit/kss.core/branch/1.2: docs kss/core/doc kss/core/docs Message-ID: <20071206202941.D19C316852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:29:41 2007 New Revision: 49467 Added: kukit/kss.core/branch/1.2/kss/core/docs/ - copied from r49466, kukit/kss.core/branch/1.2/kss/core/doc/ kukit/kss.core/branch/1.2/kss/core/docs/CREDITS.txt - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/CREDITS.TXT kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/HISTORY.txt kukit/kss.core/branch/1.2/kss/core/docs/INSTALL.txt - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/INSTALL.txt kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.GPL - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/LICENSE.GPL kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.txt - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/LICENSE.txt kukit/kss.core/branch/1.2/kss/core/docs/TODO.txt - copied unchanged from r49466, kukit/kss.core/branch/1.2/docs/TODO.txt Removed: kukit/kss.core/branch/1.2/docs/ kukit/kss.core/branch/1.2/kss/core/doc/ Log: move docs to ensure they are included in eggs From gotcha at codespeak.net Thu Dec 6 21:30:54 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:30:54 +0100 (CET) Subject: [KSS-checkins] r49468 - kukit/kss.core/tag/1.2.4 Message-ID: <20071206203054.1205616852D@codespeak.net> Author: gotcha Date: Thu Dec 6 21:30:54 2007 New Revision: 49468 Removed: kukit/kss.core/tag/1.2.4/ Log: copied to early From gotcha at codespeak.net Thu Dec 6 21:31:18 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:31:18 +0100 (CET) Subject: [KSS-checkins] r49469 - kukit/kss.core/tag/1.2.4 Message-ID: <20071206203118.41E97168531@codespeak.net> Author: gotcha Date: Thu Dec 6 21:31:18 2007 New Revision: 49469 Added: kukit/kss.core/tag/1.2.4/ - copied from r49468, kukit/kss.core/branch/1.2/ Log: prepare for release From gotcha at codespeak.net Thu Dec 6 21:33:06 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:33:06 +0100 (CET) Subject: [KSS-checkins] r49470 - kukit/kukit.js/branch/1.2/doc Message-ID: <20071206203306.7740D168535@codespeak.net> Author: gotcha Date: Thu Dec 6 21:33:05 2007 New Revision: 49470 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt Log: release properly Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Thu Dec 6 21:33:05 2007 @@ -2,10 +2,6 @@ (name of developer listed in brackets) -kukit.js - 1.2dev Unreleased - - - ... - kukit.js - 1.2.4 Released 2007-12-06 - Fix multiple selection form fields From gotcha at codespeak.net Thu Dec 6 21:33:40 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:33:40 +0100 (CET) Subject: [KSS-checkins] r49471 - kukit/kss.concatresource/branch/1.2/docs Message-ID: <20071206203340.721F616852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:33:40 2007 New Revision: 49471 Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Log: release properly Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Thu Dec 6 21:33:40 2007 @@ -2,10 +2,6 @@ (name of developer listed in brackets) -kss.concatresource - 1.2dev Unreleased - - - ... - kss.concatresource - 1.2.4 Released 2007-12-06 kss.concatresource - 1.2.3 Released 2007-11-08 From gotcha at codespeak.net Thu Dec 6 21:38:16 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:38:16 +0100 (CET) Subject: [KSS-checkins] r49472 - in kukit/kss.core/tag/1.2.4: . kss/core kss/core/docs kss/core/pluginregistry Message-ID: <20071206203816.199A716852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:38:16 2007 New Revision: 49472 Modified: kukit/kss.core/tag/1.2.4/kss/core/ (props changed) kukit/kss.core/tag/1.2.4/kss/core/EXTERNALS.TXT kukit/kss.core/tag/1.2.4/kss/core/docs/HISTORY.txt kukit/kss.core/tag/1.2.4/kss/core/pluginregistry/ (props changed) kukit/kss.core/tag/1.2.4/kss/core/pluginregistry/EXTERNALS.TXT kukit/kss.core/tag/1.2.4/kss/core/version.txt kukit/kss.core/tag/1.2.4/setup.py Log: prepare for release Modified: kukit/kss.core/tag/1.2.4/kss/core/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/tag/1.2.4/kss/core/EXTERNALS.TXT (original) +++ kukit/kss.core/tag/1.2.4/kss/core/EXTERNALS.TXT Thu Dec 6 21:38:16 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/branch/1.2 +kukit http://codespeak.net/svn/kukit/kukit.js/tag/1.2.4 Modified: kukit/kss.core/tag/1.2.4/kss/core/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/tag/1.2.4/kss/core/docs/HISTORY.txt (original) +++ kukit/kss.core/tag/1.2.4/kss/core/docs/HISTORY.txt Thu Dec 6 21:38:16 2007 @@ -2,9 +2,7 @@ (name of developer listed in brackets) -kss.core - 1.2dev Unreleased - - - ... +kss.core - 1.2.4 Released 2007-12-06 - Fix multiple selection form fields marshalling on Safari Modified: kukit/kss.core/tag/1.2.4/kss/core/pluginregistry/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/tag/1.2.4/kss/core/pluginregistry/EXTERNALS.TXT (original) +++ kukit/kss.core/tag/1.2.4/kss/core/pluginregistry/EXTERNALS.TXT Thu Dec 6 21:38:16 2007 @@ -7,4 +7,4 @@ # # concatresource is now included like as batteries -_concatresource https://codespeak.net/svn/kukit/kss.concatresource/branch/1.2/kss/concatresource +_concatresource https://codespeak.net/svn/kukit/kss.concatresource/tag/1.2.4/kss/concatresource Modified: kukit/kss.core/tag/1.2.4/kss/core/version.txt ============================================================================== --- kukit/kss.core/tag/1.2.4/kss/core/version.txt (original) +++ kukit/kss.core/tag/1.2.4/kss/core/version.txt Thu Dec 6 21:38:16 2007 @@ -1 +1 @@ -1.2dev unreleased +kss.core - 1.2.4 Released 2007-12-06 Modified: kukit/kss.core/tag/1.2.4/setup.py ============================================================================== --- kukit/kss.core/tag/1.2.4/setup.py (original) +++ kukit/kss.core/tag/1.2.4/setup.py Thu Dec 6 21:38:16 2007 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = '1.2-dev' +version = '1.2.4' setup(name='kss.core', version=version, From gotcha at codespeak.net Thu Dec 6 21:41:56 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:41:56 +0100 (CET) Subject: [KSS-checkins] r49473 - kukit/kukit.js/branch/1.2/doc Message-ID: <20071206204156.B956016852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:41:56 2007 New Revision: 49473 Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt Log: revert previous checkin Modified: kukit/kukit.js/branch/1.2/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/1.2/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/1.2/doc/HISTORY.txt Thu Dec 6 21:41:56 2007 @@ -1,7 +1,11 @@ Changelog for kukit.js (name of developer listed in brackets) - + +kukit.js - 1.2dev Unreleased + + - ... + kukit.js - 1.2.4 Released 2007-12-06 - Fix multiple selection form fields From gotcha at codespeak.net Thu Dec 6 21:42:49 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:42:49 +0100 (CET) Subject: [KSS-checkins] r49474 - kukit/kss.concatresource/branch/1.2/docs Message-ID: <20071206204249.1D2BB16852D@codespeak.net> Author: gotcha Date: Thu Dec 6 21:42:49 2007 New Revision: 49474 Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Log: revert previous checkin Modified: kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt ============================================================================== --- kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt (original) +++ kukit/kss.concatresource/branch/1.2/docs/HISTORY.txt Thu Dec 6 21:42:49 2007 @@ -2,6 +2,10 @@ (name of developer listed in brackets) +kss.concatresource - 1.2dev Unreleased + + - ... + kss.concatresource - 1.2.4 Released 2007-12-06 kss.concatresource - 1.2.3 Released 2007-11-08 From gotcha at codespeak.net Thu Dec 6 21:44:39 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:44:39 +0100 (CET) Subject: [KSS-checkins] r49475 - in kukit/kss.concatresource/tag/1.2.4: docs kss/concatresource Message-ID: <20071206204439.ECA9716852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:44:39 2007 New Revision: 49475 Modified: kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt kukit/kss.concatresource/tag/1.2.4/kss/concatresource/version.txt Log: polish release Modified: kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt ============================================================================== --- kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt (original) +++ kukit/kss.concatresource/tag/1.2.4/docs/HISTORY.txt Thu Dec 6 21:44:39 2007 @@ -2,10 +2,6 @@ (name of developer listed in brackets) -kss.concatresource - 1.2dev Unreleased - - - ... - kss.concatresource - 1.2.4 Released 2007-12-06 kss.concatresource - 1.2.3 Released 2007-11-08 Modified: kukit/kss.concatresource/tag/1.2.4/kss/concatresource/version.txt ============================================================================== --- kukit/kss.concatresource/tag/1.2.4/kss/concatresource/version.txt (original) +++ kukit/kss.concatresource/tag/1.2.4/kss/concatresource/version.txt Thu Dec 6 21:44:39 2007 @@ -1 +1 @@ -1.2dev Unreleased +1.2.4 released 2007-12-06 From gotcha at codespeak.net Thu Dec 6 21:46:02 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:46:02 +0100 (CET) Subject: [KSS-checkins] r49476 - in kukit/kukit.js/tag/1.2.4: . doc Message-ID: <20071206204602.CBDBD16852D@codespeak.net> Author: gotcha Date: Thu Dec 6 21:46:02 2007 New Revision: 49476 Modified: kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt kukit/kukit.js/tag/1.2.4/version.txt Log: polish release Modified: kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt (original) +++ kukit/kukit.js/tag/1.2.4/doc/HISTORY.txt Thu Dec 6 21:46:02 2007 @@ -2,10 +2,6 @@ (name of developer listed in brackets) -kukit.js - 1.2dev Unreleased - - - ... - kukit.js - 1.2.4 Released 2007-12-06 - Fix multiple selection form fields Modified: kukit/kukit.js/tag/1.2.4/version.txt ============================================================================== --- kukit/kukit.js/tag/1.2.4/version.txt (original) +++ kukit/kukit.js/tag/1.2.4/version.txt Thu Dec 6 21:46:02 2007 @@ -1 +1 @@ -1.2dev unreleased +1.2.4 released 2007-12-06 From gotcha at codespeak.net Thu Dec 6 21:47:35 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 21:47:35 +0100 (CET) Subject: [KSS-checkins] r49477 - kukit/kss.core/tag/1.2.4/kss/core Message-ID: <20071206204735.F181D16852B@codespeak.net> Author: gotcha Date: Thu Dec 6 21:47:35 2007 New Revision: 49477 Modified: kukit/kss.core/tag/1.2.4/kss/core/version.txt Log: polish release Modified: kukit/kss.core/tag/1.2.4/kss/core/version.txt ============================================================================== --- kukit/kss.core/tag/1.2.4/kss/core/version.txt (original) +++ kukit/kss.core/tag/1.2.4/kss/core/version.txt Thu Dec 6 21:47:35 2007 @@ -1 +1 @@ -kss.core - 1.2.4 Released 2007-12-06 +1.2.4 released 2007-12-06 From jfroche at codespeak.net Thu Dec 6 21:55:53 2007 From: jfroche at codespeak.net (jfroche at codespeak.net) Date: Thu, 6 Dec 2007 21:55:53 +0100 (CET) Subject: [KSS-checkins] r49478 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin Message-ID: <20071206205553.9B60016852B@codespeak.net> Author: jfroche Date: Thu Dec 6 21:55:53 2007 New Revision: 49478 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt Log: remove ugly empty p Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss Thu Dec 6 21:55:53 2007 @@ -1,30 +1,24 @@ #parent-node:click { evt-click-allowbubbling: true; evt-click-preventdefault: true; - action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "containing DIV.

"; + insertHTMLBefore-html: "containing DIV. "; } #bubbling-node:click { evt-click-preventdefault: true; - action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "bubbling P.

"; + insertHTMLBefore-html: "bubbling P. "; } #not-bubbling-node:click { evt-click-preventdefault: true; evt-click-preventbubbling: true; - action-client: deleteNodeBefore; - deleteNodeBefore-kssSelector: #log-end; action-client: insertHTMLBefore; insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "not bubbling P.

"; + insertHTMLBefore-html: "not bubbling P. "; } #log-reset:click { @@ -32,5 +26,5 @@ clearChildNodes-kssSelector: #logger; action-client: insertHTMLAsLastChild; insertHTMLAsLastChild-kssSelector: #logger; - insertHTMLAsLastChild-html: "

"; + insertHTMLAsLastChild-html: "

"; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt Thu Dec 6 21:55:53 2007 @@ -44,7 +44,6 @@

Reset log

You clicked :

-

From jfroche at codespeak.net Thu Dec 6 22:04:21 2007 From: jfroche at codespeak.net (jfroche at codespeak.net) Date: Thu, 6 Dec 2007 22:04:21 +0100 (CET) Subject: [KSS-checkins] r49479 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin Message-ID: <20071206210421.4594A16854B@codespeak.net> Author: jfroche Date: Thu Dec 6 22:04:19 2007 New Revision: 49479 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss Log: make it human clickable Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss Thu Dec 6 22:04:19 2007 @@ -21,7 +21,7 @@ insertHTMLBefore-html: "not bubbling P. "; } -#log-reset:click { +#log-reset a:click, #log-reset:click { action-client: clearChildNodes; clearChildNodes-kssSelector: #logger; action-client: insertHTMLAsLastChild; From gotcha at codespeak.net Thu Dec 6 22:05:01 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 22:05:01 +0100 (CET) Subject: [KSS-checkins] r49480 - kukit/kss.core/branch/1.2/kss/core/docs Message-ID: <20071206210501.C002416854C@codespeak.net> Author: gotcha Date: Thu Dec 6 22:05:01 2007 New Revision: 49480 Modified: kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt Log: release Modified: kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt Thu Dec 6 22:05:01 2007 @@ -6,6 +6,8 @@ - ... +kss.core - 1.2.4 Released 2007-12-06 + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) From gotcha at codespeak.net Thu Dec 6 22:07:32 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 22:07:32 +0100 (CET) Subject: [KSS-checkins] r49481 - in kukit/kss.demo/branch/1.2: docs kss/demo/docs Message-ID: <20071206210732.C450D16854F@codespeak.net> Author: gotcha Date: Thu Dec 6 22:07:32 2007 New Revision: 49481 Added: kukit/kss.demo/branch/1.2/kss/demo/docs/ - copied from r49480, kukit/kss.demo/branch/1.2/docs/ Removed: kukit/kss.demo/branch/1.2/docs/ Log: move docs to ensure it is included in egg From jfroche at codespeak.net Thu Dec 6 22:44:36 2007 From: jfroche at codespeak.net (jfroche at codespeak.net) Date: Thu, 6 Dec 2007 22:44:36 +0100 (CET) Subject: [KSS-checkins] r49482 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071206214436.056CE168546@codespeak.net> Author: jfroche Date: Thu Dec 6 22:44:35 2007 New Revision: 49482 Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js Log: deprecate the executeCommand action Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Thu Dec 6 22:44:35 2007 @@ -975,6 +975,8 @@ // // allows excess parms in the following check ;;; oper.componentName = '[executeCommand] action'; +;;; var msg = 'Deprecated the [executeCommand] action, use [kssSelector] in a standard action!'; +;;; kukit.logWarning(msg); oper.evaluateParameters(['name', 'selector'], {'selectorType': null}, '', true); From gotcha at codespeak.net Thu Dec 6 22:50:18 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 22:50:18 +0100 (CET) Subject: [KSS-checkins] r49483 - kukit/kss.core/tag/1.2.4 Message-ID: <20071206215018.E22E016854E@codespeak.net> Author: gotcha Date: Thu Dec 6 22:50:18 2007 New Revision: 49483 Removed: kukit/kss.core/tag/1.2.4/setup.cfg Log: still learning how to release Deleted: /kukit/kss.core/tag/1.2.4/setup.cfg ============================================================================== --- /kukit/kss.core/tag/1.2.4/setup.cfg Thu Dec 6 22:50:18 2007 +++ (empty file) @@ -1,3 +0,0 @@ -[egg_info] -tag_build = dev -tag_svn_revision = true From gotcha at codespeak.net Thu Dec 6 22:57:49 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 22:57:49 +0100 (CET) Subject: [KSS-checkins] r49484 - in kukit/kss.core/trunk: docs kss/core/doc kss/core/docs Message-ID: <20071206215749.B3AA1168553@codespeak.net> Author: gotcha Date: Thu Dec 6 22:57:49 2007 New Revision: 49484 Added: kukit/kss.core/trunk/kss/core/docs/ - copied from r49483, kukit/kss.core/trunk/kss/core/doc/ kukit/kss.core/trunk/kss/core/docs/CREDITS.txt - copied unchanged from r49483, kukit/kss.core/trunk/docs/CREDITS.TXT kukit/kss.core/trunk/kss/core/docs/HISTORY.txt - copied unchanged from r49483, kukit/kss.core/trunk/docs/HISTORY.txt kukit/kss.core/trunk/kss/core/docs/INSTALL.txt - copied unchanged from r49483, kukit/kss.core/trunk/docs/INSTALL.txt kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL - copied unchanged from r49483, kukit/kss.core/trunk/docs/LICENSE.GPL kukit/kss.core/trunk/kss/core/docs/LICENSE.txt - copied unchanged from r49483, kukit/kss.core/trunk/docs/LICENSE.txt kukit/kss.core/trunk/kss/core/docs/TODO.txt - copied unchanged from r49483, kukit/kss.core/trunk/docs/TODO.txt Removed: kukit/kss.core/trunk/docs/CREDITS.TXT kukit/kss.core/trunk/docs/HISTORY.txt kukit/kss.core/trunk/docs/INSTALL.txt kukit/kss.core/trunk/docs/LICENSE.GPL kukit/kss.core/trunk/docs/LICENSE.txt kukit/kss.core/trunk/docs/TODO.txt kukit/kss.core/trunk/kss/core/doc/ Log: move docs to ensure it is included in egg Deleted: /kukit/kss.core/trunk/docs/CREDITS.TXT ============================================================================== --- /kukit/kss.core/trunk/docs/CREDITS.TXT Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,6 +0,0 @@ -Godefroid Chapelle (gotcha at bubbblenet.be) -Tarek Ziade (ziade.tarek at gmail.com) -Florian Schulze (florian.schulze at gmx.net) -Balazs Ree (ree at greenfinity.hu) -Jeroen Vloothuis (jeroen.vloothuis at xs4all.nl) -Philipp von Weitershausen Deleted: /kukit/kss.core/trunk/docs/HISTORY.txt ============================================================================== --- /kukit/kss.core/trunk/docs/HISTORY.txt Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,134 +0,0 @@ -Changelog for kss.core - - (name of developer listed in brackets) - -kss.core - 1.4dev Unreleased - - - ... - - - Fix multiple selection form fields - marshalling on Safari - (fixes #22 in kssproject) - and on IE. - [ree] - - - Fix error fallback handling - [ree] - - - Implement loglevels based on cookies - Add handling of log levels to the kss mode view - [ree] - - - Moved the core demos to this package from kss.demo. - They are now located under the core plugin. - [ree] - - - Implement event binding based on the ids fetched - dynamically from the dom, by value providers. - [ree] - - - Changed kukit payload to encode HTML content of CDATA. - This was necessary because us a supposed bug in FF, that - prevented us to use base2 (xpath selection did not work - on inserted elements, due to namespace issues.) - Get rid of forceToDom, make sure all plugins accept html - parameters as strings. - [ree] - -kss.core - 1.2 Released 2007-08-17 - - - Refactored js code. - [gotcha] - -kss.core - 1.2-rc2 Released 2007-07-27 - - - Prepare for release. - [ree] - - - when attrname is kssattr:xxx, IE chokes on certain nodes - [gotcha] - - - fix form marshalling - [gotcha] - -kss.core - 1.2-rc1.1 - - - Prepare for release. - Identical with 1.2-rc1, just created for consistent versions. - [ree] - -kss.core - 1.2-rc1 - - - Deprecated addClassName, removeClassName actions and - commands in favour of addClass and removeClass. - Deprecated "name" and "classname" parameter in addClass, - removeClass, toggleClass actions and commands in favour of - "value". - [ree] - - - implement new packing directives and two disctint - versions of the javascript (development and production), - this is achieved from javascript with the ;;; marker - Also add the @@kss_devel_mode/ui view for changing - the development mode from the browser. - [ree] - - - Add the passnode selector that can be used to access - the value of a default parm passed programmatically - from the event (via makeActionOper) - [ree] - - - Add action moveNodeAsLastChild - [ree] - - - Death to Azax (... long live KSS)! - Removing last traces of the old name from the sources - [gotcha] - - - Changed querying for css selectors to base2 instead of - cssQuery. Base2 is supposed to be a lot faster than - the old cssQuery. Usage is alternating, if base2 is - present that one is used, otherwise it uses the old - cssQuery code which stays the default. - [jvloothuis, ree] - - - Add moveNodeBefore action (presumably missing) - [ree] - - - Refactor load event, separate iload and load events. - The new event binder handles both events together. A - new parameter, evt-iload-autodetect is introduced, if - this is false we don't use detection but the iframe - must cooperate on telling us wnen we are done. There - is deprecation warning issued for the load events, if - bound on an iframe, in which case an iload event must - be used. - [ree] - - - refactor event binding to allow different iterators to bind - events in a binder instance, matching the need of the events. - [ree] - -kss.core - 1.2-beta2 - - - Make the binding of the nodes together in one batch - [ree] - - - added kssSubmitForm action parameter - and deprecation - [ree] - -kss.core - 1.2-beta1 - - - Prepare for release - [ree] - -kss.core - 1.2-alpha2 - - - Merge in Philikon's refactorization - Move docs to doc/ - [ree] - - - Initial package structure. - [zopeskel] - Deleted: /kukit/kss.core/trunk/docs/INSTALL.txt ============================================================================== --- /kukit/kss.core/trunk/docs/INSTALL.txt Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,13 +0,0 @@ -kss.core Installation -===================== - - * When you're reading this you have probably already run - ``easy_install kss.core``. Find out how to install setuptools - (and EasyInstall) here: - http://peak.telecommunity.com/DevCenter/EasyInstall - - * Copy the files called ``kss/core/kss.core-configure.zcml`` - and ``kss/core/kss.core-meta.zcml`` in the - ``/path/to/instance/etc/package-includes`` directory. - *You do not need to do this if you use kss with Plone.* - Deleted: /kukit/kss.core/trunk/docs/LICENSE.GPL ============================================================================== --- /kukit/kss.core/trunk/docs/LICENSE.GPL Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,222 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS Deleted: /kukit/kss.core/trunk/docs/LICENSE.txt ============================================================================== --- /kukit/kss.core/trunk/docs/LICENSE.txt Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,24 +0,0 @@ - kss.core is copyright KSS Project Contributors - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA. - - - - - Third party modules come with different licenses, see individual files - - BeautifulSoup.py is licensed with PSF, Copyright (c) 2004-2006 Leonard Richardson - - Firebug Lite is licensed under Mozilla Public License 1.1 Deleted: /kukit/kss.core/trunk/docs/TODO.txt ============================================================================== --- /kukit/kss.core/trunk/docs/TODO.txt Thu Dec 6 22:57:49 2007 +++ (empty file) @@ -1,2 +0,0 @@ - - From gotcha at codespeak.net Thu Dec 6 22:59:09 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 22:59:09 +0100 (CET) Subject: [KSS-checkins] r49485 - kukit/kss.core/trunk/docs Message-ID: <20071206215909.C8E19168552@codespeak.net> Author: gotcha Date: Thu Dec 6 22:59:09 2007 New Revision: 49485 Removed: kukit/kss.core/trunk/docs/ Log: finish mv From gotcha at codespeak.net Thu Dec 6 23:00:55 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Thu, 6 Dec 2007 23:00:55 +0100 (CET) Subject: [KSS-checkins] r49486 - in kukit/kss.demo/trunk: docs kss/demo/docs Message-ID: <20071206220055.668AB16854E@codespeak.net> Author: gotcha Date: Thu Dec 6 23:00:54 2007 New Revision: 49486 Added: kukit/kss.demo/trunk/kss/demo/docs/ - copied from r49485, kukit/kss.demo/trunk/docs/ Removed: kukit/kss.demo/trunk/docs/ Log: move docs to ensure it is included in egg From jfroche at codespeak.net Fri Dec 7 00:08:47 2007 From: jfroche at codespeak.net (jfroche at codespeak.net) Date: Fri, 7 Dec 2007 00:08:47 +0100 (CET) Subject: [KSS-checkins] r49488 - in kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo: . selenium_tests Message-ID: <20071206230847.BE60716854E@codespeak.net> Author: jfroche Date: Fri Dec 7 00:08:47 2007 New Revision: 49488 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/demoview.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/actions.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Log: a few more selenium tests and the needed modifications on the original demos Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/demoview.py ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/demoview.py (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/demoview.py Fri Dec 7 00:08:47 2007 @@ -155,7 +155,7 @@ if act == 'error': raise Exception, 'We have an error here.' elif act == 'explicit': - raise KssExplicitError, 'Explicit error raised.' + raise KSSExplicitError, 'Explicit error raised.' elif act == 'empty': # Just do nothing, we want to return a response with no commands. # This is valid behaviour, should raise no error, however @@ -179,24 +179,26 @@ self.getCommandSet('core').replaceHTML('div#frame', '

KSS for a life.

') return self.render() - def htmlInsertBefore(self): + def htmlInsertBefore(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLBefore('#core', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLBefore('#frame', '
KSS for a life. %s
' % text) return self.render() - def htmlInsertAfter(self): + def htmlInsertAfter(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAfter('#core', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAfter('#frame', '
KSS for a life. %s
' % text) return self.render() - def htmlInsertAsFirstChild(self): + def htmlInsertAsFirstChild(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAsFirstChild('div#frame', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAsFirstChild('div#frame', + "first: %s " % text) return self.render() - def htmlInsertAsLastChild(self): + def htmlInsertAsLastChild(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAsLastChild('div#frame', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAsLastChild('div#frame', + "last: %s" % text) return self.render() Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss Fri Dec 7 00:08:47 2007 @@ -11,12 +11,6 @@ It also demonstrates kss rules are merged like css ones */ -/* -.handled:click { - errTest-error: alert; - alert-message: nodeAttr(id); -} -*/ /* The next rule demonstrates that instead of executing a local action on the originally selected node, we use executeCommand @@ -24,11 +18,9 @@ */ .handled:click { - errTest-error: executeCommand; - executeCommand-commandSelector: 'update-status'; - executeCommand-commandSelectorType: htmlid; - executeCommand-commandName: replaceInnerHTML; - executeCommand-html: 'Error handler activated.'; + errTest-error: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Error handler activated."; } /* Spinner control @@ -48,3 +40,13 @@ setStyle-value: none; } +/* Log control +*/ + +#log-reset a:click, #log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "

"; +} Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt Fri Dec 7 00:08:47 2007 @@ -1,9 +1,7 @@ - - - + - -

header

Error handling demo

@@ -36,32 +32,28 @@ except that the second one gives a response with no commands and so it issues a warning into the kss log. "Error" gives a failed responses due to an exception in the server method on the server.

-

The buttons in the first row have no error handled.

+

The buttons in the first row have no error handlers.

- - - - - + + + +

The buttons in the second row have individual error handlers.

- - - - - + + + +

You can also try suspending your server process and start generating timed out requests. @@ -72,6 +64,12 @@ their number (currently in 4): click like crazy on the buttons and you will see that your server will not get hogged. More will be told about this topic in the upcoming documentation.

+

Log

+

Reset log

+

Error log :

+
+

+
Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.kss Fri Dec 7 00:08:47 2007 @@ -1,17 +1,25 @@ button#insertBefore:click { + evt-click-preventdefault: true; action-server: htmlInsertBefore; + htmlInsertBefore-text : currentFormVar(text-to-insert); } button#insertAfter:click { + evt-click-preventdefault: true; action-server: htmlInsertAfter; + htmlInsertAfter-text : currentFormVar(text-to-insert); } button#insertAsFirstChild:click { + evt-click-preventdefault: true; action-server: htmlInsertAsFirstChild; + htmlInsertAsFirstChild-text : currentFormVar(text-to-insert); } button#insertAsLastChild:click { + evt-click-preventdefault: true; + htmlInsertAsLastChild-text : currentFormVar(text-to-insert); action-server: htmlInsertAsLastChild; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/html_inserts.pt Fri Dec 7 00:08:47 2007 @@ -32,6 +32,8 @@

header

HTML insertions (a.k.a. Change tags II.)

+
+ Text to insert:
+

The playground:

-

KSS for a life.

+
KSS for a life.
Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/actions.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/actions.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/actions.html Fri Dec 7 00:08:47 2007 @@ -155,7 +155,6 @@ server-removeclass-button at class button click cursorPointer -/tr> Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html Fri Dec 7 00:08:47 2007 @@ -0,0 +1,119 @@ + + + +error_handling + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
error_handling
open/demo/error_handling.html
assertTextlogger
clickno_error_handler_no_error
waitForTextNotPresentloggerError handler activated
clickno_error_handler_empty_response
waitForTextNotPresentloggerError handler activated
clickno_error_handler_error
waitForTextNotPresentloggerError handler activated
clickno_error_handler_explicit_error
waitForTextNotPresentloggerError handler activated.
clickwith_error_handler_no_error
waitForTextloggerError handler activated.
clickcss=#log-reset
clickwith_error_handler_empty_response
waitForTextloggerError handler activated.
clickcss=#log-reset
clickwith_error_handler_error
waitForTextloggerError handler activated.
clickcss=#log-reset
clickwith_error_handler_explicit_error
waitForTextloggerError handler activated.
+ + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html Fri Dec 7 00:08:47 2007 @@ -0,0 +1,144 @@ + + + +form_submit + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
form_submit
open/demo/form_submit.html
typenameJohn Foo
typeaddressBar street, 12
typecityFoobar
selectcountrylabel=USA
typetelephone100
clicksubmit
waitForTextPresentAsync saved:
verifyTextPresent100
verifyTextPresentFoobar
verifyTextPresentUSA
verifyTextPresentJohn Foo
verifyTextPresentBar street, 12
typenameBrigitte Bardou
typeaddressCool street
selectcountrylabel=USA
selectcountrylabel=Norway
typecitySouthway
typetelephonedring
clicksubmit
verifyTextPresentAsync saved:
verifyTextPresentdring
verifyTextPresentSouthway
verifyTextPresentNorway
verifyTextPresentBrigitte Bardou
verifyTextPresentCool street
+ + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html Fri Dec 7 00:08:47 2007 @@ -0,0 +1,84 @@ + + + +html_inserts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
html_inserts
open/demo/html_inserts.html
assertTextframeKSS for a life.
clickinsertAsFirstChild
waitForTextframefirst: KSS for a life.
clickinsertAsLastChild
waitForTextframefirst: KSS for a life.last:
clickinsert
waitForTextframeKSS for a life.
typetext-to-insertbefore 1
clickinsertBefore
waitForTextcss=h4+divKSS for a life. before 1
typetext-to-insertafter 1
clickinsertAfter
waitForTextcss=#frame+divKSS for a life. after 1
+ + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Fri Dec 7 00:08:47 2007 @@ -0,0 +1,54 @@ + + + +more_selectors + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
more_selectors
open/demo/more_selectors.html
assertTextPresentMore complex selectors
clickbutton-one
assertAlertKeep trying until you get there, event [annoy], rule #2, node [INPUT].
clickbutton-two
waitForAlertKeep trying until you get there, from the second button, event [annoy], rule #5, node [INPUT].
clickbutton-two
waitForTextPresentButton button-two clicked.
+ + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Fri Dec 7 00:08:47 2007 @@ -1,6 +1,6 @@ -

Development mode -

+ @@ -52,12 +52,24 @@ + + + + + + + + + + + + @@ -98,7 +110,19 @@ + + + + + + + + + + + +
Selectors
More Selectors
Form submit
Error handling
HTML inserts

Production mode -

+
Selectors
More Selectors
Form submit
Error handling
HTML inserts
- + From gotcha at codespeak.net Fri Dec 7 00:57:10 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 00:57:10 +0100 (CET) Subject: [KSS-checkins] r49491 - kukit/kukit.js/trunk/kukit Message-ID: <20071206235710.97068168525@codespeak.net> Author: gotcha Date: Fri Dec 7 00:57:10 2007 New Revision: 49491 Modified: kukit/kukit.js/trunk/kukit/kukit.js kukit/kukit.js/trunk/kukit/plugin.js kukit/kukit.js/trunk/kukit/utils.js Log: merge r48953:49490 from finish-closures branch Modified: kukit/kukit.js/trunk/kukit/kukit.js ============================================================================== --- kukit/kukit.js/trunk/kukit/kukit.js (original) +++ kukit/kukit.js/trunk/kukit/kukit.js Fri Dec 7 00:57:10 2007 @@ -17,14 +17,18 @@ * 02111-1307, USA. */ -kukit.isDevelMode = false; -;;; kukit.isDevelMode = true; +kukit = new function() { /// MODULE START + +var ku = this; + +ku.isDevelMode = false; +;;; ku.isDevelMode = true; /* * class Engine */ -kukit.Engine = function() { +ku.Engine = function() { this.baseUrl = this.calculateBase(); this.documentRules = new kukit.rd.MethodTable(); // table from res_type to rule processor @@ -47,7 +51,7 @@ }; -kukit.Engine.prototype.calculateBase = function() { +ku.Engine.prototype.calculateBase = function() { var base = ''; try { var _dummy = document; @@ -82,11 +86,11 @@ return base; }; -kukit.Engine.prototype.getRuleSheetLinks = function() { +ku.Engine.prototype.getRuleSheetLinks = function() { var nodes = document.getElementsByTagName("link"); var results = []; for (var i=0; i b) { @@ -297,11 +299,11 @@ } }; -kukit.ut.SortedQueue.prototype.reset = function() { +ut.SortedQueue.prototype.reset = function() { this.elements = new Array(); }; -kukit.ut.SortedQueue.prototype.push = function(obj) { +ut.SortedQueue.prototype.push = function(obj) { // Find the position of the object. var i = 0; var length = this.elements.length; @@ -312,33 +314,33 @@ this.elements.splice(i, 0, obj); }; -kukit.ut.SortedQueue.prototype.pop = function() { +ut.SortedQueue.prototype.pop = function() { // takes minimal element return this.elements.shift(); }; -kukit.ut.SortedQueue.prototype.popn = function(n) { +ut.SortedQueue.prototype.popn = function(n) { // takes first n minimal element return this.elements.splice(0, n); }; -kukit.ut.SortedQueue.prototype.empty = function() { +ut.SortedQueue.prototype.empty = function() { return ! this.elements.length; }; -kukit.ut.SortedQueue.prototype.size = function() { +ut.SortedQueue.prototype.size = function() { return this.elements.length; }; -kukit.ut.SortedQueue.prototype.get = function(n) { +ut.SortedQueue.prototype.get = function(n) { return this.elements[n]; }; -kukit.ut.SortedQueue.prototype.front = function() { +ut.SortedQueue.prototype.front = function() { return this.elements[0]; }; -kukit.ut.evalBool = function(value, errname) { +ut.evalBool = function(value, errname) { if (value == 'true' || value == 'True' || value == '1') { value = true; } else if (value == 'false' || value == 'False' || value == '0' @@ -350,7 +352,7 @@ return value; }; -kukit.ut.evalInt = function(value, errname) { +ut.evalInt = function(value, errname) { ;;; try { value = parseInt(value); ;;; } catch(e) { @@ -359,7 +361,7 @@ return value; }; -kukit.ut.evalList = function(value, errname) { +ut.evalList = function(value, errname) { ;;; try { // remove whitespace from beginning, end value = value.replace(/^ +/, ''); @@ -384,7 +386,7 @@ * * for repeating or one time timing */ -kukit.ut.TimerCounter = function(delay, func, restart) { +ut.TimerCounter = function(delay, func, restart) { this.delay = delay; this.func = func; if (typeof(restart) == 'undefined') { @@ -394,7 +396,7 @@ this.timer = null; }; -kukit.ut.TimerCounter.prototype.start = function() { +ut.TimerCounter.prototype.start = function() { if (this.timer) { ;;; kukit.E = 'Timer already started.'; @@ -407,7 +409,7 @@ this.timer = setTimeout(func, this.delay); }; -kukit.ut.TimerCounter.prototype.timeout = function() { +ut.TimerCounter.prototype.timeout = function() { // Call the event action this.func(); // Restart the timer @@ -417,7 +419,7 @@ } }; -kukit.ut.TimerCounter.prototype.clear = function() { +ut.TimerCounter.prototype.clear = function() { if (this.timer) { window.clearTimeout(this.timer); this.timer = null; @@ -428,13 +430,13 @@ /* * class Scheduler */ -kukit.ut.Scheduler = function(func) { +ut.Scheduler = function(func) { this.func = func; this.timer = null; this.nextWake = null; }; -kukit.ut.Scheduler.prototype.setNextWake = function(ts) { +ut.Scheduler.prototype.setNextWake = function(ts) { // Sets wakeup time, null clears if (this.nextWake) { this.clear(); @@ -456,7 +458,7 @@ } }; -kukit.ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) { +ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) { // Sets wakeup time, unless it would wake up later than the // currently set timeout. Null clears the timer. if (! ts || ! this.nextWake || ts < this.nextWake) { @@ -467,7 +469,7 @@ } }; -kukit.ut.Scheduler.prototype.timeout = function() { +ut.Scheduler.prototype.timeout = function() { // clear the timer this.timer = null; this.nextWake = null; @@ -476,7 +478,7 @@ }; -kukit.ut.Scheduler.prototype.clear = function() { +ut.Scheduler.prototype.clear = function() { if (this.nextWake) { window.clearTimeout(this.timer); this.timer = null; @@ -489,22 +491,22 @@ * * Scheduler for serializing bind and load procedures */ -kukit.ut.SerializeScheduler = function() { +ut.SerializeScheduler = function() { this.items = []; this.lock = false; }; -kukit.ut.SerializeScheduler.prototype.addPre = function(func, remark) { +ut.SerializeScheduler.prototype.addPre = function(func, remark) { this.items.push({func: func, remark: remark}); this.execute(); }; -kukit.ut.SerializeScheduler.prototype.addPost = function(func, remark) { +ut.SerializeScheduler.prototype.addPost = function(func, remark) { this.items.unshift({func: func, remark: remark}); this.execute(); }; -kukit.ut.SerializeScheduler.prototype.execute = function() { +ut.SerializeScheduler.prototype.execute = function() { if (! this.lock) { this.lock = true; while (true) { @@ -533,7 +535,7 @@ /* extracted from Plone */ // cross browser function for registering event handlers -kukit.ut.registerEventListener = function(elem, event, func) { +ut.registerEventListener = function(elem, event, func) { if (elem.addEventListener) { elem.addEventListener(event, func, false); return true; @@ -545,22 +547,27 @@ return false; }; +if (typeof(window) != 'undefined') { + ut.registerEventListener(window, "load", kukit.bootstrap); +} /* collecting keys-values into a dict or into a tuple list */ -kukit.ut.DictCollector = function() { +ut.DictCollector = function() { this.result = {}; }; -kukit.ut.DictCollector.prototype.add = function(key, value) { +ut.DictCollector.prototype.add = function(key, value) { this.result[key] = value; }; -kukit.ut.TupleCollector = function() { +ut.TupleCollector = function() { this.result = []; }; -kukit.ut.TupleCollector.prototype.add = function(key, value) { +ut.TupleCollector.prototype.add = function(key, value) { this.result.push([key, value]); }; +}(); /// MODULE END + From gotcha at codespeak.net Fri Dec 7 00:57:46 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 00:57:46 +0100 (CET) Subject: [KSS-checkins] r49492 - in kukit/kss.core/trunk/kss/core: . plugins/core/demo plugins/core/demo/coreplugin plugins/core/demo/selenium_tests Message-ID: <20071206235746.53B8E168527@codespeak.net> Author: gotcha Date: Fri Dec 7 00:57:45 2007 New Revision: 49492 Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/error_handling.html - copied, changed from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/form_submit.html - copied unchanged from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/html_inserts.html - copied unchanged from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/more_selectors.html - copied, changed from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setDevMode.html - copied, changed from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html - copied, changed from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Modified: kukit/kss.core/trunk/kss/core/ (props changed) kukit/kss.core/trunk/kss/core/EXTERNALS.TXT kukit/kss.core/trunk/kss/core/concatresource.zcml kukit/kss.core/trunk/kss/core/configure.zcml kukit/kss.core/trunk/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss kukit/kss.core/trunk/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.kss kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.kss kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.pt kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/actions.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/basic_commands.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html Log: merge r48954:49490 from finish-closures branch Modified: kukit/kss.core/trunk/kss/core/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/trunk/kss/core/EXTERNALS.TXT (original) +++ kukit/kss.core/trunk/kss/core/EXTERNALS.TXT Fri Dec 7 00:57:45 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/trunk +kukit http://codespeak.net/svn/kukit/kukit.js/trunk/ Modified: kukit/kss.core/trunk/kss/core/concatresource.zcml ============================================================================== --- kukit/kss.core/trunk/kss/core/concatresource.zcml (original) +++ kukit/kss.core/trunk/kss/core/concatresource.zcml Fri Dec 7 00:57:45 2007 @@ -24,10 +24,11 @@ + + +

"; +} Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt Fri Dec 7 00:57:45 2007 @@ -6,11 +6,13 @@ @@ -22,28 +24,27 @@

header

-

Kss prevent bubbling demo

-

This demo shows how a rule can prevent bubbling of an event to its parent nodes

- - -

DIV

-
-

-Click anywhere inside this DIV to show an alert -

-

-Click here to trigger an event in both the A tag and in the parent node -

-

-Text -

-

-Click here to trigger an event only in the A tag -

-

-Text -

-
- +

Prevent bubbling

+

This demo shows how a rule can prevent bubbling of an event to its parent nodes

+

Containing DIV

+
+

+ Click anywhere inside this containing DIV and check the log hereunder. +

+

Click here to trigger an event in both the P tag and in the parent node.

+

+ Some text +

+

Click here to trigger an event only in the P tag.

+

+ Some text +

+
+

Log

+

Reset log

+

You clicked :

+
+

+
Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/demoview.py Fri Dec 7 00:57:45 2007 @@ -179,24 +179,26 @@ self.getCommandSet('core').replaceHTML('div#frame', '

KSS for a life.

') return self.render() - def htmlInsertBefore(self): + def htmlInsertBefore(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLBefore('#core', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLBefore('#frame', '
KSS for a life. %s
' % text) return self.render() - def htmlInsertAfter(self): + def htmlInsertAfter(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAfter('#core', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAfter('#frame', '
KSS for a life. %s
' % text) return self.render() - def htmlInsertAsFirstChild(self): + def htmlInsertAsFirstChild(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAsFirstChild('div#frame', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAsFirstChild('div#frame', + "first: %s " % text) return self.render() - def htmlInsertAsLastChild(self): + def htmlInsertAsLastChild(self, text=''): """html insert""" - self.getCommandSet('core').insertHTMLAsLastChild('div#frame', '
KSS for a life. %s
' % (str(datetime.datetime.now()), )) + self.getCommandSet('core').insertHTMLAsLastChild('div#frame', + "last: %s" % text) return self.render() Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.kss Fri Dec 7 00:57:45 2007 @@ -11,17 +11,11 @@ It also demonstrates kss rules are merged like css ones */ -/* -.handled:click { - errTest-error: alert; - alert-message: nodeAttr(id); -} -*/ .handled:click { - errTest-error: replaceInnerHTML; - replaceInnerHTML-kssSelector: htmlid('update-status'); - replaceInnerHTML-html: 'Error handler activated.'; + errTest-error: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Error handler activated."; } /* Spinner control @@ -41,3 +35,13 @@ setStyle-value: none; } +/* Log control +*/ + +#log-reset a:click, #log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "

"; +} Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/error_handling.pt Fri Dec 7 00:57:45 2007 @@ -1,9 +1,7 @@ - - - + - -

header

Error handling demo

@@ -36,32 +32,28 @@ except that the second one gives a response with no commands and so it issues a warning into the kss log. "Error" gives a failed responses due to an exception in the server method on the server.

-

The buttons in the first row have no error handled.

+

The buttons in the first row have no error handlers.

- - - - - + + + +

The buttons in the second row have individual error handlers.

- - - - - + + + +

You can also try suspending your server process and start generating timed out requests. @@ -72,6 +64,12 @@ their number (currently in 4): click like crazy on the buttons and you will see that your server will not get hogged. More will be told about this topic in the upcoming documentation.

+

Log

+

Reset log

+

Error log :

+
+

+
Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.kss ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.kss (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.kss Fri Dec 7 00:57:45 2007 @@ -1,17 +1,25 @@ button#insertBefore:click { + evt-click-preventdefault: true; action-server: htmlInsertBefore; + htmlInsertBefore-text : currentFormVar(text-to-insert); } button#insertAfter:click { + evt-click-preventdefault: true; action-server: htmlInsertAfter; + htmlInsertAfter-text : currentFormVar(text-to-insert); } button#insertAsFirstChild:click { + evt-click-preventdefault: true; action-server: htmlInsertAsFirstChild; + htmlInsertAsFirstChild-text : currentFormVar(text-to-insert); } button#insertAsLastChild:click { + evt-click-preventdefault: true; + htmlInsertAsLastChild-text : currentFormVar(text-to-insert); action-server: htmlInsertAsLastChild; } Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/html_inserts.pt Fri Dec 7 00:57:45 2007 @@ -32,6 +32,8 @@

header

HTML insertions (a.k.a. Change tags II.)

+
+ Text to insert:
+

The playground:

-

KSS for a life.

+
KSS for a life.
Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.kss ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.kss (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.kss Fri Dec 7 00:57:45 2007 @@ -1,3 +1,10 @@ +#log-reset a:click, #log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "

"; +} #button-one:annoyclicker-click(annoyMe) { } @@ -10,8 +17,9 @@ } behaviour:annoyclicker-annoy(annoyMe) { - action-client: alert; - alert-message: "Keep trying until you get there"; + action-client: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Keep trying until you get there. "; } #button-two:annoyclicker-click(annoyYou) { @@ -24,6 +32,7 @@ } behaviour:annoyclicker-annoy(annoyYou) { - action-client: alert; - alert-message: "Keep trying until you get there, from the second button"; + action-client: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Keep trying until you get there, from the second button. "; } Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/more_selectors.pt Fri Dec 7 00:57:45 2007 @@ -39,5 +39,11 @@ +

Log

+

Reset log

+

You clicked :

+
+

+
Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/actions.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/actions.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/actions.html Fri Dec 7 00:57:45 2007 @@ -13,273 +13,6 @@ /demo/actions.html - - - clickAndWait - link=Setup - - - - assertTextPresent - Kss mode setup - - - - clickAndWait - button_devel - - - - assertTextPresent - development - - - - clickAndWait - link=Back - - - - assertTextPresent - development - - - - - assertAttribute - toggleclass-button at class - button click cursorPointer - - - click - toggleclass-button - - - - assertAttribute - toggleclass-button at class - button click cursorPointer selected - - - click - toggleclass-button - - - - assertAttribute - toggleclass-button at class - button click cursorPointer - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer - - - click - server-toggleclass-button - - - - waitForAttribute - server-toggleclass-button at class - button click cursorPointer selected - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer selected - - - click - server-toggleclass-button - - - - waitForAttribute - server-toggleclass-button at class - button click cursorPointer - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer - - - - assertAttribute - addclass-button at class - button click cursorPointer - - - click - addclass-button - - - - waitForAttribute - addclass-button at class - button click cursorPointer selected - - - assertAttribute - addclass-button at class - button click cursorPointer selected - - - assertAttribute - server-addclass-button at class - button click cursorPointer - - - click - server-addclass-button - - - - waitForAttribute - server-addclass-button at class - button click cursorPointer selected - - - assertAttribute - server-addclass-button at class - button click cursorPointer selected - - - - assertAttribute - removeclass-button at class - button click cursorPointer selected - - - click - removeclass-button - - - - waitForAttribute - removeclass-button at class - button click cursorPointer - - - assertAttribute - removeclass-button at class - button click cursorPointer - - - assertAttribute - server-removeclass-button at class - button click cursorPointer selected - - - click - server-removeclass-button - - - - waitForAttribute - server-removeclass-button at class - button click cursorPointer - - - assertAttribute - server-removeclass-button at class - button click cursorPointer - - - - clickAndWait - link=Setup - - - - assertTextPresent - Kss mode setup - - - - clickAndWait - button_prod - - - - assertTextPresent - production - - - - clickAndWait - link=Back - - - - assertTextPresent - production - - - - - assertAttribute - toggleclass-button at class - button click cursorPointer - - - click - toggleclass-button - - - - assertAttribute - toggleclass-button at class - button click cursorPointer selected - - - click - toggleclass-button - - - - assertAttribute - toggleclass-button at class - button click cursorPointer - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer - - - click - server-toggleclass-button - - - - waitForAttribute - server-toggleclass-button at class - button click cursorPointer selected - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer selected - - - click - server-toggleclass-button - - - - waitForAttribute - server-toggleclass-button at class - button click cursorPointer - - - assertAttribute - server-toggleclass-button at class - button click cursorPointer - - assertAttribute toggleclass-button at class Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/basic_commands.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/basic_commands.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/basic_commands.html Fri Dec 7 00:57:45 2007 @@ -13,235 +13,6 @@ /demo/basic_commands.html - - - clickAndWait - link=Setup - - - - assertTextPresent - Kss mode setup - - - - clickAndWait - button_devel - - - - assertTextPresent - development - - - - clickAndWait - link=Back - - - - assertTextPresent - development - - - - - assertText - demo - KSS - - - assertText - copy - copy here - - - click - change - - - - waitForElementPresent - workedagain - - - - assertElementPresent - workedagain - - - - assertText - demo - it worked again - - - click - clear - - - - waitForElementNotPresent - workedagain - - - - assertNotText - demo - it worked again - - - click - copyFrom - - - - waitForNotText - copy - copy here - - - assertNotText - copy - copy here - - - assertElementNotPresent - workedagain - - - - click - change - - - - waitForElementPresent - workedagain - - - - assertElementPresent - workedagain - - - - assertNotText - copy - it worked again - - - click - copyFrom - - - - waitForText - copy - it worked again - - - assertText - copy - it worked again - - - click - clear - - - - waitForNotText - demo - it worked again - - - assertNotText - demo - it worked again - - - click - copyTo - - - - waitForText - demo - it worked again - - - assertText - demo - it worked again - - - click - clear - - - - waitForNotText - demo - it worked again - - - assertNotText - demo - it worked again - - - click - moveTo - - - - waitForText - demo - it worked again - - - assertText - demo - it worked again - - - assertNotText - copy - it worked again - - - - clickAndWait - link=Setup - - - - assertTextPresent - Kss mode setup - - - - clickAndWait - button_prod - - - - assertTextPresent - production - - - - clickAndWait - link=Back - - - - assertTextPresent - production - - - assertText demo Copied: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/error_handling.html (from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html) ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/error_handling.html Fri Dec 7 00:57:45 2007 @@ -64,9 +64,9 @@ - waitForText + waitForTextNotPresent logger - Error handler activated. + Error handler activated click @@ -79,9 +79,9 @@ - waitForText + waitForTextNotPresent logger - Error handler activated. + Error handler activated click Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/kss_prevent_bubbling.html Fri Dec 7 00:57:45 2007 @@ -13,168 +13,69 @@ /demo/kss_evt_preventbubbling.html - - clickAndWait - link=Setup + assertText + logger - assertTextPresent - Kss mode setup - - - - clickAndWait - button_devel - - - - assertTextPresent - development - - - - clickAndWait - link=Back - - - - assertTextPresent - development - - - - clickAt - css=div#parent-node + parent-node - assertAlert - you clicked inside the DIV tag, event [click], rule #0, node [DIV]. - - - - assertAlertNotPresent - - + assertText + logger + containing DIV. clickAt - css=a#bubbling-node - - - - assertAlert - you clicked the bubbling A tag, event [click], rule #1, node [A]. - - - - assertAlert - you clicked inside the DIV tag, event [click], rule #0, node [DIV]. + log-reset - assertAlertNotPresent - + assertText + logger clickAt - css=a#not-bubbling-node - - - - assertAlert - you clicked the not bubbling A tag, event [click], rule #2, node [A]. - - - - - clickAndWait - link=Setup + bubbling-node - assertTextPresent - Kss mode setup - - - - clickAndWait - button_prod - - - - assertTextPresent - production - - - - clickAndWait - link=Back - - - - assertTextPresent - production - - - - - assertAlertNotPresent - - + assertText + logger + bubbling P. containing DIV. clickAt - css=div#parent-node + log-reset - assertAlert - you clicked inside the DIV tag - - - - assertAlertNotPresent - + assertText + logger clickAt - css=a#bubbling-node - - - - assertAlert - you clicked the bubbling A tag - - - - assertAlert - you clicked inside the DIV tag + not-bubbling-node - assertAlertNotPresent - - + assertText + logger + not bubbling P. clickAt - css=a#not-bubbling-node + log-reset - assertAlert - you clicked the not bubbling A tag - - - - assertAlertNotPresent - + assertText + logger Copied: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/more_selectors.html (from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html) ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Fri Dec 7 00:57:45 2007 @@ -24,18 +24,48 @@ - assertAlert - Keep trying until you get there, event [annoy], rule #2, node [INPUT]. + waitForText + logger + Keep trying until you get there. + + + click + log-reset + + + + assertText + logger click - button-two + button-one + + + + waitForText + logger + Keep trying until you get there. + + + click + button-one + + + + waitForTextPresent + Button button-one clicked. + + + + click + log-reset - waitForAlert - Keep trying until you get there, from the second button, event [annoy], rule #5, node [INPUT]. + assertText + logger @@ -44,6 +74,16 @@ + waitForText + logger + Keep trying until you get there, from the second button. + + + click + button-two + + + waitForTextPresent Button button-two clicked. Copied: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setDevMode.html (from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html) ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setDevMode.html Fri Dec 7 00:57:45 2007 @@ -15,7 +15,7 @@ assertTextPresent - Kss mode setup + KSS mode setup Copied: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html (from r49489, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html) ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Fri Dec 7 00:57:45 2007 @@ -15,7 +15,7 @@ assertTextPresent - Kss mode setup + KSS mode setup Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html Fri Dec 7 00:57:45 2007 @@ -1,14 +1,128 @@ - - +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Suite
ChangeTagContent
+

+ Development mode +

+
Basic commands
Two selects
Two selects revisited
Forms
Actions
Auto update
Focus
Prevent default on click
Prevent default
Inline edit
Bubbling
Selector parameters
Selectors
More Selectors
Form submit
Error handling
HTML inserts
+

+ Production mode +

+
Basic commands
Two selects
Two selects revisited
Forms
Actions
Auto update
Focus
Prevent default on click
Prevent default
Inline edit
Bubbling
Selector parameters
Selectors
More Selectors
Form submit
Error handling
HTML inserts
- + From gotcha at codespeak.net Fri Dec 7 01:22:54 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 01:22:54 +0100 (CET) Subject: [KSS-checkins] r49493 - in kukit/kss.core/branch/finish-closures: docs kss/core/browser kss/core/doc kss/core/docs kss/core/pluginregistry/browser kss/core/plugins/core/demo kss/core/plugins/core/demo/parameterfunction kss/core/plugins/core/demo/selenium_tests Message-ID: <20071207002254.A6C5C168543@codespeak.net> Author: gotcha Date: Fri Dec 7 01:22:51 2007 New Revision: 49493 Added: kukit/kss.core/branch/finish-closures/kss/core/docs/ - copied from r49490, kukit/kss.core/trunk/kss/core/docs/ kukit/kss.core/branch/finish-closures/kss/core/docs/CREDITS.txt - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/CREDITS.txt kukit/kss.core/branch/finish-closures/kss/core/docs/HISTORY.txt - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/HISTORY.txt kukit/kss.core/branch/finish-closures/kss/core/docs/INSTALL.txt - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/INSTALL.txt kukit/kss.core/branch/finish-closures/kss/core/docs/LICENSE.GPL - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL kukit/kss.core/branch/finish-closures/kss/core/docs/LICENSE.txt - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/LICENSE.txt kukit/kss.core/branch/finish-closures/kss/core/docs/TODO.txt - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/TODO.txt kukit/kss.core/branch/finish-closures/kss/core/docs/tutorial_part2.rst - copied unchanged from r49490, kukit/kss.core/trunk/kss/core/docs/tutorial_part2.rst Removed: kukit/kss.core/branch/finish-closures/docs/ kukit/kss.core/branch/finish-closures/kss/core/doc/ Modified: kukit/kss.core/branch/finish-closures/kss/core/browser/kukitresponse.pt kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.pt kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develview.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/basic_commands.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/pf_forms.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Log: trunk merged back Modified: kukit/kss.core/branch/finish-closures/kss/core/browser/kukitresponse.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/browser/kukitresponse.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/browser/kukitresponse.pt Fri Dec 7 01:22:51 2007 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Fri Dec 7 01:22:51 2007 @@ -55,13 +55,13 @@ background-color: #880000; } -a.button, -input[type="submit"] { +a.button, .clickable { width: auto; padding: 0.2em; border: 1px solid #FF8888; color: #CC0000; text-decoration: none; + font-size: 80%; } fieldset { @@ -89,11 +89,22 @@ padding : 1em; } -.red { - color: red; +.production, .error { + color: red; +} + +.production, .development { + font-weight: bold; } -.green { - color: green; +.warning { + color: orange; } +.development, .info { + color: green; +} + +.debug { + color: blue; +} Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.pt Fri Dec 7 01:22:51 2007 @@ -54,44 +54,103 @@ + loglevel python: options.get('loglevel', view.getLogLevel()); + referer request/referer|request/HTTP_REFERER|nothing"> -

Kss mode setup

+

KSS mode setup

- Current KSS mode is - developmentproduction. + class="production" tal:condition="not: devel_mode">production mode.

-

+

+ The mode is stored in a cookie that is global to the site. +

+

+ It can be overridden by a local utility (eg. ResourceRegistries, in Plone). +

+ +

If you call @@kss_devel_mode/ison on the current context, - you get True if in development mode, False in in production mode. + you will get True in development mode, False in production mode.

-

- Set KSS mode cookie -

-
- Click the button to toggle mode. -
- -
- - - -
-

The cookie is global to the site and may be overridden by a - local utility (eg. ResourceRegistries, in Plone)

+
+

+ Set KSS mode cookie +

+

+ Click the button to toggle mode. +

+ +
+ + + +
+ +
+
+ +

+ Back to the referer page. +

+ +

KSS log level setup

+ +

+ Current KSS log level is + DEBUG. +

+

+ The log level is stored in a cookie that is global to the site. +

+ +

+ Logging is effective only in development mode. +

+ +
+
+

+ Set KSS log level +

+

+ Click the button to set log level. +

+ + +
+ + + +
+
+ +
+ +
-

Back

+

+ Back to the referer page. +

Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develview.py ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develview.py (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develview.py Fri Dec 7 01:22:51 2007 @@ -11,7 +11,8 @@ from zope.traversing.interfaces import ITraverser from zope.publisher.interfaces import NotFound -COOKIE_NAME = '__kss_devel' +COOKIE_DEVELMODE = '__kss_devel' +COOKIE_LOGLEVEL = '__kss_loglevel' class DevelView(BrowserView): implements(IDevelView) @@ -37,7 +38,7 @@ return self, ('ui', ) # -- - # Accessable methods + # Methods for handling development/production mode # -- def ison(self): @@ -51,7 +52,7 @@ select development mode without the cookie ''' - ison = COOKIE_NAME in self.request.cookies + ison = COOKIE_DEVELMODE in self.request.cookies if not ison: # Check from javascript tool @@ -76,26 +77,51 @@ def set(self): 'Sets development mode cookie' - self.request.response.setCookie(COOKIE_NAME, '1', path='/') + self.request.response.setCookie(COOKIE_DEVELMODE, '1', path='/') def unset(self): 'Unsets development mode cookie' - self.request.response.expireCookie(COOKIE_NAME, path='/') + self.request.response.expireCookie(COOKIE_DEVELMODE, path='/') + + # -- + # Methods for handling loglevel + # -- + + def getLogLevel(self, REQUEST=None): + 'Gets current log level' + loglevel = self.request.cookies.get(COOKIE_LOGLEVEL, 'DEBUG').upper() + return loglevel + + def setLogLevel(self, loglevel): + 'Sets loglevel cookie' + self.request.response.setCookie(COOKIE_LOGLEVEL, loglevel, path='/') + + # -- + # User interface + # -- _ui = ViewPageTemplateFile('develui.pt', content_type='text/html;charset=utf-8') def ui(self): 'User interface for interactive switching' options = {} + # Handle development/production mode if 'devel' in self.request.form: self.set() # setting it also to have immediate effect in the page options['devel_mode'] = True if 'prod' in self.request.form: self.unset() - if COOKIE_NAME in self.request.cookies: + if COOKIE_DEVELMODE in self.request.cookies: # setting it also to have immediate effect in the page options['devel_mode'] = False + # Handle loglevel + if 'loglevel' in self.request.form: + loglevel = self.request.form['loglevel'] + self.setLogLevel(loglevel) + # setting it also to have immediate effect in the page + options['loglevel'] = loglevel + # Return the rendered template return self._ui(**options) def ui_js(self): Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/basic_commands.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/basic_commands.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/basic_commands.pt Fri Dec 7 01:22:51 2007 @@ -91,19 +91,18 @@ For instance, let's look at the moveToDivContent response.

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:kukit="http://www.kukit.org/commands/1.0"><body>
-<kukit:commands>
-<kukit:command selector="div#copy" name="copyChildNodesTo"
-               selectorType="">
-    <kukit:param name="html_id">demo</kukit:param>
-</kukit:command>
-<kukit:command selector="div#copy" name="clearChildNodes"
-               selectorType="">
-</kukit:command>
-</kukit:commands>
-</body></html>
+   
+<kukit xmlns="http://www.kukit.org/commands/1.1">
+<commands>
+<command selector="div#copy" name="copyChildNodesTo"
+         selectorType="">
+    <param name="html_id">demo</param>
+</command>
+<command selector="div#copy" name="clearChildNodes"
+         selectorType="">
+</command>
+</commands>
+</kukit>
    

The XML specifies two commands to apply to the div#copy node : Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss Fri Dec 7 01:22:51 2007 @@ -12,11 +12,6 @@ */ -/* The next rule demonstrates that instead of executing a local - action on the originally selected node, we use executeCommand - which execute a given local action on a new set of selected nodes. -*/ - .handled:click { errTest-error: insertHTMLBefore; insertHTMLBefore-kssSelector: #log-end; Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt Fri Dec 7 01:22:51 2007 @@ -34,25 +34,25 @@ on the server.

The buttons in the first row have no error handlers.

- - - -

The buttons in the second row have individual error handlers.

- - - -

Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss Fri Dec 7 01:22:51 2007 @@ -1,3 +1,10 @@ +#log-reset a:click, #log-reset:click { + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "

"; +} #button-one:annoyclicker-click(annoyMe) { } @@ -10,8 +17,9 @@ } behaviour:annoyclicker-annoy(annoyMe) { - action-client: alert; - alert-message: "Keep trying until you get there"; + action-client: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Keep trying until you get there. "; } #button-two:annoyclicker-click(annoyYou) { @@ -24,6 +32,7 @@ } behaviour:annoyclicker-annoy(annoyYou) { - action-client: alert; - alert-message: "Keep trying until you get there, from the second button"; + action-client: insertHTMLBefore; + insertHTMLBefore-kssSelector: #log-end; + insertHTMLBefore-html: "Keep trying until you get there, from the second button. "; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt Fri Dec 7 01:22:51 2007 @@ -39,5 +39,11 @@ +

Log

+

Reset log

+

You clicked :

+
+

+
Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.pt Fri Dec 7 01:22:51 2007 @@ -182,7 +182,7 @@
Click the button.
- Click me ! + Click me !
value1:
+ listval with multiselect: + recordval: Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/parameterfunction_view.py Fri Dec 7 01:22:51 2007 @@ -19,4 +19,5 @@ def submitFullFormIntoRequest(self): # marshall back the repr of this dict. ksscore = self.getCommandSet('core') - ksscore.replaceInnerHTML('#target', repr(self.request.form)) + ksscore.replaceInnerHTML('#target', repr(list(sorted( + self.request.form.items())))) Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html Fri Dec 7 01:22:51 2007 @@ -64,9 +64,9 @@ - waitForText + waitForTextNotPresent logger - Error handler activated. + Error handler activated click @@ -79,9 +79,9 @@ - waitForText + waitForTextNotPresent logger - Error handler activated. + Error handler activated click Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Fri Dec 7 01:22:51 2007 @@ -24,18 +24,48 @@ - assertAlert - Keep trying until you get there, event [annoy], rule #2, node [INPUT]. + waitForText + logger + Keep trying until you get there. + + + click + log-reset + + + + assertText + logger click - button-two + button-one + + + + waitForText + logger + Keep trying until you get there. + + + click + button-one + + + + waitForTextPresent + Button button-one clicked. + + + + click + log-reset - waitForAlert - Keep trying until you get there, from the second button, event [annoy], rule #5, node [INPUT]. + assertText + logger @@ -44,6 +74,16 @@ + waitForText + logger + Keep trying until you get there, from the second button. + + + click + button-two + + + waitForTextPresent Button button-two clicked. Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/pf_forms.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/pf_forms.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/pf_forms.html Fri Dec 7 01:22:51 2007 @@ -113,6 +113,21 @@ target radio-2 + + click + fullform-current + + + + waitForText + target + [('listval', ['listval1', 'listval2']), ('multiple-select', ['Value 1', 'Value 3']), ('recordsval', [{'a': 'recordval_a_1', 'b': 'recordval_b_1'}, {'a': 'recordval_a_2', 'b': 'recordval_b_2'}]), ('recordval', {'a': 'recordval_a', 'b': 'recordval_b'}), ('value1', 'value1'), ('value2', 'value2')] + + + verifyTextPresent + [('listval', ['listval1', 'listval2']), ('multiple-select', ['Value 1', 'Value 3']), ('recordsval', [{'a': 'recordval_a_1', 'b': 'recordval_b_1'}, {'a': 'recordval_a_2', 'b': 'recordval_b_2'}]), ('recordval', {'a': 'recordval_a', 'b': 'recordval_b'}), ('value1', 'value1'), ('value2', 'value2')] + + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html Fri Dec 7 01:22:51 2007 @@ -15,7 +15,7 @@ assertTextPresent - Kss mode setup + KSS mode setup Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Fri Dec 7 01:22:51 2007 @@ -15,7 +15,7 @@ assertTextPresent - Kss mode setup + KSS mode setup From gotcha at codespeak.net Fri Dec 7 01:23:05 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 01:23:05 +0100 (CET) Subject: [KSS-checkins] r49494 - in kukit/kukit.js/branch/finish-closures: doc kukit Message-ID: <20071207002305.89CC4168546@codespeak.net> Author: gotcha Date: Fri Dec 7 01:23:04 2007 New Revision: 49494 Modified: kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js kukit/kukit.js/branch/finish-closures/kukit/dom.js kukit/kukit.js/branch/finish-closures/kukit/errors.js kukit/kukit.js/branch/finish-closures/kukit/forms.js kukit/kukit.js/branch/finish-closures/kukit/kukit.js kukit/kukit.js/branch/finish-closures/kukit/serveraction.js kukit/kukit.js/branch/finish-closures/kukit/utils.js Log: trunk merged back Modified: kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt Fri Dec 7 01:23:04 2007 @@ -6,6 +6,21 @@ - ... + - Fix multiple selection form fields + marshalling on Safari + (fixes #22 in kssproject) + and on IE. + [ree] + + - Fix error fallback handling + [ree] + + - Implement loglevels based on cookies + Add cookie handling code to kss.dom + Change logging on FireBug to avoid line info in debug + level messages + [ree] + - Implement event binding based on the ids fetched dynamically from the dom, by value providers. [ree] Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Fri Dec 7 01:23:04 2007 @@ -41,8 +41,9 @@ // we make sure we execute none of them. var lastcommand = this.commands[this.commands.length-1]; if (lastcommand.name == 'error') { -;;; throw kukit.err.explicitError(lastcommand); - throw new Error(kukit.E); + // We have to throw an explicitError always, since we want + // error fallbacks work both in production and development mode. + throw kukit.err.explicitError(lastcommand); } } }; Modified: kukit/kukit.js/branch/finish-closures/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/dom.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/dom.js Fri Dec 7 01:23:04 2007 @@ -432,5 +432,30 @@ } }; + +/* + * Cookie handling code taken from: + * http://www.quirksmode.org/js/cookies.html + */ + +dom.createCookie = function(name, value, days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else var expires = ""; + document.cookie = name + "=" + value + expires + "; path=/"; +}; + +// we get this from kukit utils.js. We needed an early +// definition there, because logging is needed from the +// very beginning. +dom.readCookie = kukit.readCookie; + +dom.eraseCookie = function(name) { + createCookie(name, "", -1); +}; + }(); /// MODULE END Modified: kukit/kukit.js/branch/finish-closures/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/errors.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/errors.js Fri Dec 7 01:23:04 2007 @@ -55,67 +55,84 @@ */ -;;; var ErrorAnnotation = function() { -;;; -;;; this.constructError = function(e, name, message, kw) { -;;; if (typeof(kw) == "undefined") { -;;; kw = {}; -;;; } -;;; this.kw = kw; -;;; this.message = name + ': ' + message; -;;; var addMessage = true; -;;; if (!e) { -;;; e = new Error(message); -;;; addMessage = false; -;;; } else if (typeof(e) == "string") { -;;; kukit.E = 'Do not raise string exceptions, as we cannot '; -;;; kukit.E += 'annotate them properly. Use: throw new Error(msg);'; -;;; e = new Error(e); -;;; } -;;; this.previous_info = e.info; -;;; e.name = name; -;;; e.info = this; -;;; if (addMessage) { -;;; var fullMessage = message + ' [' + e.message + ']'; -;;; // for FF, and Safari: -;;; e.message = fullMessage; -;;; // for IE, message is ignored, description is used. -;;; e.description = fullMessage; +var ErrorAnnotation = function() { + + this.constructError = function(e, name, message, kw) { +;;; if (typeof(kw) == "undefined") { +;;; kw = {}; +;;; } + this.kw = kw; +;;; this.message = name + ': ' + message; +;;; var addMessage = true; + if (!e) { +;;; e = new Error(message); +;;; addMessage = false; +;;; } else if (typeof(e) == "string") { +;;; kukit.E = 'Do not raise string exceptions, as we cannot '; +;;; kukit.E += 'annotate them properly. Use: throw new Error(msg);'; + e = new Error(kukit.E); + } +;;; this.previous_info = e.info; + e.name = name; + e.info = this; +;;; if (addMessage) { +;;; var fullMessage = message + ' [' + e.message + ']'; +;;; // for FF, and Safari: +;;; e.message = fullMessage; +;;; // for IE, message is ignored, description is used. +;;; e.description = fullMessage; ;;; } -;;; return e; -;;; }; + return e; + }; ;;; -;;; this._logRecursive = function() { -;;; kukit.logError(this.message); -;;; if (this.previous_info) { -;;; this.previous_info._logRecursive(); -;;; } -;;; }; +;;; this._logRecursive = function() { +;;; kukit.logError(this.message); +;;; if (this.previous_info) { +;;; this.previous_info._logRecursive(); +;;; } +;;; }; ;;; -;;; this.log = function() { -;;; // This is for debugging only, normal error handling -;;; // does not use it. -;;; kukit.logFatal('KSS error, stack information follows:'); -;;; this._logRecursive(); -;;; }; +;;; this.log = function() { +;;; // This is for debugging only, normal error handling +;;; // does not use it. +;;; kukit.logFatal('KSS error, stack information follows:'); +;;; this._logRecursive(); ;;; }; -;;; var setErrorInfo = function(e, name, message, kw) { -;;; return new ErrorAnnotation().constructError(e, name, message, kw); -;;; }; +}; + +var setErrorInfo = function(e, name, message, kw) { + return new ErrorAnnotation().constructError(e, name, message, kw); +}; /* Protects a function */ -;;; err.explicitError = function(errorcommand){ -;;; var kw = {'errorcommand':errorcommand}; -;;; var message = 'Explicit error'; -;;; return setErrorInfo(null, 'ExplicitError', message, kw); -;;; }; - -;;; err.responseParsingError = function(message){ -;;; return setErrorInfo(null, 'ResponseParsingError', message); -;;; }; +/* + * Explicit error represents that the server side action failed and + * we need to handle this with an explicit error action defined from + * kss. + * There are three main cases when this can happen: + * + * 1. In case the server explicitely sent us an error (hence the + * name of this class) the parameter will contain the kss + * command from the payload. + * + * 2. If a payload response parsing error lead us here, then it + * will contain a string of the error message. + * + * 3. If a timeout of the response happened, the parameter will + * contain the text "timeout". + */ +err.explicitError = function(errorcommand){ + var kw = {'errorcommand': errorcommand}; +;;; kukit.E = 'Explicit error'; + return setErrorInfo(null, 'ExplicitError', kukit.E, kw); +}; + +err.responseParsingError = function(message){ + return setErrorInfo(null, 'ResponseParsingError', message); +}; ;;; err.ruleMergeError = function(message){ ;;; return setErrorInfo(null, 'RuleMergeError', message); Modified: kukit/kukit.js/branch/finish-closures/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/forms.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/forms.js Fri Dec 7 01:23:04 2007 @@ -62,8 +62,11 @@ var elem = new _FormQueryElem(name, value); this.l.push(elem); } + // value.length is for detection of an Array. + // In addition we also check that value.pop is a function else if (typeof(value) == 'object' && - value.constructor.toString().indexOf('Array') != -1) { + typeof(value.length) == 'number' && + typeof(value.pop) == 'function') { // Special marshalling of arrays for (var i=0; i < value.length; i++) { var elem = new _FormQueryElem(name, value[i]); @@ -176,10 +179,9 @@ value=""; } else { var option = element.options[element.selectedIndex]; - value = option.value; - if (value == "") { - value = option.text; - } + // on FF and safari, option.value has the value + // on IE, option.text needs to be used + value = option.value || option.text; } // Now process selects with the multiple option set } else { @@ -187,7 +189,9 @@ for(i=0; i= this.loglevel) ? f : kukit._null; +;;; }; + + // This sets up the handlers and allows to set them + // up again with a different cookie setting. + // Will be overwritten by different loggers. + this._setupHandlers = function() { + this.logDebug = kukit._null; + this.log = kukit._null; + this.logWarning = kukit._null; + this.logError = kukit._null; + this.logFatal = kukit._null; + }; +}(); + +// Stub functions that can be used for logging +kukit.logDebug = function(message) {kukit._logger.logDebug(message);}; +kukit.log = function(message) {kukit._logger.log(message);}; +kukit.logWarning = function(message) {kukit._logger.logWarning(message);}; +kukit.logError = function(message) {kukit._logger.logError(message);}; +kukit.logFatal = function(message) {kukit._logger.logFatal(message);}; + +// Function to change the log level from javascript +// level must be one of "DEBUG", "INFO", "WARNING", "ERROR". +// (Small caps are tolerated as well) +kukit.setLogLevel = function(level) { +;;; // Store it in the cookie so that it persists through requests. +;;; 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; // you get a clickable result that brings you to Firebug inspector. @@ -73,74 +161,77 @@ // if (kukit.hasFirebug) { // kukit.log(node); // } -kukit.hasFirebug = false; ;;; // check whether the logging stuff of Firebug is available ;;; kukit.hasFirebug = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; result = result && typeof console.debug != 'undefined'; ;;; result = result && typeof console.error != 'undefined'; ;;; result = result && typeof console.warn != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasFirebug()) { -;;; kukit.log = console.log; -;;; kukit.logDebug = console.debug; -;;; kukit.logFatal = console.error; -;;; kukit.logError = console.error; -;;; kukit.logWarning = console.warn; -;;; kukit.hasFirebug = true; +;;; }(); + +;;; // Set up logging for FireBug +;;; if (kukit.hasFirebug) { +;;; kukit._logger._setupHandlers = function() { +;;; // for debug level we also log as 'info', because we do +;;; // not want FireBug to display line information. +;;; this.logDebug = console.log; +;;; this.log = console.log; +;;; this.logWarning = console.warn; +;;; this.logError = console.error; +;;; this.logFatal = console.error; +;;; } ;;; } ;;; // check whether the logging stuff of MochiKit is available ;;; kukit.hasMochiKit = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof MochiKit != 'undefined'; +;;; var result = typeof MochiKit != 'undefined'; ;;; result = result && typeof MochiKit.Logging != 'undefined'; ;;; result = result && typeof MochiKit.Logging.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasMochiKit()) { -;;; kukit.log = MochiKit.Logging.log; -;;; kukit.logError = MochiKit.Logging.logError; -;;; kukit.logDebug = MochiKit.Logging.logDebug; -;;; kukit.logFatal = MochiKit.Logging.logFatal; -;;; kukit.logWarning = MochiKit.Logging.logWarning; -;;; // make convenience url -;;; // javascript:kukit.showLog(); -;;; // instead of the need to say -;;; // javascript:void(createLoggingPane(true)); -;;; kukit.showLog = function() { -;;; createLoggingPane(true); -;;; }; +;;; }(); + +;;; // Set up logging for MochiKit +;;; if (! kukit.hasFirebug && kukit.hasMochiKit) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = MochiKit.Logging.logDebug; +;;; this.log = MochiKit.Logging.log; +;;; 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 +;;; // javascript:void(createLoggingPane(true)); +;;; kukit.showLog = function() { +;;; createLoggingPane(true); +;;; }; ;;; } ;;; // check whether the logging stuff of Safari is available ;;; kukit.hasSafari = function() { -;;; var result = typeof kukit.log == 'undefined'; -;;; result = result && typeof console != 'undefined'; +;;; var result = typeof console != 'undefined'; ;;; result = result && typeof console.log != 'undefined'; ;;; return result; -;;; } -;;; if (kukit.hasSafari()) { -;;; kukit.log = function(str) { console.log('INFO: '+str); }; -;;; kukit.logError = function(str) { console.log('ERROR: '+str); }; -;;; kukit.logDebug = function(str) { console.log('DEBUG: '+str); }; -;;; kukit.logFatal = function(str) { console.log('FATAL: '+str); }; -;;; kukit.logWarning = function(str) { console.log('WARNING: '+str); }; -;;; } +;;; }(); -/* no logging solution available */ -;;; if (typeof kukit.log == 'undefined') { - kukit.log = function(str){}; - kukit.logError = kukit.log; - kukit.logDebug = kukit.log; - kukit.logFatal = kukit.log; - kukit.logWarning = kukit.log; +;;; // Set up logging for Safari +;;; if (! kukit.hasFirebug && ! kukit.hasMochiKit && kukit.hasSafari) { +;;; kukit._logger._setupHandlers = function() { +;;; this.logDebug = function(str) { console.log('DEBUG: '+str); }; +;;; this.log = function(str) { console.log('INFO: '+str); }; +;;; 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 +kukit._logger.updateLogLevel(); + // log a startup message ;;; kukit.log('Loading KSS engine.'); From gotcha at codespeak.net Fri Dec 7 09:43:34 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 09:43:34 +0100 (CET) Subject: [KSS-checkins] r49495 - in kukit/kss.core/branch/finish-closures/kss/core: pluginregistry/browser plugins/core/demo plugins/core/demo/coreplugin Message-ID: <20071207084334.15BA316857A@codespeak.net> Author: gotcha Date: Fri Dec 7 09:43:27 2007 New Revision: 49495 Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt Log: simplify logger; move it to a macro Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Fri Dec 7 09:43:27 2007 @@ -14,7 +14,7 @@ font-size: 80%; } -#global-links ul { +#global-links ul, #log-reset { display: table-row; } @@ -22,7 +22,7 @@ display: table-cell; } -#global-links a { +#global-links a, #log-reset a { display: block; padding: 0.25em; margin: 0.25em; @@ -89,6 +89,14 @@ padding : 1em; } +.log { + margin: 0; + padding: 0.4em; + background: #CCC; + color: gray; + font-style: italic; +} + .production, .error { color: red; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.kss Fri Dec 7 09:43:27 2007 @@ -1,30 +1,27 @@ #parent-node:click { evt-click-allowbubbling: true; evt-click-preventdefault: true; - action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "containing DIV. "; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "containing DIV. "; } #bubbling-node:click { evt-click-preventdefault: true; - action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "bubbling P. "; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "bubbling P. "; } #not-bubbling-node:click { evt-click-preventdefault: true; evt-click-preventbubbling: true; - action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "not bubbling P. "; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "not bubbling P. "; } #log-reset a:click, #log-reset:click { action-client: clearChildNodes; clearChildNodes-kssSelector: #logger; - action-client: insertHTMLAsLastChild; - insertHTMLAsLastChild-kssSelector: #logger; - insertHTMLAsLastChild-html: "

"; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/coreplugin/kss_evt_preventbubbling.pt Fri Dec 7 09:43:27 2007 @@ -40,11 +40,6 @@ Some text

-

Log

-

Reset log

-

You clicked :

-
-

-
+

logger

Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.kss Fri Dec 7 09:43:27 2007 @@ -13,9 +13,9 @@ .handled:click { - errTest-error: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "Error handler activated."; + errTest-error: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "Error handler activated."; } /* Spinner control @@ -41,7 +41,4 @@ #log-reset a:click, #log-reset:click { action-client: clearChildNodes; clearChildNodes-kssSelector: #logger; - action-client: insertHTMLAsLastChild; - insertHTMLAsLastChild-kssSelector: #logger; - insertHTMLAsLastChild-html: "

"; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/error_handling.pt Fri Dec 7 09:43:27 2007 @@ -64,12 +64,6 @@ their number (currently in 4): click like crazy on the buttons and you will see that your server will not get hogged. More will be told about this topic in the upcoming documentation.

-

Log

-

Reset log

-

Error log :

-
-

-
- +

logger

Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.kss Fri Dec 7 09:43:27 2007 @@ -1,9 +1,6 @@ #log-reset a:click, #log-reset:click { action-client: clearChildNodes; clearChildNodes-kssSelector: #logger; - action-client: insertHTMLAsLastChild; - insertHTMLAsLastChild-kssSelector: #logger; - insertHTMLAsLastChild-html: "

"; } #button-one:annoyclicker-click(annoyMe) { @@ -17,9 +14,9 @@ } behaviour:annoyclicker-annoy(annoyMe) { - action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "Keep trying until you get there. "; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "Keep trying until you get there. "; } #button-two:annoyclicker-click(annoyYou) { @@ -32,7 +29,7 @@ } behaviour:annoyclicker-annoy(annoyYou) { - action-client: insertHTMLBefore; - insertHTMLBefore-kssSelector: #log-end; - insertHTMLBefore-html: "Keep trying until you get there, from the second button. "; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "Keep trying until you get there, from the second button. "; } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.pt Fri Dec 7 09:43:27 2007 @@ -39,11 +39,6 @@ -

Log

-

Reset log

-

You clicked :

-
-

-
+

logger

From gotcha at codespeak.net Fri Dec 7 09:45:58 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 09:45:58 +0100 (CET) Subject: [KSS-checkins] r49496 - kukit/kss.demo/branch/finish-closures Message-ID: <20071207084558.4F9C116857A@codespeak.net> Author: gotcha Date: Fri Dec 7 09:45:57 2007 New Revision: 49496 Added: kukit/kss.demo/branch/finish-closures/ - copied from r49495, kukit/kss.demo/trunk/ Log: finish-closures From gotcha at codespeak.net Fri Dec 7 09:47:20 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 09:47:20 +0100 (CET) Subject: [KSS-checkins] r49497 - kukit/kss.demo/branch/finish-closures/kss/demo/browser Message-ID: <20071207084720.43CCB16857D@codespeak.net> Author: gotcha Date: Fri Dec 7 09:47:19 2007 New Revision: 49497 Removed: kukit/kss.demo/branch/finish-closures/kss/demo/browser/demo.css Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml kukit/kss.demo/branch/finish-closures/kss/demo/browser/header_macros.pt Log: simplify logger; move it to a macro Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt Fri Dec 7 09:47:19 2007 @@ -29,4 +29,14 @@ + + +
+

Log

+

Reset

+
+
+ + + Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml Fri Dec 7 09:47:19 2007 @@ -53,11 +53,6 @@ permission="zope.View" /> - - - - From reebalazs at codespeak.net Fri Dec 7 12:10:03 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 12:10:03 +0100 (CET) Subject: [KSS-checkins] r49500 - in kukit/kss.demo/trunk/kss/demo: . browser selenium_utils Message-ID: <20071207111003.098D4168572@codespeak.net> Author: reebalazs Date: Fri Dec 7 12:10:03 2007 New Revision: 49500 Added: kukit/kss.demo/trunk/kss/demo/selenium_utils/builder.py Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py kukit/kss.demo/trunk/kss/demo/interfaces.py kukit/kss.demo/trunk/kss/demo/registry.py Log: Some cleanup and preparation for zelenium hookup to registry. Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/trunk/kss/demo/browser/registry.py Fri Dec 7 12:10:03 2007 @@ -4,6 +4,7 @@ from zope.publisher.interfaces import NotFound from zope.component import getUtility from zope.interface import implements +from kss.demo.selenium_utils.builder import cookSeleniumTests try: from Products.Five import BrowserView BrowserView # make pyflakes happy @@ -90,5 +91,8 @@ of kss.demo.selenium_utils . """ registry = getUtility(IKSSDemoRegistry) - registry.cookSeleniumTests() - return "Selenium tests cooked OK. (%i)" % (len(registry.selenium_tests), ) + filenames = registry.selenium_tests + # Cook them. This will create seltest_all.py. + cookSeleniumTests(filenames) + # We are done. + return "Selenium tests cooked OK. (%i)" % (len(filenames), ) Modified: kukit/kss.demo/trunk/kss/demo/interfaces.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/interfaces.py (original) +++ kukit/kss.demo/trunk/kss/demo/interfaces.py Fri Dec 7 12:10:03 2007 @@ -126,13 +126,6 @@ def unregisterSeleniumTestFile(test_filename): """Unregister the given test directory.""" - def cookSeleniumTests(): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ # -- # Event that gets redispatched, for allowing Modified: kukit/kss.demo/trunk/kss/demo/registry.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/registry.py (original) +++ kukit/kss.demo/trunk/kss/demo/registry.py Fri Dec 7 12:10:03 2007 @@ -16,25 +16,12 @@ IRegistered, IUnregistered, ) -import sys, os, re, textwrap -from elementtree import HTMLTreeBuilder -from string import Template -import kss.demo.selenium_utils -# shut the mouth of pyflakes -kss.demo.selenium_utils +from kss.demo.selenium_utils.builder import getSeleniumTestsFromSuite # -- # Registry implementation for use with Zope # -- -def getRootDirOfModule(module_name): - return os.path.dirname(sys.modules[module_name].__file__) - -def getRootDirOfClass(cls): - return getRootDirOfModule(cls.__module__) - -def getRootDirOfInstance(obj): - return getRootDirOfClass(obj.__class__) # Create a mesh of provided interfaces # This is needed, because an utility must have a single interface. @@ -76,6 +63,8 @@ for name, plugin in site.getUtilitiesFor(IKSSDemoResource): for demo in plugin.demos: self.registerDemo(demo) + for test_filename in self._getSeleniumTestsFromPlugin(plugin): + self.registerSeleniumTestFile(test_filename) @adapter(IKSSDemoResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) def registerDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None): @@ -142,13 +131,9 @@ @staticmethod def _getSeleniumTestsFromPlugin(plugin): test_filenames = [] - root_dir = getRootDirOfInstance(plugin) - for selenium_test_directory in plugin.selenium_tests: - tests_root_dir = os.path.join(root_dir, selenium_test_directory.test_directory) - for test_filename in os.listdir(tests_root_dir): - if test_filename.lower().endswith('.html') or \ - test_filename.endswith('.htm'): - test_filenames.append(os.path.join(tests_root_dir, test_filename)) + for selenium_test_suite in plugin.selenium_tests: + filenames = getSeleniumTestsFromSuite(plugin, selenium_test_suite) + test_filenames.extend(filenames) return test_filenames @adapter(IKSSSeleniumTestResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) @@ -178,77 +163,3 @@ del self.selenium_tests[test_filename] except KeyError: raise Exception, 'The selenium test for %s is yet unregistered. Cannot remove.' % (test_filename, ) - - template = Template(textwrap.dedent('''\ - from seleniumtestcase import SeleniumTestCase - import unittest, time - - class seltest_$testname(SeleniumTestCase): - - $tests - - def test_suite(): - return unittest.makeSuite(seltest_$testname) - - if __name__ == "__main__": - unittest.main() - ''')) - - variable_regexp = re.compile('\$\{(?P\w*)\}') - @classmethod - def formatcommand(cls, command, *args): - if not command: - return '' # Change this to raise an exception? - - arguments = [] - for arg in args: - if not arg: - continue - matched = cls.variable_regexp.match(arg) - if matched is None: - arguments.append('"%s"'%arg) - else: - arguments.append("self.getVar('%s')"%matched.group('varname')) - return 'self.%s(%s)' % (command, ', '.join(arguments)) - - def cookSeleniumTests(self): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ - # Try to open the file for writing. - output_dir = getRootDirOfModule('kss.demo.selenium_utils') - output_filename = os.path.join(output_dir, 'seltest_all.py') - try: - f = open(output_filename, 'wb') - except IOError, exc: - raise IOError, ('Cannot open file "%s" for writing. ' - 'Make sure zope process has write access in directory. ' - '["%s"]') \ - % (output_filename, exc) - - htmlparser = HTMLTreeBuilder.TreeBuilder() - tests = [] - for filename in self.selenium_tests: - tree = HTMLTreeBuilder.parse(filename) - root = tree.getroot() - - try: - testname = root.find('.//title').text - except AttributeError: - continue - commands = [] - for row in root.findall('.//tbody/tr'): - commands.append(self.formatcommand(*[td.text for td in row.findall('td')])) - - testfilename = 'seltest_%s.py' % testname - testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' - tests.append(testbody) - - f.write(self.template.substitute(dict( - testname=testname, - tests='\n'.join(tests), - ))) - f.close() Added: kukit/kss.demo/trunk/kss/demo/selenium_utils/builder.py ============================================================================== --- (empty file) +++ kukit/kss.demo/trunk/kss/demo/selenium_utils/builder.py Fri Dec 7 12:10:03 2007 @@ -0,0 +1,113 @@ + +import sys, os, re, textwrap +from elementtree import HTMLTreeBuilder +from string import Template + +# -- +# This is used to build the seltest_all.py file into the same directory. +# -- + +# root directory finding code +def getRootDirOfModule(module_name): + return os.path.dirname(sys.modules[module_name].__file__) + +def getRootDirOfClass(cls): + return getRootDirOfModule(cls.__module__) + +def getRootDirOfInstance(obj): + return getRootDirOfClass(obj.__class__) + +def getSeleniumTestsFromSuite(owner_instance, suite): + """Get absolute filenames of all tests from the suite. + Suite contains the directory that we need to find. + owner_instance is used for the directory finding, + the suite's directory is traversed relative from that. + """ + test_filenames = [] + # The owner instance is only used to traverse the sute directory + # relative from it. + root_dir = getRootDirOfInstance(owner_instance) + tests_root_dir = os.path.join(root_dir, suite.test_directory) + for test_filename in os.listdir(tests_root_dir): + if test_filename.lower().endswith('.html') or \ + test_filename.endswith('.htm'): + test_filenames.append(os.path.join(tests_root_dir, test_filename)) + return test_filenames + +template = Template(textwrap.dedent('''\ + from seleniumtestcase import SeleniumTestCase + import unittest, time + + class seltest_$testname(SeleniumTestCase): + + $tests + + def test_suite(): + return unittest.makeSuite(seltest_$testname) + + if __name__ == "__main__": + unittest.main() + ''')) + +variable_regexp = re.compile('\$\{(?P\w*)\}') + +def formatcommand(command, *args): + if not command: + return '' # Change this to raise an exception? + + arguments = [] + for arg in args: + if not arg: + continue + matched = variable_regexp.match(arg) + if matched is None: + arguments.append('"%s"'%arg) + else: + arguments.append("self.getVar('%s')"%matched.group('varname')) + return 'self.%s(%s)' % (command, ', '.join(arguments)) + + + +def cookSeleniumTests(filenames): + """Cook selenium tests + """ + # Try to open the file for writing. + output_dir = getRootDirOfModule('kss.demo.selenium_utils') + output_filename = os.path.join(output_dir, 'seltest_all.py') + try: + f = open(output_filename, 'wb') + except IOError, exc: + raise IOError, ('Cannot open file "%s" for writing. ' + 'Make sure zope process has write access in directory. ' + '["%s"]') \ + % (output_filename, exc) + + htmlparser = HTMLTreeBuilder.TreeBuilder() + tests = [] + + # Now, we find all filenames that are in the suite passed to us. + testname = 'all' + + for filename in filenames: + tree = HTMLTreeBuilder.parse(filename) + root = tree.getroot() + + try: + testname = root.find('.//title').text + except AttributeError: + continue + commands = [] + for row in root.findall('.//tbody/tr'): + commands.append(formatcommand(*[td.text for td in row.findall('td')])) + + testfilename = 'seltest_%s.py' % testname + testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' + tests.append(testbody) + + # Use the last test's name as filename (???) + # XXX I think we want to change this. + f.write(template.substitute(dict( + testname=testname, + tests='\n'.join(tests), + ))) + f.close() From reebalazs at codespeak.net Fri Dec 7 12:11:11 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 12:11:11 +0100 (CET) Subject: [KSS-checkins] r49501 - kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils Message-ID: <20071207111111.00A36168572@codespeak.net> Author: reebalazs Date: Fri Dec 7 12:11:11 2007 New Revision: 49501 Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py Log: Fix on builder in case no tests are registered Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/selenium_utils/builder.py Fri Dec 7 12:11:11 2007 @@ -85,7 +85,8 @@ htmlparser = HTMLTreeBuilder.TreeBuilder() tests = [] - # Now, we find all filenames that are inthe suite passed to us. + # Now, we find all filenames that are in the suite passed to us. + testname = 'all' for filename in filenames: tree = HTMLTreeBuilder.parse(filename) @@ -103,6 +104,8 @@ testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' tests.append(testbody) + # Use the last test's name as filename (???) + # XXX I think we want to change this. f.write(template.substitute(dict( testname=testname, tests='\n'.join(tests), From reebalazs at codespeak.net Fri Dec 7 13:35:28 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 13:35:28 +0100 (CET) Subject: [KSS-checkins] r49506 - kukit/kss.demo/trunk/kss/demo/browser Message-ID: <20071207123528.C208916856F@codespeak.net> Author: reebalazs Date: Fri Dec 7 13:35:27 2007 New Revision: 49506 Added: kukit/kss.demo/trunk/kss/demo/browser/kss_demo_suite.pt kukit/kss.demo/trunk/kss/demo/browser/setDevMode.html kukit/kss.demo/trunk/kss/demo/browser/setProdMode.html Modified: kukit/kss.demo/trunk/kss/demo/browser/configure.zcml kukit/kss.demo/trunk/kss/demo/browser/kss_demo_index.pt kukit/kss.demo/trunk/kss/demo/browser/registry.py Log: Hook upzelenium to the registry AND: make it accessable from demo index. Modified: kukit/kss.demo/trunk/kss/demo/browser/configure.zcml ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/configure.zcml (original) +++ kukit/kss.demo/trunk/kss/demo/browser/configure.zcml Fri Dec 7 13:35:27 2007 @@ -60,10 +60,24 @@ + + @@ -81,5 +95,29 @@ permission="demo.Manager" /> + + + + + + + + + Modified: kukit/kss.demo/trunk/kss/demo/browser/kss_demo_index.pt ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/kss_demo_index.pt (original) +++ kukit/kss.demo/trunk/kss/demo/browser/kss_demo_index.pt Fri Dec 7 13:35:27 2007 @@ -8,10 +8,20 @@

KSS demos

Kss mode

-

Unit tests

+

Tests

+

+ Zelenium object link must be an absolute path from the domain root, + or a relative path from the demo SimpleContent's parent. +

Core plugin

Added: kukit/kss.demo/trunk/kss/demo/browser/kss_demo_suite.pt ============================================================================== --- (empty file) +++ kukit/kss.demo/trunk/kss/demo/browser/kss_demo_suite.pt Fri Dec 7 13:35:27 2007 @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + +
Test Suite
+

+ Development mode +

+
Title
+

+ Production mode +

+
Title
+ + Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/trunk/kss/demo/browser/registry.py Fri Dec 7 13:35:27 2007 @@ -5,6 +5,7 @@ from zope.component import getUtility from zope.interface import implements from kss.demo.selenium_utils.builder import cookSeleniumTests +import os.path try: from Products.Five import BrowserView BrowserView # make pyflakes happy @@ -55,6 +56,57 @@ group.append(demo) return demo_groups + @staticmethod + def _filename_to_title(filename): + """Automatic conversion of filename to readable title""" + if filename.lower().endswith('.html'): + filename = filename[:-5] + elif filename.lower().endswith('.htm'): + filename = filename[:-4] + words = os.path.basename(filename).split('_') + result = ' '.join([word.capitalize() for word in words]) + return result + + @staticmethod + def _filename_to_href(filename): + """Automatic conversion of filename to publication href""" + return "@@resource?filename=%s" % (filename, ) + + def getSeleniumTests(self): + """Get selenium tests annotated with title and href.""" + return [dict( + href = self._filename_to_href(filename), + title=self._filename_to_title(filename), + ) + for filename in self.selenium_test_filenames] + + @property + def selenium_test_filenames(self): + """A cached representation of all filenames.""" + try: + return self._cooked_selenium_test_filenames + except AttributeError: + registry = getUtility(IKSSDemoRegistry) + self._cooked_selenium_test_filenames = filenames = \ + registry.selenium_tests + return filenames + + def getSeleniumTestResource(self, filename): + """Return the html resource, whose absolute filename is given,""" + # First of all, let's check if this is one of our file. + # (Refuse otherwise - we don't want access to all files on the server.) + if filename not in self.selenium_test_filenames: + raise Exception, "Nonexistent resource" + # Return the file's content. + self.request.response.setHeader('Content-type', 'text/html;charset=utf-8') + return file(filename).read() + + def getZuiteHomePage(self, path): + """Redirects to the Zuite home page, Zuite object is found from path.""" + zuite = self.context.aq_inner.aq_parent.restrictedTraverse(path) + html = "%s?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url()) + return self.request.response.redirect(html) + class KSSDemoRegistryAdminView(BrowserView): """Things that only admin should do""" implements(IBrowserPublisher) Added: kukit/kss.demo/trunk/kss/demo/browser/setDevMode.html ============================================================================== --- (empty file) +++ kukit/kss.demo/trunk/kss/demo/browser/setDevMode.html Fri Dec 7 13:35:27 2007 @@ -0,0 +1,33 @@ + + + +basic_commands + + + + + + + + + + + + + + + + + + + + + + + + + + +
basic_commands
opendemo/@@kss_devel_mode/ui
assertTextPresentKSS mode setup
clickAndWaitbutton_devel
assertTextPresentdevelopment
+ + Added: kukit/kss.demo/trunk/kss/demo/browser/setProdMode.html ============================================================================== --- (empty file) +++ kukit/kss.demo/trunk/kss/demo/browser/setProdMode.html Fri Dec 7 13:35:27 2007 @@ -0,0 +1,33 @@ + + + +basic_commands + + + + + + + + + + + + + + + + + + + + + + + + + + +
basic_commands
open/demo/@@kss_devel_mode/ui
assertTextPresentKSS mode setup
clickAndWaitbutton_prod
assertTextPresentproduction
+ + From reebalazs at codespeak.net Fri Dec 7 13:41:42 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 13:41:42 +0100 (CET) Subject: [KSS-checkins] r49507 - in kukit/kss.core/trunk/kss/core: . plugins/core/demo/selenium_tests Message-ID: <20071207124142.04C22168440@codespeak.net> Author: reebalazs Date: Fri Dec 7 13:41:42 2007 New Revision: 49507 Removed: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setDevMode.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html Modified: kukit/kss.core/trunk/kss/core/configure.zcml Log: Remove zuite support from the core plugin, as this is now done from within kss.demo. Modified: kukit/kss.core/trunk/kss/core/configure.zcml ============================================================================== --- kukit/kss.core/trunk/kss/core/configure.zcml (original) +++ kukit/kss.core/trunk/kss/core/configure.zcml Fri Dec 7 13:41:42 2007 @@ -53,15 +53,6 @@ name="base2-dom-fp.js" /> - - - -basic_commands - - - - - - - - - - - - - - - - - - - - - - - - - - -
basic_commands
opendemo/@@kss_devel_mode/ui
assertTextPresentKSS mode setup
clickAndWaitbutton_devel
assertTextPresentdevelopment
- - Deleted: /kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html ============================================================================== --- /kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Fri Dec 7 13:41:42 2007 +++ (empty file) @@ -1,33 +0,0 @@ - - - -basic_commands - - - - - - - - - - - - - - - - - - - - - - - - - - -
basic_commands
open/demo/@@kss_devel_mode/ui
assertTextPresentKSS mode setup
clickAndWaitbutton_prod
assertTextPresentproduction
- - Deleted: /kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- /kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/suite.html Fri Dec 7 13:41:42 2007 +++ (empty file) @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Test Suite
-

- Development mode -

-
Basic commands
Two selects
Two selects revisited
Forms
Actions
Auto update
Focus
Prevent default on click
Prevent default
Inline edit
Bubbling
Selector parameters
Selectors
More Selectors
Form submit
Error handling
HTML inserts
-

- Production mode -

-
Basic commands
Two selects
Two selects revisited
Forms
Actions
Auto update
Focus
Prevent default on click
Prevent default
Inline edit
Bubbling
Selector parameters
Selectors
More Selectors
Form submit
Error handling
HTML inserts
- - From reebalazs at codespeak.net Fri Dec 7 14:08:55 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 14:08:55 +0100 (CET) Subject: [KSS-checkins] r49509 - kukit/kss.demo/trunk/kss/demo/browser Message-ID: <20071207130855.BB10116855D@codespeak.net> Author: reebalazs Date: Fri Dec 7 14:08:55 2007 New Revision: 49509 Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py Log: Fix correct entry url to zuite Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/trunk/kss/demo/browser/registry.py Fri Dec 7 14:08:55 2007 @@ -104,7 +104,7 @@ def getZuiteHomePage(self, path): """Redirects to the Zuite home page, Zuite object is found from path.""" zuite = self.context.aq_inner.aq_parent.restrictedTraverse(path) - html = "%s?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url()) + html = "%s/core/TestRunner.html?test=%s/suite.html&ResultsUrl=../PostResults" % (zuite.absolute_url(), self.context.absolute_url()) return self.request.response.redirect(html) class KSSDemoRegistryAdminView(BrowserView): From reebalazs at codespeak.net Fri Dec 7 14:19:32 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 14:19:32 +0100 (CET) Subject: [KSS-checkins] r49510 - kukit/kss.demo/trunk/kss/demo/browser Message-ID: <20071207131932.56BDB168564@codespeak.net> Author: reebalazs Date: Fri Dec 7 14:19:31 2007 New Revision: 49510 Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py Log: Fix correct entry url to zuite Modified: kukit/kss.demo/trunk/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/trunk/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/trunk/kss/demo/browser/registry.py Fri Dec 7 14:19:31 2007 @@ -104,7 +104,7 @@ def getZuiteHomePage(self, path): """Redirects to the Zuite home page, Zuite object is found from path.""" zuite = self.context.aq_inner.aq_parent.restrictedTraverse(path) - html = "%s/core/TestRunner.html?test=%s/suite.html&ResultsUrl=../PostResults" % (zuite.absolute_url(), self.context.absolute_url()) + html = "%s/core/TestRunner.html?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url()) return self.request.response.redirect(html) class KSSDemoRegistryAdminView(BrowserView): From reebalazs at codespeak.net Fri Dec 7 15:59:39 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 15:59:39 +0100 (CET) Subject: [KSS-checkins] r49511 - kukit/kukit.js/trunk/kukit Message-ID: <20071207145939.56024168529@codespeak.net> Author: reebalazs Date: Fri Dec 7 15:59:38 2007 New Revision: 49511 Modified: kukit/kukit.js/trunk/kukit/utils.js Log: Change loglevel code to not fail, if run from a console test. Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Fri Dec 7 15:59:38 2007 @@ -96,7 +96,11 @@ ;;; // set default level ;;; this.loglevel = 0; ;;; // read the cookie -;;; var cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; /// (ignore if we run from test) +;;; var cookie; +;;; if (typeof(document.cookie) != 'undefined') { +;;; cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; } ;;; if (cookie) { ;;; // decode it to a numeric level ;;; cookie = cookie.toLowerCase(); From reebalazs at codespeak.net Fri Dec 7 16:01:52 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:01:52 +0100 (CET) Subject: [KSS-checkins] r49512 - kukit/kukit.js/branch/1.2/kukit Message-ID: <20071207150152.7CF38168558@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:01:51 2007 New Revision: 49512 Modified: kukit/kukit.js/branch/1.2/kukit/utils.js Log: Backport of -r49511 from trunk: Change loglevel code to not fail, if run from a console test. Modified: kukit/kukit.js/branch/1.2/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/utils.js (original) +++ kukit/kukit.js/branch/1.2/kukit/utils.js Fri Dec 7 16:01:51 2007 @@ -96,7 +96,11 @@ ;;; // set default level ;;; this.loglevel = 0; ;;; // read the cookie -;;; var cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; /// (ignore if we run from test) +;;; var cookie; +;;; if (typeof(document.cookie) != 'undefined') { +;;; cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; } ;;; if (cookie) { ;;; // decode it to a numeric level ;;; cookie = cookie.toLowerCase(); From reebalazs at codespeak.net Fri Dec 7 16:09:51 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:09:51 +0100 (CET) Subject: [KSS-checkins] r49513 - kukit/kukit.js/branch/1.2/kukit Message-ID: <20071207150951.E3A0A168527@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:09:51 2007 New Revision: 49513 Modified: kukit/kukit.js/branch/1.2/kukit/utils.js Log: Complement the previous testing fix: document mustexist too Modified: kukit/kukit.js/branch/1.2/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/utils.js (original) +++ kukit/kukit.js/branch/1.2/kukit/utils.js Fri Dec 7 16:09:51 2007 @@ -98,7 +98,13 @@ ;;; // read the cookie ;;; /// (ignore if we run from test) ;;; var cookie; -;;; if (typeof(document.cookie) != 'undefined') { +;;; try { +;;; // in test, document would throw ReferenceError +;;; var __dummy = document; +;;; } catch(e) { +;;; var _dummy; +;;; } +;;; if (_dummy && typeof(document.cookie) != 'undefined') { ;;; cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); ;;; } ;;; if (cookie) { From reebalazs at codespeak.net Fri Dec 7 16:12:48 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:12:48 +0100 (CET) Subject: [KSS-checkins] r49514 - kukit/kukit.js/trunk/kukit Message-ID: <20071207151248.36FFA16843C@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:12:47 2007 New Revision: 49514 Modified: kukit/kukit.js/trunk/kukit/utils.js Log: To complement the previous fix, port forward -r49386 from 1.2. Probably not needed here, but it's better to be safe. Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Fri Dec 7 16:12:47 2007 @@ -98,7 +98,13 @@ ;;; // read the cookie ;;; /// (ignore if we run from test) ;;; var cookie; -;;; if (typeof(document.cookie) != 'undefined') { +;;; try { +;;; // in test, document would throw ReferenceError +;;; var __dummy = document; +;;; } catch(e) { +;;; var _dummy; +;;; } +;;; if (_dummy && typeof(document.cookie) != 'undefined') { ;;; cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); ;;; } ;;; if (cookie) { From reebalazs at codespeak.net Fri Dec 7 16:16:15 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:16:15 +0100 (CET) Subject: [KSS-checkins] r49515 - kukit/kukit.js/trunk/tests Message-ID: <20071207151615.0E89016843C@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:16:14 2007 New Revision: 49515 Modified: kukit/kukit.js/trunk/tests/runner.html kukit/kukit.js/trunk/tests/runtests.sh Log: Change resource order that became necessary after the last merge, to run the ecma tests. Modified: kukit/kukit.js/trunk/tests/runner.html ============================================================================== --- kukit/kukit.js/trunk/tests/runner.html (original) +++ kukit/kukit.js/trunk/tests/runner.html Fri Dec 7 16:16:14 2007 @@ -39,18 +39,18 @@ - - Modified: kukit/kukit.js/trunk/tests/runtests.sh ============================================================================== --- kukit/kukit.js/trunk/tests/runtests.sh (original) +++ kukit/kukit.js/trunk/tests/runtests.sh Fri Dec 7 16:16:14 2007 @@ -3,10 +3,10 @@ -f unittestUtilities.js \ -f browserstub.js \ -f ../3rd_party/base2-dom-fp.js \ + -f ../kukit/kukit.js \ -f ../kukit/utils.js \ -f ../kukit/errors.js \ -f ../kukit/oper.js \ - -f ../kukit/kukit.js \ -f ../kukit/tokenizer.js \ -f ../kukit/providerreg.js \ -f ../kukit/resourcedata.js \ From reebalazs at codespeak.net Fri Dec 7 16:18:54 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:18:54 +0100 (CET) Subject: [KSS-checkins] r49516 - kukit/kss.base/trunk/kss/base Message-ID: <20071207151854.5884716843C@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:18:48 2007 New Revision: 49516 Modified: kukit/kss.base/trunk/kss/base/config.py Log: Change resource order that became necessary after last kukit.js merge. Modified: kukit/kss.base/trunk/kss/base/config.py ============================================================================== --- kukit/kss.base/trunk/kss/base/config.py (original) +++ kukit/kss.base/trunk/kss/base/config.py Fri Dec 7 16:18:48 2007 @@ -7,10 +7,10 @@ kukit_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'kukit') # Define the Javascripts by hand to ensure the order -core_js = ['utils.js', +core_js = ['kukit.js', + 'utils.js', 'errors.js', 'oper.js', - 'kukit.js', 'tokenizer.js', 'providerreg.js', 'resourcedata.js', From reebalazs at codespeak.net Fri Dec 7 16:22:18 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:22:18 +0100 (CET) Subject: [KSS-checkins] r49517 - kukit/kss.demo/trunk/kss/demo/docs Message-ID: <20071207152218.091AE16843C@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:22:18 2007 New Revision: 49517 Modified: kukit/kss.demo/trunk/kss/demo/docs/HISTORY.txt Log: Add history for previous fix Modified: kukit/kss.demo/trunk/kss/demo/docs/HISTORY.txt ============================================================================== --- kukit/kss.demo/trunk/kss/demo/docs/HISTORY.txt (original) +++ kukit/kss.demo/trunk/kss/demo/docs/HISTORY.txt Fri Dec 7 16:22:18 2007 @@ -6,6 +6,10 @@ - ... + - Hooked zelenium into the demo index page. + Made zelenium reuse the demo registry. + [ree] + - Moved the core demos to kss.core. [ree] From reebalazs at codespeak.net Fri Dec 7 16:31:43 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:31:43 +0100 (CET) Subject: [KSS-checkins] r49518 - kukit/kss.zope/trunk/kss/zope/browser Message-ID: <20071207153143.86EE1168546@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:31:42 2007 New Revision: 49518 Modified: kukit/kss.zope/trunk/kss/zope/browser/develui.css kukit/kss.zope/trunk/kss/zope/browser/develui.pt kukit/kss.zope/trunk/kss/zope/browser/develview.py Log: Merge up from -r48536:48557 of kss.core trunk, pluginregistry/browser directory Modified: kukit/kss.zope/trunk/kss/zope/browser/develui.css ============================================================================== --- kukit/kss.zope/trunk/kss/zope/browser/develui.css (original) +++ kukit/kss.zope/trunk/kss/zope/browser/develui.css Fri Dec 7 16:31:42 2007 @@ -55,13 +55,13 @@ background-color: #880000; } -a.button, -input[type="submit"] { +a.button, .clickable { width: auto; padding: 0.2em; border: 1px solid #FF8888; color: #CC0000; text-decoration: none; + font-size: 80%; } fieldset { @@ -89,11 +89,22 @@ padding : 1em; } -.red { - color: red; +.production, .error { + color: red; +} + +.production, .development { + font-weight: bold; } -.green { - color: green; +.warning { + color: orange; } +.development, .info { + color: green; +} + +.debug { + color: blue; +} Modified: kukit/kss.zope/trunk/kss/zope/browser/develui.pt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/browser/develui.pt (original) +++ kukit/kss.zope/trunk/kss/zope/browser/develui.pt Fri Dec 7 16:31:42 2007 @@ -54,46 +54,103 @@ + loglevel python: options.get('loglevel', view.getLogLevel()); + referer request/referer|request/HTTP_REFERER|nothing"> -

Kss mode setup

+

KSS mode setup

- Current KSS mode is - developmentproduction. + class="production" tal:condition="not: devel_mode">production mode.

-

+

+ The mode is stored in a cookie that is global to the site. +

+

+ It can be overridden by a local utility (eg. ResourceRegistries, in Plone). +

+ +

If you call @@kss_devel_mode/ison on the current context, - you get True if in development mode, False in in production mode. + you will get True in development mode, False in production mode.

-

- Set KSS mode cookie -

-
- Click the button to toggle mode. -
- -
- - - -
-

The cookie is global to the site and may be overridden by a - local utility (eg. ResourceRegistries, in Plone)

+
+

+ Set KSS mode cookie +

+

+ Click the button to toggle mode. +

+ +
+ + + +
+ +
+
+ +

+ Back to the referer page. +

+ +

KSS log level setup

+ +

+ Current KSS log level is + DEBUG. +

+

+ The log level is stored in a cookie that is global to the site. +

+ +

+ Logging is effective only in development mode. +

+ +
+
+

+ Set KSS log level +

+

+ Click the button to set log level. +

+ + +
+ + + +
+
+ +
+ +
-

Back

+

+ Back to the referer page. +

Modified: kukit/kss.zope/trunk/kss/zope/browser/develview.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/browser/develview.py (original) +++ kukit/kss.zope/trunk/kss/zope/browser/develview.py Fri Dec 7 16:31:42 2007 @@ -11,7 +11,8 @@ from zope.traversing.interfaces import ITraverser from zope.publisher.interfaces import NotFound -COOKIE_NAME = '__kss_devel' +COOKIE_DEVELMODE = '__kss_devel' +COOKIE_LOGLEVEL = '__kss_loglevel' class DevelView(BrowserView): implements(IDevelView) @@ -37,7 +38,7 @@ return self, ('ui', ) # -- - # Accessable methods + # Methods for handling development/production mode # -- def ison(self): @@ -51,7 +52,7 @@ select development mode without the cookie ''' - ison = COOKIE_NAME in self.request.cookies + ison = COOKIE_DEVELMODE in self.request.cookies if not ison: # Check from javascript tool @@ -76,26 +77,51 @@ def set(self): 'Sets development mode cookie' - self.request.response.setCookie(COOKIE_NAME, '1', path='/') + self.request.response.setCookie(COOKIE_DEVELMODE, '1', path='/') def unset(self): 'Unsets development mode cookie' - self.request.response.expireCookie(COOKIE_NAME, path='/') + self.request.response.expireCookie(COOKIE_DEVELMODE, path='/') + + # -- + # Methods for handling loglevel + # -- + + def getLogLevel(self, REQUEST=None): + 'Gets current log level' + loglevel = self.request.cookies.get(COOKIE_LOGLEVEL, 'DEBUG').upper() + return loglevel + + def setLogLevel(self, loglevel): + 'Sets loglevel cookie' + self.request.response.setCookie(COOKIE_LOGLEVEL, loglevel, path='/') + + # -- + # User interface + # -- _ui = ViewPageTemplateFile('develui.pt', content_type='text/html;charset=utf-8') def ui(self): 'User interface for interactive switching' options = {} + # Handle development/production mode if 'devel' in self.request.form: self.set() # setting it also to have immediate effect in the page options['devel_mode'] = True if 'prod' in self.request.form: self.unset() - if COOKIE_NAME in self.request.cookies: + if COOKIE_DEVELMODE in self.request.cookies: # setting it also to have immediate effect in the page options['devel_mode'] = False + # Handle loglevel + if 'loglevel' in self.request.form: + loglevel = self.request.form['loglevel'] + self.setLogLevel(loglevel) + # setting it also to have immediate effect in the page + options['loglevel'] = loglevel + # Return the rendered template return self._ui(**options) def ui_js(self): From reebalazs at codespeak.net Fri Dec 7 16:33:39 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:33:39 +0100 (CET) Subject: [KSS-checkins] r49519 - kukit/kukit.js/trunk/kukit Message-ID: <20071207153339.ACDDE168547@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:33:38 2007 New Revision: 49519 Modified: kukit/kukit.js/trunk/kukit/utils.js Log: Correct typo Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Fri Dec 7 16:33:38 2007 @@ -100,7 +100,7 @@ ;;; var cookie; ;;; try { ;;; // in test, document would throw ReferenceError -;;; var __dummy = document; +;;; var _dummy = document; ;;; } catch(e) { ;;; var _dummy; ;;; } From reebalazs at codespeak.net Fri Dec 7 16:34:50 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 16:34:50 +0100 (CET) Subject: [KSS-checkins] r49520 - kukit/kukit.js/branch/1.2/kukit Message-ID: <20071207153450.EA87D168547@codespeak.net> Author: reebalazs Date: Fri Dec 7 16:34:50 2007 New Revision: 49520 Modified: kukit/kukit.js/branch/1.2/kukit/utils.js Log: Correct typo Modified: kukit/kukit.js/branch/1.2/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/1.2/kukit/utils.js (original) +++ kukit/kukit.js/branch/1.2/kukit/utils.js Fri Dec 7 16:34:50 2007 @@ -100,7 +100,7 @@ ;;; var cookie; ;;; try { ;;; // in test, document would throw ReferenceError -;;; var __dummy = document; +;;; var _dummy = document; ;;; } catch(e) { ;;; var _dummy; ;;; } From reebalazs at codespeak.net Fri Dec 7 17:13:31 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 17:13:31 +0100 (CET) Subject: [KSS-checkins] r49521 - kukit/kss.demo/trunk/kss/demo Message-ID: <20071207161331.CD8CF168519@codespeak.net> Author: reebalazs Date: Fri Dec 7 17:13:30 2007 New Revision: 49521 Modified: kukit/kss.demo/trunk/kss/demo/meta.zcml Log: Insert a marker that 1.2 version plugins that want to be kss.base compatible can use to set up their utilities Modified: kukit/kss.demo/trunk/kss/demo/meta.zcml ============================================================================== --- kukit/kss.demo/trunk/kss/demo/meta.zcml (original) +++ kukit/kss.demo/trunk/kss/demo/meta.zcml Fri Dec 7 17:13:30 2007 @@ -1,6 +1,11 @@ + + + From reebalazs at codespeak.net Fri Dec 7 17:16:09 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 17:16:09 +0100 (CET) Subject: [KSS-checkins] r49522 - in kukit/kss.core/trunk/kss/core/plugins/core/demo: . binderids Message-ID: <20071207161609.A661D168519@codespeak.net> Author: reebalazs Date: Fri Dec 7 17:16:07 2007 New Revision: 49522 Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/config.py kukit/kss.core/trunk/kss/core/plugins/core/demo/config.py Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml Log: Allow the core plugin demos to be used both from kss.core and kss.zope transition Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/config.py ============================================================================== --- (empty file) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/config.py Fri Dec 7 17:16:07 2007 @@ -0,0 +1,22 @@ + +from kss.base.plugin import Plugin +from kss.demo.resource import ( + KSSDemo, + KSSSeleniumTestDirectory, + ) + +class CoreDemos(Plugin): + + zope_demos = ( + # List your demos here. + # (Second parameter can be a subcategory within the demo if needed.) + KSSDemo('', 'Core syntax', 'binderids.html', 'Binder ids'), + + ) + + # directories are relative from the location of this .py file + zope_selenium_testsuites = ( + # if you only have one test directory, you + # need not change anything here. + KSSSeleniumTestDirectory('selenium_tests'), + ) Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml Fri Dec 7 17:16:07 2007 @@ -1,6 +1,7 @@ @@ -9,12 +10,14 @@ --> + + name="core_demo_for_binderids" + factory=".zopeconfig.KSSDemos" + provides="kss.demo.interfaces.IKSSDemoResource" + permission="zope.Public" + /> + @@ -20,12 +21,14 @@ --> - + + + Author: reebalazs Date: Fri Dec 7 17:20:00 2007 New Revision: 49523 Removed: kukit/kss.zope/trunk/kss/zope/plugins/core/demo/ Modified: kukit/kss.zope/trunk/kss/zope/plugins/core/ (props changed) Log: Make core demos linked directly from kss.core, so that we can test the same things. From reebalazs at codespeak.net Fri Dec 7 17:20:21 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 17:20:21 +0100 (CET) Subject: [KSS-checkins] r49524 - kukit/kss.zope/trunk/kss/zope/plugins/core Message-ID: <20071207162021.77A6F168511@codespeak.net> Author: reebalazs Date: Fri Dec 7 17:20:21 2007 New Revision: 49524 Added: kukit/kss.zope/trunk/kss/zope/plugins/core/EXTERNALS.TXT Log: Make core demos linked directly from kss.core, so that we can test the same things. Added: kukit/kss.zope/trunk/kss/zope/plugins/core/EXTERNALS.TXT ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/plugins/core/EXTERNALS.TXT Fri Dec 7 17:20:21 2007 @@ -0,0 +1,8 @@ +# +# results of svn propget svn:externals +# http://codespeak.net/svn/kukit/kss.core/trunk +# +# You can update your working dir by: +# svn propset svn:externals -F EXTERNALS.TXT . +# +demo https://codespeak.net/svn/kukit/kss.core/trunk/kss/core/plugins/core/demo From reebalazs at codespeak.net Fri Dec 7 17:26:13 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 17:26:13 +0100 (CET) Subject: [KSS-checkins] r49525 - in kukit/kss.core/trunk/kss/core/plugins/core/demo: . binderids Message-ID: <20071207162613.CAA05168511@codespeak.net> Author: reebalazs Date: Fri Dec 7 17:26:13 2007 New Revision: 49525 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml Log: Allow the core plugin demos to be used both from kss.core and kss.zope transition (Fix up) Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/configure.zcml Fri Dec 7 17:26:13 2007 @@ -11,12 +11,12 @@ - + Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/configure.zcml Fri Dec 7 17:26:13 2007 @@ -21,7 +21,7 @@ --> - + Author: reebalazs Date: Fri Dec 7 18:47:26 2007 New Revision: 49529 Added: kukit/buildout/kss.zope/extraproducts/ (props changed) kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT kukit/buildout/kss.zope/extraproducts/__init__.py Modified: kukit/buildout/kss.zope/buildout.cfg Log: Add Zelenium to config Modified: kukit/buildout/kss.zope/buildout.cfg ============================================================================== --- kukit/buildout/kss.zope/buildout.cfg (original) +++ kukit/buildout/kss.zope/buildout.cfg Fri Dec 7 18:47:26 2007 @@ -24,6 +24,7 @@ products = ${buildout:directory}/products + ${buildout:directory}/extraproducts # ${clouseau:location} # ${docfindertab:location} Added: kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT ============================================================================== --- (empty file) +++ kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT Fri Dec 7 18:47:26 2007 @@ -0,0 +1,8 @@ +# +# results of svn propget svn:externals +# http://codespeak.net/svn/kukit/kss.core/trunk +# +# You can update your working dir by: +# svn propset svn:externals -F EXTERNALS.TXT . +# +Zelenium svn://svn.zope.org/repos/main/Zelenium/branches/gotcha-selenium-0.8.1 Added: kukit/buildout/kss.zope/extraproducts/__init__.py ============================================================================== --- (empty file) +++ kukit/buildout/kss.zope/extraproducts/__init__.py Fri Dec 7 18:47:26 2007 @@ -0,0 +1,6 @@ +# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) From reebalazs at codespeak.net Fri Dec 7 19:10:53 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 19:10:53 +0100 (CET) Subject: [KSS-checkins] r49530 - in kukit/kss.demo/branch/kss-zope-transition/kss/demo: . browser Message-ID: <20071207181053.D37511684E7@codespeak.net> Author: reebalazs Date: Fri Dec 7 19:10:53 2007 New Revision: 49530 Added: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/kss_demo_suite.pt - copied unchanged from r49525, kukit/kss.demo/trunk/kss/demo/browser/kss_demo_suite.pt kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/setDevMode.html - copied unchanged from r49525, kukit/kss.demo/trunk/kss/demo/browser/setDevMode.html kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/setProdMode.html - copied unchanged from r49525, kukit/kss.demo/trunk/kss/demo/browser/setProdMode.html Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/body_macros.pt kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure-z3.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/demo.css kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/kss_demo_index.pt kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py Log: Merge up -r48516:48557 from trunk of kss.demo. Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/body_macros.pt ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/body_macros.pt (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/body_macros.pt Fri Dec 7 19:10:53 2007 @@ -19,12 +19,12 @@

- Kss is in - development - production + KSS is in + development + production mode. - Setup + Setup

Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure-z3.zcml ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure-z3.zcml (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure-z3.zcml Fri Dec 7 19:10:53 2007 @@ -8,31 +8,16 @@ Define resources for the demo central --> - - - - - - - - - + for="kss.demo.interfaces.ISimpleContent" + template="kss_demo_index.pt" + name="index.html" + permission="zope.View" + menu="zmi_views" + title="View demos" + /> - + + @@ -81,5 +80,29 @@ permission="demo.Manager" /> + + + + + + + + +
Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml Fri Dec 7 19:10:53 2007 @@ -42,10 +42,24 @@ + + @@ -63,5 +77,29 @@ permission="demo.Manager" /> + + + + + + + + +
Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/demo.css ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/demo.css (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/demo.css Fri Dec 7 19:10:53 2007 @@ -14,7 +14,7 @@ font-size: 80%; } -#global-links ul { +#global-links ul, #log-reset { display: table-row; } @@ -22,7 +22,7 @@ display: table-cell; } -#global-links a { +#global-links a, #log-reset a { display: block; padding: 0.25em; margin: 0.25em; @@ -88,3 +88,13 @@ .container { padding : 1em; } + +.log { + margin: 0; + padding: 0.4em; + background: #CCC; + color: gray; + font-style: italic; +} + + Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/kss_demo_index.pt ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/kss_demo_index.pt (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/kss_demo_index.pt Fri Dec 7 19:10:53 2007 @@ -8,10 +8,20 @@

KSS demos

Kss mode

-

Unit tests

+

Tests

+

+ Zelenium object link must be an absolute path from the domain root, + or a relative path from the demo SimpleContent's parent. +

Core plugin

Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py Fri Dec 7 19:10:53 2007 @@ -5,6 +5,7 @@ from zope.component import getUtility from zope.interface import implements from kss.demo.selenium_utils.builder import getSeleniumTestsFromSuite, cookSeleniumTests +import os.path try: from Products.Five import BrowserView BrowserView # make pyflakes happy @@ -55,6 +56,60 @@ group.append(demo) return demo_groups + @staticmethod + def _filename_to_title(filename): + """Automatic conversion of filename to readable title""" + if filename.lower().endswith('.html'): + filename = filename[:-5] + elif filename.lower().endswith('.htm'): + filename = filename[:-4] + words = os.path.basename(filename).split('_') + result = ' '.join([word.capitalize() for word in words]) + return result + + @staticmethod + def _filename_to_href(filename): + """Automatic conversion of filename to publication href""" + return "@@resource?filename=%s" % (filename, ) + + def getSeleniumTests(self): + """Get selenium tests annotated with title and href.""" + return [dict( + href = self._filename_to_href(filename), + title=self._filename_to_title(filename), + ) + for filename in self.selenium_test_filenames] + + @property + def selenium_test_filenames(self): + """A cached representation of all filenames.""" + try: + return self._cooked_selenium_test_filenames + except AttributeError: + registry = getUtility(IKSSPluginRegistry) + suites = registry.zope_selenium_testsuites() + # Extract filenames from all suites + filenames = [] + for owner_instance, suite in suites: + filenames.extend(getSeleniumTestsFromSuite(owner_instance, suite)) + return filenames + + def getSeleniumTestResource(self, filename): + """Return the html resource, whose absolute filename is given,""" + # First of all, let's check if this is one of our file. + # (Refuse otherwise - we don't want access to all files on the server.) + if filename not in self.selenium_test_filenames: + raise Exception, "Nonexistent resource" + # Return the file's content. + self.request.response.setHeader('Content-type', 'text/html;charset=utf-8') + return file(filename).read() + + def getZuiteHomePage(self, path): + """Redirects to the Zuite home page, Zuite object is found from path.""" + zuite = self.context.aq_inner.aq_parent.restrictedTraverse(path) + html = "%s/core/TestRunner.html?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url()) + return self.request.response.redirect(html) + class KSSDemoRegistryAdminView(BrowserView): """Things that only admin should do""" implements(IBrowserPublisher) @@ -87,7 +142,7 @@ """Cook selenium tests The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory + into the file seltest_all.py in the directory of kss.demo.selenium_utils . """ registry = getUtility(IKSSPluginRegistry) Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/interfaces.py Fri Dec 7 19:10:53 2007 @@ -1,7 +1,6 @@ from zope.interface import Interface from zope.schema import ( TextLine, - List, ) class ISimpleContent(Interface): From reebalazs at codespeak.net Fri Dec 7 19:17:33 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 7 Dec 2007 19:17:33 +0100 (CET) Subject: [KSS-checkins] r49531 - kukit/kss.demo/branch/kss-zope-transition/docs Message-ID: <20071207181733.9546016851D@codespeak.net> Author: reebalazs Date: Fri Dec 7 19:17:31 2007 New Revision: 49531 Modified: kukit/kss.demo/branch/kss-zope-transition/docs/HISTORY.txt Log: Add history from merge-up Modified: kukit/kss.demo/branch/kss-zope-transition/docs/HISTORY.txt ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/docs/HISTORY.txt (original) +++ kukit/kss.demo/branch/kss-zope-transition/docs/HISTORY.txt Fri Dec 7 19:17:31 2007 @@ -6,6 +6,10 @@ - ... + - Hooked zelenium into the demo index page. + Made zelenium reuse the demo registry. + [ree] + - Moved the core demos to kss.core. [ree] From gotcha at codespeak.net Fri Dec 7 23:46:42 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 23:46:42 +0100 (CET) Subject: [KSS-checkins] r49543 - kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser Message-ID: <20071207224642.9B5381684E7@codespeak.net> Author: gotcha Date: Fri Dec 7 23:46:41 2007 New Revision: 49543 Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Log: use kssproject.org color scheme Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Fri Dec 7 23:46:41 2007 @@ -1,6 +1,15 @@ body { font-family: Verdana, Arial, sans-serif; font-size: 11pt; + background-color: #FAFAED; +} + +h1, h2, h3, h4, h5, a { + color: #FF4916; +} + +h1, h2, h3, h4, h5 { + border-bottom: 1px solid #A8A890; } h3 { @@ -26,21 +35,22 @@ display: block; padding: 0.25em; margin: 0.25em; - border: 1px solid #FF8888; - color: #CC0000; + border: 1px solid #FF4916; + color: #FF4916; text-decoration: none; } #global-links a:hover { - border-color: #FF0000; - background-color: #FFCCCC; + border-color: #FF4916; + background-color: #FF4916; + color: white; } #target { padding: 1em; margin: 0.5em 0; - border: 1px solid #CCCCCC; - background-color: #EEEEEE; + border: 1px solid #A8A890; + background-color: #D8D8C0; } .cursorPointer { @@ -58,14 +68,17 @@ a.button, .clickable { width: auto; padding: 0.2em; - border: 1px solid #FF8888; - color: #CC0000; + border: 1px solid #FF4916; + color: #FF4916; text-decoration: none; font-size: 80%; + background-color: #FAFAED; } fieldset { margin: 0.5em 0; + border: 2px solid #A8A890; + background-color: white; } fieldset div { @@ -74,7 +87,7 @@ .help { font-size: 80%; - color: #AAAAAA; + color: #A8A890; } .help pre { @@ -92,8 +105,8 @@ .log { margin: 0; padding: 0.4em; - background: #CCC; - color: gray; + background: #A8A890; + color: white; font-style: italic; } From gotcha at codespeak.net Fri Dec 7 23:47:02 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Fri, 7 Dec 2007 23:47:02 +0100 (CET) Subject: [KSS-checkins] r49544 - kukit/kss.demo/branch/finish-closures/kss/demo/browser Message-ID: <20071207224702.CB1561684E9@codespeak.net> Author: gotcha Date: Fri Dec 7 23:47:02 2007 New Revision: 49544 Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt Log: fix broken log macro Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/body_macros.pt Fri Dec 7 23:47:02 2007 @@ -34,7 +34,7 @@

Log

Reset

-
+
From gotcha at codespeak.net Sat Dec 8 09:26:02 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 09:26:02 +0100 (CET) Subject: [KSS-checkins] r49546 - kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser Message-ID: <20071208082602.57C25168527@codespeak.net> Author: gotcha Date: Sat Dec 8 09:25:58 2007 New Revision: 49546 Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Log: cosmetics Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Sat Dec 8 09:25:58 2007 @@ -2,6 +2,9 @@ font-family: Verdana, Arial, sans-serif; font-size: 11pt; background-color: #FAFAED; + border: 1px solid #A8A890; + padding: 1em; + margin: 3em; } h1, h2, h3, h4, h5, a { @@ -12,6 +15,14 @@ border-bottom: 1px solid #A8A890; } +h1 { + font-size: 130%; +} + +h2 { + font-size: 120%; +} + h3 { font-size: 110%; margin-top: 0.5em; @@ -57,12 +68,12 @@ cursor: pointer; } -.click { - color: #880000; +code, .click { + color: #FF4916; } radio.click { - background-color: #880000; + background-color: #FF4916; } a.button, .clickable { @@ -90,10 +101,10 @@ color: #A8A890; } -.help pre { +pre { color: black; - border: 1px solid #CCCCCC; - background-color: #EEEEEE; + border: 1px solid #A8A890; + background-color: #D8D8C0; padding: 0.5em; margin: 0.25em; } From gotcha at codespeak.net Sat Dec 8 14:12:08 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 14:12:08 +0100 (CET) Subject: [KSS-checkins] r49547 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071208131208.7769416854E@codespeak.net> Author: gotcha Date: Sat Dec 8 14:12:05 2007 New Revision: 49547 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Log: try other way of expressing prototypes Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sat Dec 8 14:12:05 2007 @@ -28,7 +28,9 @@ this.commands = new Array(); }; -cp.CommandProcessor.prototype.parseCommands = +CommandProcessor = cp.CommandProcessor.prototype; + +CommandProcessor.parseCommands = function(commands, transport) { ;;;kukit.log('Parsing commands.'); ;;;kukit.logDebug('Number of commands : ' + commands.length + '.'); @@ -48,7 +50,7 @@ } }; -cp.CommandProcessor.prototype.parseCommand = +CommandProcessor.parseCommand = function(command, transport) { var selector = ""; var params = {}; @@ -106,11 +108,11 @@ this.addCommand(command); }; -cp.CommandProcessor.prototype.addCommand = function(command) { +CommandProcessor.addCommand = function(command) { this.commands[this.commands.length] = command; }; -cp.CommandProcessor.prototype.executeCommands = function(oper) { +CommandProcessor.executeCommands = function(oper) { kukit.engine.beginSetupEventsCollection(); // node, eventRule, binder are given on oper, in case // the command was called up from an event From gotcha at codespeak.net Sat Dec 8 14:44:24 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 14:44:24 +0100 (CET) Subject: [KSS-checkins] r49548 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071208134424.E540916854C@codespeak.net> Author: gotcha Date: Sat Dec 8 14:44:22 2007 New Revision: 49548 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Log: I suppose 'var' was really needed Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sat Dec 8 14:44:22 2007 @@ -28,7 +28,7 @@ this.commands = new Array(); }; -CommandProcessor = cp.CommandProcessor.prototype; +var CommandProcessor = cp.CommandProcessor.prototype; CommandProcessor.parseCommands = function(commands, transport) { From gotcha at codespeak.net Sat Dec 8 14:47:14 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 14:47:14 +0100 (CET) Subject: [KSS-checkins] r49549 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071208134714.DAA2416854F@codespeak.net> Author: gotcha Date: Sat Dec 8 14:47:14 2007 New Revision: 49549 Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js Log: fixture Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/oper.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/oper.js Sat Dec 8 14:47:14 2007 @@ -17,9 +17,9 @@ * 02111-1307, USA. */ +kukit.op = new function() { /// MODULE START - -kukit.op = {}; +var op = this; /* * class Oper @@ -49,7 +49,7 @@ * * browserevent: the original browser event. */ -kukit.op.Oper = function (dict) { +op.Oper = function (dict) { this.node = null; this.parms = {}; this.eventRule = null; @@ -61,18 +61,20 @@ this.unrestrictedUpdate(dict); }; -kukit.op.Oper.prototype.clone = function(dict, restricted) { +var Oper = op.Oper.prototype; + +Oper.clone = function(dict, restricted) { var newoper = new kukit.op.Oper(this); newoper.unrestrictedUpdate(dict, restricted); return newoper; }; -kukit.op.Oper.prototype.update = function(dict) { +Oper.update = function(dict) { // restricted attrs must not be changed on existing oper. this.unrestrictedUpdate(dict, true); }; -kukit.op.Oper.prototype.unrestrictedUpdate = function(dict, restricted) { +Oper.unrestrictedUpdate = function(dict, restricted) { if (typeof(dict) == 'undefined') { return; } @@ -99,7 +101,7 @@ } }; -kukit.op.Oper.prototype.logDebug = function() { +Oper.logDebug = function() { ;;; var result = []; ;;; for (var key in this){ ;;; if (key == 'parms') { @@ -115,7 +117,7 @@ ;;; kukit.logDebug('Oper values: ' + result.join(', ')); }; -kukit.op.Oper.prototype.executeClientAction = function(name) { +Oper.executeClientAction = function(name) { // Check kss action parms var nodes = null; // XXX TODO this should be refactored with parms constraint checking @@ -166,7 +168,7 @@ } }; -kukit.op.Oper.prototype.executeDefaultAction = function(name, optional) { +Oper.executeDefaultAction = function(name, optional) { // Check kss action parms ;;; for (key in this.kssParms) { ;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; @@ -203,7 +205,7 @@ return success; }; -kukit.op.Oper.prototype.executeServerAction = function(name) { +Oper.executeServerAction = function(name) { ;;; for (key in this.kssParms) { ;;; if (key == 'kssUrl') { ;;; // Value will be evaluated. @@ -222,17 +224,17 @@ /* Helpers the serve binding */ -kukit.op.Oper.prototype.getEventName = function () { +Oper.getEventName = function () { // Gets event name return this.eventRule.kssSelector.name; }; -kukit.op.Oper.prototype.getEventNamespace = function () { +Oper.getEventNamespace = function () { // Gets event name return this.eventRule.kssSelector.namespace; }; -kukit.op.Oper.prototype.hasExecuteActions = function () { +Oper.hasExecuteActions = function () { // Decide if there are any actions (or a default action) // to execute. This can speed up execution if in case // we have nothing to do, there is no reason to bind @@ -254,7 +256,7 @@ return false; }; -kukit.op.Oper.prototype.makeExecuteActionsHook = function (filter) { +Oper.makeExecuteActionsHook = function (filter) { // Factory that creates the function that executes the actions. // The function may take a dict that is updated on the oper // If filter is specified, it will we called with a function and @@ -286,7 +288,7 @@ /* Utility for parameter checking */ -kukit.op.Oper.prototype.evaluateParameters = +Oper.evaluateParameters = function(mandatory, defaults, errname, allow_excess) { // Checks if mandatory params are supplied and there are no excess params // also fill up default values @@ -327,7 +329,7 @@ this.parms = newParameters; }; -kukit.op.Oper.prototype.completeParms = +Oper.completeParms = function(mandatory, defaults, errname, allow_excess) { ;;; var msg = 'Deprecated [Oper.completeParms],'; ;;; msg += 'use [Oper.evaluateParameters] instead !'; @@ -335,27 +337,27 @@ this.evaluateParameters(mandatory, defaults, errname, allow_excess); }; -kukit.op.Oper.prototype.evalBool = function(key, errname) { +Oper.evalBool = function(key, errname) { var value = this.parms[key]; ;;; kukit.E = 'for key [' + key + '] in [' + errname + '].'; this.parms[key] = kukit.ut.evalBool(value, kukit.E); }; -kukit.op.Oper.prototype.evalInt = function(key, errname) { +Oper.evalInt = function(key, errname) { var value = this.parms[key]; ;;; kukit.E = 'for key [' + key + '] in ['; ;;; kukit.E += errname || this.componentName + '].'; this.parms[key] = kukit.ut.evalInt(value, kukit.E); }; -kukit.op.Oper.prototype.evalList = function(key, errname) { +Oper.evalList = function(key, errname) { var value = this.parms[key]; ;;; kukit.E = 'for key [' + key + '] in ['; ;;; kukit.E += errname || this.componentName + '].'; this.parms[key] = kukit.ut.evalList(value, kukit.E); }; -;;; kukit.op.Oper.prototype.debugInformation = function() { +;;; Oper.debugInformation = function() { ;;; if (this.eventRule) { ;;; var eventRule = this.eventRule; ;;; var node = this.node; @@ -370,3 +372,5 @@ ;;; } ;;; return ''; ;;; }; + +}(); /// MODULE END From gotcha at codespeak.net Sat Dec 8 14:47:59 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 14:47:59 +0100 (CET) Subject: [KSS-checkins] r49550 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071208134759.C81CB16854F@codespeak.net> Author: gotcha Date: Sat Dec 8 14:47:59 2007 New Revision: 49550 Added: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Log: status Added: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- (empty file) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sat Dec 8 14:47:59 2007 @@ -0,0 +1,11 @@ +file where fixtures are missing + +kssparser.js +plugin.js +providerreg.js +requestmanager.js +resourcedata.js +selectorreg.js +serveraction.js +tokenizer.js +utils.js move to kukit th names that are defined in kukit namespaces. From gotcha at codespeak.net Sat Dec 8 16:27:22 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 16:27:22 +0100 (CET) Subject: [KSS-checkins] r49560 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction Message-ID: <20071208152722.6A2E416853D@codespeak.net> Author: gotcha Date: Sat Dec 8 16:27:20 2007 New Revision: 49560 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.kss Log: replace deprecated executeCommand Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/parameterfunction/forms.kss Sat Dec 8 16:27:20 2007 @@ -1,56 +1,48 @@ #text:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(); } #text-by-name:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(text-by-name); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(text-by-name); } #text-by-kssname:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(kssAttr(key1, true)); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(kssAttr(key1, true)); } #textarea:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(); } #textarea-by-name:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar("textarea-by-name"); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar("textarea-by-name"); } #radio1:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(); } #radio2:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(); } #radio-by-name:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(radio-by-name); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(radio-by-name); } #fullform-simple:click { @@ -79,10 +71,9 @@ } #single-select:click { - action-client: executeCommand; - executeCommand-name: replaceInnerHTML; - executeCommand-selector: "#target"; - executeCommand-html: currentFormVar(single-select); + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: "#target"; + replaceInnerHTML-html: currentFormVar(single-select); } #multiple-select:click { From gotcha at codespeak.net Sat Dec 8 16:27:50 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 16:27:50 +0100 (CET) Subject: [KSS-checkins] r49561 - kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser Message-ID: <20071208152750.99125168546@codespeak.net> Author: gotcha Date: Sat Dec 8 16:27:50 2007 New Revision: 49561 Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Log: some more cosmetics Modified: kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css (original) +++ kukit/kss.core/branch/finish-closures/kss/core/pluginregistry/browser/develui.css Sat Dec 8 16:27:50 2007 @@ -1,3 +1,7 @@ +html { + background-color: white; +} + body { font-family: Verdana, Arial, sans-serif; font-size: 11pt; From gotcha at codespeak.net Sat Dec 8 16:28:21 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 16:28:21 +0100 (CET) Subject: [KSS-checkins] r49562 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071208152821.E0C7D16853D@codespeak.net> Author: gotcha Date: Sat Dec 8 16:28:21 2007 New Revision: 49562 Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Log: fixture Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Sat Dec 8 16:28:21 2007 @@ -17,7 +17,9 @@ * 02111-1307, USA. */ -kukit.pr = {}; +kukit.pr = new function() { /// MODULE START + +var pr = this; /* * class ValueProviderRegistry @@ -25,11 +27,13 @@ * The parameter providers need to be registered here. */ -kukit.pr.ValueProviderRegistry = function () { +pr.ValueProviderRegistry = function () { this.content = {}; }; -kukit.pr.ValueProviderRegistry.prototype.register = function(name, func) { +var ValueProviderRegistry = pr.ValueProviderRegistry.prototype; + +ValueProviderRegistry.register = function(name, func) { if (typeof(func) == 'undefined') { ;;; kukit.E = 'func argument is mandatory when registering a parameter' ;;; kukit.E += ' provider [ValueProviderRegistry.register].'; @@ -45,12 +49,12 @@ this.content[name] = func; }; -kukit.pr.ValueProviderRegistry.prototype.exists = function(name) { +ValueProviderRegistry.exists = function(name) { var entry = this.content[name]; return (typeof(entry) != 'undefined'); }; -kukit.pr.ValueProviderRegistry.prototype.get = function(name) { +ValueProviderRegistry.get = function(name) { var func = this.content[name]; if (! func) { // not found @@ -65,8 +69,22 @@ return func; }; -kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry(); +pr.IdentityPP = function() {}; +pr.IdentityPP.prototype = { + check: function(args) { + // check does not need to be used here actually. +;;; if (args.length != 1) { +;;; throw new Error('internal error, IdentityPP needs 1 argument'); +;;; } + }, + eval: function(args, node) { + return args[0]; + } +}; + +}(); /// MODULE END +kukit.dummy = new function() { /// MODULE START /* * Register the core parameter providers * @@ -90,36 +108,20 @@ * this provider expects a single parameter, the string. */ -kukit.pr.IdentityPP = function() {}; -kukit.pr.IdentityPP.prototype = { - check: function(args) { - // check does not need to be used here actually. -;;; if (args.length != 1) { -;;; throw new Error('internal error, IdentityPP needs 1 argument'); -;;; } - }, - eval: function(args, node) { - return args[0]; - } -}; -kukit.pprovidersGlobalRegistry.register('', kukit.pr.IdentityPP); - -kukit.pr.FormVarPP = function() {}; -kukit.pr.FormVarPP.prototype = { +var FormVarPP = function() {}; +FormVarPP.prototype = { check: function(args) { ;;; if (args.length != 2) { ;;; throw new Error('formVar method needs 2 arguments [formname, varname]'); ;;; } }, - eval: function(args, node) { - return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), - args[1]); + eval:function(args, node) { + return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), args[1]); } }; -kukit.pprovidersGlobalRegistry.register('formVar', kukit.pr.FormVarPP); -kukit.pr.CurrentFormVarPP = function() {}; -kukit.pr.CurrentFormVarPP.prototype = { +var CurrentFormVarPP = function() {}; +CurrentFormVarPP.prototype = { check: function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]'); @@ -135,11 +137,9 @@ } } }; -kukit.pprovidersGlobalRegistry.register('currentFormVar', - kukit.pr.CurrentFormVarPP); -kukit.pr.CurrentFormVarFromKssAttrPP = function() {}; -kukit.pr.CurrentFormVarFromKssAttrPP.prototype = { +var CurrentFormVarFromKssAttrPP = function() {}; +CurrentFormVarFromKssAttrPP.prototype = { check: function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument'; @@ -162,13 +162,11 @@ formvarname); } }; -kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr', - kukit.pr.CurrentFormVarFromKssAttrPP); /* BBB. To be deprecated at 2007-08-15 */ -kukit.pr.FormPP = function() {}; -kukit.pr.FormPP.prototype = { +var FormPP = function() {}; +FormPP.prototype = { check: function(args) { ;;; if (args.length != 1) { ;;; throw new Error('form method needs 1 arguments [formname]'); @@ -182,11 +180,10 @@ new kukit.ut.DictCollector()); } }; -kukit.pprovidersGlobalRegistry.register('form', kukit.pr.FormPP); /* BBB. To be deprecated at 2007-08-15 */ -kukit.pr.CurrentFormPP = function() {}; -kukit.pr.CurrentFormPP.prototype = { +var CurrentFormPP = function() {}; +CurrentFormPP.prototype = { check: function(args) { ;;; if (args.length != 0) { ;;; throw new Error('currentForm method needs no argument'); @@ -200,10 +197,9 @@ new kukit.ut.DictCollector()); } }; -kukit.pprovidersGlobalRegistry.register('currentForm', kukit.pr.CurrentFormPP); -kukit.pr.NodeAttrPP = function() {}; -kukit.pr.NodeAttrPP.prototype = { +var NodeAttrPP = function() {}; +NodeAttrPP.prototype = { check: function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,'; @@ -229,10 +225,9 @@ kukit.dom.getAttribute); } }; -kukit.pprovidersGlobalRegistry.register('nodeAttr', kukit.pr.NodeAttrPP); -kukit.pr.KssAttrPP = function() {}; -kukit.pr.KssAttrPP.prototype = { +var KssAttrPP = function() {}; +KssAttrPP.prototype = { check: function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,'; @@ -257,10 +252,9 @@ kukit.dom.getKssAttribute); } }; -kukit.pprovidersGlobalRegistry.register('kssAttr', kukit.pr.KssAttrPP); -kukit.pr.NodeContentPP = function() {}; -kukit.pr.NodeContentPP.prototype = { +var NodeContentPP = function() {}; +NodeContentPP.prototype = { check: function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].'); @@ -274,10 +268,9 @@ return kukit.dom.textContent(node, recursive); } }; -kukit.pprovidersGlobalRegistry.register('nodeContent', kukit.pr.NodeContentPP); -kukit.pr.StateVarPP = function() {}; -kukit.pr.StateVarPP.prototype = { +var StateVarPP = function() {}; +StateVarPP.prototype = { check: function(args) { ;;; if (args.length != 1) { ;;; throw new Error('stateVar method needs 1 argument [varname].'); @@ -294,10 +287,9 @@ return value; } }; -kukit.pprovidersGlobalRegistry.register('stateVar', kukit.pr.StateVarPP); -kukit.pr.PassPP = function() {}; -kukit.pr.PassPP.prototype = { +var PassPP = function() {}; +PassPP.prototype = { check: function(args) { ;;; if (args.length != 1) { ;;; throw new Error('pass method needs 1 argument [attrname].'); @@ -314,5 +306,22 @@ return value; } }; -kukit.pprovidersGlobalRegistry.register('pass', kukit.pr.PassPP); + +kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry(); + +kukit.pprovidersGlobalRegistry.register('', kukit.pr.IdentityPP); +kukit.pprovidersGlobalRegistry.register('currentFormVar', + CurrentFormVarPP); +kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr', + CurrentFormVarFromKssAttrPP); +kukit.pprovidersGlobalRegistry.register('formVar', FormVarPP); +kukit.pprovidersGlobalRegistry.register('kssAttr', KssAttrPP); +kukit.pprovidersGlobalRegistry.register('stateVar', StateVarPP); +kukit.pprovidersGlobalRegistry.register('pass', PassPP); +kukit.pprovidersGlobalRegistry.register('nodeContent', NodeContentPP); +kukit.pprovidersGlobalRegistry.register('nodeAttr', NodeAttrPP); +kukit.pprovidersGlobalRegistry.register('form', FormPP); +kukit.pprovidersGlobalRegistry.register('currentForm', CurrentFormPP); + +}(); /// MODULE END From gotcha at codespeak.net Sat Dec 8 16:29:49 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 8 Dec 2007 16:29:49 +0100 (CET) Subject: [KSS-checkins] r49563 - kukit/buildout/kss.zope/extraproducts Message-ID: <20071208152949.2109816853D@codespeak.net> Author: gotcha Date: Sat Dec 8 16:29:48 2007 New Revision: 49563 Modified: kukit/buildout/kss.zope/extraproducts/ (props changed) kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT Log: branch has been merged to trunk Modified: kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT ============================================================================== --- kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT (original) +++ kukit/buildout/kss.zope/extraproducts/EXTERNALS.TXT Sat Dec 8 16:29:48 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -Zelenium svn://svn.zope.org/repos/main/Zelenium/branches/gotcha-selenium-0.8.1 +Zelenium svn://svn.zope.org/repos/main/Zelenium/trunk From reebalazs at codespeak.net Sun Dec 9 12:21:59 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 9 Dec 2007 12:21:59 +0100 (CET) Subject: [KSS-checkins] r49566 - kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser Message-ID: <20071209112159.1F92D168412@codespeak.net> Author: reebalazs Date: Sun Dec 9 12:21:57 2007 New Revision: 49566 Added: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/ecmaview.py - copied unchanged from r49565, kukit/kss.zope/trunk/kss/core/tests/ecmaview.py Log: Copy this file to kss.demo From reebalazs at codespeak.net Sun Dec 9 12:23:15 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 9 Dec 2007 12:23:15 +0100 (CET) Subject: [KSS-checkins] r49567 - kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser Message-ID: <20071209112315.B1B941684CA@codespeak.net> Author: reebalazs Date: Sun Dec 9 12:23:14 2007 New Revision: 49567 Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/ecmaview.py kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py Log: Add fixed exmaview support Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/configure.zcml Sun Dec 9 12:23:14 2007 @@ -100,6 +100,14 @@ permission="zope.View" /> + + + Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/ecmaview.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/ecmaview.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/ecmaview.py Sun Dec 9 12:23:14 2007 @@ -17,22 +17,16 @@ try: from Products.Five import BrowserView + BrowserView # satisfy pyflakes except ImportError: from zope.app.publisher.browser import BrowserView -from zope.interface import Interface, implements -from zope.app import zapi +from zope.interface import implements from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile import os.path from zope.publisher.interfaces.browser import IBrowserPublisher from zope.publisher.interfaces import NotFound - -# Oh well... file resource has different import locations in zope and five, -# the factories take different parameters order, -# plus these are not "entirely clean" as far as caching is concerned... -# Instead, use the resources implemented from concatresource: -# this is version free and has properly implemented cache control. -from kss.core.pluginregistry._concatresource.resource import ConcatResourceFactory +import sys _marker = object() @@ -47,28 +41,40 @@ '''A wrapper for file resources that can be used in a view Similar to ViewPageTemplate in usage. - (We only use the FileResource here, no distinction on content types - like in the resourceDirectory code.) ''' - def __init__(self, name, path): - # Create the resource with cache control most proper for debugging. - self.resource_factory = ConcatResourceFactory([path], name, - compress_level='none', caching='memory', lmt_check_period=0.0, - checker=checker) + def __init__(self, request, name, path): + self.request = request self.name = name + self.path = path + + def __call__(self): + ##self.request.response.setHeader('Content-type', 'x-application/javascript;charset=utf-8') + return open(self.path).read() - def __get__(self, obj, cls=None): - 'The view wants a method only.' - request = obj.request - resource = self.resource_factory(request) - resource.__parent__ = obj - resource.__name__ = self.name - return resource - -def absolute_dir(path): - here = os.path.split(globals()['__file__'])[0] - return os.path.abspath(os.path.join(here, path)) +def absolute_dir(path, module_name=None): + # module_initpath will be the path of __init__.py (ecmaview.py) in the module + if module_name is None: + # Take the path of this file + module_initpath = globals()['__file__'] + else: + # traverse to module __init__.py + module_traverse = module_name.split('.') + next = module_traverse[0] + module = None + try: + # we take first module section + module = sys.modules[next] + # and we traverse to the module + for next in module_traverse[1:]: + module = getattr(module, next) + except (KeyError, AttributeError): + raise ImportError, 'Can not traverse path %s from %r while importing module %s.' % \ + (next, module, module_name) + module_initpath = module.__file__ + # we take off xxxx.py from the end + module_root = os.path.split(module_initpath)[0] + return os.path.abspath(os.path.join(module_root, path)) class EcmaView(BrowserView): '''Kukit test view @@ -82,9 +88,10 @@ implements(IBrowserPublisher) - _testdir = absolute_dir('../kukit/tests') + _testdir = absolute_dir('kukit/tests', 'kss.base') - _runner = ViewPageTemplateFile('../kukit/tests/runner.html', content_type='text/html; charset=utf-8') + _runner = ViewPageTemplateFile(os.path.join(_testdir, 'runner.html'), + content_type='text/html; charset=utf-8') # The next is only necessary on Zope (<=) 2.9, # provides a docstring to the method @@ -127,10 +134,8 @@ path = os.path.join(self._testdir, name) if os.path.isfile(path): # Ok, this is a file. Cook it. - resource = ViewFile(name, path) - setattr(self.__class__, name, resource) - # important: return accessed *from* the view. - return getattr(self, name) + resource = ViewFile(self.request, name, path) + return resource # Not found. if default is _marker: Modified: kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/branch/kss-zope-transition/kss/demo/browser/registry.py Sun Dec 9 12:23:14 2007 @@ -102,7 +102,7 @@ raise Exception, "Nonexistent resource" # Return the file's content. self.request.response.setHeader('Content-type', 'text/html;charset=utf-8') - return file(filename).read() + return open(filename).read() def getZuiteHomePage(self, path): """Redirects to the Zuite home page, Zuite object is found from path.""" From reebalazs at codespeak.net Sun Dec 9 12:25:55 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 9 Dec 2007 12:25:55 +0100 (CET) Subject: [KSS-checkins] r49568 - in kukit/kss.zope/trunk/kss/core: . tests Message-ID: <20071209112555.83CB61684CA@codespeak.net> Author: reebalazs Date: Sun Dec 9 12:25:54 2007 New Revision: 49568 Removed: kukit/kss.zope/trunk/kss/core/tests/configure-online.zcml kukit/kss.zope/trunk/kss/core/tests/ecmaview.py Modified: kukit/kss.zope/trunk/kss/core/configure.zcml Log: Remove ecmaview that now moved to kss.demo Modified: kukit/kss.zope/trunk/kss/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/core/configure.zcml Sun Dec 9 12:25:54 2007 @@ -5,11 +5,6 @@ - - - Deleted: /kukit/kss.zope/trunk/kss/core/tests/configure-online.zcml ============================================================================== --- /kukit/kss.zope/trunk/kss/core/tests/configure-online.zcml Sun Dec 9 12:25:54 2007 +++ (empty file) @@ -1,15 +0,0 @@ - - - - - - - Deleted: /kukit/kss.zope/trunk/kss/core/tests/ecmaview.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/tests/ecmaview.py Sun Dec 9 12:25:54 2007 +++ (empty file) @@ -1,143 +0,0 @@ -# Copyright (c) 2005-2007 -# Authors: KSS Project Contributors (see docs/CREDITS.txt) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -try: - from Products.Five import BrowserView -except ImportError: - from zope.app.publisher.browser import BrowserView - -from zope.interface import Interface, implements -from zope.app import zapi -from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile -import os.path -from zope.publisher.interfaces.browser import IBrowserPublisher -from zope.publisher.interfaces import NotFound - -# Oh well... file resource has different import locations in zope and five, -# the factories take different parameters order, -# plus these are not "entirely clean" as far as caching is concerned... -# Instead, use the resources implemented from concatresource: -# this is version free and has properly implemented cache control. -from kss.core.pluginregistry._concatresource.resource import ConcatResourceFactory - -_marker = object() - -# z3 only -from zope.security.checker import CheckerPublic, NamesChecker -allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault', - 'request', '__call__') -permission = CheckerPublic -checker = NamesChecker(allowed_names, permission) - -class ViewFile(object): - '''A wrapper for file resources that can be used in a view - - Similar to ViewPageTemplate in usage. - (We only use the FileResource here, no distinction on content types - like in the resourceDirectory code.) - ''' - - def __init__(self, name, path): - # Create the resource with cache control most proper for debugging. - self.resource_factory = ConcatResourceFactory([path], name, - compress_level='none', caching='memory', lmt_check_period=0.0, - checker=checker) - self.name = name - - def __get__(self, obj, cls=None): - 'The view wants a method only.' - request = obj.request - resource = self.resource_factory(request) - resource.__parent__ = obj - resource.__name__ = self.name - return resource - -def absolute_dir(path): - here = os.path.split(globals()['__file__'])[0] - return os.path.abspath(os.path.join(here, path)) - -class EcmaView(BrowserView): - '''Kukit test view - - This allows the runner.html to be used on this view. - - This provides the tests run with the compiled kukit.js - resource, in the same way as they would be run - in production with kss. - ''' - - implements(IBrowserPublisher) - - _testdir = absolute_dir('../kukit/tests') - - _runner = ViewPageTemplateFile('../kukit/tests/runner.html', content_type='text/html; charset=utf-8') - - # The next is only necessary on Zope (<=) 2.9, - # provides a docstring to the method - def _runner_proxy(self, *arg, **kw): - 'Publishable method' - return self._runner(*arg, **kw) - - def publishTraverse(self, request, name): - '''See interface IBrowserPublisher''' - return self.get(name) - - def browserDefault(self, request): - '''See interface IBrowserPublisher''' - return self, () - - def __getitem__(self, name): - res = self.get(name, None) - if res is None: - raise KeyError(name) - return res - - def get(self, name, default=_marker): - # runner.html is compiled as a pagetemplate - if name == 'runner.html': - # XXX For Zope2.9 we need this. - if not hasattr(self.request, 'debug'): - self.request.debug = None - # proxy is used to make it publishable, on Zope <= 2.9 - return self._runner_proxy - - # We store them on the view on demand. - # Is it there yet? - if name[0] != '_': - try: - return getattr(self, name) - except AttributeError: - pass - - # See the file we need - path = os.path.join(self._testdir, name) - if os.path.isfile(path): - # Ok, this is a file. Cook it. - resource = ViewFile(name, path) - setattr(self.__class__, name, resource) - # important: return accessed *from* the view. - return getattr(self, name) - - # Not found. - if default is _marker: - raise NotFound(None, name) - return default - - def __call__(self): - 'By default we redirect to runner.html.' - # on Zope3, the url is of zope.publisher.http.URLGetter class, so we must stringify it - return self.request.response.redirect(str(self.request.URL) + '/runner.html') From jvloothuis at codespeak.net Sun Dec 9 14:44:48 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 14:44:48 +0100 (CET) Subject: [KSS-checkins] r49569 - in kukit/kss.zope/trunk/kss/zope: . tests Message-ID: <20071209134448.A622C1684DB@codespeak.net> Author: jvloothuis Date: Sun Dec 9 14:44:47 2007 New Revision: 49569 Added: kukit/kss.zope/trunk/kss/zope/tests/test_kssview.py - copied, changed from r49568, kukit/kss.zope/trunk/kss/core/tests/test_kssview.py kukit/kss.zope/trunk/kss/zope/view.txt - copied, changed from r49568, kukit/kss.zope/trunk/kss/core/kssview.txt Log: Ported the KSS view (events system) test to kss.zope Copied: kukit/kss.zope/trunk/kss/zope/tests/test_kssview.py (from r49568, kukit/kss.zope/trunk/kss/core/tests/test_kssview.py) ============================================================================== --- kukit/kss.zope/trunk/kss/core/tests/test_kssview.py (original) +++ kukit/kss.zope/trunk/kss/zope/tests/test_kssview.py Sun Dec 9 14:44:47 2007 @@ -18,39 +18,29 @@ import unittest -from kss.core.interfaces import IKSSView, IKSSCommands -from kss.core.plugins.core.interfaces import IKSSCoreCommands -from kss.core.plugins.core.commands import KSSCoreCommands -from kss.core.pluginregistry.interfaces import IAction, ICommandSet -from kss.core.pluginregistry.action import Action -from kss.core.pluginregistry.plugin import registerPlugin -from kss.core.pluginregistry.commandset import CommandSet -from kss.core.tests.commandinspector import CommandInspectorView - -import zope.component.event from zope.testing import doctest, cleanup -from zope.publisher.interfaces.browser import IBrowserRequest from zope.app.component.hooks import setHooks +# Import zope.component.event for side effects +import zope.component.event +flakes = zope.component.event # Do this for pyflakes +from zope import component + +from kss.zope.interfaces import IKSSPluginRegistry +from kss.zope.registry import GlobalPluginRegistry def setUpAjaxView(test=None): + cleanup.CleanUp().setUp() setHooks() - zope.component.provideAdapter(CommandInspectorView, - adapts=(IKSSCommands, IBrowserRequest)) - registerPlugin(Action, IAction, 'replaceInnerHTML', None, - 'selector', 'html', [], None) - zope.component.provideAdapter(KSSCoreCommands, - adapts=(IKSSView,), - provides=IKSSCoreCommands) - registerPlugin(CommandSet, ICommandSet, 'core', IKSSCoreCommands) + component.provideUtility(GlobalPluginRegistry(), IKSSPluginRegistry) def tearDownAjaxView(test=None): - cleanup.cleanUp() + cleanup.CleanUp().tearDown() def test_suite(): return unittest.TestSuite([ - doctest.DocTestSuite('kss.core.kssview'), - doctest.DocFileSuite('kssview.txt', - package='kss.core', + doctest.DocTestSuite('kss.zope.view'), + doctest.DocFileSuite('view.txt', + package='kss.zope', setUp=setUpAjaxView, tearDown=tearDownAjaxView), ]) Copied: kukit/kss.zope/trunk/kss/zope/view.txt (from r49568, kukit/kss.zope/trunk/kss/core/kssview.txt) ============================================================================== --- kukit/kss.zope/trunk/kss/core/kssview.txt (original) +++ kukit/kss.zope/trunk/kss/zope/view.txt Sun Dec 9 14:44:47 2007 @@ -14,7 +14,7 @@ this by creating an example. The following will setup our enviroment and show that normal operation works. - >>> from kss.core import KSSView + >>> from kss.zope import KSSView >>> from zope import component >>> from zope.lifecycleevent import ObjectModifiedEvent >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent @@ -27,7 +27,7 @@ >>> request = TestRequest() >>> request.RESPONSE = HTTPResponse() -Now we will write our custom. +Now we will write our KSS view. >>> class SampleView(KSSView): ... def setTitle(self, title): @@ -44,24 +44,27 @@ Let's set a title: - >>> view.setTitle("some title") - [] + >>> output = view.setTitle("some title") + >>> print view.commands + Now that we have shown that this will not generate any KSS commands we will register a handler. This handler will catch the object event and add some KSS commands. - >>> @component.adapter(None, SampleView, IObjectModifiedEvent) + >>> from zope.interface import Interface + >>> @component.adapter(Interface, Interface, IObjectModifiedEvent) ... def stuff_happend(object, view, event): - ... view.getCommandSet('core').replaceInnerHTML( + ... view.commands.core.replaceInnerHTML( ... 'div.class', object.title) >>> component.provideHandler(stuff_happend) When we call the renderer now it should have some more data in it. -(html parameters are marshalled as CDATA, so we check for that too) >>> view = SampleView(myfolder, request) >>> setSite(view) - >>> view.setTitle(u"some title")[0]['params']['html'] - u'' + >>> xml_output = view.setTitle(u"some title") + >>> print view.commands + replaceInnerHTML(css('div.class'), html='some title') + From jvloothuis at codespeak.net Sun Dec 9 14:49:55 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 14:49:55 +0100 (CET) Subject: [KSS-checkins] r49570 - in kukit/kss.zope/trunk/kss/core: . tests Message-ID: <20071209134955.8F41C1684DD@codespeak.net> Author: jvloothuis Date: Sun Dec 9 14:49:55 2007 New Revision: 49570 Removed: kukit/kss.zope/trunk/kss/core/kssview.txt kukit/kss.zope/trunk/kss/core/tests/test_kssview.py Log: Removed the KSS view from kss.core since they have been ported to kss.zope Deleted: /kukit/kss.zope/trunk/kss/core/kssview.txt ============================================================================== --- /kukit/kss.zope/trunk/kss/core/kssview.txt Sun Dec 9 14:49:55 2007 +++ (empty file) @@ -1,67 +0,0 @@ -==================== -KSS views and events -==================== - -When we make a change using Ajax calls we would like to update the -browser page. This can be done by sending browser commands. Some part -of the page may need to be update based on modifications. - -We don't want to handle all these modifications in our own code. An -example of such a modification change would be changing the -title. This should also update the navigation portlet. - -To make this work KSS views do something special. We will explain -this by creating an example. The following will setup our enviroment -and show that normal operation works. - - >>> from kss.core import KSSView - >>> from zope import component - >>> from zope.lifecycleevent import ObjectModifiedEvent - >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent - >>> from zope.publisher.browser import TestRequest - >>> from zope.publisher.http import HTTPResponse - >>> from zope import event - - >>> from zope.app.folder import folder - >>> myfolder = folder.rootFolder() - >>> request = TestRequest() - >>> request.RESPONSE = HTTPResponse() - -Now we will write our custom. - - >>> class SampleView(KSSView): - ... def setTitle(self, title): - ... self.context.title = title - ... event.notify(ObjectModifiedEvent(self.context)) - ... return self.render() - - >>> view = SampleView(myfolder, request) - -Simulate traversal by making the view the current site: - - >>> from zope.app.component.hooks import setSite - >>> setSite(view) - -Let's set a title: - - >>> view.setTitle("some title") - [] - -Now that we have shown that this will not generate any KSS commands -we will register a handler. This handler will catch the object event -and add some KSS commands. - - >>> @component.adapter(None, SampleView, IObjectModifiedEvent) - ... def stuff_happend(object, view, event): - ... view.getCommandSet('core').replaceInnerHTML( - ... 'div.class', object.title) - >>> component.provideHandler(stuff_happend) - -When we call the renderer now it should have some more data in it. -(html parameters are marshalled as CDATA, so we check for that too) - - >>> view = SampleView(myfolder, request) - >>> setSite(view) - - >>> view.setTitle(u"some title")[0]['params']['html'] - u'' Deleted: /kukit/kss.zope/trunk/kss/core/tests/test_kssview.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/tests/test_kssview.py Sun Dec 9 14:49:55 2007 +++ (empty file) @@ -1,56 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (c) 2005-2007 -# Authors: KSS Project Contributors (see docs/CREDITS.txt) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -import unittest - -from kss.core.interfaces import IKSSView, IKSSCommands -from kss.core.plugins.core.interfaces import IKSSCoreCommands -from kss.core.plugins.core.commands import KSSCoreCommands -from kss.core.pluginregistry.interfaces import IAction, ICommandSet -from kss.core.pluginregistry.action import Action -from kss.core.pluginregistry.plugin import registerPlugin -from kss.core.pluginregistry.commandset import CommandSet -from kss.core.tests.commandinspector import CommandInspectorView - -import zope.component.event -from zope.testing import doctest, cleanup -from zope.publisher.interfaces.browser import IBrowserRequest -from zope.app.component.hooks import setHooks - -def setUpAjaxView(test=None): - setHooks() - zope.component.provideAdapter(CommandInspectorView, - adapts=(IKSSCommands, IBrowserRequest)) - registerPlugin(Action, IAction, 'replaceInnerHTML', None, - 'selector', 'html', [], None) - zope.component.provideAdapter(KSSCoreCommands, - adapts=(IKSSView,), - provides=IKSSCoreCommands) - registerPlugin(CommandSet, ICommandSet, 'core', IKSSCoreCommands) - -def tearDownAjaxView(test=None): - cleanup.cleanUp() - -def test_suite(): - return unittest.TestSuite([ - doctest.DocTestSuite('kss.core.kssview'), - doctest.DocFileSuite('kssview.txt', - package='kss.core', - setUp=setUpAjaxView, - tearDown=tearDownAjaxView), - ]) From reebalazs at codespeak.net Sun Dec 9 15:02:09 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 9 Dec 2007 15:02:09 +0100 (CET) Subject: [KSS-checkins] r49571 - kukit/kss.base/trunk/kss/base Message-ID: <20071209140209.C80DE1684FE@codespeak.net> Author: reebalazs Date: Sun Dec 9 15:02:08 2007 New Revision: 49571 Modified: kukit/kss.base/trunk/kss/base/javascript.py kukit/kss.base/trunk/kss/base/javascript.txt Log: Replace concatinated with concatenated (correct spelling) Modified: kukit/kss.base/trunk/kss/base/javascript.py ============================================================================== --- kukit/kss.base/trunk/kss/base/javascript.py (original) +++ kukit/kss.base/trunk/kss/base/javascript.py Sun Dec 9 15:02:08 2007 @@ -3,7 +3,7 @@ from kss.base.plugin import activated_plugins from kss.base.compression.javascript import compress -def concatinated(include_extras=False): +def concatenated(include_extras=False): '''Concatinate the Javascript files for all activate plugins''' scripts = [] @@ -21,7 +21,7 @@ return '\n'.join(scripts) def packed(compression_level=None, include_extras=False): - return compress(concatinated(include_extras), compression_level) + return compress(concatenated(include_extras), compression_level) def extra_scripts(): '''Return a dictionary of the extra javascripts for all activated Modified: kukit/kss.base/trunk/kss/base/javascript.txt ============================================================================== --- kukit/kss.base/trunk/kss/base/javascript.txt (original) +++ kukit/kss.base/trunk/kss/base/javascript.txt Sun Dec 9 15:02:08 2007 @@ -8,15 +8,15 @@ Concatinated ============ -With the concatinated function you can get the a single string +With the concatenated function you can get the a single string containing all the Javascript from each active plugin. - >>> from kss.base.javascript import concatinated + >>> from kss.base.javascript import concatenated When we run the code without activating any plugin we will get an empty string. - >>> concatinated() + >>> concatenated() '' Now if we run the code again after we activate a plugin we get @@ -24,20 +24,20 @@ >>> from kss.base import load_plugins >>> load_plugins('kss-core') - >>> concatinated() + >>> concatenated() '/*\n* Copyright (c) 2005-2007\n* Authors: KSS Project Contributors...' -An optimization you might want to enable is concatinate the extra +An optimization you might want to enable is concatenate the extra dependencies along side with the plugin code. This will reduce the number of requests a browser has to make to a website therefore making it slightly faster (only for the first page load). - >>> 'XPathParser' in concatinated(include_extras=True) + >>> 'XPathParser' in concatenated(include_extras=True) True This example was not there in the previous concatination. - >>> 'XPathParser' in concatinated() + >>> 'XPathParser' in concatenated() False Finally we will unregister the core plugin to clean up. From gotcha at codespeak.net Sun Dec 9 17:45:35 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 17:45:35 +0100 (CET) Subject: [KSS-checkins] r49572 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209164535.0CA3F168561@codespeak.net> Author: gotcha Date: Sun Dec 9 17:45:34 2007 New Revision: 49572 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Log: class closure Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sun Dec 9 17:45:34 2007 @@ -26,114 +26,111 @@ */ cp.CommandProcessor = function() { this.commands = new Array(); -}; - -var CommandProcessor = cp.CommandProcessor.prototype; -CommandProcessor.parseCommands = - function(commands, transport) { -;;;kukit.log('Parsing commands.'); -;;;kukit.logDebug('Number of commands : ' + commands.length + '.'); - for (var y=0;y < commands.length;y++) { - var command = commands[y]; - this.parseCommand(command, transport); - // If we receive an error command, we handle that separately. - // We abort immediately and let the processError handler do its job. - // This means that although no other commands should be in commands, - // we make sure we execute none of them. - var lastcommand = this.commands[this.commands.length-1]; - if (lastcommand.name == 'error') { - // We have to throw an explicitError always, since we want - // error fallbacks work both in production and development mode. - throw kukit.err.explicitError(lastcommand); + this.parseCommands = function(commands, transport) { +;;; kukit.log('Parsing commands.'); +;;; kukit.logDebug('Number of commands : ' + commands.length + '.'); + for (var y=0;y < commands.length;y++) { + var command = commands[y]; + this.parseCommand(command, transport); + // If we receive an error command, we handle that separately. + // We abort immediately and let the processError handler do its job. + // This means that although no other commands should be in commands, + // we make sure we execute none of them. + var lastcommand = this.commands[this.commands.length-1]; + if (lastcommand.name == 'error') { + // We have to throw an explicitError always, since we want + // error fallbacks work both in production and development mode. + throw kukit.err.explicitError(lastcommand); + } } - } -}; + }; -CommandProcessor.parseCommand = - function(command, transport) { - var selector = ""; - var params = {}; - var name = ""; - - selector = command.getAttribute("selector"); - name = command.getAttribute("name"); - type = command.getAttribute("selectorType"); - if (name == null) - name = ""; - var childNodes = command.childNodes; - for (var n=0;n < childNodes.length;n++) { - var childNode = childNodes[n]; - if (childNode.nodeType != 1) - continue; - if (childNode.localName) { - if (childNode.localName.toLowerCase() != "param") { - throw new Error('Bad payload, expected param'); - } - } else { - //IE does not know DOM2 - if (childNode.nodeName.toLowerCase() != "param") { - throw new Error('Bad payload, expected param (IE)'); - } - } - data = childNode.getAttribute('name'); - if (data != null) { - // Decide if we have a string or a dom parameter - var childCount = childNode.childNodes.length; - var result; - if (childCount == 0) { - result = ''; + this.parseCommand = function(command, transport) { + var selector = ""; + var params = {}; + var name = ""; + + selector = command.getAttribute("selector"); + name = command.getAttribute("name"); + type = command.getAttribute("selectorType"); + if (name == null) + name = ""; + var childNodes = command.childNodes; + for (var n=0;n < childNodes.length;n++) { + var childNode = childNodes[n]; + if (childNode.nodeType != 1) + continue; + if (childNode.localName) { + if (childNode.localName.toLowerCase() != "param") { + throw new Error('Bad payload, expected param'); + } + } else { + //IE does not know DOM2 + if (childNode.nodeName.toLowerCase() != "param") { + throw new Error('Bad payload, expected param (IE)'); + } + } + data = childNode.getAttribute('name'); + if (data != null) { + // Decide if we have a string or a dom parameter + var childCount = childNode.childNodes.length; + var result; + if (childCount == 0) { + result = ''; + } else { + // (we do not interpret html inline content any more) + // we have a single text node + // OR + // we have a single CDATA node (HTML parameter CDATA-style) +;;; var isTextNode = childNode.firstChild.nodeType == 3; +;;; var isCData = childNode.firstChild.nodeType == 4; +;;; if (! (childCount == 1 && (isTextNode || isCData))) { +;;; kukit.E = 'Bad payload, expected a text or a CDATA node'; +;;; throw new Error(kukit.E); +;;; } + // we consider this as html payload + // The result is always a string from here. + result = childNode.firstChild.nodeValue; + } + params[data] = result; } else { - // (we do not interpret html inline content any more) - // we have a single text node - // OR - // we have a single CDATA node (HTML parameter CDATA-style) -;;; var isTextNode = childNode.firstChild.nodeType == 3; -;;; var isCData = childNode.firstChild.nodeType == 4; -;;; if (! (childCount == 1 && (isTextNode || isCData))) { -;;; kukit.E = 'Bad payload, expected a text or a CDATA node'; -;;; throw new Error(kukit.E); -;;; } - // we consider this as html payload - // The result is always a string from here. - result = childNode.firstChild.nodeValue; + throw new Error('Bad payload, expected attribute "name"'); } - params[data] = result; - } else { - throw new Error('Bad payload, expected attribute "name"'); } - } - var command = new kukit.cr.makeCommand(selector, name, type, params, - transport); - this.addCommand(command); -}; + var command = new kukit.cr.makeCommand(selector, name, type, params, + transport); + this.addCommand(command); + }; -CommandProcessor.addCommand = function(command) { + this.addCommand = function(command) { this.commands[this.commands.length] = command; }; -CommandProcessor.executeCommands = function(oper) { - kukit.engine.beginSetupEventsCollection(); - // node, eventRule, binder are given on oper, in case - // the command was called up from an event - if (typeof(oper) == 'undefined' || oper == null) { - oper = new kukit.op.Oper(); - } - var commands = this.commands; - for (var y=0;y < commands.length;y++) { - var command = commands[y]; -;;; try { - command.execute(oper); -;;; } catch (e) { -;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { -;;; throw(e); -;;; } else { -;;; // augment the error message -;;; throw kukit.err.commandExecutionError(e, command); + this.executeCommands = function(oper) { + kukit.engine.beginSetupEventsCollection(); + // node, eventRule, binder are given on oper, in case + // the command was called up from an event + if (typeof(oper) == 'undefined' || oper == null) { + oper = new kukit.op.Oper(); + } + var commands = this.commands; + for (var y=0;y < commands.length;y++) { + var command = commands[y]; +;;; try { + command.execute(oper); +;;; } catch (e) { +;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { +;;; throw(e); +;;; } else { +;;; // augment the error message +;;; throw kukit.err.commandExecutionError(e, command); +;;; } ;;; } -;;; } - } - kukit.engine.finishSetupEventsCollection(); + } + kukit.engine.finishSetupEventsCollection(); + }; + }; }(); /// MODULE END From jvloothuis at codespeak.net Sun Dec 9 17:58:50 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 17:58:50 +0100 (CET) Subject: [KSS-checkins] r49573 - kukit/kss.core/branch/payload-fixes Message-ID: <20071209165850.F1CC31684D8@codespeak.net> Author: jvloothuis Date: Sun Dec 9 17:58:50 2007 New Revision: 49573 Added: kukit/kss.core/branch/payload-fixes/ - copied from r49572, kukit/kss.core/trunk/ Log: Branched to fix the payload From jvloothuis at codespeak.net Sun Dec 9 18:11:21 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 18:11:21 +0100 (CET) Subject: [KSS-checkins] r49574 - kukit/kss.buildout/trunk Message-ID: <20071209171121.0B6F8168569@codespeak.net> Author: jvloothuis Date: Sun Dec 9 18:11:21 2007 New Revision: 49574 Modified: kukit/kss.buildout/trunk/buildout.cfg Log: Buildout fixed by changing the import lines for the ZCML Modified: kukit/kss.buildout/trunk/buildout.cfg ============================================================================== --- kukit/kss.buildout/trunk/buildout.cfg (original) +++ kukit/kss.buildout/trunk/buildout.cfg Sun Dec 9 18:11:21 2007 @@ -1,7 +1,5 @@ [buildout] parts = - javaversion - seleniumrc zope2 instance ksspy @@ -9,16 +7,8 @@ develop = src/kss.core src/kss.demo - src/kss.recipe.checkjavaversion - src/kss.recipe.seleniumrc -[javaversion] -recipe = kss.recipe.checkjavaversion -javaversion = 1.5 - -[seleniumrc] -recipe = kss.recipe.seleniumrc -url = http://release.openqa.org/selenium-remote-control/0.9.0/selenium-remote-control-0.9.0.zip +eggs=elementtree [zope2] recipe = plone.recipe.zope2install @@ -32,11 +22,12 @@ eggs = kss.core kss.demo + elementtree zcml = - kss.core:kss.core-meta.zcml - kss.core:kss.core-configure.zcml - kss.demo:kss.demo-meta.zcml - kss.demo:kss.demo-configure.zcml + kss.core-meta + kss.core + kss.demo-meta + kss.demo [ksspy] recipe = zc.recipe.egg From jvloothuis at codespeak.net Sun Dec 9 18:47:49 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 18:47:49 +0100 (CET) Subject: [KSS-checkins] r49575 - in kukit/kss.core/branch/payload-fixes/kss/core: browser plugins/core/demo tests Message-ID: <20071209174749.855E5168543@codespeak.net> Author: jvloothuis Date: Sun Dec 9 18:47:48 2007 New Revision: 49575 Modified: kukit/kss.core/branch/payload-fixes/kss/core/browser/errorresponse.pt kukit/kss.core/branch/payload-fixes/kss/core/browser/kukitresponse.pt kukit/kss.core/branch/payload-fixes/kss/core/plugins/core/demo/protocol.pt kukit/kss.core/branch/payload-fixes/kss/core/tests/kukitresponse_test.pt kukit/kss.core/branch/payload-fixes/kss/core/tests/test_browserview.py kukit/kss.core/branch/payload-fixes/kss/core/tests/test_kssview_core.py Log: Increased the version of the protocol to start off and made all (Python) tests pass. Modified: kukit/kss.core/branch/payload-fixes/kss/core/browser/errorresponse.pt ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/browser/errorresponse.pt (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/browser/errorresponse.pt Sun Dec 9 18:47:48 2007 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/branch/payload-fixes/kss/core/browser/kukitresponse.pt ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/browser/kukitresponse.pt (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/browser/kukitresponse.pt Sun Dec 9 18:47:48 2007 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/branch/payload-fixes/kss/core/plugins/core/demo/protocol.pt ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/plugins/core/demo/protocol.pt (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/plugins/core/demo/protocol.pt Sun Dec 9 18:47:48 2007 @@ -30,6 +30,10 @@
  • Large dataset
  • +
    + The contents of this node will change +
    +

    Currently kss.core treats non-HTML commands differently from others. The following examples show why I think this to be a mistake.

    Modified: kukit/kss.core/branch/payload-fixes/kss/core/tests/kukitresponse_test.pt ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/tests/kukitresponse_test.pt (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/tests/kukitresponse_test.pt Sun Dec 9 18:47:48 2007 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/branch/payload-fixes/kss/core/tests/test_browserview.py ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/tests/test_browserview.py (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/tests/test_browserview.py Sun Dec 9 18:47:48 2007 @@ -31,7 +31,7 @@ header = response.getHeader('x-ksscommands') self.assert_('the_&lt;&gt;message' in header) # no < > in the message self.assert_('\n' not in header) # no /n in the payload: would destroy the page - self.assertEqual(header, ' \t \t\tsystem \t\tTheError: the_&lt;&gt;message \t ') + self.assertEqual(header, ' \t \t\tsystem \t\tTheError: the_&lt;&gt;message \t ') def test_suite(): suites = [] Modified: kukit/kss.core/branch/payload-fixes/kss/core/tests/test_kssview_core.py ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/tests/test_kssview_core.py (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/tests/test_kssview_core.py Sun Dec 9 18:47:48 2007 @@ -100,7 +100,7 @@ def _wrapped_commands(self, inline): header = textwrap.dedent(u'''\ - + ''') footer = textwrap.dedent('''\ From gotcha at codespeak.net Sun Dec 9 19:09:11 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 19:09:11 +0100 (CET) Subject: [KSS-checkins] r49576 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209180911.0C29D16856C@codespeak.net> Author: gotcha Date: Sun Dec 9 19:09:11 2007 New Revision: 49576 Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Log: class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Sun Dec 9 19:09:11 2007 @@ -29,62 +29,39 @@ pr.ValueProviderRegistry = function () { this.content = {}; -}; - -var ValueProviderRegistry = pr.ValueProviderRegistry.prototype; -ValueProviderRegistry.register = function(name, func) { - if (typeof(func) == 'undefined') { -;;; kukit.E = 'func argument is mandatory when registering a parameter' -;;; kukit.E += ' provider [ValueProviderRegistry.register].'; - throw new Error(kukit.E); - } -;;; if (this.content[name]) { -;;; // Do not allow redefinition -;;; var msg = 'Error : parameter provider [' + name; -;;; msg += '] already registered.'; -;;; kukit.logError(msg); -;;; return; -;;; } - this.content[name] = func; -}; - -ValueProviderRegistry.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); -}; - -ValueProviderRegistry.get = function(name) { - var func = this.content[name]; - if (! func) { - // not found - if (name == '') { - // default provider for the strings - return kukit.pr.IdentityPP; - } else { + this.register = function(name, func) { + if (typeof(func) == 'undefined') { +;;; kukit.E = 'func argument is mandatory when registering a parameter' +;;; kukit.E += ' provider [ValueProviderRegistry.register].'; + throw new Error(kukit.E); + } +;;; if (this.content[name]) { +;;; // Do not allow redefinition +;;; var msg = 'Error : parameter provider [' + name; +;;; msg += '] already registered.'; +;;; kukit.logError(msg); +;;; return; +;;; } + this.content[name] = func; + }; + + this.exists = function(name) { + var entry = this.content[name]; + return (typeof(entry) != 'undefined'); + }; + + this.get = function(name) { + var func = this.content[name]; + if (! func) { ;;; kukit.E = 'Error : undefined parameter provider [' + name + '].'; throw new Error(kukit.E); } - } - return func; -}; + return func; + }; -pr.IdentityPP = function() {}; -pr.IdentityPP.prototype = { - check: function(args) { - // check does not need to be used here actually. -;;; if (args.length != 1) { -;;; throw new Error('internal error, IdentityPP needs 1 argument'); -;;; } - }, - eval: function(args, node) { - return args[0]; - } }; -}(); /// MODULE END - -kukit.dummy = new function() { /// MODULE START /* * Register the core parameter providers * @@ -108,26 +85,37 @@ * this provider expects a single parameter, the string. */ -var FormVarPP = function() {}; -FormVarPP.prototype = { - check: function(args) { +var IdentityPP = function() { + this.check = function(args) { + // check does not need to be used here actually. +;;; if (args.length != 1) { +;;; throw new Error('internal error, IdentityPP needs 1 argument'); +;;; } + }; + + this.eval = function(args, node) { + return args[0]; + }; +}; + +var FormVarPP = function() { + this.check = function(args) { ;;; if (args.length != 2) { ;;; throw new Error('formVar method needs 2 arguments [formname, varname]'); ;;; } - }, - eval:function(args, node) { + }; + this.eval = function(args, node) { return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), args[1]); - } + }; }; -var CurrentFormVarPP = function() {}; -CurrentFormVarPP.prototype = { - check: function(args) { +var CurrentFormVarPP = function() { + this.check = function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]'); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { if (args.length == 1) { return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), args[0]); @@ -135,19 +123,18 @@ // no form var name, just get the value of the node. return kukit.fo.getValueOfFormElement(node); } - } + }; }; -var CurrentFormVarFromKssAttrPP = function() {}; -CurrentFormVarFromKssAttrPP.prototype = { - check: function(args) { +var CurrentFormVarFromKssAttrPP = function() { + this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument'; ;;; kukit.E += ' [attrname, [recurseParents]]'; ;;; throw new Error(kukit.E); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { var argname = args[0]; var recurseParents = false; if (args.length == 2) { @@ -160,47 +147,44 @@ recurseParents, kukit.dom.getKssAttribute); return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), formvarname); - } + }; }; /* BBB. To be deprecated at 2007-08-15 */ -var FormPP = function() {}; -FormPP.prototype = { - check: function(args) { +var FormPP = function() { + this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('form method needs 1 arguments [formname]'); ;;; } ;;; var msg = 'Deprecated the [form(formname)] parameter provider,'; ;;; msg += ' use [xxx-kssSubmitForm: form(formname)] instead !'; ;;; kukit.logWarning(msg); - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { return kukit.fo.getAllFormVars(new kukit.fo.NamedFormLocator(args[0]), new kukit.ut.DictCollector()); - } + }; }; /* BBB. To be deprecated at 2007-08-15 */ -var CurrentFormPP = function() {}; -CurrentFormPP.prototype = { - check: function(args) { +var CurrentFormPP = function() { + this.check = function(args) { ;;; if (args.length != 0) { ;;; throw new Error('currentForm method needs no argument'); ;;; } ;;; var msg = 'Deprecated the [currentForm()] parameter provider,'; ;;; msg += ' use [xxx-kssSubmitForm: currentForm()] instead !'; ;;; kukit.logWarning(msg); - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { return kukit.fo.getAllFormVars(new kukit.fo.CurrentFormLocator(node), new kukit.ut.DictCollector()); - } + }; }; -var NodeAttrPP = function() {}; -NodeAttrPP.prototype = { - check: function(args) { +var NodeAttrPP = function() { + this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,'; ;;; kukit.E += ' [recurseParents]).'; @@ -212,8 +196,8 @@ ;;; if (args[0].match(/[ ]/)) { ;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { var argname = args[0]; var recurseParents = false; if (args.length == 2) { @@ -223,12 +207,11 @@ } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getAttribute); - } + }; }; -var KssAttrPP = function() {}; -KssAttrPP.prototype = { - check: function(args) { +var KssAttrPP = function() { + this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,'; ;;; kukit.E += ' [recurseParents]).'; @@ -239,8 +222,8 @@ ;;; kukit.E += ' dashes or spaces.'; ;;; throw new Error(kukit.E); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { var argname = args[0]; var recurseParents = false; if (args.length == 2) { @@ -250,33 +233,31 @@ } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getKssAttribute); - } + }; }; -var NodeContentPP = function() {}; -NodeContentPP.prototype = { - check: function(args) { +var NodeContentPP = function() { + this.check = function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].'); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { var recursive = false; if (args.length == 1) { recursive = args[0]; } return kukit.dom.textContent(node, recursive); - } + }; }; -var StateVarPP = function() {}; -StateVarPP.prototype = { - check: function(args) { +var StateVarPP = function() { + this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('stateVar method needs 1 argument [varname].'); ;;; } - }, - eval: function(args, node) { + }; + this.eval = function(args, node) { var key = args[0]; var value = kukit.engine.stateVariables[key]; if (typeof(value) == 'undefined') { @@ -285,17 +266,16 @@ throw new Error(kukit.E); } return value; - } + }; }; -var PassPP = function() {}; -PassPP.prototype = { - check: function(args) { +var PassPP = function() { + this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('pass method needs 1 argument [attrname].'); ;;; } - }, - eval: function(args, node, defaultParameters) { + }; + this.eval = function(args, node, defaultParameters) { var key = args[0]; var value = defaultParameters[key]; if (typeof(value) == 'undefined') { @@ -304,13 +284,13 @@ throw new Error(kukit.E); } return value; - } + }; }; -kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry(); +kukit.pprovidersGlobalRegistry = new this.ValueProviderRegistry(); -kukit.pprovidersGlobalRegistry.register('', kukit.pr.IdentityPP); +kukit.pprovidersGlobalRegistry.register('', IdentityPP); kukit.pprovidersGlobalRegistry.register('currentFormVar', CurrentFormVarPP); kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr', @@ -325,3 +305,4 @@ kukit.pprovidersGlobalRegistry.register('currentForm', CurrentFormPP); }(); /// MODULE END + From jvloothuis at codespeak.net Sun Dec 9 19:17:33 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 9 Dec 2007 19:17:33 +0100 (CET) Subject: [KSS-checkins] r49577 - kukit/kss.core/branch/payload-fixes/kss/core Message-ID: <20071209181733.7925116856E@codespeak.net> Author: jvloothuis Date: Sun Dec 9 19:17:32 2007 New Revision: 49577 Modified: kukit/kss.core/branch/payload-fixes/kss/core/commands.py Log: Fixed the protocol so that it now properly escapes CDATA sections, transparently converts large text data to CDATA and escapes small text data using proper XML escaping. Modified: kukit/kss.core/branch/payload-fixes/kss/core/commands.py ============================================================================== --- kukit/kss.core/branch/payload-fixes/kss/core/commands.py (original) +++ kukit/kss.core/branch/payload-fixes/kss/core/commands.py Sun Dec 9 19:17:32 2007 @@ -22,6 +22,7 @@ in the defined format ''' +from xml.sax.saxutils import escape as xml_escape from zope.interface import implements from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from interfaces import IKSSCommands, IKSSCommand, IKSSParam, IKSSCommandView @@ -106,6 +107,16 @@ # just send complex data types directly with AddParam def addParam(self, name, content=''): + # Check for the size of the content. Larger than 4K will give + # problems with Firefox (which splits text nodes). Therefore + # we give this special treatment. + if len(content) > (4 * 1024): + return self.addCdataParam(name, content) + else: + # Escape all XML characters + return self._addParam(name, content=xml_escape(content)) + + def _addParam(self, name, content=''): 'Add the param as is' param = KSSParam(name, content) self.params.append(param) @@ -114,15 +125,14 @@ # # Some helpers # - - def addUnicodeParam(self, name, content=''): + def addUnicodeParam(self, name, content=u''): 'Add the param as unicode' - self.addParam(name, content=content) + self.addParam(name, content) - def addStringParam(self, name, content='', encoding='utf'): + def addStringParam(self, name, content='', encoding='utf8'): 'Add the param as an encoded string, by default UTF-8' - content = unicode(content, 'utf') - self.addParam(name, content=content) + content = unicode(content, encoding) + self.addUnicodeParam(name, content=content) def addHtmlParam(self, name, content=''): 'Add the param as an HTML content.' @@ -134,12 +144,14 @@ def addXmlParam(self, name, content=''): 'Add the param as XML content' content = XmlParser(content)().encode('ascii', 'xmlcharrefreplace') - self.addParam(name, content=content) + self._addParam(name, content=content) def addCdataParam(self, name, content=''): 'Add the param as a CDATA node' - content = '' % (content, ) - self.addParam(name, content=content) + # Replace `>` part of `]]>` with the entity ref so it won't + # accidentally close the CDATA (required by the XML spec) + content = '' % content.replace(']]>', ']]>') + self._addParam(name, content=content) # -- From gotcha at codespeak.net Sun Dec 9 20:06:39 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:06:39 +0100 (CET) Subject: [KSS-checkins] r49578 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209190639.AB52716845F@codespeak.net> Author: gotcha Date: Sun Dec 9 20:06:38 2007 New Revision: 49578 Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Log: class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Sun Dec 9 20:06:38 2007 @@ -22,53 +22,55 @@ var ar = this; /* -* class ActionRegistry +* class actionregistry * -* The local event actions need to be registered here. +* the local event actions need to be registered here. */ var ActionRegistry = function () { this.content = {}; -}; - -ActionRegistry.prototype.register = function(name, func) { -;;;if (typeof(func) == 'undefined') { -;;; kukit.E = '[func] argument is mandatory when registering an action'; -;;; kukit.E += ' [ActionRegistry.register].'; -;;; throw new Error(kukit.E); -;;;} - if (this.content[name]) { - // Do not allow redefinition -;;; kukit.logError('Error : action [' + name + '] already registered.'); - return; - } - this.content[name] = func; -}; -ActionRegistry.prototype.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); + this.register = function(name, func) { +;;; if (typeof(func) == 'undefined') { +;;; kukit.e = '[func] argument is mandatory when registering an action'; +;;; kukit.e += ' [actionregistry.register].'; +;;; throw new error(kukit.e); +;;; } + if (this.content[name]) { + // do not allow redefinition +;;; kukit.logerror('error : action [' + name + '] already registered.'); + return; + } + this.content[name] = func; + }; + + this.exists = function(name) { + var entry = this.content[name]; + return (typeof(entry) != 'undefined'); + }; + + this.get = function(name) { + var func = this.content[name]; + if (! func) { + // not found +;;; kukit.E = 'Error : undefined local action [' + name + '].'; + throw Error(kukit.E); + } + return func; + }; }; -ActionRegistry.prototype.get = function(name) { - var func = this.content[name]; - if (! func) { - // not found -;;; kukit.E = 'Error : undefined local action [' + name + '].'; - throw Error(kukit.E); - } - return func; -}; kukit.actionsGlobalRegistry = new ActionRegistry(); /* XXX deprecated methods, to be removed asap */ -ar.actionRegistry = {}; -ar.actionRegistry.register = function(name, func) { -;;;var msg='Deprecated kukit.ar.actionRegistry.register, use '; -;;;msg += 'kukit.actionsGlobalRegistry.register instead !'; -;;;kukit.logWarning(msg); - kukit.actionsGlobalRegistry.register(name, func); +ar.actionRegistry = function() { + this.register = function(name, func) { +;;; var msg='Deprecated kukit.ar.actionRegistry.register, use '; +;;; msg += 'kukit.actionsGlobalRegistry.register instead !'; +;;; kukit.logWarning(msg); + kukit.actionsGlobalRegistry.register(name, func); + }; }; }(); /// MODULE END From gotcha at codespeak.net Sun Dec 9 20:44:13 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:44:13 +0100 (CET) Subject: [KSS-checkins] r49580 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209194413.20D101684D2@codespeak.net> Author: gotcha Date: Sun Dec 9 20:44:12 2007 New Revision: 49580 Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Log: private class Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Sun Dec 9 20:44:12 2007 @@ -26,7 +26,7 @@ * * the local event actions need to be registered here. */ -var ActionRegistry = function () { +var _ActionRegistry = function () { this.content = {}; this.register = function(name, func) { @@ -60,7 +60,7 @@ }; -kukit.actionsGlobalRegistry = new ActionRegistry(); +kukit.actionsGlobalRegistry = new _ActionRegistry(); /* XXX deprecated methods, to be removed asap */ From gotcha at codespeak.net Sun Dec 9 20:44:39 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:44:39 +0100 (CET) Subject: [KSS-checkins] r49581 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209194439.3B40F1684D4@codespeak.net> Author: gotcha Date: Sun Dec 9 20:44:38 2007 New Revision: 49581 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Log: indentation Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sun Dec 9 20:44:38 2007 @@ -25,7 +25,7 @@ * class CommandProcessor */ cp.CommandProcessor = function() { - this.commands = new Array(); + this.commands = new Array(); this.parseCommands = function(commands, transport) { ;;; kukit.log('Parsing commands.'); From gotcha at codespeak.net Sun Dec 9 20:45:01 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:45:01 +0100 (CET) Subject: [KSS-checkins] r49582 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209194501.6C368168543@codespeak.net> Author: gotcha Date: Sun Dec 9 20:45:01 2007 New Revision: 49582 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandreg.js Log: class closure Modified: kukit/kukit.js/branch/finish-closures/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandreg.js Sun Dec 9 20:45:01 2007 @@ -28,6 +28,40 @@ */ var _CommandRegistry = function () { this.commands = {}; + + this.registerFromAction = + function(srcname, factory, name) { + if (typeof(name) == 'undefined') { + // allows to set a different name as the action name, + // usable for backward + // compatibility setups + name = srcname; + } + // register a given action as a command, using the given vactor + var f = kukit.actionsGlobalRegistry.get(srcname); + factory(name, f); + }; + + this.register = function(name, klass) { + if (this.commands[name]) { + // Do not allow redefinition +;;; var msg = 'ValueError : command [' + name + '] is already registered.'; +;;; kukit.logError(msg); + return; + } + this.commands[name] = klass; + }; + + this.get = function(name) { + var klass = this.commands[name]; +;;; if (! klass) { +;;; // not found +;;; var msg = 'ValueError : no command registered under [' + name + '].'; +;;; kukit.logError(msg); +;;; } + return klass; + }; + }; /* @@ -44,39 +78,6 @@ * kukit.commandsGlobalRegistry.registerFromAction('replaceInnerHTML', * kukit.cr.makeSelectorCommand); */ -_CommandRegistry.prototype.registerFromAction = - function(srcname, factory, name) { - if (typeof(name) == 'undefined') { - // allows to set a different name as the action name, - // usable for backward - // compatibility setups - name = srcname; - } - // register a given action as a command, using the given vactor - var f = kukit.actionsGlobalRegistry.get(srcname); - factory(name, f); -}; - -_CommandRegistry.prototype.register = function(name, klass) { - if (this.commands[name]) { - // Do not allow redefinition -;;; var msg = 'ValueError : command [' + name + '] is already registered.'; -;;; kukit.logError(msg); - return; - } - this.commands[name] = klass; -}; - -_CommandRegistry.prototype.get = function(name) { - var klass = this.commands[name]; -;;;if (! klass) { -;;; // not found -;;; var msg = 'ValueError : no command registered under [' + name + '].'; -;;; kukit.logError(msg); -;;; } - return klass; -}; - kukit.commandsGlobalRegistry = new _CommandRegistry(); From gotcha at codespeak.net Sun Dec 9 20:49:15 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:49:15 +0100 (CET) Subject: [KSS-checkins] r49583 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209194915.C54EA1684D2@codespeak.net> Author: gotcha Date: Sun Dec 9 20:49:15 2007 New Revision: 49583 Modified: kukit/kukit.js/branch/finish-closures/kukit/dom.js Log: class closure Modified: kukit/kukit.js/branch/finish-closures/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/dom.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/dom.js Sun Dec 9 20:49:15 2007 @@ -299,6 +299,20 @@ }; /* +* From http://xkr.us/articles/dom/iframe-document/ +* Note it's not necessary for the iframe to have the name +* attribute since we don't access it from window.frames by name. +*/ +var _getIframeDocument = function(framename) { + var iframe = document.getElementById(framename); + var doc = iframe.contentWindow || iframe.contentDocument; + if (doc.document) { + doc = doc.document; + } + return doc; +}; + +/* * class EmbeddedContentLoadedScheduler * * Scheduler for embedded window content loaded @@ -317,87 +331,73 @@ //this.counter.timeout(); // XXX can't execute immediately, it fails on IE. this.counter.start(); -}; -/* -* From http://xkr.us/articles/dom/iframe-document/ -* Note it's not necessary for the iframe to have the name -* attribute since we don't access it from window.frames by name. -*/ -var _getIframeDocument = function(framename) { - var iframe = document.getElementById(framename); - var doc = iframe.contentWindow || iframe.contentDocument; - if (doc.document) { - doc = doc.document; - } - return doc; -}; - -dom.EmbeddedContentLoadedScheduler.prototype.check = function() { - -;;;kukit.logDebug('Is iframe loaded ?'); - - var doc = _getIframeDocument(this.framename); - - // quit if the init function has already been called - // XXX I believe we want to call the function too, then - // XXX attribute access starting with _ breaks full compression, - // even in strings - //if (doc._embeddedContentLoadedInitDone) { - if (doc['_' + 'embeddedContentLoadedInitDone']) { -;;; var msg = 'Iframe already initialized, but we execute the action'; -;;; msg += ' anyway, as requested.'; -;;; kukit.logWarning(msg); - this.counter.restart = false; - } - - // autodetect=false implements a more reliable detection method - // that involves cooperation from the internal document. In this - // case the internal document sets the _kssReadyForLoadEvent attribute - // on the document, when loaded. It is safe to check for this in any - // case, however if this option is selected, we rely only on this, - // and skip the otherwise problematic default checking. - // XXX attribute access starting with _ breaks full compression, - // even in strings - //if (typeof doc._kssReadyForLoadEvent != 'undefined') { - if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') { - this.counter.restart = false; - } - - if (this.autodetect && this.counter.restart) { - - // obviously we are not there... this happens on FF - if (doc.location.href == 'about:blank') { - return; - } /* */ + this.check = function() { - // First check for Safari or - // if DOM methods are supported, and the body element exists - // (using a double-check including document.body, - // for the benefit of older moz builds [eg ns7.1] - // in which getElementsByTagName('body')[0] is undefined, - // unless this script is in the body section) +;;; kukit.logDebug('Is iframe loaded ?'); - if(/KHTML|WebKit/i.test(navigator.userAgent)) { - if(/loaded|complete/.test(doc.readyState)) { - this.counter.restart = false; - } - } else if(typeof doc.getElementsByTagName != 'undefined' - && (doc.getElementsByTagName('body')[0] != null || - doc.body != null)) { - this.counter.restart = false; - } /* */ + var doc = _getIframeDocument(this.framename); - } + // quit if the init function has already been called + // XXX I believe we want to call the function too, then + // XXX attribute access starting with _ breaks full compression, + // even in strings + //if (doc._embeddedContentLoadedInitDone) { + if (doc['_' + 'embeddedContentLoadedInitDone']) { +;;; var msg = 'Iframe already initialized, but we execute the action'; +;;; msg += ' anyway, as requested.'; +;;; kukit.logWarning(msg); + this.counter.restart = false; + } - if ( ! this.counter.restart) { -;;; kukit.logDebug('Yes, iframe is loaded.'); + // autodetect=false implements a more reliable detection method + // that involves cooperation from the internal document. In this + // case the internal document sets the _kssReadyForLoadEvent attribute + // on the document, when loaded. It is safe to check for this in any + // case, however if this option is selected, we rely only on this, + // and skip the otherwise problematic default checking. // XXX attribute access starting with _ breaks full compression, // even in strings - // doc._embeddedContentLoadedInitDone = true; - doc['_' + 'embeddedContentLoadedInitDone'] = true; - this.func(); - } + //if (typeof doc._kssReadyForLoadEvent != 'undefined') { + if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') { + this.counter.restart = false; + } + + if (this.autodetect && this.counter.restart) { + + // obviously we are not there... this happens on FF + if (doc.location.href == 'about:blank') { + return; + } /* */ + + // First check for Safari or + // if DOM methods are supported, and the body element exists + // (using a double-check including document.body, + // for the benefit of older moz builds [eg ns7.1] + // in which getElementsByTagName('body')[0] is undefined, + // unless this script is in the body section) + + if(/KHTML|WebKit/i.test(navigator.userAgent)) { + if(/loaded|complete/.test(doc.readyState)) { + this.counter.restart = false; + } + } else if(typeof doc.getElementsByTagName != 'undefined' + && (doc.getElementsByTagName('body')[0] != null || + doc.body != null)) { + this.counter.restart = false; + } /* */ + + } + + if ( ! this.counter.restart) { +;;; kukit.logDebug('Yes, iframe is loaded.'); + // XXX attribute access starting with _ breaks full compression, + // even in strings + // doc._embeddedContentLoadedInitDone = true; + doc['_' + 'embeddedContentLoadedInitDone'] = true; + this.func(); + } + }; }; dom.getNsTags = function(dom_obj, tagName) { From gotcha at codespeak.net Sun Dec 9 20:55:26 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:55:26 +0100 (CET) Subject: [KSS-checkins] r49584 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209195526.7F2ED1684D2@codespeak.net> Author: gotcha Date: Sun Dec 9 20:55:26 2007 New Revision: 49584 Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Log: private classes Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Sun Dec 9 20:55:26 2007 @@ -85,11 +85,14 @@ * this provider expects a single parameter, the string. */ -var IdentityPP = function() { +/* +* class _IdentityPP +*/ +var _IdentityPP = function() { this.check = function(args) { // check does not need to be used here actually. ;;; if (args.length != 1) { -;;; throw new Error('internal error, IdentityPP needs 1 argument'); +;;; throw new Error('internal error, _IdentityPP needs 1 argument'); ;;; } }; @@ -98,7 +101,10 @@ }; }; -var FormVarPP = function() { +/* +* class _FormVarPP +*/ +var _FormVarPP = function() { this.check = function(args) { ;;; if (args.length != 2) { ;;; throw new Error('formVar method needs 2 arguments [formname, varname]'); @@ -109,7 +115,10 @@ }; }; -var CurrentFormVarPP = function() { +/* +* class _CurrentFormPP +*/ +var _CurrentFormVarPP = function() { this.check = function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]'); @@ -126,7 +135,10 @@ }; }; -var CurrentFormVarFromKssAttrPP = function() { +/* +* class _CurrentFormVarFromKssAttrPP +*/ +var _CurrentFormVarFromKssAttrPP = function() { this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument'; @@ -152,7 +164,10 @@ /* BBB. To be deprecated at 2007-08-15 */ -var FormPP = function() { +/* +* class _FormPP +*/ +var _FormPP = function() { this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('form method needs 1 arguments [formname]'); @@ -168,7 +183,10 @@ }; /* BBB. To be deprecated at 2007-08-15 */ -var CurrentFormPP = function() { +/* +* class _CurrentFormPP +*/ +var _CurrentFormPP = function() { this.check = function(args) { ;;; if (args.length != 0) { ;;; throw new Error('currentForm method needs no argument'); @@ -183,7 +201,10 @@ }; }; -var NodeAttrPP = function() { +/* +* class _NodeAttrPP +*/ +var _NodeAttrPP = function() { this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,'; @@ -210,7 +231,10 @@ }; }; -var KssAttrPP = function() { +/* +* class _KssAttrPP +*/ +var _KssAttrPP = function() { this.check = function(args) { ;;; if (args.length != 1 && args.length != 2) { ;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,'; @@ -236,7 +260,10 @@ }; }; -var NodeContentPP = function() { +/* +* class _NodeContentPP +*/ +var _NodeContentPP = function() { this.check = function(args) { ;;; if (args.length != 0 && args.length != 1) { ;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].'); @@ -251,7 +278,10 @@ }; }; -var StateVarPP = function() { +/* +* class _StateVarPP +*/ +var _StateVarPP = function() { this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('stateVar method needs 1 argument [varname].'); @@ -269,7 +299,10 @@ }; }; -var PassPP = function() { +/* +* class _PassPP +*/ +var _PassPP = function() { this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('pass method needs 1 argument [attrname].'); @@ -290,19 +323,19 @@ kukit.pprovidersGlobalRegistry = new this.ValueProviderRegistry(); -kukit.pprovidersGlobalRegistry.register('', IdentityPP); +kukit.pprovidersGlobalRegistry.register('', _IdentityPP); kukit.pprovidersGlobalRegistry.register('currentFormVar', - CurrentFormVarPP); + _CurrentFormVarPP); kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr', - CurrentFormVarFromKssAttrPP); -kukit.pprovidersGlobalRegistry.register('formVar', FormVarPP); -kukit.pprovidersGlobalRegistry.register('kssAttr', KssAttrPP); -kukit.pprovidersGlobalRegistry.register('stateVar', StateVarPP); -kukit.pprovidersGlobalRegistry.register('pass', PassPP); -kukit.pprovidersGlobalRegistry.register('nodeContent', NodeContentPP); -kukit.pprovidersGlobalRegistry.register('nodeAttr', NodeAttrPP); -kukit.pprovidersGlobalRegistry.register('form', FormPP); -kukit.pprovidersGlobalRegistry.register('currentForm', CurrentFormPP); + _CurrentFormVarFromKssAttrPP); +kukit.pprovidersGlobalRegistry.register('formVar', _FormVarPP); +kukit.pprovidersGlobalRegistry.register('kssAttr', _KssAttrPP); +kukit.pprovidersGlobalRegistry.register('stateVar', _StateVarPP); +kukit.pprovidersGlobalRegistry.register('pass', _PassPP); +kukit.pprovidersGlobalRegistry.register('nodeContent', _NodeContentPP); +kukit.pprovidersGlobalRegistry.register('nodeAttr', _NodeAttrPP); +kukit.pprovidersGlobalRegistry.register('form', _FormPP); +kukit.pprovidersGlobalRegistry.register('currentForm', _CurrentFormPP); }(); /// MODULE END From gotcha at codespeak.net Sun Dec 9 20:57:52 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 20:57:52 +0100 (CET) Subject: [KSS-checkins] r49585 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209195752.0F4991684D2@codespeak.net> Author: gotcha Date: Sun Dec 9 20:57:52 2007 New Revision: 49585 Modified: kukit/kukit.js/branch/finish-closures/kukit/errors.js Log: private class Modified: kukit/kukit.js/branch/finish-closures/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/errors.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/errors.js Sun Dec 9 20:57:52 2007 @@ -54,8 +54,10 @@ * */ - -var ErrorAnnotation = function() { +/* +* class _ErrorAnnotation +*/ +var _ErrorAnnotation = function() { this.constructError = function(e, name, message, kw) { ;;; if (typeof(kw) == "undefined") { @@ -102,7 +104,7 @@ }; var setErrorInfo = function(e, name, message, kw) { - return new ErrorAnnotation().constructError(e, name, message, kw); + return new _ErrorAnnotation().constructError(e, name, message, kw); }; /* Protects a function */ From gotcha at codespeak.net Sun Dec 9 21:37:22 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 9 Dec 2007 21:37:22 +0100 (CET) Subject: [KSS-checkins] r49586 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071209203722.00144168546@codespeak.net> Author: gotcha Date: Sun Dec 9 21:37:21 2007 New Revision: 49586 Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Log: class closure Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Sun Dec 9 21:37:21 2007 @@ -31,219 +31,222 @@ * * usage: * -* kukit.eventsGlobalRegistry.register(namespace, eventName, func, +* kukit.eventsGlobalRegistry.register(namespace, eventName, func, * bindMethodName, defaultActionMethodName); -* -* namespace = null: means global namespace -* defaultActionMethodName = null: if there is no default action implemented -* func must be a class (constructor) function, this is the class that -* implements the binder. +* +* namespace = null: means global namespace +* defaultActionMethodName = null: if there is no default action implemented +* func must be a class (constructor) function, this is the class that +* implements the binder. +* */ var _EventRegistry = function () { this.content = {}; this.classes = {}; this.eventSets = []; -}; /* binder registration */ -_EventRegistry.prototype.registerBinder = function(className, func) { - if (typeof(func) == 'undefined') { -;;; kukit.E = 'func argument is mandatory when registering an event'; -;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; - throw new Error(kukit.E); - } - if (this.classes[className]) { - // Do not allow redefinition -;;; var msg = 'Error : event class [' + className + '] already registered.'; -;;; kukit.logError(msg); - return; - - } - // Decorate and store the class - decorateEventBinderClass(func); - this.classes[className] = func; -}; + this.registerBinder = function(className, func) { + if (typeof(func) == 'undefined') { +;;; kukit.E = 'func argument is mandatory when registering an event'; +;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; + throw new Error(kukit.E); + } + if (this.classes[className]) { + // Do not allow redefinition +;;; var msg = 'Error : event class [' + className + '] already registered.'; +;;; kukit.logError(msg); + return; + + } + // Decorate and store the class + decorateEventBinderClass(func); + this.classes[className] = func; + }; + + this.existsBinder = function(className) { + var func = this.classes[className]; + return (typeof(func) != 'undefined'); + }; + + this.getBinderClass = function(className) { + var func = this.classes[className]; + if (! func) { + // not found +;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; + throw new Error(kukit.E); + } + return func; + }; -_EventRegistry.prototype.existsBinder = function(className) { - var func = this.classes[className]; - return (typeof(func) != 'undefined'); -}; + /* events (methods) registration helpers (not to be called directly) */ -_EventRegistry.prototype.getBinderClass = function(className) { - var func = this.classes[className]; - if (! func) { - // not found -;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; - throw new Error(kukit.E); + this._register = + function(namespace, eventName, klass, + bindMethodName, defaultActionMethodName, iterName) { + if (typeof(defaultActionMethodName) == 'undefined') { +;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; + throw new Error(kukit.E); } - return func; -}; + // Find out the class name. (Not specified now.) + var className = klass.prototype.__className__; + if (typeof(className) == 'undefined') { + // Create a className, and register it too. + className = '' + _eventClassCounter; + _eventClassCounter += 1; + this.registerBinder(className, klass); + klass.prototype.__className__ = className; + } + if (!eventName) { +;;; kukit.E = '[eventName] argument cannot be empty when registering'; +;;; kukit.E += ' an event with [_EventRegistry.register].'; + throw new Error(kukit.E); + } + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + if (typeof(entry) != 'undefined') { + if (key[0] == '-') { + key = key.substring(1); + } +;;; kukit.E = 'Attempt to register key [' + key; +;;; kukit.E += '] twice when registering'; +;;; kukit.E += ' an event with [_EventRegistry.register].'; + throw new Error(kukit.E); + } + // check bindMethodName and defaultActionMethodName + if (bindMethodName && ! klass.prototype[bindMethodName]) { +;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; +;;; kukit.E += '] is undefined for event [' + eventName; +;;; kukit.E += '] namespace [' + namespace + '].'; + throw new Error(kukit.E); + } + if (defaultActionMethodName && ! klass.prototype[defaultActionMethodName]) { +;;; kukit.E = 'In _EventRegistry.register default action method ['; +;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; +;;; kukit.E += eventName + '] namespace [' + namespace + '].'; + throw new Error(kukit.E); + } + // check the iterator. + if (! er.getBindIterator(iterName)) { +;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; +;;; kukit.E += iterName + '].'; + throw new Error(kukit.E); + } + // register it + this.content[key] = { + 'className': className, + 'bindMethodName': bindMethodName, + 'defaultActionMethodName': defaultActionMethodName, + 'iterName': iterName + }; + }; -/* events (methods) registration helpers (not to be called directly) */ + /* events (methods) binding [ForAll] registration */ -_EventRegistry.prototype._register = - function(namespace, eventName, klass, - bindMethodName, defaultActionMethodName, iterName) { - if (typeof(defaultActionMethodName) == 'undefined') { -;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // Find out the class name. (Not specified now.) - var className = klass.prototype.__className__; - if (typeof(className) == 'undefined') { - // Create a className, and register it too. - className = '' + _eventClassCounter; - _eventClassCounter += 1; - this.registerBinder(className, klass); - klass.prototype.__className__ = className; - } - if (!eventName) { -;;; kukit.E = '[eventName] argument cannot be empty when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - if (typeof(entry) != 'undefined') { - if (key[0] == '-') { - key = key.substring(1); - } -;;; kukit.E = 'Attempt to register key [' + key; -;;; kukit.E += '] twice when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // check bindMethodName and defaultActionMethodName - if (bindMethodName && ! klass.prototype[bindMethodName]) { -;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; -;;; kukit.E += '] is undefined for event [' + eventName; -;;; kukit.E += '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - if (defaultActionMethodName && ! klass.prototype[defaultActionMethodName]) { -;;; kukit.E = 'In _EventRegistry.register default action method ['; -;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; -;;; kukit.E += eventName + '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - // check the iterator. - if (! er.getBindIterator(iterName)) { -;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; -;;; kukit.E += iterName + '].'; - throw new Error(kukit.E); - } - // register it - this.content[key] = { - 'className': className, - 'bindMethodName': bindMethodName, - 'defaultActionMethodName': defaultActionMethodName, - 'iterName': iterName - }; -}; - -/* events (methods) binding [ForAll] registration */ - -_EventRegistry.prototype._registerEventSet = - function(namespace, names, iterName, bindMethodName) { - // At this name the values should be checked already. so this should - // be called _after_ _register. - this.eventSets.push({ - 'namespace': namespace, - 'names': names, - 'iterName': iterName, - 'bindMethodName': bindMethodName - }); -}; - -/* there are the actual registration methods, to be called from plugins */ - -_EventRegistry.prototype.register = - function(namespace, eventName, klass, bindMethodName, - defaultActionMethodName) { - this._register(namespace, eventName, klass, bindMethodName, - defaultActionMethodName, 'EachLegacy'); - this._registerEventSet(namespace, [eventName], 'EachLegacy', - bindMethodName); -}; - -_EventRegistry.prototype.unregister = - function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - delete this.content[key]; - var found = null; - for (var i=0; i < this.eventSets.length; i++) { - var eventSet = this.eventSets[i]; - if (eventSet['namespace'] == namespace) { - found = i; - break; + this._registerEventSet = + function(namespace, names, iterName, bindMethodName) { + // At this name the values should be checked already. so this should + // be called _after_ _register. + this.eventSets.push({ + 'namespace': namespace, + 'names': names, + 'iterName': iterName, + 'bindMethodName': bindMethodName + }); + }; + + /* there are the actual registration methods, to be called from plugins */ + + this.register = + function(namespace, eventName, klass, bindMethodName, + defaultActionMethodName) { + this._register(namespace, eventName, klass, bindMethodName, + defaultActionMethodName, 'EachLegacy'); + this._registerEventSet(namespace, [eventName], 'EachLegacy', + bindMethodName); + }; + + this.unregister = + function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + delete this.content[key]; + var found = null; + for (var i=0; i < this.eventSets.length; i++) { + var eventSet = this.eventSets[i]; + if (eventSet['namespace'] == namespace) { + found = i; + break; + } } - } - if (found != null) { - this.eventSets.splice(found, 1); - } -}; + if (found != null) { + this.eventSets.splice(found, 1); + } + }; -_EventRegistry.prototype.registerForAllEvents = - function(namespace, eventNames, klass, - bindMethodName, defaultActionMethodName, iterName) { - if (typeof(eventNames) == 'string') { - eventNames = [eventNames]; - } - for (var i=0; i 1) { +;;; kukit.E = 'In [_EventRegistry.register], [namespace] cannot have'; +;;; kukit.E += 'dashes.'; + throw new Error(kukit.E); + } + return namespace + '-' + eventName; + }; -_EventRegistry.prototype._getKey = function(namespace, eventName) { - if (namespace == null) { - namespace = ''; - } else if (namespace.split('-') > 1) { -;;; kukit.E = 'In [_EventRegistry.register], [namespace] cannot have'; -;;; kukit.E += 'dashes.'; - throw new Error(kukit.E); - } - return namespace + '-' + eventName; + this.exists = function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + return (typeof(entry) != 'undefined'); + }; + + this.get = function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + if (typeof(entry) == 'undefined') { +;;; if (key.substr(0, 1) == '-') { +;;; key = key.substring(1); +;;; kukit.E = 'Error : undefined global event ['; +;;; kukit.E += key + '] (or maybe namespace is missing ?).'; +;;; } else { +;;; kukit.E = 'Error : undefined namespace or event in [' + key + '].'; +;;; } + throw new Error(kukit.E); + } + return entry; + }; }; -_EventRegistry.prototype.exists = function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - return (typeof(entry) != 'undefined'); -}; - -_EventRegistry.prototype.get = function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - if (typeof(entry) == 'undefined') { -;;; if (key.substr(0, 1) == '-') { -;;; key = key.substring(1); -;;; kukit.E = 'Error : undefined global event ['; -;;; kukit.E += key + '] (or maybe namespace is missing ?).'; -;;; } else { -;;; kukit.E = 'Error : undefined namespace or event in [' + key + '].'; -;;; } - throw new Error(kukit.E); - } - return entry; -}; kukit.eventsGlobalRegistry = new _EventRegistry(); /* XXX deprecated methods, to be removed asap */ -var _eventRegistry = {}; -_eventRegistry.register = function(namespace, eventName, klass, - bindMethodName, defaultActionMethodName) { -;;; var msg = 'Deprecated _eventRegistry.register,'; -;;; msg += ' use kukit.eventsGlobalRegistry.register instead ! ['; -;;; msg += namespace + '-' + eventName + '].'; -;;; kukit.logWarning(msg); - kukit.eventsGlobalRegistry.register(namespace, eventName, klass, - bindMethodName, defaultActionMethodName); +var _eventRegistry = function() { + this.register = function(namespace, eventName, klass, + bindMethodName, defaultActionMethodName) { +;;; var msg = 'Deprecated _eventRegistry.register,'; +;;; msg += ' use kukit.eventsGlobalRegistry.register instead ! ['; +;;; msg += namespace + '-' + eventName + '].'; +;;; kukit.logWarning(msg); + kukit.eventsGlobalRegistry.register(namespace, eventName, klass, + bindMethodName, defaultActionMethodName); + }; }; /* Event class decoration @@ -408,34 +411,34 @@ this.name = name; this.node = node; this.boundEvent = null; -}; -_LateBinder.prototype.executeActions = function() { - if (! this.boundEvent) { -;;; var msg = 'Attempt of late binding for event [' + this.name; -;;; msg += '], node [' + this.node.nodeName + '].'; -;;; kukit.log(msg); - if (kukit.hasFirebug) { - kukit.log(this.node); - } - var info = kukit.engine.binderInfoRegistry.getBinderInfoById( - this.binder.__binderId__); - var oper = info.bound.getBoundOperForNode(this.name, this.node); - if (oper) { - // (if eventRule is null here, we could still have the default - // method, so go on.) - oper.parms = {}; - this.boundEvent = function() { - this.binder._EventBinder_triggerEvent(this.name, oper); - }; -;;; kukit.log('Node bound.'); - } else { -;;; kukit.logWarning('No node bound.'); - this.boundEvent = function() {}; + this.executeActions = function() { + if (! this.boundEvent) { +;;; var msg = 'Attempt of late binding for event [' + this.name; +;;; msg += '], node [' + this.node.nodeName + '].'; +;;; kukit.log(msg); + if (kukit.hasFirebug) { + kukit.log(this.node); + } + var info = kukit.engine.binderInfoRegistry.getBinderInfoById( + this.binder.__binderId__); + var oper = info.bound.getBoundOperForNode(this.name, this.node); + if (oper) { + // (if eventRule is null here, we could still have the default + // method, so go on.) + oper.parms = {}; + this.boundEvent = function() { + this.binder._EventBinder_triggerEvent(this.name, oper); + }; +;;; kukit.log('Node bound.'); + } else { +;;; kukit.logWarning('No node bound.'); + this.boundEvent = function() {}; + } } - } - this.boundEvent(); -}; + this.boundEvent(); + }; +}; var _EventBinder_triggerEvent = function(name, oper) { // Private. Called from __continueEvent__ or from main event execution. @@ -499,82 +502,82 @@ er.BinderInfoRegistry = function () { this.info = {}; -}; - -er.BinderInfoRegistry.prototype.getOrCreateBinderInfo = - function (id, className, namespace) { - // Get or create the event. - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { - // Create a new event. -;;; var msg = 'Instantiating event id [' + id + '], className ['; -;;; msg += className + '], namespace [' + namespace + '].'; -;;; kukit.logDebug(msg); - var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); - var binder = new binderClass(); - - binderInfo = this.info[id] = new _BinderInfo(binder); - - // decorate it with id and class - binder.__binderId__ = id; - binder.__binderClassName__ = className; - binder.__eventNamespace__ = namespace; - // store the bound rules - //binder.__bound_rules__ = []; - } else if (binderInfo.getBinder().__binderClassName__ != - className) { - // just paranoia -;;; kukit.E = 'Conflicting class for event id [' + id + '], ['; -;;; kukit.E += binderInfo.getBinder().__binderClassName__; -;;; kukit.E += '] != [' + className + '].'; - throw new Error(kukit.E); - } - return binderInfo; -}; -er.BinderInfoRegistry.prototype.getBinderInfoById = function (id) { - // Get an event. - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { -;;; kukit.E = 'Event with id [' + id + '] not found.'; - throw new Error(kukit.E); - } - return binderInfo; -}; - -er.BinderInfoRegistry.prototype.getSingletonBinderInfoByName = - function (namespace, name) { - //Get className - var className = kukit.eventsGlobalRegistry.get(namespace, name).className; - // Get an event. - var id = er.makeId(namespace, className); - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { -;;; kukit.E = 'Singleton event with namespace [' + namespace; -;;; kukit.E += '] and (event) name [' + name + '] not found.'; - throw new Error(kukit.E); - } - return binderInfo; -}; + this.getOrCreateBinderInfo = + function (id, className, namespace) { + // Get or create the event. + var binderInfo = this.info[id]; + if (typeof(binderInfo) == 'undefined') { + // Create a new event. +;;; var msg = 'Instantiating event id [' + id + '], className ['; +;;; msg += className + '], namespace [' + namespace + '].'; +;;; kukit.logDebug(msg); + var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); + var binder = new binderClass(); + + binderInfo = this.info[id] = new _BinderInfo(binder); + + // decorate it with id and class + binder.__binderId__ = id; + binder.__binderClassName__ = className; + binder.__eventNamespace__ = namespace; + // store the bound rules + //binder.__bound_rules__ = []; + } else if (binderInfo.getBinder().__binderClassName__ != + className) { + // just paranoia +;;; kukit.E = 'Conflicting class for event id [' + id + '], ['; +;;; kukit.E += binderInfo.getBinder().__binderClassName__; +;;; kukit.E += '] != [' + className + '].'; + throw new Error(kukit.E); + } + return binderInfo; + }; -er.BinderInfoRegistry.prototype.startBindingPhase = function () { - // At the end of the binding phase, we want to process our events. This - // must include all the binder instances we bound in this phase. - for (var id in this.info) { + this.getBinderInfoById = function (id) { + // Get an event. var binderInfo = this.info[id]; - // process binding on this instance. - binderInfo.startBindingPhase(); - } -}; + if (typeof(binderInfo) == 'undefined') { +;;; kukit.E = 'Event with id [' + id + '] not found.'; + throw new Error(kukit.E); + } + return binderInfo; + }; -er.BinderInfoRegistry.prototype.processBindingEvents = function () { - // At the end of the binding phase, we want to process our events. This - // must include all the binder instances we bound in this phase. - for (var id in this.info) { + this.getSingletonBinderInfoByName = + function (namespace, name) { + //Get className + var className = kukit.eventsGlobalRegistry.get(namespace, name).className; + // Get an event. + var id = er.makeId(namespace, className); var binderInfo = this.info[id]; - // process binding on this instance. - binderInfo.processBindingEvents(); - } + if (typeof(binderInfo) == 'undefined') { +;;; kukit.E = 'Singleton event with namespace [' + namespace; +;;; kukit.E += '] and (event) name [' + name + '] not found.'; + throw new Error(kukit.E); + } + return binderInfo; + }; + + this.startBindingPhase = function () { + // At the end of the binding phase, we want to process our events. This + // must include all the binder instances we bound in this phase. + for (var id in this.info) { + var binderInfo = this.info[id]; + // process binding on this instance. + binderInfo.startBindingPhase(); + } + }; + + this.processBindingEvents = function () { + // At the end of the binding phase, we want to process our events. This + // must include all the binder instances we bound in this phase. + for (var id in this.info) { + var binderInfo = this.info[id]; + // process binding on this instance. + binderInfo.processBindingEvents(); + } + }; }; /* @@ -588,163 +591,153 @@ var _BinderInfo = function (binder) { this.binder = binder; this.bound = new _OperRegistry(); - this.startBindingPhase(); -}; - -_BinderInfo.prototype.getBinder = function () { - return this.binder; -}; -_BinderInfo.prototype.startBindingPhase = function () { - // The binding phase starts and it has the information for - // the currently on-bound events. - this.binding = new _OperRegistry(); -}; + this.getBinder = function () { + return this.binder; + }; + + this.startBindingPhase = function () { + // The binding phase starts and it has the information for + // the currently on-bound events. + this.binding = new _OperRegistry(); + }; + + this.bindOper = function (oper) { + // We mark a given oper. This means a binding on the binder + // for given event, node and eventRule (containing event namespace, + // name, and evt- parms.) + // + // first see if it can go to already bound ones + this.bound.checkOperBindable(oper); + // then register it properly to the binding events + this.binding.bindOper(oper); + }; + + this.processBindingEvents = function () { + // We came to the end of the binding phase. Now we process all our binding + // events, This will do the actual binding on the browser side. + this.binding.processBindingEvents(this.binder); + // Now we to add these to the new ones. + this.binding.propagateTo(this.bound); + // Delete them from the registry, to protect against accidents. + this.binding = null; + }; -_BinderInfo.prototype.bindOper = function (oper) { - // We mark a given oper. This means a binding on the binder - // for given event, node and eventRule (containing event namespace, - // name, and evt- parms.) - // - // first see if it can go to already bound ones - this.bound.checkOperBindable(oper); - // then register it properly to the binding events - this.binding.bindOper(oper); -}; - -_BinderInfo.prototype.processBindingEvents = function () { - // We came to the end of the binding phase. Now we process all our binding - // events, This will do the actual binding on the browser side. - this.binding.processBindingEvents(this.binder); - // Now we to add these to the new ones. - this.binding.propagateTo(this.bound); - // Delete them from the registry, to protect against accidents. - this.binding = null; + this.startBindingPhase(); }; +var _iterators = {}; -/* -* class _OperRegistry -* -* OperRegistry is associated with a binder instance in the -* BinderInfoRegistry, and remembers bounding information. -* This is used both to remember all the bindings for a given -* instance, but also just to remember the bindings done during -* a given event setup phase. -*/ - -var _OperRegistry = function () { - this.infoPerName = {}; - this.infoPerNode = {}; -}; - -// XXX we can do this without full cloning, more efficiently. -_OperRegistry.prototype.propagateTo = function (newreg) { - for (var key in this.infoPerName) { - var rulesPerName = this.infoPerName[key]; - for (var name in rulesPerName) { - var oper = rulesPerName[name]; - newreg.bindOper(oper); + // This calls the bind method by each bound oper one by one. + // Eventname and funcToBind are passed too. + // this is the legacy ([EachLegacy]) way + _iterators['EachLegacy'] = + function (eventSet, binder) { + for (var i=0; i An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071212/b3800da1/attachment.htm From reebalazs at codespeak.net Thu Dec 13 13:08:09 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 13 Dec 2007 13:08:09 +0100 (CET) Subject: [KSS-checkins] r49702 - kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071213120809.A9BFE168487@codespeak.net> Author: reebalazs Date: Thu Dec 13 13:08:09 2007 New Revision: 49702 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/inline_edit.html Log: I think this fixes the inline edit test Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/inline_edit.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/inline_edit.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/inline_edit.html Thu Dec 13 13:08:09 2007 @@ -30,13 +30,8 @@ waitForValue - value - click me! - - - assertValue - value - click me! + save + save type From reebalazs at codespeak.net Thu Dec 13 13:49:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 13 Dec 2007 13:49:01 +0100 (CET) Subject: [KSS-checkins] r49710 - kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071213124901.708C3168453@codespeak.net> Author: reebalazs Date: Thu Dec 13 13:49:00 2007 New Revision: 49710 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/selectors.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_selects.html Log: Attempt to fix the missing newline asserts. Apparently text of nodes taken from the dom is separated by newline now, however this is not totally consistent. All tests GREEN now (one known broken) Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/selectors.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/selectors.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/selectors.html Thu Dec 13 13:49:00 2007 @@ -25,8 +25,8 @@ assertText - target - Target Click me! + parentnodeok + Click me! click Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html Thu Dec 13 13:49:00 2007 @@ -16,7 +16,7 @@ assertText first-master - animals machines + animals machines assertText @@ -56,7 +56,7 @@ assertText second-master - animals machines + animals machines assertText @@ -96,7 +96,7 @@ assertText third-master - animals machines + animals machines assertText Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_selects.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_selects.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/two_selects.html Thu Dec 13 13:49:00 2007 @@ -16,7 +16,7 @@ assertText first - animals machines + animals machines assertText From reebalazs at codespeak.net Thu Dec 13 14:10:48 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 13 Dec 2007 14:10:48 +0100 (CET) Subject: [KSS-checkins] r49712 - kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071213131048.6D6261684D0@codespeak.net> Author: reebalazs Date: Thu Dec 13 14:10:47 2007 New Revision: 49712 Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/form_submit.html Log: Fix form submit test, fix waiting condition Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/form_submit.html ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/form_submit.html (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/form_submit.html Thu Dec 13 14:10:47 2007 @@ -109,6 +109,11 @@ + waitForTextPresent + dring + + + verifyTextPresent Async saved: From gotcha at codespeak.net Sun Dec 16 20:53:38 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 16 Dec 2007 20:53:38 +0100 (CET) Subject: [KSS-checkins] r49854 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071216195338.203DD168480@codespeak.net> Author: gotcha Date: Sun Dec 16 20:53:37 2007 New Revision: 49854 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandreg.js kukit/kukit.js/branch/finish-closures/kukit/forms.js kukit/kukit.js/branch/finish-closures/kukit/kukit.js Log: class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandreg.js Sun Dec 16 20:53:37 2007 @@ -142,22 +142,20 @@ }; cr.makeSelectorCommand = function(name, executeOnSingleNode) { - var commandClass = function() {}; - commandClass.prototype = { - execute: _executeCommand, - executeOnScope: _executeCommandOnSelector, - executeOnSingleNode: executeOnSingleNode - }; + var commandClass = function() { + this.execute = _executeCommand; + this.executeOnScope = _executeCommandOnSelector; + this.executeOnSingleNode = executeOnSingleNode; + }; kukit.commandsGlobalRegistry.register(name, commandClass); }; cr.makeGlobalCommand = function(name, executeOnce) { - var commandClass = function() {}; - commandClass.prototype = { - execute: _executeCommand, - executeOnScope: executeOnce, - executeOnSingleNode: executeOnce - }; + var commandClass = function() { + this.execute = _executeCommand; + this.executeOnScope = executeOnce; + this.executeOnSingleNode = executeOnce; + }; kukit.commandsGlobalRegistry.register(name, commandClass); }; Modified: kukit/kukit.js/branch/finish-closures/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/forms.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/forms.js Sun Dec 16 20:53:37 2007 @@ -38,10 +38,11 @@ var _FormQueryElem = function(name, value) { this.name = name; this.value = value; -}; -_FormQueryElem.prototype.encode = function() { - return this.name+ "=" + encodeURIComponent(this.value); + this.encode = function() { + return this.name+ "=" + encodeURIComponent(this.value); + }; + }; /* @@ -49,56 +50,56 @@ */ fo.FormQuery = function() { this.l = []; -}; -fo.FormQuery.prototype.appendElem = function(name, value) { - if (value == null) { - // do not marshall nulls -;;; var msg = "Parameter '" + name + "' is null,"; -;;; msg += " it is not marshalled."; -;;; kukit.logDebug(msg); - } - else if (typeof(value) == 'string') { - var elem = new _FormQueryElem(name, value); - this.l.push(elem); - } - // value.length is for detection of an Array. - // In addition we also check that value.pop is a function - else if (typeof(value) == 'object' && - typeof(value.length) == 'number' && - typeof(value.pop) == 'function') { - // Special marshalling of arrays - for (var i=0; i < value.length; i++) { - var elem = new _FormQueryElem(name, value[i]); + this.appendElem = function(name, value) { + if (value == null) { + // do not marshall nulls +;;; var msg = "Parameter '" + name + "' is null,"; +;;; msg += " it is not marshalled."; +;;; kukit.logDebug(msg); + } + else if (typeof(value) == 'string') { + var elem = new _FormQueryElem(name, value); this.l.push(elem); } - } - else if (typeof(value) == 'object') { - // Special marshalling of dicts - for (var key in value) { - var qkey = _dictPrefix + name + _dictSeparator; - qkey += key + _dictPostfix; - var elem = new _FormQueryElem(qkey, value[key]); - this.l.push(elem); + // value.length is for detection of an Array. + // In addition we also check that value.pop is a function + else if (typeof(value) == 'object' && + typeof(value.length) == 'number' && + typeof(value.pop) == 'function') { + // Special marshalling of arrays + for (var i=0; i < value.length; i++) { + var elem = new _FormQueryElem(name, value[i]); + this.l.push(elem); + } } - } -}; + else if (typeof(value) == 'object') { + // Special marshalling of dicts + for (var key in value) { + var qkey = _dictPrefix + name + _dictSeparator; + qkey += key + _dictPostfix; + var elem = new _FormQueryElem(qkey, value[key]); + this.l.push(elem); + } + } + }; -fo.FormQuery.prototype.encode = function() { - var poster = []; - for (var i=0;i < this.l.length;i++) { - poster[poster.length] = this.l[i].encode(); - } - return poster.join("&"); -}; + this.encode = function() { + var poster = []; + for (var i=0;i < this.l.length;i++) { + poster[poster.length] = this.l[i].encode(); + } + return poster.join("&"); + }; -fo.FormQuery.prototype.toDict = function() { - var d = {}; - for (var i=0;i < this.l.length;i++) { - var elem = this.l[i]; - d[elem.name] = elem.value; - } - return d; + this.toDict = function() { + var d = {}; + for (var i=0;i < this.l.length;i++) { + var elem = this.l[i]; + d[elem.name] = elem.value; + } + return d; + }; }; /* Form data extraction, helpers */ @@ -122,29 +123,29 @@ fo.CurrentFormLocator = function(target) { this.target = target; -}; -fo.CurrentFormLocator.prototype.queryForm = function() { - // Find the form that contains the target node. - return findContainer(this.target, function(node) { - if (!node.nodeName) { - return false; - } - if (node.nodeName.toLowerCase() == "form") { - return true; - } else { - return false; - } - }); -}; + this.queryForm = function() { + // Find the form that contains the target node. + return findContainer(this.target, function(node) { + if (!node.nodeName) { + return false; + } + if (node.nodeName.toLowerCase() == "form") { + return true; + } else { + return false; + } + }); + }; -fo.CurrentFormLocator.prototype.getForm = function() { - var form = this.queryForm(); - if (!form) { -;;; kukit.logWarning("No form found"); - return null; - } - return form; + this.getForm = function() { + var form = this.queryForm(); + if (!form) { +;;; kukit.logWarning("No form found"); + return null; + } + return form; + }; }; /* @@ -154,15 +155,14 @@ fo.NamedFormLocator = function(formname) { this.formname = formname; -}; -fo.NamedFormLocator.prototype.queryForm = function() { - // Find the form with the given name. - return document.forms[this.formname]; -}; + this.getForm = fo.CurrentFormLocator.getForm; -fo.NamedFormLocator.prototype.getForm = - fo.CurrentFormLocator.prototype.getForm; + this.queryForm = function() { + // Find the form with the given name. + return document.forms[this.formname]; + }; +}; /* methods to take the desired value(s) from the form */ @@ -279,27 +279,27 @@ */ var _FieldUpdateRegistry = function() { this.editors = {}; -}; - -_FieldUpdateRegistry.prototype.register = function(node, editor) { - var hash = kukit.rd.hashNode(node); - if (typeof(this.editors[hash]) != 'undefined') { -;;; kukit.E = 'Double registration of editor update on node.'; - throw new Error(kukit.E); - } - this.editors[hash] = editor; - //kukit.logDebug('Registered '+node.name + ' hash=' + hash); - //Initialize the editor - editor.doInit(); -}; -_FieldUpdateRegistry.prototype.doUpdate = function(node) { - var hash = kukit.rd.hashNode(node); - var editor = this.editors[hash]; - if (typeof(editor) != 'undefined') { - editor.doUpdate(node); - //kukit.logDebug('Updated '+node.name + ' hash=' + hash); - } + this.register = function(node, editor) { + var hash = kukit.rd.hashNode(node); + if (typeof(this.editors[hash]) != 'undefined') { +;;; kukit.E = 'Double registration of editor update on node.'; + throw new Error(kukit.E); + } + this.editors[hash] = editor; + //kukit.logDebug('Registered '+node.name + ' hash=' + hash); + //Initialize the editor + editor.doInit(); + }; + + this.doUpdate = function(node) { + var hash = kukit.rd.hashNode(node); + var editor = this.editors[hash]; + if (typeof(editor) != 'undefined') { + editor.doUpdate(node); + //kukit.logDebug('Updated '+node.name + ' hash=' + hash); + } + }; }; // fieldUpdateRegistry is a public service, available to all components @@ -321,20 +321,20 @@ * class _FormValueProvider * */ -var _FormValueProvider = function() {}; - -_FormValueProvider.prototype = { - check: function(args) { +var _FormValueProvider = function() { + this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('form method needs 1 arguments (formname)'); ;;; } - }, - eval: function(args, node) { + }; + + this.eval = function(args, node) { var locator = new fo.NamedFormLocator(args[0]); var collector = new kukit.ut.TupleCollector(); return fo.getAllFormVars(locator, collector); - } + }; }; + fo.pproviderFormRegistry.register('form', _FormValueProvider); /* @@ -342,19 +342,20 @@ * class _CurrentFormValueProvider * */ -var _CurrentFormValueProvider = function() {}; -_CurrentFormValueProvider.prototype = { - check: function(args) { +var _CurrentFormValueProvider = function() { + this.check = function(args) { ;;; if (args.length != 0) { ;;; throw new Error('currentForm method needs no argument'); ;;; } - }, - eval: function(args, node) { + }; + + this.eval = function(args, node) { var locator = new fo.CurrentFormLocator(node); var collector = new kukit.ut.TupleCollector(); return fo.getAllFormVars(locator, collector); - } + }; }; + fo.pproviderFormRegistry.register('currentForm', _CurrentFormValueProvider); // If a string is given, that will look like a form lookup, Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kukit.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js Sun Dec 16 20:53:37 2007 @@ -24,12 +24,26 @@ ku.isDevelMode = false; ;;; ku.isDevelMode = true; +var _isKineticStylesheet = function(node) { + var rel = node.rel; + if (rel=="kinetic-stylesheet") { + return true; + } + // BBB to be removed after 2008-02-17 + if (rel=="kukit" || rel=="k-stylesheet") { +;;; var msg = node.href + ': rel "' + rel +'" is deprecated;'; +;;; msg = msg + ' use "kinetic-stylesheet" instead.'; +;;; kukit.logWarning(msg); + return true; + } + return false; +}; + /* * class Engine */ ku.Engine = function() { - this.baseUrl = this.calculateBase(); this.documentRules = new kukit.rd.MethodTable(); // table from res_type to rule processor this._ruleProcessorClasses = {}; @@ -49,243 +63,226 @@ this.setupEventsQueue = []; this.setupEventsInProgress = false; -}; - -ku.Engine.prototype.calculateBase = function() { - var base = ''; - try { - var _dummy = document; - _dummy = window; - } catch (e) { - // testing or what - return base; - } - var nodes = document.getElementsByTagName("link"); - if (nodes.length > 0) { - for (var i=0; i 0) { + for (var i=0; i 0 && base.substring(baselen - 1) == '/') { - base = base.substring(0, baselen - 1); + nodes = document.getElementsByTagName("base"); + if (nodes.length == 0) { + var base = window.location.href; + var pieces = base.split('/'); + pieces.pop(); + base = pieces.join('/'); + } else { + base = nodes[0].href; + // take off trailing slash + var baselen = base.length; + if (baselen > 0 && base.substring(baselen - 1) == '/') { + base = base.substring(0, baselen - 1); + } } - } - return base; -}; + return base; + }; + this.baseUrl = this.calculateBase(); -ku.Engine.prototype.getRuleSheetLinks = function() { - var nodes = document.getElementsByTagName("link"); - var results = []; - for (var i=0; i Author: gotcha Date: Sun Dec 16 20:54:07 2007 New Revision: 49855 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: module and class closures -- step 1 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Sun Dec 16 20:54:07 2007 @@ -19,36 +19,38 @@ /* Tokens of the KSS parser */ -kukit.kssp = {}; +kukit.kssp = new function() { /// MODULE START + +var kssp = this; /* Tokens */ -kukit.kssp.openComment = kukit.tk.mkToken('openComment', "\/\*"); -kukit.kssp.closeComment = kukit.tk.mkToken('closeComment', "\*\/"); -kukit.kssp.openBrace = kukit.tk.mkToken('openBrace', "{"); -kukit.kssp.closeBrace = kukit.tk.mkToken('closeBrace', "}"); -kukit.kssp.openBracket = kukit.tk.mkToken('openBracket', "["); -kukit.kssp.closeBracket = kukit.tk.mkToken('closeBracket', "]"); -kukit.kssp.openParent = kukit.tk.mkToken('openParent', "("); -kukit.kssp.closeParent = kukit.tk.mkToken('closeParent', ")"); -kukit.kssp.semicolon = kukit.tk.mkToken('semicolon', ";"); -kukit.kssp.colon = kukit.tk.mkToken('colon', ":"); -kukit.kssp.quote = kukit.tk.mkToken('quote', "'"); -kukit.kssp.dquote = kukit.tk.mkToken('dquote', '"'); -kukit.kssp.backslash = kukit.tk.mkToken('backslash', '\x5c'); -kukit.kssp.comma = kukit.tk.mkToken('comma', ","); -kukit.kssp.equals = kukit.tk.mkToken('equals', "="); +kssp.openComment = kukit.tk.mkToken('openComment', "\/\*"); +kssp.closeComment = kukit.tk.mkToken('closeComment', "\*\/"); +kssp.openBrace = kukit.tk.mkToken('openBrace', "{"); +kssp.closeBrace = kukit.tk.mkToken('closeBrace', "}"); +kssp.openBracket = kukit.tk.mkToken('openBracket', "["); +kssp.closeBracket = kukit.tk.mkToken('closeBracket', "]"); +kssp.openParent = kukit.tk.mkToken('openParent', "("); +kssp.closeParent = kukit.tk.mkToken('closeParent', ")"); +kssp.semicolon = kukit.tk.mkToken('semicolon', ";"); +kssp.colon = kukit.tk.mkToken('colon', ":"); +kssp.quote = kukit.tk.mkToken('quote', "'"); +kssp.dquote = kukit.tk.mkToken('dquote', '"'); +kssp.backslash = kukit.tk.mkToken('backslash', '\x5c'); +kssp.comma = kukit.tk.mkToken('comma', ","); +kssp.equals = kukit.tk.mkToken('equals', "="); /* Parsers */ /* * class Document */ -kukit.kssp.Document = kukit.tk.mkParser('document', { +kssp.Document = kukit.tk.mkParser('document', { "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', "{": 'new kukit.kssp.Block(this.cursor, kukit.kssp.openBrace)' }); -kukit.kssp.Document.prototype.process = function() { +kssp.Document.prototype.process = function() { this.eventRules = []; // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; @@ -67,7 +69,7 @@ this.txt = ''; }; -kukit.kssp.Document.prototype.addRules = function(rules) { +kssp.Document.prototype.addRules = function(rules) { // Create the event rules. for(var i=0; i-: // evt---: @@ -208,7 +210,7 @@ eventParameters[eventKey] = value.txt; } -kukit.kssp.Block.prototype.addActionDeclaration = function(key, splitkey, value) { +kssp.Block.prototype.addActionDeclaration = function(key, splitkey, value) { // action-server: // action-client: // action-client: - @@ -250,7 +252,7 @@ } } -kukit.kssp.Block.prototype.addActionError = function(action, key, value) { +kssp.Block.prototype.addActionError = function(action, key, value) { // -error: // default-error: ;;; if (value.isMethod == true) { @@ -265,7 +267,7 @@ err_action.setType('E'); } -kukit.kssp.Block.prototype.addActionParameter = function(action, key, value) { +kssp.Block.prototype.addActionParameter = function(action, key, value) { var ppRegistries = { '': kukit.pprovidersGlobalRegistry, 'kssSelector': kukit.sr.pproviderSelRegistry, @@ -299,7 +301,7 @@ action.parms[key] = value; } -kukit.kssp.Block.prototype.addDeclaration = function(key, value) { +kssp.Block.prototype.addDeclaration = function(key, value) { // p.s. value is here a KssXxParm. In most cases we check and unwrap it. // the keys look like this: // @@ -368,7 +370,7 @@ /* * class PropValue */ -kukit.kssp.PropValue = kukit.tk.mkParser('propValue', { +kssp.PropValue = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -378,7 +380,7 @@ "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)' }); -kukit.kssp.PropValue.prototype.process = function() { +kssp.PropValue.prototype.process = function() { // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); @@ -424,9 +426,9 @@ } this.result = []; }; -kukit.kssp.PropValue.prototype.multiword_allowed = true; -kukit.kssp.PropValue.prototype.valueClass = kukit.rd.KssMethodValue; -kukit.kssp.PropValue.prototype.produceTxt = function(txt) { +kssp.PropValue.prototype.multiword_allowed = true; +kssp.PropValue.prototype.valueClass = kukit.rd.KssMethodValue; +kssp.PropValue.prototype.produceTxt = function(txt) { // txt parms are returned embedded this.value = new kukit.rd.KssTextValue(txt); }; @@ -436,7 +438,7 @@ * * PropValue in method cannot have method-style vars. */ -kukit.kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { +kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -446,10 +448,10 @@ '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' }); -kukit.kssp.PropValueInMethod.prototype.multiword_allowed = false; -kukit.kssp.PropValueInMethod.prototype.process = - kukit.kssp.PropValue.prototype.process; -kukit.kssp.PropValueInMethod.prototype.produceTxt = function(txt) { +kssp.PropValueInMethod.prototype.multiword_allowed = false; +kssp.PropValueInMethod.prototype.process = + kssp.PropValue.prototype.process; +kssp.PropValueInMethod.prototype.produceTxt = function(txt) { // txt parms are returned unwrapped this.txt = txt; }; @@ -459,7 +461,7 @@ * * PropValue in pseudo must be single word with no spaces around. */ -kukit.kssp.EventValue = kukit.tk.mkParser('propValue', { +kssp.EventValue = kukit.tk.mkParser('propValue', { "{": 'this.emitAndReturn()', " ": 'this.emitAndReturn()', "\t": 'this.emitAndReturn()', @@ -470,8 +472,8 @@ "(": '[new kukit.kssp.openParent(this.cursor), new kukit.kssp.PropValue(this.cursor)]', ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))' }); -kukit.kssp.EventValue.prototype.multiword_allowed = false; -kukit.kssp.EventValue.prototype.process = function() { +kssp.EventValue.prototype.multiword_allowed = false; +kssp.EventValue.prototype.process = function() { // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); @@ -522,7 +524,7 @@ this.result = []; }; -kukit.kssp.EventValue.prototype.produceTxt = function(txt) { +kssp.EventValue.prototype.produceTxt = function(txt) { // txt parms are returned embedded this.value = new kukit.rd.KssEventValue(txt, null); }; @@ -530,11 +532,11 @@ /* * class String */ -kukit.kssp.String = kukit.tk.mkParser('string', { +kssp.String = kukit.tk.mkParser('string', { "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }); -kukit.kssp.String.prototype.process = function() { +kssp.String.prototype.process = function() { // collect up the value of the string, omitting the quotes this.txt = ''; for (var i=1; i cursor.pos) { - this.result.push(new kukit.tk.Fraction(cursor, best_pos)); - cursor.pos = best_pos; - } - if (best_symbol) { - // found a symbol, handle that - // make the token and push it - var tokens = eval(table[best_symbol]); - if (typeof(tokens) != 'undefined') { - if (typeof(tokens.length) == 'undefined') { - tokens = [tokens]; + this.nextStep = function() { + var table = this.table + var cursor = this.cursor; + // Search for symbol according to table. + var best_pos = cursor.text.length; + var best_symbol = null; + for (var symbol in table) { + var pos = cursor.text.indexOf(symbol, cursor.pos); + if (pos != -1 && pos < best_pos) { + best_pos = pos; + best_symbol = symbol; } - for (var i=0; i cursor.pos) { + this.result.push(new tk.Fraction(cursor, best_pos)); + cursor.pos = best_pos; + } + if (best_symbol) { + // found a symbol, handle that + // make the token and push it + var tokens = eval(table[best_symbol]); + if (typeof(tokens) != 'undefined') { + if (typeof(tokens.length) == 'undefined') { + tokens = [tokens]; + } + for (var i=0; i= this.result.length) { -;;; kukit.E = 'Missing token : [' + symbol + '].'; - this.emitError(kukit.E); - } else if (this.result[i].symbol != symbol) { -;;; kukit.E = 'Unexpected token : [' + this.result[i].symbol; -;;; kukit.E += '] found, [' + symbol + '] was expected.'; - this.emitError(kukit.E); + this.process = function() { + // default process after tokenization + this.txt = ''; + for (var i=0; i= this.result.length) { -;;; kukit.E = 'Missing token.'; - this.emitError(kukit.E); + }; + + this.expectToken = function(context, token) { + var i = context.nextTokenIndex; + if (token) { + var symbol = token.prototype.symbol; + if (i >= this.result.length) { +;;; kukit.E = 'Missing token : [' + symbol + '].'; + this.emitError(kukit.E); + } else if (this.result[i].symbol != symbol) { +;;; kukit.E = 'Unexpected token : [' + this.result[i].symbol; +;;; kukit.E += '] found, [' + symbol + '] was expected.'; + this.emitError(kukit.E); + } + } else { + if (i >= this.result.length) { +;;; kukit.E = 'Missing token.'; + this.emitError(kukit.E); + } } - } - context.token = this.result[i]; - context.nextTokenIndex += 1; -}; + context.token = this.result[i]; + context.nextTokenIndex += 1; + }; -kukit.tk._ParserBase.prototype.resultIsNullOrNotToken = - function(token, currentValue) { - return (!token || currentValue.symbol != token.prototype.symbol); -}; + this.resultIsNullOrNotToken = + function(token, currentValue) { + return (!token || currentValue.symbol != token.prototype.symbol); + }; -kukit.tk._ParserBase.prototype.notInTokens = - function(context, token1, token2, token3, token4) { - var i = context.nextTokenIndex; - var currentValue = this.result[i]; - return !( - (i >= this.result.length) || - (this.resultIsNullOrNotToken(token1, currentValue) && - this.resultIsNullOrNotToken(token2, currentValue) && - this.resultIsNullOrNotToken(token3, currentValue) && - this.resultIsNullOrNotToken(token4, currentValue)) - ); -}; + this.notInTokens = + function(context, token1, token2, token3, token4) { + var i = context.nextTokenIndex; + var currentValue = this.result[i]; + return !( + (i >= this.result.length) || + (this.resultIsNullOrNotToken(token1, currentValue) && + this.resultIsNullOrNotToken(token2, currentValue) && + this.resultIsNullOrNotToken(token3, currentValue) && + this.resultIsNullOrNotToken(token4, currentValue)) + ); + }; -kukit.tk._ParserBase.prototype.digestTxt = - function(context, token1, token2, token3, token4) { - // digests the txt from the tokens, ignores given token - // plus whitespace removal - this.digestExactTxt(context, token1, token2, token3, token4); - context.txt = this.removeWhitespacesAndTrim(context.txt); -}; + this.digestTxt = + function(context, token1, token2, token3, token4) { + // digests the txt from the tokens, ignores given token + // plus whitespace removal + this.digestExactTxt(context, token1, token2, token3, token4); + context.txt = this.removeWhitespacesAndTrim(context.txt); + }; -kukit.tk._ParserBase.prototype.digestExactTxt = - function(context, token1, token2, token3, token4) { - // digests the txt from the tokens, ignores given token - // exact value: no whitespace removal - var result = ''; - while (this.notInTokens(context, token1, token2, token3, token4)) { - result += this.result[context.nextTokenIndex].txt; - context.nextTokenIndex ++; - } - context.txt = result; -}; + this.digestExactTxt = + function(context, token1, token2, token3, token4) { + // digests the txt from the tokens, ignores given token + // exact value: no whitespace removal + var result = ''; + while (this.notInTokens(context, token1, token2, token3, token4)) { + result += this.result[context.nextTokenIndex].txt; + context.nextTokenIndex ++; + } + context.txt = result; + }; -kukit.tk._ParserBase.prototype.removeWhitespaces = function(txt) { - // removes ws but leaves leading and trailing one - if (txt != ' ') { //speedup only - txt = txt.replace(/[\r\n\t ]+/g, ' '); - } - return txt; -}; - -kukit.tk._ParserBase.prototype.removeWhitespacesAndTrim = function(txt) { - txt = this.removeWhitespaces(txt); - // XXX Strange thing is: following replace works from - // tests and the original demo, but with kukitportlet demo - // it breaks. Someone stinks! - //txt = txt.replace(/^ /, ''); - if (txt && txt.charAt(0) == ' ') { - txt = txt.substr(1); - } - txt = txt.replace(/ $/, ''); - return txt; + this.removeWhitespaces = function(txt) { + // removes ws but leaves leading and trailing one + if (txt != ' ') { //speedup only + txt = txt.replace(/[\r\n\t ]+/g, ' '); + } + return txt; + }; + + this.removeWhitespacesAndTrim = function(txt) { + txt = this.removeWhitespaces(txt); + // XXX Strange thing is: following replace works from + // tests and the original demo, but with kukitportlet demo + // it breaks. Someone stinks! + //txt = txt.replace(/^ /, ''); + if (txt && txt.charAt(0) == ' ') { + txt = txt.substr(1); + } + txt = txt.replace(/ $/, ''); + return txt; + }; }; +tk._ParserBase.prototype = new tk._TokenBase(); + /* * class Fraction */ -kukit.tk.Fraction = function(cursor, endpos) { +tk.Fraction = function(cursor, endpos) { this.txt = cursor.text.substring(cursor.pos, endpos); this.startpos = cursor.pos; this.endpos = cursor.pos; this.finished = true; }; -kukit.tk.Fraction.prototype.symbol = 'fraction'; +tk.Fraction.prototype.symbol = 'fraction'; /* Factories to make tokens and parsers */ -kukit.tk.mkToken = function(symbol, txt) { +tk.mkToken = function(symbol, txt) { // Poor man's subclassing. f = function(cursor) { this.cursor = cursor; @@ -215,15 +219,16 @@ this.endpos = cursor.pos; //this.cursor = null; }; - f.prototype = new kukit.tk._TokenBase; + f.prototype = new tk._TokenBase(); f.prototype.symbol = symbol; f.prototype.txt = txt; return f; }; -kukit.tk.mkParser = function(symbol, table) { +tk.mkParser = function(symbol, table) { // Poor man's subclassing. f = function(cursor, tokenClass, isTopLevelParser) { + this.table = table this.cursor = cursor; this.startpos = cursor.pos; this.finished = false; @@ -235,7 +240,7 @@ } this.updateFinished(); while (!this.finished) { - this.nextStep(table); + this.nextStep(); this.updateFinished(); } this.endpos = cursor.pos; @@ -244,7 +249,7 @@ //this.cursor = null; }; - f.prototype = new kukit.tk._ParserBase; + f.prototype = new tk._ParserBase(); f.prototype.symbol = symbol; return f; }; @@ -252,44 +257,46 @@ /* * class Cursor */ -kukit.tk.Cursor = function(txt) { +tk.Cursor = function(txt) { this.text = txt; this.pos = 0; -}; -kukit.tk.Cursor.prototype.makeMarker = function(pos) { - // create a cursor to mark this position - var cursor = new kukit.tk.Cursor(); - cursor.text = this.text; - cursor.pos = pos; - // Calculate the row and column information on the cursor - cursor.calcRowCol(); - return cursor; -}; + this.makeMarker = function(pos) { + // create a cursor to mark this position + var cursor = new tk.Cursor(); + cursor.text = this.text; + cursor.pos = pos; + // Calculate the row and column information on the cursor + cursor.calcRowCol(); + return cursor; + }; -kukit.tk.Cursor.prototype.getRowCol = function(pos) { - // Gets the row, col information for the position. - if (typeof(pos) == 'undefined') { - pos = this.pos; - } - var index = 0; - var row = 1; - var next = 0; - while (true) { - next = this.text.indexOf('\n', index); - if (next == -1 || next >= pos) { - break; - } - index = next + 1; - row += 1; - } - var col = pos - index + 1; - return {'row': row, 'col': col}; -}; + this.getRowCol = function(pos) { + // Gets the row, col information for the position. + if (typeof(pos) == 'undefined') { + pos = this.pos; + } + var index = 0; + var row = 1; + var next = 0; + while (true) { + next = this.text.indexOf('\n', index); + if (next == -1 || next >= pos) { + break; + } + index = next + 1; + row += 1; + } + var col = pos - index + 1; + return {'row': row, 'col': col}; + }; -kukit.tk.Cursor.prototype.calcRowCol = function(pos) { - // Calculates row and column information on the cursor. - var rowcol = this.getRowCol(); - this.row = rowcol.row; - this.col = rowcol.col; + this.calcRowCol = function(pos) { + // Calculates row and column information on the cursor. + var rowcol = this.getRowCol(); + this.row = rowcol.row; + this.col = rowcol.col; + }; }; + +}(); /// MODULE END From gotcha at codespeak.net Sun Dec 16 23:42:28 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 16 Dec 2007 23:42:28 +0100 (CET) Subject: [KSS-checkins] r49856 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071216224228.0913216847F@codespeak.net> Author: gotcha Date: Sun Dec 16 23:42:27 2007 New Revision: 49856 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: class closures - step 2 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Sun Dec 16 23:42:27 2007 @@ -46,331 +46,400 @@ /* * class Document */ -kssp.Document = kukit.tk.mkParser('document', { - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', - "{": 'new kukit.kssp.Block(this.cursor, kukit.kssp.openBrace)' - }); -kssp.Document.prototype.process = function() { - this.eventRules = []; - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - while (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - var key = context.txt; - if (! key) { - break; - } - this.expectToken(context, kukit.kssp.Block); - var block = context.token; - var rules = block.parseSelectors(key); - this.addRules(rules); - } - this.result = []; - this.txt = ''; -}; +var _Document = function() { + this.process = function() { + this.eventRules = []; + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + while (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + var key = context.txt; + if (! key) { + break; + } + this.expectToken(context, kukit.kssp.Block); + var block = context.token; + var rules = block.parseSelectors(key); + this.addRules(rules); + } + this.result = []; + this.txt = ''; + }; -kssp.Document.prototype.addRules = function(rules) { - // Create the event rules. - for(var i=0; i-: - // evt---: -;;; if (splitkey.length < 3) { -;;; kukit.E = 'Wrong rule key : "' + key + '". '; -;;; kukit.E += 'KSS rule key must be "-"'; -;;; kukit.E += ' or "--" or '; -;;; kukit.E += '"evt--" or '; -;;; kukit.E += '"evt---".'; -;;; this.emitError(kukit.E); -;;; } - var eventNamespace; - var eventName; - var eventKey; - var eventFullName; - if (splitkey.length == 3) { - // evt--: - eventName = splitkey[1]; - eventKey = splitkey[2]; - eventFullName = eventName; - } else { - // evt---: - eventNamespace = splitkey[1]; - eventName = splitkey[2]; - eventKey = splitkey[3]; - eventFullName = eventNamespace + '-' + eventName; - } -;;; if (value.isMethod != false) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed as value for '; -;;; kukit.E += 'evt-[-]- keys.'; -;;; this.emitError(kukit.E); -;;; } - var eventParameters = this.eventFullNames[eventFullName]; - if (typeof(eventParameters) == 'undefined') { - this.eventFullNames[eventFullName] = {}; - eventParameters = this.eventFullNames[eventFullName]; - } - eventParameters[eventKey] = value.txt; -} - -kssp.Block.prototype.addActionDeclaration = function(key, splitkey, value) { - // action-server: - // action-client: - // action-client: - - // action-cancel: - // action-cancel: - -;;; if (splitkey.length != 2) { -;;; kukit.E = 'Wrong key [' + key + '] : '; -;;; kukit.E += 'action- keys can have only one dash.'; -;;; this.emitError(kukit.E); + return results; + }; + + this.addEventDeclaration = function(key, splitkey, value) { + + // evt--: + // evt---: +;;; if (splitkey.length < 3) { +;;; kukit.E = 'Wrong rule key : "' + key + '". '; +;;; kukit.E += 'KSS rule key must be "-"'; +;;; kukit.E += ' or "--" or '; +;;; kukit.E += '"evt--" or '; +;;; kukit.E += '"evt---".'; +;;; this.emitError(kukit.E); ;;; } -;;; if (value.isMethod != false) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed for action- keys.'; -;;; this.emitError(kukit.E); + var eventNamespace; + var eventName; + var eventKey; + var eventFullName; + if (splitkey.length == 3) { + // evt--: + eventName = splitkey[1]; + eventKey = splitkey[2]; + eventFullName = eventName; + } else { + // evt---: + eventNamespace = splitkey[1]; + eventName = splitkey[2]; + eventKey = splitkey[3]; + eventFullName = eventNamespace + '-' + eventName; + } +;;; if (value.isMethod != false) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed as value for '; +;;; kukit.E += 'evt-[-]- keys.'; +;;; this.emitError(kukit.E); ;;; } - var atab = {'server': 'S', 'client': 'C', 'cancel': 'X'}; - var actionType = atab[splitkey[1]]; -;;; if (! actionType) { -;;; kukit.E = 'Wrong key [' + key + '] : '; -;;; kukit.E += 'qualifier in action- keys must be '; -;;; kukit.E += '"server" or "client" or "cancel".'; -;;; this.emitError(kukit.E); -;;; } -;;; // force value to be or - -;;; var splitvalue = value.txt.split('-'); -;;; if (splitvalue.length > 2) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value must be or '; -;;; kukit.E += '- for action- keys.'; -;;; this.emitError(kukit.E); + var eventParameters = this.eventFullNames[eventFullName]; + if (typeof(eventParameters) == 'undefined') { + this.eventFullNames[eventFullName] = {}; + eventParameters = this.eventFullNames[eventFullName]; + } + eventParameters[eventKey] = value.txt; + }; + + this.addActionDeclaration = function(key, splitkey, value) { + // action-server: + // action-client: + // action-client: - + // action-cancel: + // action-cancel: - +;;; if (splitkey.length != 2) { +;;; kukit.E = 'Wrong key [' + key + '] : '; +;;; kukit.E += 'action- keys can have only one dash.'; +;;; this.emitError(kukit.E); +;;; } +;;; if (value.isMethod != false) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed for action- keys.'; +;;; this.emitError(kukit.E); +;;; } + var atab = {'server': 'S', 'client': 'C', 'cancel': 'X'}; + var actionType = atab[splitkey[1]]; +;;; if (! actionType) { +;;; kukit.E = 'Wrong key [' + key + '] : '; +;;; kukit.E += 'qualifier in action- keys must be '; +;;; kukit.E += '"server" or "client" or "cancel".'; +;;; this.emitError(kukit.E); +;;; } +;;; // force value to be or - +;;; var splitvalue = value.txt.split('-'); +;;; if (splitvalue.length > 2) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value must be or '; +;;; kukit.E += '- for action- keys.'; +;;; this.emitError(kukit.E); +;;; } + // set it + var action = this.actions.getOrCreateAction(value.txt); + if (actionType != 'X' || action.type == null) { + action.setType(actionType); + } else { + this.actions.deleteAction(value.txt); + } + }; + + this.addActionError = function(action, key, value) { + // -error: + // default-error: +;;; if (value.isMethod == true) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed for -error keys.'; +;;; this.emitError(kukit.E); ;;; } - // set it - var action = this.actions.getOrCreateAction(value.txt); - if (actionType != 'X' || action.type == null) { - action.setType(actionType); - } else { - this.actions.deleteAction(value.txt); - } -} - -kssp.Block.prototype.addActionError = function(action, key, value) { - // -error: - // default-error: -;;; if (value.isMethod == true) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed for -error keys.'; -;;; this.emitError(kukit.E); -;;; } - action.setError(value.txt); - // also create the action for the error itself. - var err_action = this.actions.getOrCreateAction(value.txt); - err_action.setType('E'); -} - -kssp.Block.prototype.addActionParameter = function(action, key, value) { - var ppRegistries = { - '': kukit.pprovidersGlobalRegistry, - 'kssSelector': kukit.sr.pproviderSelRegistry, - 'kssSubmitForm': kukit.fo.pproviderFormRegistry - }; - - // -: - // default-: - // - // value may be either txt or method parms, - // and they get stored with the wrapper. - // - // Check the syntax of the value at this point. - // This will also set the value providers on the value - // (from check). - // - // Figure out which registry to use. - var registry = ppRegistries[key]; - if (typeof(registry) == 'undefined') { - // use default pproviders - registry = ppRegistries['']; - } - // - try { - // Check also sets the value provider on the value. - value.check(registry); - } catch(e) { -;;; kukit.E = 'Error in value : ' + e + '.'; - this.emitError(kukit.E); - } - action.parms[key] = value; -} + action.setError(value.txt); + // also create the action for the error itself. + var err_action = this.actions.getOrCreateAction(value.txt); + err_action.setType('E'); + }; + + this.addActionParameter = function(action, key, value) { + var ppRegistries = { + '': kukit.pprovidersGlobalRegistry, + 'kssSelector': kukit.sr.pproviderSelRegistry, + 'kssSubmitForm': kukit.fo.pproviderFormRegistry + }; -kssp.Block.prototype.addDeclaration = function(key, value) { - // p.s. value is here a KssXxParm. In most cases we check and unwrap it. - // the keys look like this: - // - // evt--: - // evt---: - // - // action-server: - // action-client: - // action-client: - - // action-cancel: - // action-cancel: - - // - // -: - // --: - // -error: - // --error: - // - // default-: - // default-error: - // - var splitkey = key.split('-'); -;;; if (splitkey.length < 2 || splitkey.length > 4) { -;;; kukit.E = 'Wrong rule key : "' + key + '". '; -;;; kukit.E += 'KSS rule key must be "-" or '; -;;; kukit.E += '"--" or '; -;;; kukit.E += '"evt--" or '; -;;; kukit.E += '"evt---".'; -;;; this.emitError(kukit.E); -;;; } - var name = splitkey[0]; - if (name == 'evt') { - this.addEventDeclaration(key, splitkey, value); - } else if (name == 'action') { - this.addActionDeclaration(key, splitkey, value); - } else { + // -: + // default-: + // + // value may be either txt or method parms, + // and they get stored with the wrapper. + // + // Check the syntax of the value at this point. + // This will also set the value providers on the value + // (from check). + // + // Figure out which registry to use. + var registry = ppRegistries[key]; + if (typeof(registry) == 'undefined') { + // use default pproviders + registry = ppRegistries['']; + } + // + try { + // Check also sets the value provider on the value. + value.check(registry); + } catch(e) { +;;; kukit.E = 'Error in value : ' + e + '.'; + this.emitError(kukit.E); + } + action.parms[key] = value; + }; + + this.addDeclaration = function(key, value) { + // p.s. value is here a KssXxParm. In most cases we check and unwrap it. + // the keys look like this: + // + // evt--: + // evt---: + // + // action-server: + // action-client: + // action-client: - + // action-cancel: + // action-cancel: - + // // -: // --: // -error: // --error: + // // default-: // default-error: - var actionName; - var actionKey; - if (splitkey.length == 2) { + // + var splitkey = key.split('-'); +;;; if (splitkey.length < 2 || splitkey.length > 4) { +;;; kukit.E = 'Wrong rule key : "' + key + '". '; +;;; kukit.E += 'KSS rule key must be "-" or '; +;;; kukit.E += '"--" or '; +;;; kukit.E += '"evt--" or '; +;;; kukit.E += '"evt---".'; +;;; this.emitError(kukit.E); +;;; } + var name = splitkey[0]; + if (name == 'evt') { + this.addEventDeclaration(key, splitkey, value); + } else if (name == 'action') { + this.addActionDeclaration(key, splitkey, value); + } else { // -: + // --: // -error: + // --error: // default-: // default-error: - actionName = splitkey[0]; - actionKey = splitkey[1]; - } else { - // --: - // --error: - actionName = splitkey[0] + '-' + splitkey[1]; - actionKey = splitkey[2]; - } - var action = this.actions.getOrCreateAction(actionName); - if (actionKey == 'error') { - this.addActionError(action, key, value); - } else { - this.addActionParameter(action, actionKey, value); + var actionName; + var actionKey; + if (splitkey.length == 2) { + // -: + // -error: + // default-: + // default-error: + actionName = splitkey[0]; + actionKey = splitkey[1]; + } else { + // --: + // --error: + actionName = splitkey[0] + '-' + splitkey[1]; + actionKey = splitkey[2]; + } + var action = this.actions.getOrCreateAction(actionName); + if (actionKey == 'error') { + this.addActionError(action, key, value); + } else { + this.addActionParameter(action, actionKey, value); + } } - } + }; }; +kssp.Block = kukit.tk.mkParserBis('block', { + ";": 'new kukit.kssp.semicolon(this.cursor)', + ":": '[new kukit.kssp.colon(this.cursor), new kukit.kssp.PropValue(this.cursor)]', + "}": 'this.emitAndReturn(new kukit.kssp.closeBrace(this.cursor))' + }, + _Block + ); /* * class PropValue */ -kssp.PropValue = kukit.tk.mkParser('propValue', { +var _PropValue = function() { + + this.process = function() { + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.txt = ''; + var txt = context.txt; + if (this.notInTokens(context, kukit.kssp.String)) { + // The previous txt must be all whitespace. + if (txt) { +;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; +;;; kukit.E += ' before a string.'; + this.emitError(kukit.E); + } + // the next one must be a string. + this.expectToken(context, kukit.kssp.String); + this.produceTxt(context.token.txt); + } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) { + // see if not empty and has no spaces in it + if (! txt || txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : method name [' + txt + '] cannot '; +;;; kukit.E += 'have spaces.'; + this.emitError(kukit.E); + } + // the next one must be the rules + this.expectToken(context, kukit.kssp.MethodArgs); + this.value = new this.valueClass(txt, context.token.args); + } else { + // not a string or method: check if we allowed multiword. + if (! this.multiword_allowed && txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; + this.emitError(kukit.E); + } + this.produceTxt(txt); + } + // see what's after + if (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + // we have to be at the end and have no text after + if (context.nextTokenIndex < this.result.length || context.txt) { +;;; kukit.E = 'Wrong value : unallowed characters after '; +;;; kukit.E += 'the property.'; + this.emitError(kukit.E); + } + } + this.result = []; + }; + this.multiword_allowed = true; + this.valueClass = kukit.rd.KssMethodValue; + this.produceTxt = function(txt) { + // txt parms are returned embedded + this.value = new kukit.rd.KssTextValue(txt); + }; +}; + +kssp.PropValue = kukit.tk.mkParserBis('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -379,66 +448,24 @@ '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)' - }); -kssp.PropValue.prototype.process = function() { - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - this.txt = ''; - var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { - // The previous txt must be all whitespace. - if (txt) { -;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; -;;; kukit.E += ' before a string.'; - this.emitError(kukit.E); - } - // the next one must be a string. - this.expectToken(context, kukit.kssp.String); - this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) { - // see if not empty and has no spaces in it - if (! txt || txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : method name [' + txt + '] cannot '; -;;; kukit.E += 'have spaces.'; - this.emitError(kukit.E); - } - // the next one must be the rules - this.expectToken(context, kukit.kssp.MethodArgs); - this.value = new this.valueClass(txt, context.token.args); - } else { - // not a string or method: check if we allowed multiword. - if (! this.multiword_allowed && txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; - this.emitError(kukit.E); - } - this.produceTxt(txt); - } - // see what's after - if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.nextTokenIndex < this.result.length || context.txt) { -;;; kukit.E = 'Wrong value : unallowed characters after '; -;;; kukit.E += 'the property.'; - this.emitError(kukit.E); - } - } - this.result = []; -}; -kssp.PropValue.prototype.multiword_allowed = true; -kssp.PropValue.prototype.valueClass = kukit.rd.KssMethodValue; -kssp.PropValue.prototype.produceTxt = function(txt) { - // txt parms are returned embedded - this.value = new kukit.rd.KssTextValue(txt); -}; + }, + _PropValue + ); /* * class PropValueInMethod * * PropValue in method cannot have method-style vars. */ -kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { +var _PropValueInMethod = function() { + this.multiword_allowed = false; + this.produceTxt = function(txt) { + // txt parms are returned unwrapped + this.txt = txt; + }; +}; +_PropValueInMethod.prototype = new _PropValue(); +kssp.PropValueInMethod = kukit.tk.mkParserBis('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -447,21 +474,73 @@ "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' - }); -kssp.PropValueInMethod.prototype.multiword_allowed = false; -kssp.PropValueInMethod.prototype.process = - kssp.PropValue.prototype.process; -kssp.PropValueInMethod.prototype.produceTxt = function(txt) { - // txt parms are returned unwrapped - this.txt = txt; -}; + }, + _PropValueInMethod + ); /* * class EventValue * -* PropValue in pseudo must be single word with no spaces around. */ -kssp.EventValue = kukit.tk.mkParser('propValue', { +var _EventValue = function() { + this.multiword_allowed = false; + this.process = function() { + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.txt = ''; + var txt = context.txt; + if (this.notInTokens(context, kukit.kssp.String)) { + // The previous txt must be all whitespace. + if (txt) { +;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; +;;; kukit.E += ' before a string.'; + this.emitError(kukit.E); + } + // the next one must be a string. + this.expectToken(context, kukit.kssp.String); + this.produceTxt(context.token.txt); + } else if (this.notInTokens(context, kukit.kssp.openParent)) { + this.expectToken(context, kukit.kssp.openParent); + this.expectToken(context, kukit.kssp.PropValue); + this.value = new kukit.rd.KssEventValue(txt, context.token.value); + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + // we have to be at the end and have no text after + if (context.txt) { +;;; kukit.E = 'Wrong event selector : [' + context.txt; +;;; kukit.E += '] is not expected before the closing'; +;;; kukit.E += ' parenthesis. :() can have'; +;;; kukit.E += ' only one parameter.'; + this.emitError(kukit.E); + } + // eat up everything before the closing parent + this.expectToken(context, kukit.kssp.closeParent); + } else { + // not a string or method: check if we allowed multiword. + if (! this.multiword_allowed && txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; + this.emitError(kukit.E); + } + this.produceTxt(txt); + } + // see what's after + if (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + // we have to be at the end and have no text after + if (context.nextTokenIndex < this.result.length || context.txt) { +;;; kukit.E = 'Excess characters after the property value'; + this.emitError(kukit.E); + } + } + this.result = []; + }; + + this.produceTxt = function(txt) { + // txt parms are returned embedded + this.value = new kukit.rd.KssEventValue(txt, null); + }; +}; +kssp.EventValue = kukit.tk.mkParserBis('propValue', { "{": 'this.emitAndReturn()', " ": 'this.emitAndReturn()', "\t": 'this.emitAndReturn()', @@ -471,63 +550,9 @@ ":": 'this.emitAndReturn()', "(": '[new kukit.kssp.openParent(this.cursor), new kukit.kssp.PropValue(this.cursor)]', ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))' - }); -kssp.EventValue.prototype.multiword_allowed = false; -kssp.EventValue.prototype.process = function() { - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - this.txt = ''; - var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { - // The previous txt must be all whitespace. - if (txt) { -;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; -;;; kukit.E += ' before a string.'; - this.emitError(kukit.E); - } - // the next one must be a string. - this.expectToken(context, kukit.kssp.String); - this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.openParent)) { - this.expectToken(context, kukit.kssp.openParent); - this.expectToken(context, kukit.kssp.PropValue); - this.value = new kukit.rd.KssEventValue(txt, context.token.value); - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.txt) { -;;; kukit.E = 'Wrong event selector : [' + context.txt; -;;; kukit.E += '] is not expected before the closing'; -;;; kukit.E += ' parenthesis. :() can have'; -;;; kukit.E += ' only one parameter.'; - this.emitError(kukit.E); - } - // eat up everything before the closing parent - this.expectToken(context, kukit.kssp.closeParent); - } else { - // not a string or method: check if we allowed multiword. - if (! this.multiword_allowed && txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; - this.emitError(kukit.E); - } - this.produceTxt(txt); - } - // see what's after - if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.nextTokenIndex < this.result.length || context.txt) { -;;; kukit.E = 'Excess characters after the property value'; - this.emitError(kukit.E); - } - } - this.result = []; -}; - -kssp.EventValue.prototype.produceTxt = function(txt) { - // txt parms are returned embedded - this.value = new kukit.rd.KssEventValue(txt, null); -}; + }, + _EventValue + ); /* * class String Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Sun Dec 16 23:42:27 2007 @@ -254,6 +254,36 @@ return f; }; +tk.mkParserBis = function(symbol, table, _class) { + // Poor man's subclassing. + f = function(cursor, tokenClass, isTopLevelParser) { + this.table = table + this.cursor = cursor; + this.startpos = cursor.pos; + this.finished = false; + this.isTopLevelParser = isTopLevelParser; + this.result = []; + if (tokenClass) { + // Reentry with starting token propagated. + this.result.push(new tokenClass(this.cursor)); + } + this.updateFinished(); + while (!this.finished) { + this.nextStep(); + this.updateFinished(); + } + this.endpos = cursor.pos; + // post processing + this.process(); + + //this.cursor = null; + }; + _class.prototype = new tk._ParserBase(); + f.prototype = new _class(); + f.prototype.symbol = symbol; + return f; +}; + /* * class Cursor */ From gotcha at codespeak.net Sun Dec 16 23:53:35 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 16 Dec 2007 23:53:35 +0100 (CET) Subject: [KSS-checkins] r49857 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071216225335.8736916847B@codespeak.net> Author: gotcha Date: Sun Dec 16 23:53:35 2007 New Revision: 49857 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Log: class closures - step 3 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Sun Dec 16 23:53:35 2007 @@ -557,41 +557,50 @@ /* * class String */ -kssp.String = kukit.tk.mkParser('string', { +var _String = function() { + this.process = function() { + // collect up the value of the string, omitting the quotes + this.txt = ''; + for (var i=1; i Author: gotcha Date: Tue Dec 18 18:44:47 2007 New Revision: 49897 Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js Log: fixes for hiccups found with jslint Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kukit.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js Tue Dec 18 18:44:47 2007 @@ -17,6 +17,8 @@ * 02111-1307, USA. */ +/*global kukit, document, window */ + kukit = new function() { /// MODULE START var ku = this; @@ -39,6 +41,14 @@ return false; }; +/* +* class _RuleSheetLink +*/ +var _RuleSheetLink = function(href, res_type) { + this.href = href; + this.res_type = res_type; +}; + /* * class Engine @@ -48,8 +58,8 @@ // table from res_type to rule processor this._ruleProcessorClasses = {}; // register processor for type kss - this._ruleProcessorClasses['kss'] = kukit.kssp.KssRuleProcessor; - this._ruleProcessors = new Array(); + this._ruleProcessorClasses.kss = kukit.kssp.KssRuleProcessor; + this._ruleProcessors = []; this.bindScheduler = new kukit.ut.SerializeScheduler(); // State vars storage. This can be used from kss via a method. this.stateVariables = {}; @@ -82,8 +92,8 @@ } } nodes = document.getElementsByTagName("base"); - if (nodes.length == 0) { - var base = window.location.href; + if (nodes.length === 0) { + base = window.location.href; var pieces = base.split('/'); pieces.pop(); base = pieces.join('/'); @@ -120,16 +130,17 @@ }; this.createRuleProcessor = function(rulelink) { - var ruleProcessorClass = this._ruleProcessorClasses[rulelink.res_type]; - if (ruleProcessorClass) { -;;; var msg = "Start loading and processing " + rulelink.href; + var _RuleProcessorClass = this._ruleProcessorClasses[rulelink.res_type]; +;;; var msg = ''; + if (_RuleProcessorClass) { +;;; msg = "Start loading and processing " + rulelink.href; ;;; msg = msg + " of type " + rulelink.res_type; ;;; kukit.log(msg); - var ruleprocessor = new ruleProcessorClass(rulelink.href); + var ruleprocessor = new _RuleProcessorClass(rulelink.href); this._ruleProcessors[this._ruleProcessors.length] = ruleprocessor; return ruleprocessor; ;;; } else { -;;; var msg = "Ignore rulesheet " + rulelink.href; +;;; msg = "Ignore rulesheet " + rulelink.href; ;;; msg = msg + " of type " + rulelink.res_type; ;;; kukit.log(msg); } @@ -138,8 +149,8 @@ this.getRules = function() { - var rules = new Array(); - var ruleProcessors = this._ruleProcessors + var rules = []; + var ruleProcessors = this._ruleProcessors; for (var j=0; j Author: gotcha Date: Wed Dec 19 11:23:31 2007 New Revision: 49924 Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js Log: class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/oper.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/oper.js Wed Dec 19 11:23:31 2007 @@ -57,320 +57,318 @@ this.orignode = null; this.action = null; this.browserevent = null; - // update from the dict - this.unrestrictedUpdate(dict); -}; -var Oper = op.Oper.prototype; - -Oper.clone = function(dict, restricted) { - var newoper = new kukit.op.Oper(this); - newoper.unrestrictedUpdate(dict, restricted); - return newoper; -}; + this.clone = function(dict, restricted) { + var newoper = new kukit.op.Oper(this); + newoper.unrestrictedUpdate(dict, restricted); + return newoper; + }; -Oper.update = function(dict) { - // restricted attrs must not be changed on existing oper. - this.unrestrictedUpdate(dict, true); -}; + this.update = function(dict) { + // restricted attrs must not be changed on existing oper. + this.unrestrictedUpdate(dict, true); + }; -Oper.unrestrictedUpdate = function(dict, restricted) { - if (typeof(dict) == 'undefined') { - return; - } - for (var key in dict) { -;;; if (typeof(checkKey) == 'undefined') { -;;; var checkKey = function(key) { -;;; var isNode = key == 'node'; -;;; var isParameters = key == 'parms'; -;;; var isEventRule = key == 'eventRule'; -;;; var isBinder = key == 'binder'; -;;; var isOrig = key == 'orignode'; -;;; return isNode || isParameters || isEventRule || isBinder || isOrig; -;;; }; -;;; } -;;; if (restricted && checkKey(key)) { -;;; kukit.E = 'Illegal update on oper object, protected attribute ['; -;;; kukit.E += key + '].'; -;;; throw new Error(kukit.E); -;;; } - var value = dict[key]; - if (typeof(value) != 'function') { - this[key] = value; + this.unrestrictedUpdate = function(dict, restricted) { + if (typeof(dict) == 'undefined') { + return; } - } -}; + for (var key in dict) { +;;; if (typeof(checkKey) == 'undefined') { +;;; var checkKey = function(key) { +;;; var isNode = key == 'node'; +;;; var isParameters = key == 'parms'; +;;; var isEventRule = key == 'eventRule'; +;;; var isBinder = key == 'binder'; +;;; var isOrig = key == 'orignode'; +;;; return isNode || isParameters || isEventRule || isBinder || isOrig; +;;; }; +;;; } +;;; if (restricted && checkKey(key)) { +;;; kukit.E = 'Illegal update on oper object, protected attribute ['; +;;; kukit.E += key + '].'; +;;; throw new Error(kukit.E); +;;; } + var value = dict[key]; + if (typeof(value) != 'function') { + this[key] = value; + } + } + }; + // update from the dict + this.unrestrictedUpdate(dict); -Oper.logDebug = function() { -;;; var result = []; -;;; for (var key in this){ -;;; if (key == 'parms') { -;;; var res2 = []; -;;; for (var k2 in this.parms){ -;;; res2.push(k2 + '="' + this.parms[k2] + '"'); + this.logDebug = function() { +;;; var result = []; +;;; for (var key in this){ +;;; if (key == 'parms') { +;;; var res2 = []; +;;; for (var k2 in this.parms){ +;;; res2.push(k2 + '="' + this.parms[k2] + '"'); +;;; } +;;; result.push('parms={' + res2.join(',') + '}'); +;;; } else if (typeof(kukit.op.Oper.prototype[key]) == 'undefined') { +;;; result.push(key + '=' + this[key]); ;;; } -;;; result.push('parms={' + res2.join(',') + '}'); -;;; } else if (typeof(kukit.op.Oper.prototype[key]) == 'undefined') { -;;; result.push(key + '=' + this[key]); ;;; } -;;; } -;;; kukit.logDebug('Oper values: ' + result.join(', ')); -}; +;;; kukit.logDebug('Oper values: ' + result.join(', ')); + }; -Oper.executeClientAction = function(name) { - // Check kss action parms - var nodes = null; - // XXX TODO this should be refactored with parms constraint checking - for (key in this.kssParms) { - switch (key) { - case 'kssSelector': { - // The value already contains the results - nodes = this.kssParms[key]; - } break; - default: { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with '; -;;; kukit.E += '"kss"; normal parms (that do not start with'; -;;; kukit.E += ' "kss") only are allowed in action-client keys.'; - throw new Error(kukit.E); - } break; + this.executeClientAction = function(name) { + // Check kss action parms + var nodes = null; + // XXX TODO this should be refactored with parms constraint checking + for (key in this.kssParms) { + switch (key) { + case 'kssSelector': { + // The value already contains the results + nodes = this.kssParms[key]; + } break; + default: { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with '; +;;; kukit.E += '"kss"; normal parms (that do not start with'; +;;; kukit.E += ' "kss") only are allowed in action-client keys.'; + throw new Error(kukit.E); + } break; + } } - } - // XXX TODO refactor this with commands execution (or the other way) -;;; var nodetext = function(node) { -;;; if (node) { -;;; return node.tagName.toLowerCase(); -;;; } else { -;;; return 'DOCUMENT'; -;;; } -;;; }; - var executeActions = kukit.actionsGlobalRegistry.get(name); - if (nodes != null) { -;;; var msg = nodes.length + ' nodes found for action [' + name + '].'; -;;; kukit.logDebug(msg); -;;; if (!nodes || nodes.length == 0) { -;;; kukit.logWarning('Action selector found no nodes.'); -;;; } - for (var i=0; i < nodes.length; i++) { - this.node = nodes[i]; - //XXX error handling for wrong command name -;;; var msg = '[' + name + '] action executes on target (' + (i+1); -;;; msg += '/' + nodes.length + ') '; + // XXX TODO refactor this with commands execution (or the other way) +;;; var nodetext = function(node) { +;;; if (node) { +;;; return node.tagName.toLowerCase(); +;;; } else { +;;; return 'DOCUMENT'; +;;; } +;;; }; + var executeActions = kukit.actionsGlobalRegistry.get(name); + if (nodes != null) { +;;; var msg = nodes.length + ' nodes found for action [' + name + '].'; +;;; kukit.logDebug(msg); +;;; if (!nodes || nodes.length == 0) { +;;; kukit.logWarning('Action selector found no nodes.'); +;;; } + for (var i=0; i < nodes.length; i++) { + this.node = nodes[i]; + //XXX error handling for wrong command name +;;; var msg = '[' + name + '] action executes on target (' + (i+1); +;;; msg += '/' + nodes.length + ') '; +;;; msg += '[' + nodetext(this.node) + '].'; +;;; kukit.logDebug(msg); + executeActions(this); + } + } else { + // single node +;;; var msg = '[' + name + '] action executes on single node '; ;;; msg += '[' + nodetext(this.node) + '].'; ;;; kukit.logDebug(msg); executeActions(this); } - } else { - // single node -;;; var msg = '[' + name + '] action executes on single node '; -;;; msg += '[' + nodetext(this.node) + '].'; -;;; kukit.logDebug(msg); - executeActions(this); - } -}; + }; -Oper.executeDefaultAction = function(name, optional) { - // Check kss action parms -;;; for (key in this.kssParms) { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; -;;; kukit.E += ' normal parms (that do not start with kss)'; -;;; kukit.E += ' only are allowed in action-default keys.'; -;;; throw new Error(kukit.E); -;;; } - // - var namespace = this.binder.__eventNamespace__; - var kssevent = kukit.eventsGlobalRegistry.get(namespace, name); - var methodName = kssevent.defaultActionMethodName; - var success = false; - if (! methodName) { -;;; if (! optional) { -;;; kukit.E = 'Could not trigger event [' + name; -;;; kukit.E += '] from namespace [' + namespace + '], because this'; -;;; kukit.E += ' event has no default method registered.'; + this.executeDefaultAction = function(name, optional) { + // Check kss action parms +;;; for (key in this.kssParms) { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; +;;; kukit.E += ' normal parms (that do not start with kss)'; +;;; kukit.E += ' only are allowed in action-default keys.'; ;;; throw new Error(kukit.E); ;;; } - } else { - // Put defaultParameters to parms! - // This makes sure, that for implicit events - // you do not need to specify pass(key) - // for making the parms arrive to the action. - if (typeof(this.defaultParameters) != 'undefined') { - this.parms = this.defaultParameters; + // + var namespace = this.binder.__eventNamespace__; + var kssevent = kukit.eventsGlobalRegistry.get(namespace, name); + var methodName = kssevent.defaultActionMethodName; + var success = false; + if (! methodName) { +;;; if (! optional) { +;;; kukit.E = 'Could not trigger event [' + name; +;;; kukit.E += '] from namespace [' + namespace + '], because this'; +;;; kukit.E += ' event has no default method registered.'; +;;; throw new Error(kukit.E); +;;; } } else { - this.parms = {}; + // Put defaultParameters to parms! + // This makes sure, that for implicit events + // you do not need to specify pass(key) + // for making the parms arrive to the action. + if (typeof(this.defaultParameters) != 'undefined') { + this.parms = this.defaultParameters; + } else { + this.parms = {}; + } + this.binder._EventBinder_callMethod( + namespace, name, this, methodName); + success = true; } - this.binder._EventBinder_callMethod( - namespace, name, this, methodName); - success = true; - } - return success; -}; + return success; + }; -Oper.executeServerAction = function(name) { -;;; for (key in this.kssParms) { -;;; if (key == 'kssUrl') { -;;; // Value will be evaluated. -;;; } else if (key == 'kssSubmitForm') { -;;; // Value will be evaluated. -;;; } else { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; -;;; kukit.E += ' normal parms (that do not start with kss)'; -;;; kukit.E += ' only are allowed in action-server keys.'; -;;; throw new Error(kukit.E); + this.executeServerAction = function(name) { +;;; for (key in this.kssParms) { +;;; if (key == 'kssUrl') { +;;; // Value will be evaluated. +;;; } else if (key == 'kssSubmitForm') { +;;; // Value will be evaluated. +;;; } else { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; +;;; kukit.E += ' normal parms (that do not start with kss)'; +;;; kukit.E += ' only are allowed in action-server keys.'; +;;; throw new Error(kukit.E); +;;; } ;;; } -;;; } - // oper will be accessible to some commands that execute in return - var sa = new kukit.sa.ServerAction(name, this); -}; + // oper will be accessible to some commands that execute in return + var sa = new kukit.sa.ServerAction(name, this); + }; -/* Helpers the serve binding */ + /* Helpers the serve binding */ -Oper.getEventName = function () { - // Gets event name - return this.eventRule.kssSelector.name; -}; + this.getEventName = function () { + // Gets event name + return this.eventRule.kssSelector.name; + }; -Oper.getEventNamespace = function () { - // Gets event name - return this.eventRule.kssSelector.namespace; -}; + this.getEventNamespace = function () { + // Gets event name + return this.eventRule.kssSelector.namespace; + }; -Oper.hasExecuteActions = function () { - // Decide if there are any actions (or a default action) - // to execute. This can speed up execution if in case - // we have nothing to do, there is no reason to bind - // the actions hook. - if (this.eventRule) { - // if it has actions, the answer is yes - if (this.eventRule.actions.hasActions()) - 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 - // valid, even if it received no parms in the eventRule, - // in which case it is not present as an action. - var kssevent = kukit.eventsGlobalRegistry.get( - this.getEventNamespace(), this.getEventName()) - var methodName = kssevent.defaultActionMethodName; - return (typeof methodName != 'undefined'); - } else - return false; -}; + this.hasExecuteActions = function () { + // Decide if there are any actions (or a default action) + // to execute. This can speed up execution if in case + // we have nothing to do, there is no reason to bind + // the actions hook. + if (this.eventRule) { + // if it has actions, the answer is yes + if (this.eventRule.actions.hasActions()) + 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 + // valid, even if it received no parms in the eventRule, + // in which case it is not present as an action. + var kssevent = kukit.eventsGlobalRegistry.get( + this.getEventNamespace(), this.getEventName()) + var methodName = kssevent.defaultActionMethodName; + return (typeof methodName != 'undefined'); + } else + return false; + }; -Oper.makeExecuteActionsHook = function (filter) { - // Factory that creates the function that executes the actions. - // The function may take a dict that is updated on the oper - // If filter is specified, it will we called with a function and - // the event will only be triggered if the filter returned true. - // THe return value of func_to_bind will show if the event - // has executed or not. - // - // Speedup. - if (! this.hasExecuteActions()) { - return function() {}; - } - var eventName = this.getEventName(); - var self = this; - var func_to_bind = function(dict) { - // (XXX XXX TODO it should happen here, that we change to a different - // oper class. This is for the future when we separate the BindOper - // from the ActionOper.) - var newoper = self.clone(dict, true); - // call the filter and if it says skip it, we are done - // (Filter has a chance to set a defaultParameters on oper. - if (filter && ! filter(newoper)) return false; - // execute the event's actions - newoper.binder._EventBinder_triggerEvent(eventName, newoper); - // show that the event's actions have been executed - return true; + this.makeExecuteActionsHook = function (filter) { + // Factory that creates the function that executes the actions. + // The function may take a dict that is updated on the oper + // If filter is specified, it will we called with a function and + // the event will only be triggered if the filter returned true. + // THe return value of func_to_bind will show if the event + // has executed or not. + // + // Speedup. + if (! this.hasExecuteActions()) { + return function() {}; + } + var eventName = this.getEventName(); + var self = this; + var func_to_bind = function(dict) { + // (XXX XXX TODO it should happen here, that we change to a different + // oper class. This is for the future when we separate the BindOper + // from the ActionOper.) + var newoper = self.clone(dict, true); + // call the filter and if it says skip it, we are done + // (Filter has a chance to set a defaultParameters on oper. + if (filter && ! filter(newoper)) return false; + // execute the event's actions + newoper.binder._EventBinder_triggerEvent(eventName, newoper); + // show that the event's actions have been executed + return true; + }; + return func_to_bind; }; - return func_to_bind; -}; -/* Utility for parameter checking */ + /* Utility for parameter checking */ -Oper.evaluateParameters = - function(mandatory, defaults, errname, allow_excess) { - // Checks if mandatory params are supplied and there are no excess params - // also fill up default values - // Parms are cloned and returned. - // Example: - // oper.evaluateParameters(['mand1', 'mand2'], {'key1': 'defval'}, - // 'event X'); -;;; if (typeof(allow_excess) == 'undefined') { -;;; allow_excess = false; -;;;} - var newParameters = {}; - for (var i=0; i Author: gotcha Date: Wed Dec 19 13:57:09 2007 New Revision: 49930 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Log: class closures -- step 4 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Wed Dec 19 13:57:09 2007 @@ -595,7 +595,7 @@ } }; }; -kssp.StringInSelector = kukit.tk.mkParser('string', { +kssp.StringInSelector = kukit.tk.mkParserBis('string', { "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, @@ -605,33 +605,38 @@ /* * class String2InSelector */ -kssp.String2InSelector = kukit.tk.mkParser('string', { +kssp.String2InSelector = kukit.tk.mkParserBis('string', { '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, - _String + _StringInSelector ); /* * class Backslashed */ -kssp.Backslashed = kukit.tk.mkParser('backslashed', {}); -kssp.Backslashed.prototype.nextStep = function(table) { - // digest the next character and store it as txt - var cursor = this.cursor; - var length = cursor.text.length; - if (length < cursor.pos + 1) { -;;; kukit.E = 'Missing character after backslash.'; - this.emitError(kukit.E); - } else { - this.result.push(new kukit.tk.Fraction(cursor, cursor.pos+1)); - this.cursor.pos += 1; - this.finished = true; - } -}; -kssp.Backslashed.prototype.process = function() { - this.txt = this.result[1].txt; +var _Backslashed = function() { + this.nextStep = function(table) { + // digest the next character and store it as txt + var cursor = this.cursor; + var length = cursor.text.length; + if (length < cursor.pos + 1) { +;;; kukit.E = 'Missing character after backslash.'; + this.emitError(kukit.E); + } else { + this.result.push(new kukit.tk.Fraction(cursor, cursor.pos+1)); + this.cursor.pos += 1; + this.finished = true; + } + }; + this.process = function() { + this.txt = this.result[1].txt; + }; }; +kssp.Backslashed = kukit.tk.mkParserBis('backslashed', { + }, + _Backslashed + ); /* * class MethodArgs From gotcha at codespeak.net Wed Dec 19 14:13:14 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 19 Dec 2007 14:13:14 +0100 (CET) Subject: [KSS-checkins] r49931 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071219131314.F17FE16853A@codespeak.net> Author: gotcha Date: Wed Dec 19 14:13:14 2007 New Revision: 49931 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: class closures -- step 5 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Wed Dec 19 14:13:14 2007 @@ -74,7 +74,7 @@ }; }; -kssp.Document = kukit.tk.mkParserBis('document', { +kssp.Document = kukit.tk.mkParser('document', { "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', "{": 'new kukit.kssp.Block(this.cursor, kukit.kssp.openBrace)' }, @@ -90,7 +90,7 @@ this.txt = ' '; }; }; -kssp.Comment = kukit.tk.mkParserBis('comment', { +kssp.Comment = kukit.tk.mkParser('comment', { // it's not 100% good, but will do "\*\/": 'this.emitAndReturn(new kukit.kssp.closeComment(this.cursor))' }, @@ -372,7 +372,7 @@ } }; }; -kssp.Block = kukit.tk.mkParserBis('block', { +kssp.Block = kukit.tk.mkParser('block', { ";": 'new kukit.kssp.semicolon(this.cursor)', ":": '[new kukit.kssp.colon(this.cursor), new kukit.kssp.PropValue(this.cursor)]', "}": 'this.emitAndReturn(new kukit.kssp.closeBrace(this.cursor))' @@ -439,7 +439,7 @@ }; }; -kssp.PropValue = kukit.tk.mkParserBis('propValue', { +kssp.PropValue = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -465,7 +465,7 @@ }; }; _PropValueInMethod.prototype = new _PropValue(); -kssp.PropValueInMethod = kukit.tk.mkParserBis('propValue', { +kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', ")": 'this.emitAndReturn()', @@ -540,7 +540,7 @@ this.value = new kukit.rd.KssEventValue(txt, null); }; }; -kssp.EventValue = kukit.tk.mkParserBis('propValue', { +kssp.EventValue = kukit.tk.mkParser('propValue', { "{": 'this.emitAndReturn()', " ": 'this.emitAndReturn()', "\t": 'this.emitAndReturn()', @@ -566,7 +566,7 @@ } }; }; -kssp.String = kukit.tk.mkParserBis('string', { +kssp.String = kukit.tk.mkParser('string', { "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, @@ -576,7 +576,7 @@ /* * class String2 */ -kssp.String2 = kukit.tk.mkParserBis('string', { +kssp.String2 = kukit.tk.mkParser('string', { '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, @@ -595,7 +595,7 @@ } }; }; -kssp.StringInSelector = kukit.tk.mkParserBis('string', { +kssp.StringInSelector = kukit.tk.mkParser('string', { "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, @@ -605,7 +605,7 @@ /* * class String2InSelector */ -kssp.String2InSelector = kukit.tk.mkParserBis('string', { +kssp.String2InSelector = kukit.tk.mkParser('string', { '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))', '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' }, @@ -633,7 +633,7 @@ this.txt = this.result[1].txt; }; }; -kssp.Backslashed = kukit.tk.mkParserBis('backslashed', { +kssp.Backslashed = kukit.tk.mkParser('backslashed', { }, _Backslashed ); @@ -643,6 +643,51 @@ * * methodargs are (a, b, c) lists. */ +var _MethodArgs = function() { + this.process = function() { + this.args = []; + // Parse all tokens (except first and last) + var context = {'nextTokenIndex': 1}; + while (context.nextTokenIndex < this.result.length-1) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + var value = context.txt; + if (! value) { + // allow to bail out after widow , + if (context.nextTokenIndex == this.result.length-1) break; + // here be a string then. + this.expectToken(context, kukit.kssp.String); + value = context.token.txt; + } else { + // Just a value, must be one word then. + if (value.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong method argument [' + value; +;;; kukit.E += '] : value cannot have spaces (if needed,'; +;;; kukit.E += ' quote it as a string).'; + this.emitError(kukit.E); + } + } + var valueClass; + var args; + var providedValue; + if (this.notInTokens(context, kukit.kssp.MethodArgs)){ + this.expectToken(context, kukit.kssp.MethodArgs); + valueClass = kukit.rd.KssMethodValue; + args = context.token.args; + providedValue = new valueClass(value, args); + } else { + // XXX This should be wrapped too ! + //valueClass = kukit.rd.KssTextValue; + //providedValue = new valueClass(value); + providedValue = value; + } + this.args.push(providedValue); + if (context.nextTokenIndex == this.result.length-1) break; + this.expectToken(context, kukit.kssp.comma); + } + this.result = []; + this.txt = ''; + }; +}; kssp.MethodArgs = kukit.tk.mkParser('methodargs', { "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', @@ -650,50 +695,10 @@ ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))', "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' - }); -kssp.MethodArgs.prototype.process = function() { - this.args = []; - // Parse all tokens (except first and last) - var context = {'nextTokenIndex': 1}; - while (context.nextTokenIndex < this.result.length-1) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - var value = context.txt; - if (! value) { - // allow to bail out after widow , - if (context.nextTokenIndex == this.result.length-1) break; - // here be a string then. - this.expectToken(context, kukit.kssp.String); - value = context.token.txt; - } else { - // Just a value, must be one word then. - if (value.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong method argument [' + value; -;;; kukit.E += '] : value cannot have spaces (if needed,'; -;;; kukit.E += ' quote it as a string).'; - this.emitError(kukit.E); - } - } - var valueClass; - var args; - var providedValue; - if (this.notInTokens(context, kukit.kssp.MethodArgs)){ - this.expectToken(context, kukit.kssp.MethodArgs); - valueClass = kukit.rd.KssMethodValue; - args = context.token.args; - providedValue = new valueClass(value, args); - } else { - // XXX This should be wrapped too ! - //valueClass = kukit.rd.KssTextValue; - //providedValue = new valueClass(value); - providedValue = value; - } - this.args.push(providedValue); - if (context.nextTokenIndex == this.result.length-1) break; - this.expectToken(context, kukit.kssp.comma); - } - this.result = []; - this.txt = ''; -}; + }, + _MethodArgs + ); + /* * class KssSelectors @@ -704,33 +709,38 @@ * KSS method selector: (has no spaces in it) * document:name(id) or behaviour:name(id) */ +var _KssSelectors = function() { + this.process = function() { + this.selectors = []; + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + while (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment, + kukit.kssp.String, kukit.kssp.String2); + var cursor = new kukit.tk.Cursor(context.txt + ' ') + var parser = new kukit.kssp.KssSelector(cursor, null, true); + this.selectors.push(parser.kssSelector); + if (context.nextTokenIndex == this.result.length) break; + this.expectToken(context, kukit.kssp.comma); + if (context.nextTokenIndex == this.result.length) { +;;; kukit.E = 'Wrong event selector : trailing comma'; + this.emitError(kukit.E); + } + }; + this.result = []; + this.txt = ''; + }; +}; kssp.KssSelectors = kukit.tk.mkParser('kssselectors', { "'": 'new kukit.kssp.StringInSelector(this.cursor, kukit.kssp.quote)', '"': 'new kukit.kssp.String2InSelector(this.cursor, kukit.kssp.dquote)', ",": 'new kukit.kssp.comma(this.cursor)', "{": 'this.emitAndReturn()', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' - }); -kssp.KssSelectors.prototype.process = function() { - this.selectors = []; - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - while (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment, - kukit.kssp.String, kukit.kssp.String2); - var cursor = new kukit.tk.Cursor(context.txt + ' ') - var parser = new kukit.kssp.KssSelector(cursor, null, true); - this.selectors.push(parser.kssSelector); - if (context.nextTokenIndex == this.result.length) break; - this.expectToken(context, kukit.kssp.comma); - if (context.nextTokenIndex == this.result.length) { -;;; kukit.E = 'Wrong event selector : trailing comma'; - this.emitError(kukit.E); - } - }; - this.result = []; - this.txt = ''; -}; + }, + _KssSelectors + ); + /* * class KssSelector @@ -743,123 +753,127 @@ * document:name(id) or behaviour:name(id) * document:name(pprov(id)) or behaviour:name(pprov(id)) */ +var _KssSelector = function() { + this.process = function() { + var name; + var namespace = null; + var id = null; + var tokenIndex = this.result.length - 1; + // Find the method parms and calculate the end of css parms. (RL) + var cycle = true; + while (cycle && tokenIndex >= 0) { + var token = this.result[tokenIndex]; + switch (token.symbol) { + case kukit.tk.Fraction.prototype.symbol: { + // if all spaces, go to previous one + if (token.txt.match(/^[\r\n\t ]*$/) != null) { + tokenIndex -= 1; + } else { +;;; kukit.E = 'Wrong event selector : missing event '; +;;; kukit.E += 'qualifier : '; +;;; kukit.E += 'or :().'; + this.emitError(kukit.E); + } + } break; + case kukit.kssp.Comment.prototype.symbol: { + tokenIndex -= 1; + } break; + default: { + cycle = false; + } break; + } + } + // Now we found the token that must be . + tokenIndex -= 2; + if (tokenIndex < 0 + || (this.result[tokenIndex+2].symbol != + kukit.kssp.EventValue.prototype.symbol) + || (this.result[tokenIndex+1].symbol != + kukit.kssp.colon.prototype.symbol) + || (this.result[tokenIndex].symbol != + kukit.tk.Fraction.prototype.symbol)) { +;;; kukit.E = 'Wrong event selector : missing event qualifier '; +;;; kukit.E += ': or :().'; + this.emitError(kukit.E); + } + // See that the last fraction does not end with space. + var lasttoken = this.result[tokenIndex]; + var commatoken = this.result[tokenIndex+1]; + var pseudotoken = this.result[tokenIndex+2]; + var txt = lasttoken.txt; + if (txt.match(/[\r\n\t ]$/) != null) { +;;; kukit.E = 'Wrong event selector :'; +;;; kukit.E += ' space before the colon.'; + this.emitError(kukit.E); + } + if (! pseudotoken.value.methodName) { +;;; kukit.E = 'Wrong event selector :'; +;;; kukit.E += ' event name cannot have spaces.'; + this.emitError(kukit.E); + } + css = this.cursor.text.substring(this.startpos, commatoken.startpos); + // Decide if we have an event or a method selector. + // We have a method selector if a single word "document" or "behaviour". + var singleword = css.replace(/[\r\n\t ]/g, ' '); + if (singleword && singleword.charAt(0) == ' ') { + singleword = singleword.substring(1); + } + var isEvent = (singleword != 'document' && singleword != 'behaviour'); + if (! isEvent) { + // just store the single word, in case of event selectors + css = singleword; + } + // create the selector. + var id = null; + var ppid = null; + if (pseudotoken.value.arg) { + // We have something in the parentheses after the event name. + if (pseudotoken.value.arg.isMethod) { + // we have a param provider here. Just store. + ppid = pseudotoken.value.arg; + // Check its syntax too. + ppid.check(kukit.pprovidersGlobalRegistry); + } else { + // just an id. Express in txt. + id = pseudotoken.value.arg.txt; + } + } + var name = pseudotoken.value.methodName; + var splitname = name.split('-'); + var namespace = null; + if (splitname.length > 2) { +;;; kukit.E = 'Wrong event selector [' + name + '] : '; +;;; kukit.E += 'qualifier should be : or '; +;;; kukit.E += ':-.'; + this.emitError(kukit.E); + } else if (splitname.length == 2) { + name = splitname[1]; + namespace = splitname[0]; + } + // Protect the error for better logging +;;; try { + this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, + namespace, id, ppid); +;;; } catch(e) { +;;; if (e.name == 'KssSelectorError') { +;;; // Log the message +;;; this.emitError(e.toString()); +;;; } else { +;;; throw e; +;;; } +;;; } + this.txt = ''; + this.result = []; + }; +}; kssp.KssSelector = kukit.tk.mkParser('kssselector', { ":": '[new kukit.kssp.colon(this.cursor), new ' + 'kukit.kssp.EventValue(this.cursor)]', "{": 'this.emitAndReturn()', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' - }); -kssp.KssSelector.prototype.process = function() { - var name; - var namespace = null; - var id = null; - var tokenIndex = this.result.length - 1; - // Find the method parms and calculate the end of css parms. (RL) - var cycle = true; - while (cycle && tokenIndex >= 0) { - var token = this.result[tokenIndex]; - switch (token.symbol) { - case kukit.tk.Fraction.prototype.symbol: { - // if all spaces, go to previous one - if (token.txt.match(/^[\r\n\t ]*$/) != null) { - tokenIndex -= 1; - } else { -;;; kukit.E = 'Wrong event selector : missing event '; -;;; kukit.E += 'qualifier : '; -;;; kukit.E += 'or :().'; - this.emitError(kukit.E); - } - } break; - case kukit.kssp.Comment.prototype.symbol: { - tokenIndex -= 1; - } break; - default: { - cycle = false; - } break; - } - } - // Now we found the token that must be . - tokenIndex -= 2; - if (tokenIndex < 0 - || (this.result[tokenIndex+2].symbol != - kukit.kssp.EventValue.prototype.symbol) - || (this.result[tokenIndex+1].symbol != - kukit.kssp.colon.prototype.symbol) - || (this.result[tokenIndex].symbol != - kukit.tk.Fraction.prototype.symbol)) { -;;; kukit.E = 'Wrong event selector : missing event qualifier '; -;;; kukit.E += ': or :().'; - this.emitError(kukit.E); - } - // See that the last fraction does not end with space. - var lasttoken = this.result[tokenIndex]; - var commatoken = this.result[tokenIndex+1]; - var pseudotoken = this.result[tokenIndex+2]; - var txt = lasttoken.txt; - if (txt.match(/[\r\n\t ]$/) != null) { -;;; kukit.E = 'Wrong event selector :'; -;;; kukit.E += ' space before the colon.'; - this.emitError(kukit.E); - } - if (! pseudotoken.value.methodName) { -;;; kukit.E = 'Wrong event selector :'; -;;; kukit.E += ' event name cannot have spaces.'; - this.emitError(kukit.E); - } - css = this.cursor.text.substring(this.startpos, commatoken.startpos); - // Decide if we have an event or a method selector. - // We have a method selector if a single word "document" or "behaviour". - var singleword = css.replace(/[\r\n\t ]/g, ' '); - if (singleword && singleword.charAt(0) == ' ') { - singleword = singleword.substring(1); - } - var isEvent = (singleword != 'document' && singleword != 'behaviour'); - if (! isEvent) { - // just store the single word, in case of event selectors - css = singleword; - } - // create the selector. - var id = null; - var ppid = null; - if (pseudotoken.value.arg) { - // We have something in the parentheses after the event name. - if (pseudotoken.value.arg.isMethod) { - // we have a param provider here. Just store. - ppid = pseudotoken.value.arg; - // Check its syntax too. - ppid.check(kukit.pprovidersGlobalRegistry); - } else { - // just an id. Express in txt. - id = pseudotoken.value.arg.txt; - } - } - var name = pseudotoken.value.methodName; - var splitname = name.split('-'); - var namespace = null; - if (splitname.length > 2) { -;;; kukit.E = 'Wrong event selector [' + name + '] : '; -;;; kukit.E += 'qualifier should be : or '; -;;; kukit.E += ':-.'; - this.emitError(kukit.E); - } else if (splitname.length == 2) { - name = splitname[1]; - namespace = splitname[0]; - } - // Protect the error for better logging -;;; try { - this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, - namespace, id, ppid); -;;; } catch(e) { -;;; if (e.name == 'KssSelectorError') { -;;; // Log the message -;;; this.emitError(e.toString()); -;;; } else { -;;; throw e; -;;; } -;;; } - this.txt = ''; - this.result = []; -}; + }, + _KssSelector + ); /* * class KssRuleProcessor Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Wed Dec 19 14:13:14 2007 @@ -225,36 +225,7 @@ return f; }; -tk.mkParser = function(symbol, table) { - // Poor man's subclassing. - f = function(cursor, tokenClass, isTopLevelParser) { - this.table = table - this.cursor = cursor; - this.startpos = cursor.pos; - this.finished = false; - this.isTopLevelParser = isTopLevelParser; - this.result = []; - if (tokenClass) { - // Reentry with starting token propagated. - this.result.push(new tokenClass(this.cursor)); - } - this.updateFinished(); - while (!this.finished) { - this.nextStep(); - this.updateFinished(); - } - this.endpos = cursor.pos; - // post processing - this.process(); - - //this.cursor = null; - }; - f.prototype = new tk._ParserBase(); - f.prototype.symbol = symbol; - return f; -}; - -tk.mkParserBis = function(symbol, table, _class) { +tk.mkParser = function(symbol, table, _class) { // Poor man's subclassing. f = function(cursor, tokenClass, isTopLevelParser) { this.table = table From gotcha at codespeak.net Wed Dec 19 14:16:37 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 19 Dec 2007 14:16:37 +0100 (CET) Subject: [KSS-checkins] r49932 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071219131637.D68D016853A@codespeak.net> Author: gotcha Date: Wed Dec 19 14:16:37 2007 New Revision: 49932 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Log: update Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Wed Dec 19 14:16:37 2007 @@ -1,11 +1,8 @@ -file where fixtures are missing +file where closures are missing -kssparser.js plugin.js -providerreg.js requestmanager.js resourcedata.js selectorreg.js serveraction.js -tokenizer.js -utils.js move to kukit th names that are defined in kukit namespaces. +utils.js move to kukit the names that are defined in kukit namespaces. From gotcha at codespeak.net Wed Dec 19 16:47:45 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 19 Dec 2007 16:47:45 +0100 (CET) Subject: [KSS-checkins] r49933 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071219154745.82FBE168578@codespeak.net> Author: gotcha Date: Wed Dec 19 16:47:44 2007 New Revision: 49933 Modified: kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Log: module and class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Wed Dec 19 16:47:44 2007 @@ -17,222 +17,225 @@ * 02111-1307, USA. */ -kukit.sa = {}; +kukit.sa = new function() { /// MODULE START -kukit.sa.ServerAction = function(name, oper) { +var sa = this; + +this.ServerAction = function(name, oper) { + this.oper = oper; this.url = oper.kssParms.kssUrl; if (typeof(this.url) == 'undefined') { this.url = name; } - this.url = this.calculateAbsoluteURL(this.url); - this.oper = oper; - this.notifyServer(); -}; -kukit.sa.ServerAction.prototype.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?:\/\//'))) { - return url; - } else { - var result = kukit.engine.baseUrl + '/' + url; - return result; - } -}; + 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?:\/\//'))) { + return url; + } else { + var result = kukit.engine.baseUrl + '/' + url; + return result; + } + }; + this.url = this.calculateAbsoluteURL(this.url); -// Backparameters can be used on command execution. -kukit.sa.ServerAction.prototype.notifyServer = function() { - var self = this; - var sendHook = function(queueItem) { - // store the queue reception on the oper - self.oper.queueItem = queueItem; - self.reallyNotifyServer(); - }; - var timeoutHook = function(queueItem) { - // store the queue reception on the oper - self.oper.queueItem = queueItem; - self.processError('timeout'); + // Backparameters can be used on command execution. + this.notifyServer = function() { + var self = this; + var sendHook = function(queueItem) { + // store the queue reception on the oper + self.oper.queueItem = queueItem; + self.reallyNotifyServer(); + }; + var timeoutHook = function(queueItem) { + // store the queue reception on the oper + self.oper.queueItem = queueItem; + self.processError('timeout'); + }; + kukit.engine.requestManager.notifyServer(sendHook, this.url, timeoutHook); }; - kukit.engine.requestManager.notifyServer(sendHook, this.url, timeoutHook); -}; -kukit.sa.ServerAction.prototype.reallyNotifyServer = function() { - // make a deferred callback - var domDoc = new XMLHttpRequest(); - var self = this; - var notifyServer_done = function() { - self.notifyServer_done(domDoc); - }; - // convert params - var query = new kukit.fo.FormQuery(); - for (var key in this.oper.parms) { - query.appendElem(key, this.oper.parms[key]); - } - // also add the parms that result from submitting an entire form. - // This is, unlike the normal parms, is a list. Keys and values are - // added at the end of the query, without mangling names. - var submitForm = this.oper.kssParms.kssSubmitForm; - if (submitForm) { - for (var i=0; i Author: gotcha Date: Wed Dec 19 16:53:56 2007 New Revision: 49934 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Log: update Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Wed Dec 19 16:53:56 2007 @@ -4,5 +4,4 @@ requestmanager.js resourcedata.js selectorreg.js -serveraction.js utils.js move to kukit the names that are defined in kukit namespaces. Modified: kukit/kukit.js/branch/finish-closures/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Wed Dec 19 16:53:56 2007 @@ -21,7 +21,7 @@ var sa = this; -this.ServerAction = function(name, oper) { +sa.ServerAction = function(name, oper) { this.oper = oper; this.url = oper.kssParms.kssUrl; if (typeof(this.url) == 'undefined') { From gotcha at codespeak.net Wed Dec 19 17:12:46 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 19 Dec 2007 17:12:46 +0100 (CET) Subject: [KSS-checkins] r49935 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071219161246.12EE11684F2@codespeak.net> Author: gotcha Date: Wed Dec 19 17:12:45 2007 New Revision: 49935 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js Log: module and class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Wed Dec 19 17:12:45 2007 @@ -3,5 +3,4 @@ plugin.js requestmanager.js resourcedata.js -selectorreg.js utils.js move to kukit the names that are defined in kukit namespaces. Modified: kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js Wed Dec 19 17:12:45 2007 @@ -17,51 +17,49 @@ * 02111-1307, USA. */ -kukit.sr = {}; +kukit.sr = new function() { /// MODULE START -// Registry of the pprovider functions for selecting +var sr = this; -kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry(); +// Registry of the pprovider functions for selecting +sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry(); // this will provide an arbitrary selector, and is designed to // be used with the makeAnyPP factory function. -kukit.sr.AnyPP = function() {}; -kukit.sr.AnyPP.prototype = { - check: function(args) { +var _AnyPP = function() { + this.check = function(args) { // check does not need to be used here actually. ;;; if (args.length != 1) { ;;; throw new Error('internal error, xxxselector() needs 1 argument'); ;;; } - }, - eval: function(args, node, defaultParameters) { + }; + this.eval = function(args, node, defaultParameters) { var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type); // We don't have orignode if we evaluate from here, consequently // the orignode parameter cannot be used from selectors. We pass // node just to be sure... return f(args[0], node, defaultParameters, node); - } + }; }; -kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP); +sr.pproviderSelRegistry.register('', _AnyPP); -kukit.sr.makeAnyPP = function(selector_type) { +sr.makeAnyPP = function(selector_type) { var pp = function () {}; - pp.prototype.eval = kukit.sr.AnyPP.prototype.eval; -;;; pp.prototype.check = kukit.sr.AnyPP.prototype.check; + pp.prototype = new _AnyPP(); pp.prototype.selector_type = selector_type; return pp; }; // this can be used to pass a node programmatically -kukit.sr.PassnodePP = function() {}; -kukit.sr.PassnodePP.prototype = { - check: function(args) { +var _PassnodePP = function() { + this.check = function(args) { ;;; if (args.length != 1) { ;;; throw new Error('passnode selector method needs 1 argument'); ;;; } - }, - eval: function(args, node, defaultParameters) { + }; + this.eval = function(args, node, defaultParameters) { var value = defaultParameters[args[0]]; if (typeof(value) == 'undefined') { // notfound arguments will get null @@ -70,9 +68,9 @@ } nodes = [value]; return nodes; - } + }; }; -kukit.sr.pproviderSelRegistry.register('passnode', kukit.sr.PassnodePP); +sr.pproviderSelRegistry.register('passnode', _PassnodePP); /* @@ -85,41 +83,41 @@ * kukit.selectorTypesGlobalRegistry.register(name, func); * */ -kukit.sr.SelectorTypeRegistry = function () { +var _SelectorTypeRegistry = function () { this.mapping = {}; + this.register = function(name, func) { + if (typeof(func) == 'undefined') { + throw new Error('Func is mandatory.'); + } +;;; if (this.mapping[name]) { +;;; // Do not allow redefinition +;;; kukit.logError('Error : redefinition attempt of selector ' + name); +;;; return; +;;; } + this.mapping[name] = func; + // Also register the selector param provider + var pp = sr.makeAnyPP(name); + sr.pproviderSelRegistry.register(name, pp); + }; + + this.get = function(name) { + if (! name) { + // if name is null or undefined or '', + // we use the default type. + name = this.defaultSelectorType; + } + var result = this.mapping[name]; +;;; if (typeof(result) == 'undefined') { +;;; throw new Error('Unknown selector type "' + name + '"'); +;;; } + return result; + }; }; -kukit.sr.SelectorTypeRegistry.prototype.defaultSelectorType = 'css'; +_SelectorTypeRegistry.prototype.defaultSelectorType = 'css'; -kukit.sr.SelectorTypeRegistry.prototype.register = function(name, func) { - if (typeof(func) == 'undefined') { - throw new Error('Func is mandatory.'); - } -;;; if (this.mapping[name]) { -;;; // Do not allow redefinition -;;; kukit.logError('Error : redefinition attempt of selector ' + name); -;;; return; -;;; } - this.mapping[name] = func; - // Also register the selector param provider - var pp = kukit.sr.makeAnyPP(name); - kukit.sr.pproviderSelRegistry.register(name, pp); -}; -kukit.sr.SelectorTypeRegistry.prototype.get = function(name) { - if (! name) { - // if name is null or undefined or '', - // we use the default type. - name = this.defaultSelectorType; - } - var result = this.mapping[name]; -;;; if (typeof(result) == 'undefined') { -;;; throw new Error('Unknown selector type "' + name + '"'); -;;; } - return result; -}; - -kukit.selectorTypesGlobalRegistry = new kukit.sr.SelectorTypeRegistry(); +kukit.selectorTypesGlobalRegistry = new _SelectorTypeRegistry(); kukit.selectorTypesGlobalRegistry.register('htmlid', function(expr, node) { var nodes = []; @@ -166,3 +164,5 @@ } return results; }); + +}(); /// MODULE END From kukit-checkins at codespeak.net Thu Dec 20 00:32:01 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Thu, 20 Dec 2007 00:32:01 +0100 (CET) Subject: [KSS-checkins] SALE 70% OFF on Pfizer Message-ID: <20071220093201.8542.qmail@vindictive.fusion.volia.net> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071220/d53624e6/attachment.htm From kukit-checkins at codespeak.net Thu Dec 20 06:23:41 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Thu, 20 Dec 2007 06:23:41 +0100 (CET) Subject: [KSS-checkins] SALE 70% OFF on Pfizer Message-ID: <20071220155343.2277.qmail@ABTS-mp-dynamic-073.16.168.122.airtelbroadband.in> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071220/a0a79bfc/attachment.htm From kukit-checkins at codespeak.net Fri Dec 21 16:19:46 2007 From: kukit-checkins at codespeak.net (VIAGRA ® Official Site) Date: Fri, 21 Dec 2007 16:19:46 +0100 (CET) Subject: [KSS-checkins] December 77% OFF Message-ID: <20071221052621.4174.qmail@dslb-088-065-128-229.pools.arcor-ip.net> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071221/7b526ce9/attachment.htm From gotcha at codespeak.net Sat Dec 22 11:08:37 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 22 Dec 2007 11:08:37 +0100 (CET) Subject: [KSS-checkins] r50001 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071222100837.A527E168551@codespeak.net> Author: gotcha Date: Sat Dec 22 11:08:36 2007 New Revision: 50001 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Log: use assert in Selenium tests Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/error_handling.html Sat Dec 22 11:08:36 2007 @@ -29,6 +29,11 @@ Error handler activated + assertTextNotPresent + logger + Error handler activated + + click no_error_handler_empty_response @@ -39,6 +44,11 @@ Error handler activated + assertTextNotPresent + logger + Error handler activated + + click no_error_handler_error @@ -49,6 +59,11 @@ Error handler activated + assertTextNotPresent + logger + Error handler activated + + click no_error_handler_explicit_error @@ -59,6 +74,11 @@ Error handler activated. + assertTextNotPresent + logger + Error handler activated. + + click with_error_handler_no_error @@ -69,6 +89,11 @@ Error handler activated + assertTextNotPresent + logger + Error handler activated + + click css=#log-reset @@ -84,6 +109,11 @@ Error handler activated + assertTextNotPresent + logger + Error handler activated + + click css=#log-reset @@ -99,6 +129,11 @@ Error handler activated. + assertText + logger + Error handler activated. + + click css=#log-reset @@ -113,6 +148,11 @@ logger Error handler activated. + + assertText + logger + Error handler activated. + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html Sat Dec 22 11:08:36 2007 @@ -49,27 +49,27 @@ - verifyTextPresent + assertTextPresent 100 - verifyTextPresent + assertTextPresent Foobar - verifyTextPresent + assertTextPresent USA - verifyTextPresent + assertTextPresent John Foo - verifyTextPresent + assertTextPresent Bar street, 12 @@ -109,32 +109,32 @@ - verifyTextPresent + assertTextPresent Async saved: - verifyTextPresent + assertTextPresent dring - verifyTextPresent + assertTextPresent Southway - verifyTextPresent + assertTextPresent Norway - verifyTextPresent + assertTextPresent Brigitte Bardou - verifyTextPresent + assertTextPresent Cool street Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/html_inserts.html Sat Dec 22 11:08:36 2007 @@ -29,6 +29,11 @@ first: KSS for a life. + assertText + frame + first: KSS for a life. + + click insertAsLastChild @@ -39,6 +44,11 @@ first: KSS for a life.last: + assertText + frame + first: KSS for a life.last: + + click insert @@ -49,6 +59,11 @@ KSS for a life. + assertText + frame + KSS for a life. + + type text-to-insert before 1 @@ -64,6 +79,11 @@ KSS for a life. before 1 + assertText + css=h4+div + KSS for a life. before 1 + + type text-to-insert after 1 @@ -78,6 +98,11 @@ css=#frame+div KSS for a life. after 1 + + assertText + css=#frame+div + KSS for a life. after 1 + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/more_selectors.html Sat Dec 22 11:08:36 2007 @@ -25,7 +25,12 @@ waitForText - logger + logger + Keep trying until you get there. + + + assertText + logger Keep trying until you get there. @@ -35,7 +40,7 @@ assertText - logger + logger @@ -45,7 +50,12 @@ waitForText - logger + logger + Keep trying until you get there. + + + assertText + logger Keep trying until you get there. @@ -59,13 +69,23 @@ + assertTextPresent + Button button-one clicked. + + + click log-reset + waitForText + logger + + + assertText - logger + logger @@ -75,7 +95,12 @@ waitForText - logger + logger + Keep trying until you get there, from the second button. + + + assertText + logger Keep trying until you get there, from the second button. @@ -88,6 +113,11 @@ Button button-two clicked. + + assertTextPresent + Button button-two clicked. + + From gotcha at codespeak.net Sat Dec 22 11:10:56 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sat, 22 Dec 2007 11:10:56 +0100 (CET) Subject: [KSS-checkins] r50002 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071222101056.9A62F168553@codespeak.net> Author: gotcha Date: Sat Dec 22 11:10:55 2007 New Revision: 50002 Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Log: unindent and use of __init__ Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Sat Dec 22 11:10:55 2007 @@ -27,36 +27,39 @@ * the local event actions need to be registered here. */ var _ActionRegistry = function () { +this.__init__ = function() { this.content = {}; +}; - this.register = function(name, func) { -;;; if (typeof(func) == 'undefined') { -;;; kukit.e = '[func] argument is mandatory when registering an action'; -;;; kukit.e += ' [actionregistry.register].'; -;;; throw new error(kukit.e); -;;; } - if (this.content[name]) { - // do not allow redefinition -;;; kukit.logerror('error : action [' + name + '] already registered.'); - return; - } - this.content[name] = func; - }; +this.register = function(name, func) { +;;; if (typeof(func) == 'undefined') { +;;; kukit.e = '[func] argument is mandatory when registering an action'; +;;; kukit.e += ' [actionregistry.register].'; +;;; throw new error(kukit.e); +;;; } + if (this.content[name]) { + // do not allow redefinition +;;; kukit.logerror('error : action [' + name + '] already registered.'); + return; + } + this.content[name] = func; +}; - this.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); - }; +this.exists = function(name) { + var entry = this.content[name]; + return (typeof(entry) != 'undefined'); +}; - this.get = function(name) { - var func = this.content[name]; - if (! func) { - // not found -;;; kukit.E = 'Error : undefined local action [' + name + '].'; - throw Error(kukit.E); - } - return func; - }; +this.get = function(name) { + var func = this.content[name]; + if (! func) { + // not found +;;; kukit.E = 'Error : undefined local action [' + name + '].'; + throw Error(kukit.E); + } + return func; +}; +this.__init__(); }; From gotcha at codespeak.net Sun Dec 23 11:06:15 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:06:15 +0100 (CET) Subject: [KSS-checkins] r50030 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223100615.795E1168476@codespeak.net> Author: gotcha Date: Sun Dec 23 11:06:14 2007 New Revision: 50030 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Log: switch to initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 11:06:14 2007 @@ -1,6 +1,27 @@ -file where closures are missing +files where closures are missing plugin.js requestmanager.js resourcedata.js utils.js move to kukit the names that are defined in kukit namespaces. + + +files where indentation has to be undone and initialize needs to be done + +commandprocessor.js +commandreg.js +dom.js +errors.js +eventreg.js +forms.js +kssparser.js +kukit.js +oper.js +plugin.js +providerreg.js +requestmanager.js +resourcedata.js +selectorreg.js +serveraction.js +tokenizer.js +utils.js Modified: kukit/kukit.js/branch/finish-closures/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/actionreg.js Sun Dec 23 11:06:14 2007 @@ -27,7 +27,7 @@ * the local event actions need to be registered here. */ var _ActionRegistry = function () { -this.__init__ = function() { +this.initialize = function() { this.content = {}; }; @@ -59,7 +59,7 @@ } return func; }; -this.__init__(); +this.initialize.apply(this, arguments); }; From gotcha at codespeak.net Sun Dec 23 11:30:01 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:30:01 +0100 (CET) Subject: [KSS-checkins] r50031 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223103001.7CFC7168476@codespeak.net> Author: gotcha Date: Sun Dec 23 11:30:00 2007 New Revision: 50031 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js Log: module and class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 11:30:00 2007 @@ -2,7 +2,6 @@ plugin.js requestmanager.js -resourcedata.js utils.js move to kukit the names that are defined in kukit namespaces. @@ -17,11 +16,8 @@ kssparser.js kukit.js oper.js -plugin.js providerreg.js -requestmanager.js resourcedata.js selectorreg.js serveraction.js tokenizer.js -utils.js Modified: kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js Sun Dec 23 11:30:00 2007 @@ -19,12 +19,16 @@ /* Supplemental data that the parser builds up */ -kukit.rd = {}; +kukit.rd = new function() { /// MODULE START + +var rd = this; /* * class KssSelector */ -kukit.rd.KssSelector = function(isEvent, css, name, namespace, id, ppid) { +rd.KssSelector = function() { + +this.initialize = function(isEvent, css, name, namespace, id, ppid, eventRegistry) { this.isEventSelector = isEvent; this.isMethodSelector = ! isEvent; // XXX GC row and column are wrong... @@ -66,25 +70,22 @@ this.className = null; this.id = id; this.ppid = ppid; - // finish up the KSS on it - // XXX We should not have this here, because this disables testing the parser - // standalone, without a plugin registry. Original behaviour - // should be reverted instead. - this.setClassName(); + this.setClassName(eventRegistry); }; - -kukit.rd.KssSelector.prototype.setClassName = function() { + +// finish up the KSS on it +this.setClassName = function(eventRegistry) { // Sets up id and class on the selector, based on registration info // XXX GC instead of relying on exceptions, test if key exists try { - this.className = kukit.eventsGlobalRegistry.get( + this.className = eventRegistry.get( this.namespace, this.name).className; } catch(e) { throw kukit.err.parsingError(e.message); } }; -kukit.rd.KssSelector.prototype.prepareId = function() { +this.prepareId = function() { if (this.ppid == null) { if (this.id == null && this.ppid == null) { // singleton for class @@ -96,7 +97,7 @@ } }; -kukit.rd.KssSelector.prototype.getId = function(node) { +this.getId = function(node) { // Gives the id depending on a node. if (this.id) { // Statically set. @@ -122,7 +123,7 @@ } }; -kukit.rd.KssSelector.prototype.getMergeId = function(node) { +this.getMergeId = function(node) { // Gives the merge id depending on a node. if (this.mergeId) { // Statically set. @@ -133,6 +134,8 @@ this.mergeId = kukit.er.makeMergeId(id, this.namespace, this.name); } }; +this.initialize.apply(this, arguments); +}; /* * Kss parameter values. There are two kinds: text and method. @@ -146,80 +149,81 @@ /* * class KssTextValue */ -kukit.rd.KssTextValue = function(txt) { +rd.KssTextValue = function(txt) { // A text parameter in the format // key: value; +this.initialize = function(txt) { this.txt = txt; -}; +} -kukit.rd.KssTextValue.prototype.isMethod = false; - -kukit.rd.KssTextValue.prototype.check = function(registry) { +this.check = function(registry) { // use the IdentityPP provider. this.pprovider = new (registry.get(''))(); }; -kukit.rd.KssTextValue.prototype.evaluate = +this.evaluate = function(node, defaultParameters) { // For normal string parms, this would return the string itself. // In other execution contexts (like kssSelector, for example) this can // do something else. return this.pprovider.eval([this.txt], node, defaultParameters); }; +this.initialize.apply(this, arguments); +}; +rd.KssTextValue.prototype.isMethod = false; /* -* class KssTextValue +* class KssMethodValue */ -kukit.rd.KssMethodValue = function(methodName, args) { +rd.KssMethodValue = function(methodName, args) { // A method parameter in the format // key: methodName(v1, v2, ... vn); this.methodName = methodName; this.args = args; -}; - -kukit.rd.KssMethodValue.prototype.isMethod = true; - -kukit.rd.KssMethodValue.prototype.check = function(registry) { - // Check syntax - var f = registry.get(this.methodName); - this.pprovider = new f(); - for(i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO - var arg = this.args[i]; - if(arg.check){ - // With the recursion we always use the global - // provider registry - arg.check(kukit.pprovidersGlobalRegistry); + this.check = function(registry) { + // Check syntax + var f = registry.get(this.methodName); + this.pprovider = new f(); + for(i=0; i < this.args.length; i++){ + // XXX We treat text values separetly because + // they are now currently wrapped as KssTextValue + // (as they should). TODO + var arg = this.args[i]; + if(arg.check){ + // With the recursion we always use the global + // provider registry + arg.check(kukit.pprovidersGlobalRegistry); + } } - } -;;; this.pprovider.check(this.args); -}; + ;;; this.pprovider.check(this.args); + }; -kukit.rd.KssMethodValue.prototype.evaluate = - function(node, defaultParameters) { - // First recursivly evaluate all arguments - var newArgs = []; - for(var i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO - var arg = this.args[i]; - if(arg.evaluate){ - newArgs.push(arg.evaluate(node, defaultParameters)); - } else { - newArgs.push(arg); + this.evaluate = + function(node, defaultParameters) { + // First recursivly evaluate all arguments + var newArgs = []; + for(var i=0; i < this.args.length; i++){ + // XXX We treat text values separetly because + // they are now currently wrapped as KssTextValue + // (as they should). TODO + var arg = this.args[i]; + if(arg.evaluate){ + newArgs.push(arg.evaluate(node, defaultParameters)); + } else { + newArgs.push(arg); + } } - } - // return the value - return this.pprovider.eval(newArgs, node, defaultParameters); + // return the value + return this.pprovider.eval(newArgs, node, defaultParameters); + }; }; +rd.KssMethodValue.prototype.isMethod = true; + /* * class KssEventValue */ -kukit.rd.KssEventValue = function(methodName, arg) { +rd.KssEventValue = function(methodName, arg) { // A method parameter in the format // methodname(v1) // can be also: @@ -227,19 +231,18 @@ // in both cases, arg is KssTextValue, or KssMethodValue this.methodName = methodName; this.arg = arg; + this.check = function() {}; }; +rd.KssEventValue.prototype.isMethod = true; -kukit.rd.KssEventValue.prototype.isMethod = true; - -kukit.rd.KssEventValue.prototype.check = function() { -}; - -kukit.rd.EventRuleNr = 0; // just a counter +rd.EventRuleNr = 0; // just a counter /* * class EventRule */ -kukit.rd.EventRule = function(kssSelector, parms, actions) { +rd.EventRule = function() { + +this.initialize = function(kssSelector, parms, actions) { if (typeof(parms) == 'undefined') { // called for merging clone // Setting up kssSelector is enough here. Parms and the rest @@ -247,9 +250,9 @@ // on the rule after creation. this.kssSelector = kssSelector; } else { - this.index = kukit.rd.EventRuleNr; + this.index = rd.EventRuleNr; this.mergedIndex = null; - kukit.rd.EventRuleNr = this.index + 1; + rd.EventRuleNr = this.index + 1; ;;; var namestr; ;;; if (kssSelector.namespace) { ;;; namestr = kssSelector.namespace + '-' + kssSelector.name; @@ -265,7 +268,7 @@ } }; -kukit.rd.EventRule.prototype.getIndex = function() { +this.getIndex = function() { if (this.mergedIndex) { return this.mergedIndex; } else { @@ -273,7 +276,7 @@ } }; -kukit.rd.EventRule.prototype.mergeForSelectedNodes = +this.mergeForSelectedNodes = function(ruletable, phase, inNodes) { // Select all nodes within the inNodes for phase==2. @@ -306,7 +309,7 @@ } }; -kukit.rd.EventRule.prototype.getBinderInfo = function(node) { +this.getBinderInfo = function(node) { // Figure out what will be the "state id" for the kss event rule. var id = this.kssSelector.getId(node); // Gets the event instance for the rule. @@ -326,7 +329,7 @@ * */ -kukit.rd.EventRule.prototype.bind = function(node) { +this.bind = function(node) { this.store(node); // Creation of the binding oper var oper = new kukit.op.Oper(); @@ -339,7 +342,7 @@ binderInfo.bindOper(oper); }; -kukit.rd.EventRule.prototype.store = function(node) { +this.store = function(node) { if (node == null) { // node == null is *always* valid, it means "document". return; @@ -350,19 +353,18 @@ } node.kukitEventRules.push(this); }; - /* * Merging event rules */ -kukit.rd.EventRule.prototype.isMerged = function() { +this.isMerged = function() { return (this.mergedIndex != null); }; -kukit.rd.EventRule.prototype.cloneForMerge = function() { +this.cloneForMerge = function() { // Do not touch ourselves, make a new copy for the merge. - var merged = new kukit.rd.EventRule(this.kssSelector); - merged.actions = new kukit.rd.ActionSet(); + var merged = new rd.EventRule(this.kssSelector); + merged.actions = new rd.ActionSet(); merged.parms = {}; merged.mergedIndex = 'X'; merged.merge(this); @@ -370,7 +372,7 @@ return merged; }; -kukit.rd.EventRule.prototype.merge = function(other) { +this.merge = function(other) { ;;; if (! this.isMerged()) { ;;; throw new Error('Cannot merge into a genuine event rule'); ;;; } @@ -398,7 +400,7 @@ ;;; } }; -kukit.rd.EventRule.prototype.mergeIntoDict = function(dict, key) { +this.mergeIntoDict = function(dict, key) { // Merge into the given dictionary by given key. // If possible, store the genuine rule first - if not, // clone it and do a merge. Never destroy the genuine @@ -417,29 +419,34 @@ mergedRule.merge(this); } }; +this.initialize.apply(this, arguments); +}; + /* * class ActionSet */ -kukit.rd.ActionSet = function() { +rd.ActionSet = function() { + +this.initialize = function() { this.content = {}; }; -kukit.rd.ActionSet.prototype.hasActions = function() { +this.hasActions = function() { for (var name in this.content) { return true; } return false; }; -kukit.rd.ActionSet.prototype.merge = function(other) { +this.merge = function(other) { for (var key in other.content) { var action = this.content[key]; var action2 = other.content[key]; if (typeof(action) == 'undefined') { if (action2.type != 'X') { // new action - action = new kukit.rd.Action(); + action = new _Action(); this.content[key] = action; } else { ;;; var msg = 'Cannot action-delete unexisting action, ['; @@ -460,7 +467,7 @@ } }; -kukit.rd.ActionSet.prototype.execute = function(oper) { +this.execute = function(oper) { for (var key in this.content) { var action = this.content[key]; // do not execute error actions! @@ -480,17 +487,17 @@ } }; -kukit.rd.ActionSet.prototype.getOrCreateAction = function(name) { +this.getOrCreateAction = function(name) { var action = this.content[name]; if (typeof(action) == 'undefined') { - action = new kukit.rd.Action(); + action = new _Action(); action.setName(name); this.content[name] = action; } return action; }; -kukit.rd.ActionSet.prototype.getActionOrNull = function(name) { +this.getActionOrNull = function(name) { var action = this.content[name]; if (typeof(action) == 'undefined') { action = null; @@ -498,7 +505,7 @@ return action; }; -kukit.rd.ActionSet.prototype.deleteAction = function(name) { +this.deleteAction = function(name) { var action = this.content[name]; ;;; if (typeof(action) == 'undefined') { ;;; throw new Error('Action [' + name + '] does not exist and cannot be deleted.'); @@ -507,27 +514,31 @@ }; -kukit.rd.ActionSet.prototype.getDefaultAction = function() { +this.getDefaultAction = function() { return this.getActionOrNull('default'); }; -kukit.rd.ActionSet.prototype.getErrorActionFor = function(action) { +this.getErrorActionFor = function(action) { // Get the error action of a given action: or null, // if the action does not define an error handler. return this.getActionOrNull(action.error); }; +this.initialize.apply(this, arguments); +}; /* -* class Action +* class _Action */ -kukit.rd.Action = function() { +var _Action = function() { + +this.initialize = function() { this.name = null; this.error = null; this.parms = {}; this.type = null; }; -kukit.rd.Action.prototype.setName = function(name) { +this.setName = function(name) { ;;; if (this.name != null && this.name != name) { ;;; var msg = 'Error overriding action name [' + this.name; ;;; msg = msg + '] to [' + name + '] (Unmatching action names at merge?)'; @@ -544,7 +555,7 @@ } }; -kukit.rd.Action.prototype.setType = function(type) { +this.setType = function(type) { // Allowed types: // // S = server @@ -573,7 +584,7 @@ this.type = type; }; -kukit.rd.Action.prototype.setError = function(error) { +this.setError = function(error) { ;;; if (this.type != null && this.type != 'S') { ;;; var msg = 'Error setting action error handler on action [' + this.name; ;;; msg = msg + '], this is only allowed on server actions.'; @@ -582,7 +593,7 @@ this.error = error; }; -kukit.rd.Action.prototype.merge = function(other) { +this.merge = function(other) { // Merge to the instance. if (other.name != null) { this.setName(other.name); @@ -599,7 +610,7 @@ } }; -kukit.rd.Action.prototype.makeActionOper = function(oper) { +this.makeActionOper = function(oper) { // Fill the completed action parms, based on the node // The kssXxx parms, reserved for the action, are // handled as appropriate. @@ -630,7 +641,7 @@ return anOper; }; -kukit.rd.Action.prototype.execute = function(oper) { +this.execute = function(oper) { oper = this.makeActionOper(oper); switch (this.type) { case 'D': { @@ -652,31 +663,35 @@ } break; } }; +this.initialize.apply(this, arguments); +}; /* * class LoadActions */ -kukit.rd.LoadActions = function() { +rd.LoadActions = function() { + +this.initialize = function() { this.items = []; }; -kukit.rd.LoadActions.prototype.empty = function() { +this.empty = function() { return (this.size() == 0); }; -kukit.rd.LoadActions.prototype.size = function() { +this.size = function() { return this.items.length; }; -kukit.rd.LoadActions.prototype.push = function(f) { +this.push = function(f) { if (this.items.length >= 100) { throw ('Infinite recursion, stack full'); } this.items.push(f); }; -kukit.rd.LoadActions.prototype.execute = function() { +this.execute = function() { var f = this.items.shift(); if (f) { f(); @@ -686,7 +701,7 @@ } }; -kukit.rd.LoadActions.prototype.executeAll = function() { +this.executeAll = function() { var i = 0; while(true) { var success = this.execute(); @@ -697,7 +712,8 @@ } return i; }; - +this.initialize.apply(this, arguments); +}; /* * class RuleTable @@ -722,14 +738,16 @@ * */ -kukit.rd.RuleTable = function(loadScheduler) { +rd.RuleTable = function() { + +this.initialize = function(loadScheduler) { this.loadScheduler = loadScheduler; this.nodes = {}; }; -kukit.rd.RuleTable.prototype.add = function(node, eventRule) { +this.add = function(node, eventRule) { // look up node - var nodehash = kukit.rd.hashNode(node); + var nodehash = rd.hashNode(node); var nodeval = this.nodes[nodehash]; if (typeof(nodeval) == 'undefined') { nodeval = {'node': node, 'val': {}}; @@ -740,7 +758,7 @@ nodeval.val, eventRule.kssSelector.getMergeId(node)); }; -kukit.rd.RuleTable.prototype.bindall = function(phase) { +this.bindall = function(phase) { // Bind all nodes var counter = 0; for (var nodehash in this.nodes) { @@ -762,10 +780,12 @@ ;;; kukit.logDebug(count + ' load actions executed.'); } }; +this.initialize.apply(this, arguments); +}; -kukit.rd.uid = 0; +rd.uid = 0; -kukit.rd.hashNode = function(node) { +rd.hashNode = function(node) { // It is, generally, not possible to use a node as a key. // However we try to set this right. // We generate an uniqueID on the node. This does not work @@ -776,9 +796,9 @@ } var id = node.uniqueID; if (typeof(id) == 'undefined') { - id = kukit.rd.uid; + id = rd.uid; node.uniqueID = id; - kukit.rd.uid ++; + rd.uid ++; } return id; }; @@ -791,13 +811,15 @@ * Unlike the rule table that is specific for each binding, * this is unique to the page. */ -kukit.rd.MethodTable = function() { +rd.MethodTable = function() { + +this.initialize = function() { this.content = {}; this.content['document'] = {}; this.content['behaviour'] = {}; }; -kukit.rd.MethodTable.prototype.add = function(eventRule) { +this.add = function(eventRule) { // Get the entry by the type which is now at css var category = eventRule.kssSelector.css; var dict = this.content[category]; @@ -809,7 +831,7 @@ eventRule.mergeIntoDict(dict, eventRule.kssSelector.getMergeId()); }; -kukit.rd.MethodTable.prototype.getMergedRule = +this.getMergedRule = function(category, name, binder) { // Returns the rule for a given event instance, @@ -830,7 +852,7 @@ return mergedRule; }; -kukit.rd.MethodTable.prototype.bindall = function() { +this.bindall = function() { // bind document events var documentRules = this.content['document']; var counter = 0; @@ -841,3 +863,7 @@ } ;;; kukit.logDebug(counter + ' rules bound to document.'); }; +this.initialize.apply(this, arguments); +}; + +}(); /// MODULE END From gotcha at codespeak.net Sun Dec 23 11:31:59 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:31:59 +0100 (CET) Subject: [KSS-checkins] r50032 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223103159.8CD3D168476@codespeak.net> Author: gotcha Date: Sun Dec 23 11:31:58 2007 New Revision: 50032 Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Log: move setupEventCollection Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sun Dec 23 11:31:58 2007 @@ -104,11 +104,10 @@ }; this.addCommand = function(command) { - this.commands[this.commands.length] = command; -}; + this.commands[this.commands.length] = command; + }; this.executeCommands = function(oper) { - kukit.engine.beginSetupEventsCollection(); // node, eventRule, binder are given on oper, in case // the command was called up from an event if (typeof(oper) == 'undefined' || oper == null) { @@ -128,7 +127,6 @@ ;;; } ;;; } } - kukit.engine.finishSetupEventsCollection(); }; }; Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Sun Dec 23 11:31:58 2007 @@ -853,7 +853,7 @@ // Protect the error for better logging ;;; try { this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, - namespace, id, ppid); + namespace, id, ppid, kukit.eventsGlobalRegistry); ;;; } catch(e) { ;;; if (e.name == 'KssSelectorError') { ;;; // Log the message Modified: kukit/kukit.js/branch/finish-closures/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Sun Dec 23 11:31:58 2007 @@ -193,7 +193,9 @@ // One or more valid commands to parse var command_processor = new kukit.cp.CommandProcessor(); command_processor.parseCommands(commands, domDoc); + kukit.engine.beginSetupEventsCollection(); command_processor.executeCommands(this.oper); + kukit.engine.finishSetupEventsCollection(); }; this.processError = function(errorcommand) { From gotcha at codespeak.net Sun Dec 23 11:36:44 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:36:44 +0100 (CET) Subject: [KSS-checkins] r50033 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223103644.AB2C1168476@codespeak.net> Author: gotcha Date: Sun Dec 23 11:36:44 2007 New Revision: 50033 Modified: kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js Log: unindent KssMethodValue Modified: kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/resourcedata.js Sun Dec 23 11:36:44 2007 @@ -175,47 +175,52 @@ /* * class KssMethodValue */ -rd.KssMethodValue = function(methodName, args) { +rd.KssMethodValue = function() { + +this.initialize = function(methodName, args) { // A method parameter in the format // key: methodName(v1, v2, ... vn); this.methodName = methodName; this.args = args; - this.check = function(registry) { - // Check syntax - var f = registry.get(this.methodName); - this.pprovider = new f(); - for(i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO - var arg = this.args[i]; - if(arg.check){ - // With the recursion we always use the global - // provider registry - arg.check(kukit.pprovidersGlobalRegistry); - } +}; + +this.check = function(registry) { + // Check syntax + var f = registry.get(this.methodName); + this.pprovider = new f(); + for(i=0; i < this.args.length; i++){ + // XXX We treat text values separetly because + // they are now currently wrapped as KssTextValue + // (as they should). TODO + var arg = this.args[i]; + if(arg.check){ + // With the recursion we always use the global + // provider registry + arg.check(kukit.pprovidersGlobalRegistry); } - ;;; this.pprovider.check(this.args); - }; + } +;;; this.pprovider.check(this.args); +}; - this.evaluate = - function(node, defaultParameters) { - // First recursivly evaluate all arguments - var newArgs = []; - for(var i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO - var arg = this.args[i]; - if(arg.evaluate){ - newArgs.push(arg.evaluate(node, defaultParameters)); - } else { - newArgs.push(arg); - } +this.evaluate = + function(node, defaultParameters) { + // First recursivly evaluate all arguments + var newArgs = []; + for(var i=0; i < this.args.length; i++){ + // XXX We treat text values separetly because + // they are now currently wrapped as KssTextValue + // (as they should). TODO + var arg = this.args[i]; + if(arg.evaluate){ + newArgs.push(arg.evaluate(node, defaultParameters)); + } else { + newArgs.push(arg); } - // return the value - return this.pprovider.eval(newArgs, node, defaultParameters); - }; + } + // return the value + return this.pprovider.eval(newArgs, node, defaultParameters); +}; +this.initialize.apply(this, arguments); }; rd.KssMethodValue.prototype.isMethod = true; From gotcha at codespeak.net Sun Dec 23 11:42:14 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:42:14 +0100 (CET) Subject: [KSS-checkins] r50034 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223104214.B71DE168467@codespeak.net> Author: gotcha Date: Sun Dec 23 11:42:14 2007 New Revision: 50034 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 11:42:14 2007 @@ -7,7 +7,6 @@ files where indentation has to be undone and initialize needs to be done -commandprocessor.js commandreg.js dom.js errors.js Modified: kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandprocessor.js Sun Dec 23 11:42:14 2007 @@ -25,110 +25,113 @@ * class CommandProcessor */ cp.CommandProcessor = function() { + +this.initialize = function() { this.commands = new Array(); +}; - this.parseCommands = function(commands, transport) { -;;; kukit.log('Parsing commands.'); -;;; kukit.logDebug('Number of commands : ' + commands.length + '.'); - for (var y=0;y < commands.length;y++) { - var command = commands[y]; - this.parseCommand(command, transport); - // If we receive an error command, we handle that separately. - // We abort immediately and let the processError handler do its job. - // This means that although no other commands should be in commands, - // we make sure we execute none of them. - var lastcommand = this.commands[this.commands.length-1]; - if (lastcommand.name == 'error') { - // We have to throw an explicitError always, since we want - // error fallbacks work both in production and development mode. - throw kukit.err.explicitError(lastcommand); - } +this.parseCommands = function(commands, transport) { +;;; kukit.log('Parsing commands.'); +;;; kukit.logDebug('Number of commands : ' + commands.length + '.'); + for (var y=0;y < commands.length;y++) { + var command = commands[y]; + this.parseCommand(command, transport); + // If we receive an error command, we handle that separately. + // We abort immediately and let the processError handler do its job. + // This means that although no other commands should be in commands, + // we make sure we execute none of them. + var lastcommand = this.commands[this.commands.length-1]; + if (lastcommand.name == 'error') { + // We have to throw an explicitError always, since we want + // error fallbacks work both in production and development mode. + throw kukit.err.explicitError(lastcommand); } - }; + } +}; - this.parseCommand = function(command, transport) { - var selector = ""; - var params = {}; - var name = ""; - - selector = command.getAttribute("selector"); - name = command.getAttribute("name"); - type = command.getAttribute("selectorType"); - if (name == null) - name = ""; - var childNodes = command.childNodes; - for (var n=0;n < childNodes.length;n++) { - var childNode = childNodes[n]; - if (childNode.nodeType != 1) - continue; - if (childNode.localName) { - if (childNode.localName.toLowerCase() != "param") { - throw new Error('Bad payload, expected param'); - } - } else { - //IE does not know DOM2 - if (childNode.nodeName.toLowerCase() != "param") { - throw new Error('Bad payload, expected param (IE)'); - } - } - data = childNode.getAttribute('name'); - if (data != null) { - // Decide if we have a string or a dom parameter - var childCount = childNode.childNodes.length; - var result; - if (childCount == 0) { - result = ''; - } else { - // (we do not interpret html inline content any more) - // we have a single text node - // OR - // we have a single CDATA node (HTML parameter CDATA-style) -;;; var isTextNode = childNode.firstChild.nodeType == 3; -;;; var isCData = childNode.firstChild.nodeType == 4; -;;; if (! (childCount == 1 && (isTextNode || isCData))) { -;;; kukit.E = 'Bad payload, expected a text or a CDATA node'; -;;; throw new Error(kukit.E); -;;; } - // we consider this as html payload - // The result is always a string from here. - result = childNode.firstChild.nodeValue; - } - params[data] = result; +this.parseCommand = function(command, transport) { + var selector = ""; + var params = {}; + var name = ""; + + selector = command.getAttribute("selector"); + name = command.getAttribute("name"); + type = command.getAttribute("selectorType"); + if (name == null) + name = ""; + var childNodes = command.childNodes; + for (var n=0;n < childNodes.length;n++) { + var childNode = childNodes[n]; + if (childNode.nodeType != 1) + continue; + if (childNode.localName) { + if (childNode.localName.toLowerCase() != "param") { + throw new Error('Bad payload, expected param'); + } + } else { + //IE does not know DOM2 + if (childNode.nodeName.toLowerCase() != "param") { + throw new Error('Bad payload, expected param (IE)'); + } + } + data = childNode.getAttribute('name'); + if (data != null) { + // Decide if we have a string or a dom parameter + var childCount = childNode.childNodes.length; + var result; + if (childCount == 0) { + result = ''; } else { - throw new Error('Bad payload, expected attribute "name"'); + // (we do not interpret html inline content any more) + // we have a single text node + // OR + // we have a single CDATA node (HTML parameter CDATA-style) +;;; var isTextNode = childNode.firstChild.nodeType == 3; +;;; var isCData = childNode.firstChild.nodeType == 4; +;;; if (! (childCount == 1 && (isTextNode || isCData))) { +;;; kukit.E = 'Bad payload, expected a text or a CDATA node'; +;;; throw new Error(kukit.E); +;;; } + // we consider this as html payload + // The result is always a string from here. + result = childNode.firstChild.nodeValue; } + params[data] = result; + } else { + throw new Error('Bad payload, expected attribute "name"'); } - var command = new kukit.cr.makeCommand(selector, name, type, params, - transport); - this.addCommand(command); - }; - - this.addCommand = function(command) { - this.commands[this.commands.length] = command; - }; - - this.executeCommands = function(oper) { - // node, eventRule, binder are given on oper, in case - // the command was called up from an event - if (typeof(oper) == 'undefined' || oper == null) { - oper = new kukit.op.Oper(); - } - var commands = this.commands; - for (var y=0;y < commands.length;y++) { - var command = commands[y]; -;;; try { - command.execute(oper); -;;; } catch (e) { -;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { -;;; throw(e); -;;; } else { -;;; // augment the error message -;;; throw kukit.err.commandExecutionError(e, command); -;;; } -;;; } - } - }; + } + var command = new kukit.cr.makeCommand(selector, name, type, params, + transport); + this.addCommand(command); +}; +this.addCommand = function(command) { + this.commands[this.commands.length] = command; +}; + +this.executeCommands = function(oper) { + // node, eventRule, binder are given on oper, in case + // the command was called up from an event + if (typeof(oper) == 'undefined' || oper == null) { + oper = new kukit.op.Oper(); + } + var commands = this.commands; + for (var y=0;y < commands.length;y++) { + var command = commands[y]; +;;; try { + command.execute(oper); +;;; } catch (e) { +;;; if (e.name == 'RuleMergeError' || e.name == 'EventBindError') { +;;; throw(e); +;;; } else { +;;; // augment the error message +;;; throw kukit.err.commandExecutionError(e, command); +;;; } +;;; } + } +}; +this.initialize.apply(this, arguments); }; }(); /// MODULE END From gotcha at codespeak.net Sun Dec 23 11:50:12 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:50:12 +0100 (CET) Subject: [KSS-checkins] r50035 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223105012.A9A231684C9@codespeak.net> Author: gotcha Date: Sun Dec 23 11:50:12 2007 New Revision: 50035 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/commandreg.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 11:50:12 2007 @@ -7,7 +7,6 @@ files where indentation has to be undone and initialize needs to be done -commandreg.js dom.js errors.js eventreg.js Modified: kukit/kukit.js/branch/finish-closures/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/commandreg.js Sun Dec 23 11:50:12 2007 @@ -27,41 +27,44 @@ * class _CommandRegistry */ var _CommandRegistry = function () { + +this.initialize = function() { this.commands = {}; +}; - this.registerFromAction = - function(srcname, factory, name) { - if (typeof(name) == 'undefined') { - // allows to set a different name as the action name, - // usable for backward - // compatibility setups - name = srcname; +this.registerFromAction = + function(srcname, factory, name) { + if (typeof(name) == 'undefined') { + // allows to set a different name as the action name, + // usable for backward + // compatibility setups + name = srcname; + } + // register a given action as a command, using the given vactor + var f = kukit.actionsGlobalRegistry.get(srcname); + factory(name, f); +}; + +this.register = function(name, klass) { + if (this.commands[name]) { + // Do not allow redefinition +;;; var msg = 'ValueError : command [' + name + '] is already registered.'; +;;; kukit.logError(msg); + return; } - // register a given action as a command, using the given vactor - var f = kukit.actionsGlobalRegistry.get(srcname); - factory(name, f); - }; - - this.register = function(name, klass) { - if (this.commands[name]) { - // Do not allow redefinition -;;; var msg = 'ValueError : command [' + name + '] is already registered.'; -;;; kukit.logError(msg); - return; - } - this.commands[name] = klass; - }; - - this.get = function(name) { - var klass = this.commands[name]; -;;; if (! klass) { -;;; // not found -;;; var msg = 'ValueError : no command registered under [' + name + '].'; -;;; kukit.logError(msg); -;;; } - return klass; - }; + this.commands[name] = klass; +}; +this.get = function(name) { + var klass = this.commands[name]; +;;; if (! klass) { +;;; // not found +;;; var msg = 'ValueError : no command registered under [' + name + '].'; +;;; kukit.logError(msg); +;;; } + return klass; +}; +this.initialize.apply(this, arguments); }; /* From gotcha at codespeak.net Sun Dec 23 11:56:08 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 23 Dec 2007 11:56:08 +0100 (CET) Subject: [KSS-checkins] r50036 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071223105608.447011684C9@codespeak.net> Author: gotcha Date: Sun Dec 23 11:56:07 2007 New Revision: 50036 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 11:56:07 2007 @@ -15,7 +15,5 @@ kukit.js oper.js providerreg.js -resourcedata.js selectorreg.js -serveraction.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/serveraction.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/serveraction.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/serveraction.js Sun Dec 23 11:56:07 2007 @@ -21,223 +21,227 @@ var sa = this; -sa.ServerAction = function(name, oper) { +sa.ServerAction = function() { + +this.initialize = function(name, oper) { this.oper = oper; this.url = oper.kssParms.kssUrl; if (typeof(this.url) == 'undefined') { this.url = name; } - - 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?:\/\//'))) { - return url; - } else { - var result = kukit.engine.baseUrl + '/' + url; - return result; - } - }; this.url = this.calculateAbsoluteURL(this.url); + this.notifyServer(); +}; - // Backparameters can be used on command execution. - this.notifyServer = function() { - var self = this; - var sendHook = function(queueItem) { - // store the queue reception on the oper - self.oper.queueItem = queueItem; - self.reallyNotifyServer(); - }; - var timeoutHook = function(queueItem) { - // store the queue reception on the oper - self.oper.queueItem = queueItem; - self.processError('timeout'); - }; - kukit.engine.requestManager.notifyServer(sendHook, this.url, timeoutHook); +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?:\/\//'))) { + return url; + } else { + var result = kukit.engine.baseUrl + '/' + url; + return result; + } +}; + +// Backparameters can be used on command execution. +this.notifyServer = function() { + var self = this; + var sendHook = function(queueItem) { + // store the queue reception on the oper + self.oper.queueItem = queueItem; + self.reallyNotifyServer(); + }; + var timeoutHook = function(queueItem) { + // store the queue reception on the oper + self.oper.queueItem = queueItem; + self.processError('timeout'); }; + kukit.engine.requestManager.notifyServer(sendHook, this.url, timeoutHook); +}; - this.reallyNotifyServer = function() { - // make a deferred callback - var domDoc = new XMLHttpRequest(); - var self = this; - var notifyServer_done = function() { - self.notifyServer_done(domDoc); - }; - // convert params - var query = new kukit.fo.FormQuery(); - for (var key in this.oper.parms) { - query.appendElem(key, this.oper.parms[key]); - } - // also add the parms that result from submitting an entire form. - // This is, unlike the normal parms, is a list. Keys and values are - // added at the end of the query, without mangling names. - var submitForm = this.oper.kssParms.kssSubmitForm; - if (submitForm) { - for (var i=0; i Author: gotcha Date: Sun Dec 23 12:06:53 2007 New Revision: 50038 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js Log: module and class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Sun Dec 23 12:06:53 2007 @@ -1,7 +1,6 @@ files where closures are missing plugin.js -requestmanager.js utils.js move to kukit the names that are defined in kukit namespaces. Modified: kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js Sun Dec 23 12:06:53 2007 @@ -19,19 +19,24 @@ /* Request manager */ -kukit.rm = {}; +kukit.rm = new function() { /// MODULE START + +var rm = this; + /* Generation of an integer uid on request objects */ -kukit.rm._rid = 0; +rm._rid = 0; /* -* class RequestItem +* class _RequestItem * * Request item. Encapsulates the sendout function and data. */ -kukit.rm.RequestItem = function(sendHook, url, timeoutHook, timeout, now) { +var _RequestItem = function() { + +this.initialize = function(sendHook, url, timeoutHook, timeout, now) { if (typeof(now) == 'undefined') { now = (new Date()).valueOf(); } @@ -43,27 +48,27 @@ this.timeoutHook = timeoutHook; // Generate a RID. Due to timeouting, we have enough // of these for not to overlap ever. - this.rid = kukit.rm._rid; - kukit.rm._rid ++; - if (kukit.rm._rid >= 10000000000) { - kukit.rm._rid = 0; + this.rid = rm._rid; + rm._rid ++; + if (rm._rid >= 10000000000) { + rm._rid = 0; } }; -kukit.rm.RequestItem.prototype.callTimeoutHook = function() { +this.callTimeoutHook = function() { // Calls the timeout hook for this item if (this.timeoutHook) { this.timeoutHook(this); } }; -kukit.rm.RequestItem.prototype.setReceivedCallback = function(func) { +this.setReceivedCallback = function(func) { // Sets the received callback function. It will be // called with the item as first parameter. this._receivedCallback = func; }; -kukit.rm.RequestItem.prototype.receivedResult = function(now) { +this.receivedResult = function(now) { // This is called when the result response has arrived. It // returns a booolean value, if this is false, the caller // must give up processing the result that has been timed @@ -72,35 +77,39 @@ this._receivedCallback = null; return result; }; +this.initialize.apply(this, arguments); +}; /* -* class TimerQueue +* class _TimerQueue * * the send queue. This handles timeouts, and executes * a callback for timed out items. * Callback is called with the request item as parameter. */ -kukit.rm.TimerQueue = function(callback) { +var _TimerQueue = function() { + +this.initialize = function(callback) { this.callback = callback; this.queue = new kukit.ut.SortedQueue(this._sentSort); this.count = 0; }; -kukit.rm.TimerQueue.prototype._sentSort = function(a, b) { +this._sentSort = function(a, b) { // sorting of the sent queue, by expiration if (a.expire < b.expire) return -1; else if (a.expire > b.expire) return +1; else return 0; }; -kukit.rm.TimerQueue.prototype.push = function(item) { +this.push = function(item) { // push a given slot this.queue.push(item); this.count += 1; }; -kukit.rm.TimerQueue.prototype.pop = function(item) { +this.pop = function(item) { // pop a given slot, return true if it was valid, // return false if it was already handled by timeout. // An object can be popped more times! @@ -113,7 +122,7 @@ } }; -kukit.rm.TimerQueue.prototype.handleExpiration = function(now) { +this.handleExpiration = function(now) { if (typeof(now) == 'undefined') { now = (new Date()).valueOf(); } @@ -141,11 +150,15 @@ } return next_expire; }; +this.initialize.apply(this, arguments); +}; /* * class RequestManager */ -kukit.rm.RequestManager = function (name, maxNr, schedulerClass) { +rm.RequestManager = function () { + +this.initialize = function (name, maxNr, schedulerClass) { // schedulerClass is mainly provided for debugging... this.waitingQueue = new kukit.ut.FifoQueue(); this.sentNr = 0; @@ -153,7 +166,7 @@ var timeoutItem = function(item) { self.timeoutItem(item); }; - this.timerQueue = new kukit.rm.TimerQueue(timeoutItem); + this.timerQueue = new _TimerQueue(timeoutItem); if (typeof(name) == 'undefined') { name = null; } @@ -176,27 +189,26 @@ this.timeoutScheduler = new schedulerClass(checkTimeout); this.spinnerEvents = {'off': [], 'on': []}; this.spinnerState = false; -}; - -// sending timeout in millisecs -kukit.rm.RequestManager.prototype.sendingTimeout = 8000; + // sending timeout in millisecs + this.sendingTimeout = 8000; -// max request number -kukit.rm.RequestManager.prototype.maxNr = 4; + // max request number + this.maxNr = 4; +}; -;;; kukit.rm.RequestManager.prototype.getInfo = function() { +;;; this.getInfo = function() { ;;; var msg = '(RQ: ' + this.sentNr + ' OUT, ' + this.waitingQueue.size(); ;;; msg += ' WAI)'; ;;; return msg; ;;; }; -;;; kukit.rm.RequestManager.prototype.log = function(txt) { +;;; this.log = function(txt) { ;;; var msg = 'RequestManager ' + this.nameString + txt + ' '; ;;; msg += this.getInfo() + '.'; ;;; kukit.logDebug(msg); ;;; }; -kukit.rm.RequestManager.prototype.setSpinnerState = function(newState) { +this.setSpinnerState = function(newState) { if (this.spinnerState != newState) { this.spinnerState = newState; // Call the registered spinner events for this state @@ -207,13 +219,13 @@ } }; -kukit.rm.RequestManager.prototype.pushWaitingRequest = function(item, now) { +this.pushWaitingRequest = function(item, now) { this.waitingQueue.push(item); // Set the timeout this.checkTimeout(now); }; -kukit.rm.RequestManager.prototype.popWaitingRequest = function() { +this.popWaitingRequest = function() { var q = this.waitingQueue; // pop handled elements, we don't send them out at all while (! q.empty() && q.front().handled) { @@ -227,7 +239,7 @@ } }; -kukit.rm.RequestManager.prototype.pushSentRequest = function(item, now) { +this.pushSentRequest = function(item, now) { this.sentNr += 1; ;;; this.log('notifies server ' + item.url + ', rid=' + item.rid); // Set the spinner state @@ -245,7 +257,7 @@ item.sendHook(item); }; -kukit.rm.RequestManager.prototype.checkTimeout = function(now) { +this.checkTimeout = function(now) { var nextWake = this.timerQueue.handleExpiration(now); if (nextWake) { // To make sure, add 50ms to the nextwake @@ -262,7 +274,7 @@ this.timeoutScheduler.setNextWakeAtLeast(nextWake); }; -kukit.rm.RequestManager.prototype.popSentRequest = function(item) { +this.popSentRequest = function(item) { var success = this.timerQueue.pop(item); // We remove both to be processed, and timed out requests from the queue. // This means: possibly more physical requests are out, but this @@ -271,11 +283,11 @@ return success; }; -kukit.rm.RequestManager.prototype.isSentRequestQueueFull = function() { +this.isSentRequestQueueFull = function() { return (this.sentNr >= this.maxNr); }; -kukit.rm.RequestManager.prototype.receivedResult = function(item, now) { +this.receivedResult = function(item, now) { // called automatically when the result gets processed. // Mark that we have one less request out. var success = this.popSentRequest(item); @@ -298,7 +310,7 @@ }; -kukit.rm.RequestManager.prototype.receiveItem = function(item, now) { +this.receiveItem = function(item, now) { // calls result processing var success = this.receivedResult(item, now); ;;; if (success) { @@ -311,7 +323,7 @@ return success; }; -kukit.rm.RequestManager.prototype.timeoutItem = function(item) { +this.timeoutItem = function(item) { /* Time out this item. */ ;;; this.log('timed out request rid [' + item.rid + ']'); // Call the timeout hook on the item @@ -320,7 +332,7 @@ /* request manager notification API */ -kukit.rm.RequestManager.prototype.notifyServer = +this.notifyServer = function(sendHook, url, timeoutHook, timeout, now) { // url is only for the logging // sendHook is the function that actually sends out the request. @@ -338,7 +350,7 @@ // Default value of timeout timeout = this.sendingTimeout; } - var item = new kukit.rm.RequestItem(sendHook, url, timeoutHook, timeout, + var item = new _RequestItem(sendHook, url, timeoutHook, timeout, now); // Start timing the item immediately this.timerQueue.push(item); @@ -353,7 +365,10 @@ } }; -kukit.rm.RequestManager.prototype.registerSpinnerEvent = function(func, state) { +this.registerSpinnerEvent = function(func, state) { this.spinnerEvents[state ? 'on' : 'off'].push(func); }; +this.initialize.apply(this, arguments); +}; +}(); /// MODULE END From gotcha at codespeak.net Mon Dec 24 12:19:21 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 12:19:21 +0100 (CET) Subject: [KSS-checkins] r50056 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224111921.4D0FB168472@codespeak.net> Author: gotcha Date: Mon Dec 24 12:19:19 2007 New Revision: 50056 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/utils.js Log: module and class closures Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 12:19:19 2007 @@ -1,8 +1,6 @@ files where closures are missing plugin.js -utils.js move to kukit the names that are defined in kukit namespaces. - files where indentation has to be undone and initialize needs to be done Modified: kukit/kukit.js/branch/finish-closures/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/utils.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/utils.js Mon Dec 24 12:19:19 2007 @@ -246,37 +246,43 @@ * class FifoQueue */ ut.FifoQueue = function () { + +this.initialize = function () { this.reset(); }; -ut.FifoQueue.prototype.reset = function() { +this.reset = function() { this.elements = new Array(); }; -ut.FifoQueue.prototype.push = function(obj) { +this.push = function(obj) { this.elements.push(obj); }; -ut.FifoQueue.prototype.pop = function() { +this.pop = function() { return this.elements.shift(); }; -ut.FifoQueue.prototype.empty = function() { +this.empty = function() { return ! this.elements.length; }; -ut.FifoQueue.prototype.size = function() { +this.size = function() { return this.elements.length; }; -ut.FifoQueue.prototype.front = function() { +this.front = function() { return this.elements[0]; }; +this.initialize.apply(this, arguments); +}; /* * class SortedQueue */ -ut.SortedQueue = function (comparefunc) { +ut.SortedQueue = function() { + +this.initialize = function(comparefunc) { // comparefunc(left, right) determines the order by returning // -1 if left should occur before right, // +1 if left should occur after right or @@ -289,7 +295,7 @@ this.reset(); }; -ut.SortedQueue.prototype.comparefunc = function(a, b) { +this.comparefunc = function(a, b) { if (a < b) { return -1; } else if (a > b) { @@ -299,11 +305,11 @@ } }; -ut.SortedQueue.prototype.reset = function() { +this.reset = function() { this.elements = new Array(); }; -ut.SortedQueue.prototype.push = function(obj) { +this.push = function(obj) { // Find the position of the object. var i = 0; var length = this.elements.length; @@ -314,31 +320,33 @@ this.elements.splice(i, 0, obj); }; -ut.SortedQueue.prototype.pop = function() { +this.pop = function() { // takes minimal element return this.elements.shift(); }; -ut.SortedQueue.prototype.popn = function(n) { +this.popn = function(n) { // takes first n minimal element return this.elements.splice(0, n); }; -ut.SortedQueue.prototype.empty = function() { +this.empty = function() { return ! this.elements.length; }; -ut.SortedQueue.prototype.size = function() { +this.size = function() { return this.elements.length; }; -ut.SortedQueue.prototype.get = function(n) { +this.get = function(n) { return this.elements[n]; }; -ut.SortedQueue.prototype.front = function() { +this.front = function() { return this.elements[0]; }; +this.initialize.apply(this, arguments); +}; ut.evalBool = function(value, errname) { if (value == 'true' || value == 'True' || value == '1') { @@ -386,7 +394,9 @@ * * for repeating or one time timing */ -ut.TimerCounter = function(delay, func, restart) { +ut.TimerCounter = function() { + +this.initialize = function(delay, func, restart) { this.delay = delay; this.func = func; if (typeof(restart) == 'undefined') { @@ -396,7 +406,7 @@ this.timer = null; }; -ut.TimerCounter.prototype.start = function() { +this.start = function() { if (this.timer) { ;;; kukit.E = 'Timer already started.'; @@ -409,7 +419,7 @@ this.timer = setTimeout(func, this.delay); }; -ut.TimerCounter.prototype.timeout = function() { +this.timeout = function() { // Call the event action this.func(); // Restart the timer @@ -419,24 +429,28 @@ } }; -ut.TimerCounter.prototype.clear = function() { +this.clear = function() { if (this.timer) { window.clearTimeout(this.timer); this.timer = null; } this.restart = false; }; +this.initialize.apply(this, arguments); +}; /* * class Scheduler */ -ut.Scheduler = function(func) { +ut.Scheduler = function() { + +this.initialize = function(func) { this.func = func; this.timer = null; this.nextWake = null; }; -ut.Scheduler.prototype.setNextWake = function(ts) { +this.setNextWake = function(ts) { // Sets wakeup time, null clears if (this.nextWake) { this.clear(); @@ -458,7 +472,7 @@ } }; -ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) { +this.setNextWakeAtLeast = function(ts) { // Sets wakeup time, unless it would wake up later than the // currently set timeout. Null clears the timer. if (! ts || ! this.nextWake || ts < this.nextWake) { @@ -469,7 +483,7 @@ } }; -ut.Scheduler.prototype.timeout = function() { +this.timeout = function() { // clear the timer this.timer = null; this.nextWake = null; @@ -477,14 +491,15 @@ this.func(); }; - -ut.Scheduler.prototype.clear = function() { +this.clear = function() { if (this.nextWake) { window.clearTimeout(this.timer); this.timer = null; this.nextWake = null; } }; +this.initialize.apply(this, arguments); +}; /* * class SerializeScheduler @@ -492,21 +507,23 @@ * Scheduler for serializing bind and load procedures */ ut.SerializeScheduler = function() { + +this.initialize = function() { this.items = []; this.lock = false; }; -ut.SerializeScheduler.prototype.addPre = function(func, remark) { +this.addPre = function(func, remark) { this.items.push({func: func, remark: remark}); this.execute(); }; -ut.SerializeScheduler.prototype.addPost = function(func, remark) { +this.addPost = function(func, remark) { this.items.unshift({func: func, remark: remark}); this.execute(); }; -ut.SerializeScheduler.prototype.execute = function() { +this.execute = function() { if (! this.lock) { this.lock = true; while (true) { @@ -530,6 +547,8 @@ this.lock = false; } }; +this.initialize.apply(this, arguments); +}; /* Browser event binding */ @@ -553,21 +572,35 @@ /* collecting keys-values into a dict or into a tuple list */ +/* +* class DictCollector +*/ ut.DictCollector = function() { + +this.initialize = function() { this.result = {}; }; -ut.DictCollector.prototype.add = function(key, value) { +this.add = function(key, value) { this.result[key] = value; }; +this.initialize.apply(this, arguments); +}; +/* +* class TupleCollector +*/ ut.TupleCollector = function() { + +this.initialize = function() { this.result = []; }; -ut.TupleCollector.prototype.add = function(key, value) { +this.add = function(key, value) { this.result.push([key, value]); }; +this.initialize.apply(this, arguments); +}; }(); /// MODULE END From gotcha at codespeak.net Mon Dec 24 12:24:44 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 12:24:44 +0100 (CET) Subject: [KSS-checkins] r50057 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224112444.57867168440@codespeak.net> Author: gotcha Date: Mon Dec 24 12:24:43 2007 New Revision: 50057 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/dom.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 12:24:43 2007 @@ -5,7 +5,6 @@ files where indentation has to be undone and initialize needs to be done dom.js -errors.js eventreg.js forms.js kssparser.js Modified: kukit/kukit.js/branch/finish-closures/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/dom.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/dom.js Mon Dec 24 12:24:43 2007 @@ -317,8 +317,9 @@ * * Scheduler for embedded window content loaded */ -dom.EmbeddedContentLoadedScheduler = - function(framename, func, autodetect) { +dom.EmbeddedContentLoadedScheduler = function() { + +this.initialize = function(framename, func, autodetect) { this.framename = framename; this.func = func; this.autodetect = autodetect; @@ -331,73 +332,75 @@ //this.counter.timeout(); // XXX can't execute immediately, it fails on IE. this.counter.start(); +}; - this.check = function() { +this.check = function() { + +;;; kukit.logDebug('Is iframe loaded ?'); + + var doc = _getIframeDocument(this.framename); + + // quit if the init function has already been called + // XXX I believe we want to call the function too, then + // XXX attribute access starting with _ breaks full compression, + // even in strings + //if (doc._embeddedContentLoadedInitDone) { + if (doc['_' + 'embeddedContentLoadedInitDone']) { +;;; var msg = 'Iframe already initialized, but we execute the action'; +;;; msg += ' anyway, as requested.'; +;;; kukit.logWarning(msg); + this.counter.restart = false; + } + + // autodetect=false implements a more reliable detection method + // that involves cooperation from the internal document. In this + // case the internal document sets the _kssReadyForLoadEvent attribute + // on the document, when loaded. It is safe to check for this in any + // case, however if this option is selected, we rely only on this, + // and skip the otherwise problematic default checking. + // XXX attribute access starting with _ breaks full compression, + // even in strings + //if (typeof doc._kssReadyForLoadEvent != 'undefined') { + if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') { + this.counter.restart = false; + } + + if (this.autodetect && this.counter.restart) { + + // obviously we are not there... this happens on FF + if (doc.location.href == 'about:blank') { + return; + } /* */ -;;; kukit.logDebug('Is iframe loaded ?'); + // First check for Safari or + // if DOM methods are supported, and the body element exists + // (using a double-check including document.body, + // for the benefit of older moz builds [eg ns7.1] + // in which getElementsByTagName('body')[0] is undefined, + // unless this script is in the body section) - var doc = _getIframeDocument(this.framename); - - // quit if the init function has already been called - // XXX I believe we want to call the function too, then - // XXX attribute access starting with _ breaks full compression, - // even in strings - //if (doc._embeddedContentLoadedInitDone) { - if (doc['_' + 'embeddedContentLoadedInitDone']) { -;;; var msg = 'Iframe already initialized, but we execute the action'; -;;; msg += ' anyway, as requested.'; -;;; kukit.logWarning(msg); + if(/KHTML|WebKit/i.test(navigator.userAgent)) { + if(/loaded|complete/.test(doc.readyState)) { + this.counter.restart = false; + } + } else if(typeof doc.getElementsByTagName != 'undefined' + && (doc.getElementsByTagName('body')[0] != null || + doc.body != null)) { this.counter.restart = false; - } + } /* */ + + } - // autodetect=false implements a more reliable detection method - // that involves cooperation from the internal document. In this - // case the internal document sets the _kssReadyForLoadEvent attribute - // on the document, when loaded. It is safe to check for this in any - // case, however if this option is selected, we rely only on this, - // and skip the otherwise problematic default checking. + if ( ! this.counter.restart) { +;;; kukit.logDebug('Yes, iframe is loaded.'); // XXX attribute access starting with _ breaks full compression, // even in strings - //if (typeof doc._kssReadyForLoadEvent != 'undefined') { - if (typeof doc['_' + 'kssReadyForLoadEvent'] != 'undefined') { - this.counter.restart = false; - } - - if (this.autodetect && this.counter.restart) { - - // obviously we are not there... this happens on FF - if (doc.location.href == 'about:blank') { - return; - } /* */ - - // First check for Safari or - // if DOM methods are supported, and the body element exists - // (using a double-check including document.body, - // for the benefit of older moz builds [eg ns7.1] - // in which getElementsByTagName('body')[0] is undefined, - // unless this script is in the body section) - - if(/KHTML|WebKit/i.test(navigator.userAgent)) { - if(/loaded|complete/.test(doc.readyState)) { - this.counter.restart = false; - } - } else if(typeof doc.getElementsByTagName != 'undefined' - && (doc.getElementsByTagName('body')[0] != null || - doc.body != null)) { - this.counter.restart = false; - } /* */ - - } - - if ( ! this.counter.restart) { -;;; kukit.logDebug('Yes, iframe is loaded.'); - // XXX attribute access starting with _ breaks full compression, - // even in strings - // doc._embeddedContentLoadedInitDone = true; - doc['_' + 'embeddedContentLoadedInitDone'] = true; - this.func(); - } - }; + // doc._embeddedContentLoadedInitDone = true; + doc['_' + 'embeddedContentLoadedInitDone'] = true; + this.func(); + } +}; +this.initialize.apply(this, arguments); }; dom.getNsTags = function(dom_obj, tagName) { From gotcha at codespeak.net Mon Dec 24 12:28:27 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 12:28:27 +0100 (CET) Subject: [KSS-checkins] r50058 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224112827.E56B6168446@codespeak.net> Author: gotcha Date: Mon Dec 24 12:28:26 2007 New Revision: 50058 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/kukit.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 12:28:26 2007 @@ -4,11 +4,9 @@ files where indentation has to be undone and initialize needs to be done -dom.js eventreg.js forms.js kssparser.js -kukit.js oper.js providerreg.js selectorreg.js Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kukit.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js Mon Dec 24 12:28:26 2007 @@ -54,6 +54,8 @@ * class Engine */ ku.Engine = function() { + +this.initialize = function() { this.documentRules = new kukit.rd.MethodTable(); // table from res_type to rule processor this._ruleProcessorClasses = {}; @@ -72,225 +74,227 @@ // setup events queuing, collect them at the end of commands this.setupEventsQueue = []; this.setupEventsInProgress = false; + this.baseUrl = this.calculateBase(); +}; - this.calculateBase = function() { - var base = ''; - try { - var _dummy = document; - _dummy = window; - } catch (e) { - // testing or what - return base; - } - var nodes = document.getElementsByTagName("link"); - if (nodes.length > 0) { - for (var i=0; i 0) { + for (var i=0; i 0 && base.substring(baselen - 1) == '/') { - base = base.substring(0, baselen - 1); - } + } + nodes = document.getElementsByTagName("base"); + if (nodes.length === 0) { + base = window.location.href; + var pieces = base.split('/'); + pieces.pop(); + base = pieces.join('/'); + } else { + base = nodes[0].href; + // take off trailing slash + var baselen = base.length; + if (baselen > 0 && base.substring(baselen - 1) == '/') { + base = base.substring(0, baselen - 1); } - return base; - }; - this.baseUrl = this.calculateBase(); + } + return base; +}; - this.getRuleSheetLinks = function() { - var nodes = document.getElementsByTagName("link"); - var results = []; - for (var i=0; i Author: gotcha Date: Mon Dec 24 12:38:56 2007 New Revision: 50059 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/oper.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 12:38:56 2007 @@ -7,7 +7,6 @@ eventreg.js forms.js kssparser.js -oper.js providerreg.js selectorreg.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/oper.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/oper.js Mon Dec 24 12:38:56 2007 @@ -49,7 +49,9 @@ * * browserevent: the original browser event. */ -op.Oper = function (dict) { +op.Oper = function() { + +this.initialize = function(dict) { this.node = null; this.parms = {}; this.eventRule = null; @@ -57,302 +59,303 @@ this.orignode = null; this.action = null; this.browserevent = null; + // update from the dict + this.unrestrictedUpdate(dict); +}; - this.clone = function(dict, restricted) { - var newoper = new kukit.op.Oper(this); - newoper.unrestrictedUpdate(dict, restricted); - return newoper; - }; +this.clone = function(dict, restricted) { + var newoper = new kukit.op.Oper(this); + newoper.unrestrictedUpdate(dict, restricted); + return newoper; +}; - this.update = function(dict) { - // restricted attrs must not be changed on existing oper. - this.unrestrictedUpdate(dict, true); - }; +this.update = function(dict) { + // restricted attrs must not be changed on existing oper. + this.unrestrictedUpdate(dict, true); +}; - this.unrestrictedUpdate = function(dict, restricted) { - if (typeof(dict) == 'undefined') { - return; - } - for (var key in dict) { -;;; if (typeof(checkKey) == 'undefined') { -;;; var checkKey = function(key) { -;;; var isNode = key == 'node'; -;;; var isParameters = key == 'parms'; -;;; var isEventRule = key == 'eventRule'; -;;; var isBinder = key == 'binder'; -;;; var isOrig = key == 'orignode'; +this.unrestrictedUpdate = function(dict, restricted) { + if (typeof(dict) == 'undefined') { + return; + } + for (var key in dict) { +;;; if (typeof(checkKey) == 'undefined') { +;;; var checkKey = function(key) { +;;; var isNode = key == 'node'; +;;; var isParameters = key == 'parms'; +;;; var isEventRule = key == 'eventRule'; +;;; var isBinder = key == 'binder'; +;;; var isOrig = key == 'orignode'; ;;; return isNode || isParameters || isEventRule || isBinder || isOrig; -;;; }; -;;; } -;;; if (restricted && checkKey(key)) { -;;; kukit.E = 'Illegal update on oper object, protected attribute ['; -;;; kukit.E += key + '].'; -;;; throw new Error(kukit.E); -;;; } - var value = dict[key]; - if (typeof(value) != 'function') { - this[key] = value; - } +;;; }; +;;; } +;;; if (restricted && checkKey(key)) { +;;; kukit.E = 'Illegal update on oper object, protected attribute ['; +;;; kukit.E += key + '].'; +;;; throw new Error(kukit.E); +;;; } + var value = dict[key]; + if (typeof(value) != 'function') { + this[key] = value; } - }; - // update from the dict - this.unrestrictedUpdate(dict); + } +}; - this.logDebug = function() { -;;; var result = []; -;;; for (var key in this){ -;;; if (key == 'parms') { -;;; var res2 = []; -;;; for (var k2 in this.parms){ -;;; res2.push(k2 + '="' + this.parms[k2] + '"'); -;;; } -;;; result.push('parms={' + res2.join(',') + '}'); -;;; } else if (typeof(kukit.op.Oper.prototype[key]) == 'undefined') { -;;; result.push(key + '=' + this[key]); -;;; } +this.logDebug = function() { +;;; var result = []; +;;; for (var key in this){ +;;; if (key == 'parms') { +;;; var res2 = []; +;;; for (var k2 in this.parms){ +;;; res2.push(k2 + '="' + this.parms[k2] + '"'); ;;; } -;;; kukit.logDebug('Oper values: ' + result.join(', ')); - }; +;;; result.push('parms={' + res2.join(',') + '}'); +;;; } else if (typeof(kukit.op.Oper.prototype[key]) == 'undefined') { +;;; result.push(key + '=' + this[key]); +;;; } +;;; } +;;; kukit.logDebug('Oper values: ' + result.join(', ')); +}; - this.executeClientAction = function(name) { - // Check kss action parms - var nodes = null; - // XXX TODO this should be refactored with parms constraint checking - for (key in this.kssParms) { - switch (key) { - case 'kssSelector': { - // The value already contains the results - nodes = this.kssParms[key]; - } break; - default: { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with '; -;;; kukit.E += '"kss"; normal parms (that do not start with'; -;;; kukit.E += ' "kss") only are allowed in action-client keys.'; - throw new Error(kukit.E); - } break; - } +this.executeClientAction = function(name) { + // Check kss action parms + var nodes = null; + // XXX TODO this should be refactored with parms constraint checking + for (key in this.kssParms) { + switch (key) { + case 'kssSelector': { + // The value already contains the results + nodes = this.kssParms[key]; + } break; + default: { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with '; +;;; kukit.E += '"kss"; normal parms (that do not start with'; +;;; kukit.E += ' "kss") only are allowed in action-client keys.'; + throw new Error(kukit.E); + } break; } - // XXX TODO refactor this with commands execution (or the other way) -;;; var nodetext = function(node) { -;;; if (node) { -;;; return node.tagName.toLowerCase(); -;;; } else { -;;; return 'DOCUMENT'; -;;; } -;;; }; - var executeActions = kukit.actionsGlobalRegistry.get(name); - if (nodes != null) { -;;; var msg = nodes.length + ' nodes found for action [' + name + '].'; -;;; kukit.logDebug(msg); -;;; if (!nodes || nodes.length == 0) { -;;; kukit.logWarning('Action selector found no nodes.'); -;;; } - for (var i=0; i < nodes.length; i++) { - this.node = nodes[i]; - //XXX error handling for wrong command name -;;; var msg = '[' + name + '] action executes on target (' + (i+1); -;;; msg += '/' + nodes.length + ') '; -;;; msg += '[' + nodetext(this.node) + '].'; -;;; kukit.logDebug(msg); - executeActions(this); - } - } else { - // single node -;;; var msg = '[' + name + '] action executes on single node '; + } + // XXX TODO refactor this with commands execution (or the other way) +;;; var nodetext = function(node) { +;;; if (node) { +;;; return node.tagName.toLowerCase(); +;;; } else { +;;; return 'DOCUMENT'; +;;; } +;;; }; + var executeActions = kukit.actionsGlobalRegistry.get(name); + if (nodes != null) { +;;; var msg = nodes.length + ' nodes found for action [' + name + '].'; +;;; kukit.logDebug(msg); +;;; if (!nodes || nodes.length == 0) { +;;; kukit.logWarning('Action selector found no nodes.'); +;;; } + for (var i=0; i < nodes.length; i++) { + this.node = nodes[i]; + //XXX error handling for wrong command name +;;; var msg = '[' + name + '] action executes on target (' + (i+1); +;;; msg += '/' + nodes.length + ') '; ;;; msg += '[' + nodetext(this.node) + '].'; ;;; kukit.logDebug(msg); executeActions(this); } - }; + } else { + // single node +;;; var msg = '[' + name + '] action executes on single node '; +;;; msg += '[' + nodetext(this.node) + '].'; +;;; kukit.logDebug(msg); + executeActions(this); + } +}; - this.executeDefaultAction = function(name, optional) { - // Check kss action parms -;;; for (key in this.kssParms) { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; -;;; kukit.E += ' normal parms (that do not start with kss)'; -;;; kukit.E += ' only are allowed in action-default keys.'; +this.executeDefaultAction = function(name, optional) { + // Check kss action parms +;;; for (key in this.kssParms) { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; +;;; kukit.E += ' normal parms (that do not start with kss)'; +;;; kukit.E += ' only are allowed in action-default keys.'; +;;; throw new Error(kukit.E); +;;; } + // + var namespace = this.binder.__eventNamespace__; + var kssevent = kukit.eventsGlobalRegistry.get(namespace, name); + var methodName = kssevent.defaultActionMethodName; + var success = false; + if (! methodName) { +;;; if (! optional) { +;;; kukit.E = 'Could not trigger event [' + name; +;;; kukit.E += '] from namespace [' + namespace + '], because this'; +;;; kukit.E += ' event has no default method registered.'; ;;; throw new Error(kukit.E); ;;; } - // - var namespace = this.binder.__eventNamespace__; - var kssevent = kukit.eventsGlobalRegistry.get(namespace, name); - var methodName = kssevent.defaultActionMethodName; - var success = false; - if (! methodName) { -;;; if (! optional) { -;;; kukit.E = 'Could not trigger event [' + name; -;;; kukit.E += '] from namespace [' + namespace + '], because this'; -;;; kukit.E += ' event has no default method registered.'; -;;; throw new Error(kukit.E); -;;; } + } else { + // Put defaultParameters to parms! + // This makes sure, that for implicit events + // you do not need to specify pass(key) + // for making the parms arrive to the action. + if (typeof(this.defaultParameters) != 'undefined') { + this.parms = this.defaultParameters; } else { - // Put defaultParameters to parms! - // This makes sure, that for implicit events - // you do not need to specify pass(key) - // for making the parms arrive to the action. - if (typeof(this.defaultParameters) != 'undefined') { - this.parms = this.defaultParameters; - } else { - this.parms = {}; - } - this.binder._EventBinder_callMethod( - namespace, name, this, methodName); - success = true; + this.parms = {}; } - return success; - }; + this.binder._EventBinder_callMethod( + namespace, name, this, methodName); + success = true; + } + return success; +}; - this.executeServerAction = function(name) { -;;; for (key in this.kssParms) { -;;; if (key == 'kssUrl') { -;;; // Value will be evaluated. -;;; } else if (key == 'kssSubmitForm') { -;;; // Value will be evaluated. -;;; } else { -;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; -;;; kukit.E += ' normal parms (that do not start with kss)'; -;;; kukit.E += ' only are allowed in action-server keys.'; -;;; throw new Error(kukit.E); -;;; } +this.executeServerAction = function(name) { +;;; for (key in this.kssParms) { +;;; if (key == 'kssUrl') { +;;; // Value will be evaluated. +;;; } else if (key == 'kssSubmitForm') { +;;; // Value will be evaluated. +;;; } else { +;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; +;;; kukit.E += ' normal parms (that do not start with kss)'; +;;; kukit.E += ' only are allowed in action-server keys.'; +;;; throw new Error(kukit.E); ;;; } - // oper will be accessible to some commands that execute in return - var sa = new kukit.sa.ServerAction(name, this); - }; +;;; } + // oper will be accessible to some commands that execute in return + var sa = new kukit.sa.ServerAction(name, this); +}; - /* Helpers the serve binding */ +/* Helpers the serve binding */ - this.getEventName = function () { - // Gets event name - return this.eventRule.kssSelector.name; - }; +this.getEventName = function () { + // Gets event name + return this.eventRule.kssSelector.name; +}; - this.getEventNamespace = function () { - // Gets event name - return this.eventRule.kssSelector.namespace; - }; +this.getEventNamespace = function () { + // Gets event name + return this.eventRule.kssSelector.namespace; +}; - this.hasExecuteActions = function () { - // Decide if there are any actions (or a default action) - // to execute. This can speed up execution if in case - // we have nothing to do, there is no reason to bind - // the actions hook. - if (this.eventRule) { - // if it has actions, the answer is yes - if (this.eventRule.actions.hasActions()) - 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 - // valid, even if it received no parms in the eventRule, - // in which case it is not present as an action. - var kssevent = kukit.eventsGlobalRegistry.get( - this.getEventNamespace(), this.getEventName()) - var methodName = kssevent.defaultActionMethodName; - return (typeof methodName != 'undefined'); - } else - return false; - }; +this.hasExecuteActions = function () { + // Decide if there are any actions (or a default action) + // to execute. This can speed up execution if in case + // we have nothing to do, there is no reason to bind + // the actions hook. + if (this.eventRule) { + // if it has actions, the answer is yes + if (this.eventRule.actions.hasActions()) + 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 + // valid, even if it received no parms in the eventRule, + // in which case it is not present as an action. + var kssevent = kukit.eventsGlobalRegistry.get( + this.getEventNamespace(), this.getEventName()) + var methodName = kssevent.defaultActionMethodName; + return (typeof methodName != 'undefined'); + } else + return false; +}; - this.makeExecuteActionsHook = function (filter) { - // Factory that creates the function that executes the actions. - // The function may take a dict that is updated on the oper - // If filter is specified, it will we called with a function and - // the event will only be triggered if the filter returned true. - // THe return value of func_to_bind will show if the event - // has executed or not. - // - // Speedup. - if (! this.hasExecuteActions()) { - return function() {}; - } - var eventName = this.getEventName(); - var self = this; - var func_to_bind = function(dict) { - // (XXX XXX TODO it should happen here, that we change to a different - // oper class. This is for the future when we separate the BindOper - // from the ActionOper.) - var newoper = self.clone(dict, true); - // call the filter and if it says skip it, we are done - // (Filter has a chance to set a defaultParameters on oper. - if (filter && ! filter(newoper)) return false; - // execute the event's actions - newoper.binder._EventBinder_triggerEvent(eventName, newoper); - // show that the event's actions have been executed - return true; - }; - return func_to_bind; +this.makeExecuteActionsHook = function (filter) { + // Factory that creates the function that executes the actions. + // The function may take a dict that is updated on the oper + // If filter is specified, it will we called with a function and + // the event will only be triggered if the filter returned true. + // THe return value of func_to_bind will show if the event + // has executed or not. + // + // Speedup. + if (! this.hasExecuteActions()) { + return function() {}; + } + var eventName = this.getEventName(); + var self = this; + var func_to_bind = function(dict) { + // (XXX XXX TODO it should happen here, that we change to a different + // oper class. This is for the future when we separate the BindOper + // from the ActionOper.) + var newoper = self.clone(dict, true); + // call the filter and if it says skip it, we are done + // (Filter has a chance to set a defaultParameters on oper. + if (filter && ! filter(newoper)) return false; + // execute the event's actions + newoper.binder._EventBinder_triggerEvent(eventName, newoper); + // show that the event's actions have been executed + return true; }; + return func_to_bind; +}; - /* Utility for parameter checking */ +/* Utility for parameter checking */ - this.evaluateParameters = - function(mandatory, defaults, errname, allow_excess) { - // Checks if mandatory params are supplied and there are no excess params - // also fill up default values - // Parms are cloned and returned. - // Example: - // oper.evaluateParameters(['mand1', 'mand2'], {'key1': 'defval'}, - // 'event X'); -;;; if (typeof(allow_excess) == 'undefined') { -;;; allow_excess = false; -;;; } - var newParameters = {}; - for (var i=0; i Author: gotcha Date: Mon Dec 24 16:54:50 2007 New Revision: 50062 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/eventreg.js kukit/kukit.js/branch/finish-closures/kukit/oper.js kukit/kukit.js/branch/finish-closures/kukit/plugin.js Log: module and class closures in kukit.js implied refactorings in event registry: better inheritance done with prototype instantiations *this implies changing event binder registrations* the even binders have to be functions with their own methods Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 16:54:50 2007 @@ -1,7 +1,3 @@ -files where closures are missing - -plugin.js - files where indentation has to be undone and initialize needs to be done eventreg.js Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Mon Dec 24 16:54:50 2007 @@ -36,7 +36,7 @@ * * namespace = null: means global namespace * defaultActionMethodName = null: if there is no default action implemented -* func must be a class (constructor) function, this is the class that +* klass must be a class (constructor) function, this is the class that * implements the binder. * */ @@ -47,9 +47,9 @@ /* binder registration */ - this.registerBinder = function(className, func) { - if (typeof(func) == 'undefined') { -;;; kukit.E = 'func argument is mandatory when registering an event'; + this.registerBinder = function(className, klass) { + if (typeof(klass) == 'undefined') { +;;; kukit.E = 'klass argument is mandatory when registering an event'; ;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; throw new Error(kukit.E); } @@ -60,30 +60,31 @@ return; } - // Decorate and store the class - decorateEventBinderClass(func); - this.classes[className] = func; + klass.prototype = new _EventBinder(); + klass.prototype.__className__ = className; + var newKlass = function() {}; + newKlass.prototype = new klass(); + this.classes[className] = newKlass; }; this.existsBinder = function(className) { - var func = this.classes[className]; - return (typeof(func) != 'undefined'); + var klass = this.classes[className]; + return (typeof(klass) != 'undefined'); }; this.getBinderClass = function(className) { - var func = this.classes[className]; - if (! func) { + var klass = this.classes[className]; + if (! klass) { // not found ;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; throw new Error(kukit.E); } - return func; + return klass; }; /* events (methods) registration helpers (not to be called directly) */ - this._register = - function(namespace, eventName, klass, + this._register = function(namespace, eventName, klass, bindMethodName, defaultActionMethodName, iterName) { if (typeof(defaultActionMethodName) == 'undefined') { ;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; @@ -96,8 +97,8 @@ className = '' + _eventClassCounter; _eventClassCounter += 1; this.registerBinder(className, klass); - klass.prototype.__className__ = className; } + var binderKlass = this.getBinderClass(className); if (!eventName) { ;;; kukit.E = '[eventName] argument cannot be empty when registering'; ;;; kukit.E += ' an event with [_EventRegistry.register].'; @@ -115,13 +116,13 @@ throw new Error(kukit.E); } // check bindMethodName and defaultActionMethodName - if (bindMethodName && ! klass.prototype[bindMethodName]) { + if (bindMethodName && ! binderKlass.prototype[bindMethodName]) { ;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; ;;; kukit.E += '] is undefined for event [' + eventName; ;;; kukit.E += '] namespace [' + namespace + '].'; throw new Error(kukit.E); } - if (defaultActionMethodName && ! klass.prototype[defaultActionMethodName]) { + if (defaultActionMethodName && ! binderKlass.prototype[defaultActionMethodName]) { ;;; kukit.E = 'In _EventRegistry.register default action method ['; ;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; ;;; kukit.E += eventName + '] namespace [' + namespace + '].'; @@ -230,6 +231,11 @@ } return entry; }; + + this.getBinderClassByEventNamespace = function(namespace, eventName) { + return this.getBinderClass(this.get(namespace, eventName).className); + }; + }; @@ -249,7 +255,50 @@ }; }; -/* Event class decoration +/* +* +* class _LateBinder +* +* postpone binding of actions until called first time +* +*/ +var _LateBinder = function(binder, name, node) { + this.binder = binder; + this.name = name; + this.node = node; + this.boundEvent = null; + + this.executeActions = function() { + if (! this.boundEvent) { +;;; var msg = 'Attempt of late binding for event [' + this.name; +;;; msg += '], node [' + this.node.nodeName + '].'; +;;; kukit.log(msg); + if (kukit.hasFirebug) { + kukit.log(this.node); + } + var info = kukit.engine.binderInfoRegistry.getBinderInfoById( + this.binder.__binderId__); + var oper = info.bound.getBoundOperForNode(this.name, this.node); + if (oper) { + // (if eventRule is null here, we could still have the default + // method, so go on.) + oper.parms = {}; + this.boundEvent = function() { + this.binder.triggerEvent(this.name, oper); + }; +;;; kukit.log('Node bound.'); + } else { +;;; kukit.logWarning('No node bound.'); + this.boundEvent = function() {}; + } + } + this.boundEvent(); + }; +}; + +/* +* +* class EventBinder * * poor man's subclassing * This is called automatically on registration, to dress @@ -267,7 +316,7 @@ * * trigger an event bound to a given state instance, same node * -* binder.__continueEvent__('doit', oper.node, {'extravalue': '5'}); +* binder.continueEvent('doit', oper.node, {'extravalue': '5'}); * * with kss rule: * @@ -286,7 +335,7 @@ * trigger an event bound to a given state instance, and the document * (different from current scope) * -* binder.__continueEvent__('doit', null, {'extravalue': '5'}); +* binder.continueEvent('doit', null, {'extravalue': '5'}); * * with kss rule: * @@ -304,7 +353,7 @@ * * trigger an event on all the nodes + document bound to a given state instance * -* binder.__continueEvent_allNodes__('doit', {'extravalue': '5'}); +* binder.continueEventAllNodes('doit', {'extravalue': '5'}); * * with kss rule: * @@ -317,8 +366,9 @@ * so we create a new oper below */ -var _EventBinder__continueEvent__ = - function(name, node, defaultParameters) { +var _EventBinder = function() { + +this.continueEvent = function(name, node, defaultParameters) { // Trigger a continuation event bound to a given state instance, given node // (or on document, if node = null) // @@ -362,12 +412,18 @@ oper.defaultParameters = {}; } // if eventRule is null here, we can yet have the default method, so go on. - this._EventBinder_triggerEvent(name, oper); + this.triggerEvent(name, oper); ;;; kukit.logDebug('Continuation event [' + name + '] executed on same node.'); }; -var _EventBinder__continueEvent_allNodes__ = - function(name, defaultParameters) { +this.__continueEvent__ = function(name, node, defaultParameters) { +;;; var msg = 'Deprecated [__continueEvent__],'; +;;; msg += 'use [continueEvent] instead !'; +;;; kukit.logWarning(msg); +this.continueEvent(name, node, defaultParameters); +}; + +this.continueEventAllNodes = function(name, defaultParameters) { // Trigger an event bound to a given state instance, on all nodes. // (or on document, if node = null) // if no other nodes execute. @@ -386,61 +442,34 @@ } else { newOper.defaultParameters = {}; } - this._EventBinder_triggerEvent(name, newOper); + this.triggerEvent(name, newOper); executed += 1; } ;;; kukit.logDebug('Event [' + name + '] executed on ' + executed + ' nodes.'); }; -var _EventBinder_makeFuncToBind = function(name, node) { +this.__continueEvent_allNodes__ = function(name, defaultParameters) { +;;; var msg = 'Deprecated [__continueEvent_allNodes__],'; +;;; msg += 'use [continueEventAllNodes] instead !'; +;;; kukit.logWarning(msg); +this.continueEventAllNodes(name, defaultParameters); +}; + +this.makeFuncToBind = function(name, node) { var executor = new er._LateBinder(this, name, node); return function() { executor.executeActions(); }; }; -/* -* -* class _LateBinder -* -* postpone binding of actions until called first time -* -*/ -var _LateBinder = function(binder, name, node) { - this.binder = binder; - this.name = name; - this.node = node; - this.boundEvent = null; - - this.executeActions = function() { - if (! this.boundEvent) { -;;; var msg = 'Attempt of late binding for event [' + this.name; -;;; msg += '], node [' + this.node.nodeName + '].'; -;;; kukit.log(msg); - if (kukit.hasFirebug) { - kukit.log(this.node); - } - var info = kukit.engine.binderInfoRegistry.getBinderInfoById( - this.binder.__binderId__); - var oper = info.bound.getBoundOperForNode(this.name, this.node); - if (oper) { - // (if eventRule is null here, we could still have the default - // method, so go on.) - oper.parms = {}; - this.boundEvent = function() { - this.binder._EventBinder_triggerEvent(this.name, oper); - }; -;;; kukit.log('Node bound.'); - } else { -;;; kukit.logWarning('No node bound.'); - this.boundEvent = function() {}; - } - } - this.boundEvent(); - }; +this.__makeFuncToBind__ = function(name, node) { +;;; var msg = 'Deprecated [__makeFuncToBind__],'; +;;; msg += 'use [makeFuncToBind] instead !'; +;;; kukit.logWarning(msg); +this.makeFuncToBind(name, node); }; -var _EventBinder_triggerEvent = function(name, oper) { +this.triggerEvent = function(name, oper) { // Private. Called from __continueEvent__ or from main event execution. oper.binder = this; if (oper.eventRule) { @@ -466,9 +495,16 @@ } }; +this._EventBinder_triggerEvent = function(name, oper) { +;;; var msg = 'Deprecated [_EventBinder_triggerEvent],'; +;;; msg += 'use [triggerEvent] instead !'; +;;; kukit.logWarning(msg); +this.triggerEvent(name, oper); +}; + /* (default) method call handling */ -var _EventBinder_callMethod = function(namespace, name, oper, methodName) { +this.callMethod = function(namespace, name, oper, methodName) { // hidden method for calling just a method and checking that is exists. // (called from oper) var method = this[methodName]; @@ -483,15 +519,14 @@ method.call(this, name, oper); }; -var decorateEventBinderClass = function(cls) { - cls.prototype.__continueEvent__ = _EventBinder__continueEvent__; - cls.prototype.__continueEvent_allNodes__ = - _EventBinder__continueEvent_allNodes__; - cls.prototype._EventBinder_triggerEvent = _EventBinder_triggerEvent; - cls.prototype._EventBinder_callMethod = _EventBinder_callMethod; - cls.prototype.__makeFuncToBind__ = _EventBinder_makeFuncToBind; +this._EventBinder_callMethod = function(namespace, name, oper, methodName) { +;;; var msg = 'Deprecated [_EventBinder_callMethod],'; +;;; msg += 'use [callMethod] instead !'; +;;; kukit.logWarning(msg); +this.callMethod(namespace, name, oper, methodName); }; +}; /* Event instance registry * * class BinderInfoRegistry Modified: kukit/kukit.js/branch/finish-closures/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/oper.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/oper.js Mon Dec 24 16:54:50 2007 @@ -198,7 +198,7 @@ } else { this.parms = {}; } - this.binder._EventBinder_callMethod( + this.binder.callMethod( namespace, name, this, methodName); success = true; } @@ -279,7 +279,7 @@ // (Filter has a chance to set a defaultParameters on oper. if (filter && ! filter(newoper)) return false; // execute the event's actions - newoper.binder._EventBinder_triggerEvent(eventName, newoper); + newoper.binder.triggerEvent(eventName, newoper); // show that the event's actions have been executed return true; }; Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Mon Dec 24 16:54:50 2007 @@ -19,7 +19,9 @@ /* Core plugins and utilities */ -kukit.pl = {}; +kukit.pl = new function() { /// MODULE START + +var pl = this; /* * Event plugins @@ -37,7 +39,7 @@ * can be defined to specify a default event action. */ -kukit.pl.getTargetForBrowserEvent = function(e) { +pl.getTargetForBrowserEvent = function(e) { // this prevents the handler to be called on wrong elements, which // can happen because of propagation or bubbling // XXX this needs to be tested in all browsers @@ -60,10 +62,10 @@ * * This can be used to register native events in a way that * they handle allowbubbling, preventdefault and preventbubbling as needed. -* (THe handling of these parms are optional, it is allowed not to have them +* (The handling of these parms are optional, it is allowed not to have them * in the oper.parms.) * -* THe register function can also take a filter function as parameter. +* The register function can also take a filter function as parameter. * This function needs to receive oper as a parameter, * where 'browserevent' will be set on oper too as the native browser event. * The function must return true if it wants the event to execute, @@ -78,12 +80,12 @@ * event from the desired one. */ -kukit.pl.registerBrowserEvent = function(oper, filter, eventName) { +pl.registerBrowserEvent = function(oper, filter, eventName) { var func_to_bind = oper.makeExecuteActionsHook(filter); if (! eventName) eventName = oper.getEventName(); var func = function(e) { - var target = kukit.pl.getTargetForBrowserEvent(e); + var target = pl.getTargetForBrowserEvent(e); if (oper.parms.allowbubbling || target == oper.node) { // Execute the action, provide browserevent on oper // ... however, do it protected. We want the preventdefault @@ -135,27 +137,23 @@ /* * class NativeEventBinder */ -kukit.pl.NativeEventBinder = function() { -}; +pl.NativeEventBinder = function() { -kukit.pl.NativeEventBinder.prototype.__bind__node = - function(name, func_to_bind, oper) { +this.__bind__node = function(name, func_to_bind, oper) { ;;; if (oper.node == null) { ;;; throw new Error('Native event [' + name + '] must be bound to a node.'); ;;; } this.__bind__(name, func_to_bind, oper); }; -kukit.pl.NativeEventBinder.prototype.__bind__nodeorwindow = - function(name, func_to_bind, oper) { +this.__bind__nodeorwindow = function(name, func_to_bind, oper) { if (oper.node == null) { oper.node = window; } this.__bind__(name, func_to_bind, oper); }; -kukit.pl.NativeEventBinder.prototype.__bind__window = - function(name, func_to_bind, oper) { +this.__bind__window = function(name, func_to_bind, oper) { ;;; if (oper.node != null) { ;;; throw new Error('Native event [' + name + '] must not be bound to a node.'); ;;; } @@ -163,16 +161,14 @@ this.__bind__(name, func_to_bind, oper); }; -kukit.pl.NativeEventBinder.prototype.__bind__nodeordocument = - function(name, func_to_bind, oper) { +this.__bind__nodeordocument = function(name, func_to_bind, oper) { if (oper.node == null) { oper.node = document; } this.__bind__(name, func_to_bind, oper); }; -kukit.pl.NativeEventBinder.prototype.__bind__ = - function(name, func_to_bind, oper) { +this.__bind__ = function(name, func_to_bind, oper) { ;;; oper.componentName = 'native event binding'; oper.evaluateParameters([], {'preventdefault': '', 'allowbubbling': '', 'preventbubbling': ''}); @@ -186,7 +182,7 @@ throw new Error(kukit.E); } } - kukit.pl.registerBrowserEvent(oper); + pl.registerBrowserEvent(oper); // // XXX Safari hack // necessary since Safari does not prevent the following @@ -198,13 +194,14 @@ if (oper.parms.preventdefault && kukit.HAVE_SAFARI && (oper.parms.allowbubbling || name == 'click' && oper.node.tagName.toLowerCase() == 'a')) { - oper.node.onclick = function cancelClickSafari() { + var cancelClickSafari = function() { return false; }; + oper.node.onclick = cancelClickSafari; } }; -kukit.pl.NativeEventBinder.prototype.__bind_key__ = +this.__bind_key__ = function(name, func_to_bind, oper) { ;;; oper.componentName = 'native key event binding'; oper.evaluateParameters([], @@ -275,52 +272,10 @@ return true; } }; - kukit.pl.registerBrowserEvent(oper, filter); + pl.registerBrowserEvent(oper, filter); +}; }; -/* -* Registration of all the native events that can bound -* to a node or to document -* (= document or window, depending on the event specs) -* Unsupported are those with absolute no hope to work in a cross browser way -* Preventdefault is only allowed for click and key events, currently -*/ -kukit.eventsGlobalRegistry.register(null, 'blur', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'focus', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'resize', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'click', kukit.pl.NativeEventBinder, - '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'dblclick', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'mousedown', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mouseup', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mousemove', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mouseover', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'mouseout', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'change', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'reset', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'select', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'submit', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'keydown', - kukit.pl.NativeEventBinder, '__bind_key__', null); -kukit.eventsGlobalRegistry.register(null, 'keypress', - kukit.pl.NativeEventBinder, '__bind_key__', null); -kukit.eventsGlobalRegistry.register(null, 'keyup', - kukit.pl.NativeEventBinder, '__bind_key__', null); -//kukit.eventsGlobalRegistry.register(null, 'unload', -// kukit.pl.NativeEventBinder, '__bind__window', null); /* * class TimeoutEventBinder @@ -331,12 +286,13 @@ * unless the binding node has been deleted, in which case it stops, * or it runs only once if repeat=false is given. */ -kukit.pl.TimeoutEventBinder = function() { +pl.TimeoutEventBinder = function() { + +this.initialize = function() { this.counters = {}; }; -kukit.pl.TimeoutEventBinder.prototype.__bind__ = - function(name, func_to_bind, oper) { +this.__bind__ = function(name, func_to_bind, oper) { ;;; oper.componentName = 'timeout event binding'; oper.evaluateParameters(['delay'], {'repeat': 'true'}); oper.evalBool('repeat'); @@ -371,17 +327,15 @@ ;;; kukit.logDebug(msg); } }; - -kukit.eventsGlobalRegistry.register(null, 'timeout', - kukit.pl.TimeoutEventBinder, '__bind__', null); +this.initialize.apply(this, arguments); +}; /* * class LoadEventBinder */ -kukit.pl.LoadEventBinder = function() { -}; +pl.LoadEventBinder = function() { -kukit.pl.LoadEventBinder.prototype.processParameters = +this.processParameters = function(oper, iload) { if (! oper) { return; @@ -428,7 +382,7 @@ return oper; }; -kukit.pl.LoadEventBinder.prototype.__bind__ = function(opers_by_eventName) { +this.__bind__ = function(opers_by_eventName) { // This bind method handles load and iload events together, and // opers_by_eventName is // a dictionary of opers which can contain a load and an iload key, @@ -541,11 +495,7 @@ } }; -// Use the [node] iterator to provide expected invocation -// and call signature of the bind method. -kukit.eventsGlobalRegistry.registerForAllEvents(null, ['load', 'iload'], - kukit.pl.LoadEventBinder, '__bind__', null, 'Node'); - +}; /* * class SpinnerEventBinder @@ -553,7 +503,9 @@ * Spinner support. Besides the event itself we use some utility * classes to introduce lazyness (delay) for the spinner. */ -kukit.pl.SpinnerEventBinder = function() { +pl.SpinnerEventBinder = function() { + +this.initialize = function() { this.state = false; var self = this; var timeoutSetState = function(spinnerevent) { @@ -562,7 +514,7 @@ this.scheduler = new kukit.ut.Scheduler(timeoutSetState); }; -kukit.pl.SpinnerEventBinder.prototype.__bind__ = function(name, func_to_bind, +this.__bind__ = function(name, func_to_bind, oper) { ;;; oper.componentName = '[spinner] event binding'; oper.evaluateParameters([], {'laziness': 0}); @@ -576,7 +528,7 @@ kukit.engine.requestManager.registerSpinnerEvent(func, state_to_bind); }; -kukit.pl.SpinnerEventBinder.prototype.setState = function(func_to_bind, state, +this.setState = function(func_to_bind, state, laziness) { // This is called when state changes. We introduce laziness // before calling the func. @@ -587,17 +539,73 @@ this.scheduler.setNextWakeAtLeast(wakeUp); }; -kukit.pl.SpinnerEventBinder.prototype.timeoutSetState = function() { +this.timeoutSetState = function() { // really call the bound actions which should set the spinner this.func_to_bind(); }; +this.initialize.apply(this, arguments); +}; + +}(); /// MODULE END + +/* +* Registration of all the native events that can bound +* to a node or to document +* (= document or window, depending on the event specs) +* Unsupported are those with absolute no hope to work in a cross browser way +* Preventdefault is only allowed for click and key events, currently +*/ +kukit.eventsGlobalRegistry.register(null, 'blur', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null); +kukit.eventsGlobalRegistry.register(null, 'focus', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null); +kukit.eventsGlobalRegistry.register(null, 'resize', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null); +kukit.eventsGlobalRegistry.register(null, 'click', kukit.pl.NativeEventBinder, + '__bind__nodeordocument', null); +kukit.eventsGlobalRegistry.register(null, 'dblclick', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'mousedown', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); +kukit.eventsGlobalRegistry.register(null, 'mouseup', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); +kukit.eventsGlobalRegistry.register(null, 'mousemove', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); +kukit.eventsGlobalRegistry.register(null, 'mouseover', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'mouseout', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'change', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'reset', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'select', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'submit', + kukit.pl.NativeEventBinder, '__bind__node', null); +kukit.eventsGlobalRegistry.register(null, 'keydown', + kukit.pl.NativeEventBinder, '__bind_key__', null); +kukit.eventsGlobalRegistry.register(null, 'keypress', + kukit.pl.NativeEventBinder, '__bind_key__', null); +kukit.eventsGlobalRegistry.register(null, 'keyup', + kukit.pl.NativeEventBinder, '__bind_key__', null); +//kukit.eventsGlobalRegistry.register(null, 'unload', +// kukit.pl.NativeEventBinder, '__bind__window', null); + +kukit.eventsGlobalRegistry.register(null, 'timeout', + kukit.pl.TimeoutEventBinder, '__bind__', null); + +// Use the [node] iterator to provide expected invocation +// and call signature of the bind method. +kukit.eventsGlobalRegistry.registerForAllEvents(null, ['load', 'iload'], + kukit.pl.LoadEventBinder, '__bind__', null, 'Node'); + kukit.eventsGlobalRegistry.register(null, 'spinneron', kukit.pl.SpinnerEventBinder, '__bind__', null); kukit.eventsGlobalRegistry.register(null, 'spinneroff', kukit.pl.SpinnerEventBinder, '__bind__', null); - /* Core actions * * The core client actions that can be executed on the client From gotcha at codespeak.net Mon Dec 24 16:56:54 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 16:56:54 +0100 (CET) Subject: [KSS-checkins] r50063 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo Message-ID: <20071224155654.7ACC116844A@codespeak.net> Author: gotcha Date: Mon Dec 24 16:56:54 2007 New Revision: 50063 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js Log: event binder change to accomodate class closures for event binders Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js Mon Dec 24 16:56:54 2007 @@ -3,9 +3,8 @@ kukit.more_selectors = {}; kukit.more_selectors.AnnoyClickerEvent = function() { -}; -kukit.more_selectors.AnnoyClickerEvent.prototype.__bind_click__ = function(name, func_to_bind, oper) { +this.__bind_click__ = function(name, func_to_bind, oper) { // validate and set parameters oper.evaluateParameters([], {'count': '3'}, 'annoyClicker event binding'); oper.evalInt('count', 'annoyClicker event binding'); @@ -16,21 +15,24 @@ this.count = this.countsomuch; // Just bind the event via the native event binder oper.parms = {}; - kukit.pl.NativeEventBinder.prototype.__bind__('click', func_to_bind, oper); + var clickBinder = kukit.eventsGlobalRegistry.getBinderClassByEventNamespace('', 'click'); + clickBinder.prototype.__bind__('click', func_to_bind, oper); }; -kukit.more_selectors.AnnoyClickerEvent.prototype.__default_click__ = function(name, oper) { +this.__default_click__ = function(name, oper) { oper.evaluateParameters([], {}, 'annoyClicker event binding'); this.count -= 1; if (this.count == 0) { // Continue with the real action. this.count = this.countsomuch; - this.__continueEvent__('doit', oper.node, {}); + this.continueEvent('doit', oper.node, {}); } else { - this.__continueEvent__('annoy', oper.node, {}); + this.continueEvent('annoy', oper.node, {}); } }; +}; + kukit.eventsGlobalRegistry.register('annoyclicker', 'click', kukit.more_selectors.AnnoyClickerEvent, '__bind_click__', '__default_click__'); kukit.eventsGlobalRegistry.register('annoyclicker', 'annoy', kukit.more_selectors.AnnoyClickerEvent, null, null); kukit.eventsGlobalRegistry.register('annoyclicker', 'doit', kukit.more_selectors.AnnoyClickerEvent, null, null); From gotcha at codespeak.net Mon Dec 24 17:26:46 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 17:26:46 +0100 (CET) Subject: [KSS-checkins] r50064 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224162646.6F270168455@codespeak.net> Author: gotcha Date: Mon Dec 24 17:26:43 2007 New Revision: 50064 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/forms.js kukit/kukit.js/branch/finish-closures/kukit/plugin.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 17:26:43 2007 @@ -1,7 +1,6 @@ files where indentation has to be undone and initialize needs to be done eventreg.js -forms.js kssparser.js providerreg.js selectorreg.js Modified: kukit/kukit.js/branch/finish-closures/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/forms.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/forms.js Mon Dec 24 17:26:43 2007 @@ -35,71 +35,78 @@ /* * class _FormQueryElem */ -var _FormQueryElem = function(name, value) { +var _FormQueryElem = function() { + +this.initialize = function(name, value) { this.name = name; this.value = value; +}; - this.encode = function() { - return this.name+ "=" + encodeURIComponent(this.value); - }; - +this.encode = function() { + return this.name+ "=" + encodeURIComponent(this.value); +}; +this.initialize.apply(this, arguments); }; /* * class FormQuery */ fo.FormQuery = function() { + +this.initialize = function() { this.l = []; +}; - this.appendElem = function(name, value) { - if (value == null) { - // do not marshall nulls -;;; var msg = "Parameter '" + name + "' is null,"; -;;; msg += " it is not marshalled."; -;;; kukit.logDebug(msg); - } - else if (typeof(value) == 'string') { - var elem = new _FormQueryElem(name, value); +this.appendElem = function(name, value) { + if (value == null) { + // do not marshall nulls +;;; var msg = "Parameter '" + name + "' is null,"; +;;; msg += " it is not marshalled."; +;;; kukit.logDebug(msg); + } + else if (typeof(value) == 'string') { + var elem = new _FormQueryElem(name, value); + this.l.push(elem); + } + // value.length is for detection of an Array. + // In addition we also check that value.pop is a function + else if (typeof(value) == 'object' && + typeof(value.length) == 'number' && + typeof(value.pop) == 'function') { + // Special marshalling of arrays + for (var i=0; i < value.length; i++) { + var elem = new _FormQueryElem(name, value[i]); this.l.push(elem); } - // value.length is for detection of an Array. - // In addition we also check that value.pop is a function - else if (typeof(value) == 'object' && - typeof(value.length) == 'number' && - typeof(value.pop) == 'function') { - // Special marshalling of arrays - for (var i=0; i < value.length; i++) { - var elem = new _FormQueryElem(name, value[i]); - this.l.push(elem); - } + } + else if (typeof(value) == 'object') { + // Special marshalling of dicts + for (var key in value) { + var qkey = _dictPrefix + name + _dictSeparator; + qkey += key + _dictPostfix; + var elem = new _FormQueryElem(qkey, value[key]); + this.l.push(elem); } - else if (typeof(value) == 'object') { - // Special marshalling of dicts - for (var key in value) { - var qkey = _dictPrefix + name + _dictSeparator; - qkey += key + _dictPostfix; - var elem = new _FormQueryElem(qkey, value[key]); - this.l.push(elem); - } - } - }; + } +}; - this.encode = function() { - var poster = []; - for (var i=0;i < this.l.length;i++) { - poster[poster.length] = this.l[i].encode(); - } - return poster.join("&"); - }; +this.encode = function() { + var poster = []; + for (var i=0;i < this.l.length;i++) { + poster[poster.length] = this.l[i].encode(); + } + return poster.join("&"); +}; - this.toDict = function() { - var d = {}; - for (var i=0;i < this.l.length;i++) { - var elem = this.l[i]; - d[elem.name] = elem.value; - } - return d; - }; +this.toDict = function() { + var d = {}; + for (var i=0;i < this.l.length;i++) { + var elem = this.l[i]; + d[elem.name] = elem.value; + } + return d; +}; +this.initialize.apply(this, arguments); }; /* Form data extraction, helpers */ @@ -121,31 +128,35 @@ * */ -fo.CurrentFormLocator = function(target) { - this.target = target; +fo.CurrentFormLocator = function() { - this.queryForm = function() { - // Find the form that contains the target node. - return findContainer(this.target, function(node) { - if (!node.nodeName) { - return false; - } - if (node.nodeName.toLowerCase() == "form") { - return true; - } else { - return false; - } - }); - }; +this.initialize = function(target) { + this.target = target; +} - this.getForm = function() { - var form = this.queryForm(); - if (!form) { -;;; kukit.logWarning("No form found"); - return null; +this.queryForm = function() { + // Find the form that contains the target node. + return findContainer(this.target, function(node) { + if (!node.nodeName) { + return false; } - return form; - }; + if (node.nodeName.toLowerCase() == "form") { + return true; + } else { + return false; + } + }); +}; + +this.getForm = function() { + var form = this.queryForm(); + if (!form) { +;;; kukit.logWarning("No form found"); + return null; + } + return form; +}; +this.initialize.apply(this, arguments); }; /* @@ -153,15 +164,19 @@ * */ -fo.NamedFormLocator = function(formname) { +fo.NamedFormLocator = function() { + +this.initialize = function(formname) { this.formname = formname; +}; + +this.getForm = fo.CurrentFormLocator.getForm; - this.getForm = fo.CurrentFormLocator.getForm; +this.queryForm = function() { + // Find the form with the given name. + return document.forms[this.formname]; +}; - this.queryForm = function() { - // Find the form with the given name. - return document.forms[this.formname]; - }; }; /* methods to take the desired value(s) from the form */ @@ -278,28 +293,32 @@ * class _FieldUpdateRegistry */ var _FieldUpdateRegistry = function() { + +this.initialize = function() { this.editors = {}; +}; - this.register = function(node, editor) { - var hash = kukit.rd.hashNode(node); - if (typeof(this.editors[hash]) != 'undefined') { -;;; kukit.E = 'Double registration of editor update on node.'; - throw new Error(kukit.E); - } - this.editors[hash] = editor; - //kukit.logDebug('Registered '+node.name + ' hash=' + hash); - //Initialize the editor - editor.doInit(); - }; - - this.doUpdate = function(node) { - var hash = kukit.rd.hashNode(node); - var editor = this.editors[hash]; - if (typeof(editor) != 'undefined') { - editor.doUpdate(node); - //kukit.logDebug('Updated '+node.name + ' hash=' + hash); - } - }; +this.register = function(node, editor) { + var hash = kukit.rd.hashNode(node); + if (typeof(this.editors[hash]) != 'undefined') { +;;; kukit.E = 'Double registration of editor update on node.'; + throw new Error(kukit.E); + } + this.editors[hash] = editor; + //kukit.logDebug('Registered '+node.name + ' hash=' + hash); + //Initialize the editor + editor.doInit(); +}; + +this.doUpdate = function(node) { + var hash = kukit.rd.hashNode(node); + var editor = this.editors[hash]; + if (typeof(editor) != 'undefined') { + editor.doUpdate(node); + //kukit.logDebug('Updated '+node.name + ' hash=' + hash); + } +}; +this.initialize.apply(this, arguments); }; // fieldUpdateRegistry is a public service, available to all components @@ -322,17 +341,19 @@ * */ var _FormValueProvider = function() { - this.check = function(args) { -;;; if (args.length != 1) { -;;; throw new Error('form method needs 1 arguments (formname)'); -;;; } - }; - this.eval = function(args, node) { - var locator = new fo.NamedFormLocator(args[0]); - var collector = new kukit.ut.TupleCollector(); - return fo.getAllFormVars(locator, collector); - }; +this.check = function(args) { +;;; if (args.length != 1) { +;;; throw new Error('form method needs 1 arguments (formname)'); +;;; } +}; + +this.eval = function(args, node) { + var locator = new fo.NamedFormLocator(args[0]); + var collector = new kukit.ut.TupleCollector(); + return fo.getAllFormVars(locator, collector); +}; + }; fo.pproviderFormRegistry.register('form', _FormValueProvider); @@ -343,17 +364,19 @@ * */ var _CurrentFormValueProvider = function() { - this.check = function(args) { -;;; if (args.length != 0) { -;;; throw new Error('currentForm method needs no argument'); -;;; } - }; - this.eval = function(args, node) { - var locator = new fo.CurrentFormLocator(node); - var collector = new kukit.ut.TupleCollector(); - return fo.getAllFormVars(locator, collector); - }; +this.check = function(args) { +;;; if (args.length != 0) { +;;; throw new Error('currentForm method needs no argument'); +;;; } +}; + +this.eval = function(args, node) { + var locator = new fo.CurrentFormLocator(node); + var collector = new kukit.ut.TupleCollector(); + return fo.getAllFormVars(locator, collector); +}; + }; fo.pproviderFormRegistry.register('currentForm', _CurrentFormValueProvider); Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Mon Dec 24 17:26:43 2007 @@ -508,14 +508,13 @@ this.initialize = function() { this.state = false; var self = this; - var timeoutSetState = function(spinnerevent) { + var _timeoutSetState = function(spinnerevent) { self.timeoutSetState(spinnerevent); }; - this.scheduler = new kukit.ut.Scheduler(timeoutSetState); + this.scheduler = new kukit.ut.Scheduler(_timeoutSetState); }; -this.__bind__ = function(name, func_to_bind, - oper) { +this.__bind__ = function(name, func_to_bind, oper) { ;;; oper.componentName = '[spinner] event binding'; oper.evaluateParameters([], {'laziness': 0}); oper.evalInt('laziness'); @@ -528,8 +527,7 @@ kukit.engine.requestManager.registerSpinnerEvent(func, state_to_bind); }; -this.setState = function(func_to_bind, state, - laziness) { +this.setState = function(func_to_bind, state, laziness) { // This is called when state changes. We introduce laziness // before calling the func. this.func_to_bind = func_to_bind; @@ -541,7 +539,8 @@ this.timeoutSetState = function() { // really call the bound actions which should set the spinner - this.func_to_bind(); + var func = this.func_to_bind; + func(); }; this.initialize.apply(this, arguments); }; From gotcha at codespeak.net Mon Dec 24 17:57:12 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 17:57:12 +0100 (CET) Subject: [KSS-checkins] r50066 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224165712.2831A168436@codespeak.net> Author: gotcha Date: Mon Dec 24 17:57:11 2007 New Revision: 50066 Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js Log: reverse erroneous checkin Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Mon Dec 24 17:57:11 2007 @@ -539,8 +539,7 @@ this.timeoutSetState = function() { // really call the bound actions which should set the spinner - var func = this.func_to_bind; - func(); + this.func_to_bind(); }; this.initialize.apply(this, arguments); }; From gotcha at codespeak.net Mon Dec 24 18:04:12 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Mon, 24 Dec 2007 18:04:12 +0100 (CET) Subject: [KSS-checkins] r50067 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071224170412.B04BD168451@codespeak.net> Author: gotcha Date: Mon Dec 24 18:04:12 2007 New Revision: 50067 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24 18:04:12 2007 @@ -3,5 +3,4 @@ eventreg.js kssparser.js providerreg.js -selectorreg.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/selectorreg.js Mon Dec 24 18:04:12 2007 @@ -25,22 +25,29 @@ sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry(); -// this will provide an arbitrary selector, and is designed to -// be used with the makeAnyPP factory function. +/* +* class _AnyPP +* +* This will provide an arbitrary selector, and is designed to +* be used with the makeAnyPP factory function. +* +*/ var _AnyPP = function() { - this.check = function(args) { - // check does not need to be used here actually. -;;; if (args.length != 1) { -;;; throw new Error('internal error, xxxselector() needs 1 argument'); -;;; } - }; - this.eval = function(args, node, defaultParameters) { - var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type); - // We don't have orignode if we evaluate from here, consequently - // the orignode parameter cannot be used from selectors. We pass - // node just to be sure... - return f(args[0], node, defaultParameters, node); - }; + +this.check = function(args) { + // check does not need to be used here actually. +;;; if (args.length != 1) { +;;; throw new Error('internal error, xxxselector() needs 1 argument'); +;;; } +}; +this.eval = function(args, node, defaultParameters) { + var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type); + // We don't have orignode if we evaluate from here, consequently + // the orignode parameter cannot be used from selectors. We pass + // node just to be sure... + return f(args[0], node, defaultParameters, node); +}; + }; sr.pproviderSelRegistry.register('', _AnyPP); @@ -52,23 +59,30 @@ return pp; }; -// this can be used to pass a node programmatically +/* +* class _AnyPP +* +* This can be used to pass a node programmatically +* +*/ var _PassnodePP = function() { - this.check = function(args) { -;;; if (args.length != 1) { -;;; throw new Error('passnode selector method needs 1 argument'); -;;; } - }; - this.eval = function(args, node, defaultParameters) { - var value = defaultParameters[args[0]]; - if (typeof(value) == 'undefined') { - // notfound arguments will get null -;;; kukit.E = 'Nonexistent default parm "'+ key +'"'; - throw new Error(kukit.E); - } - nodes = [value]; - return nodes; - }; + +this.check = function(args) { +;;; if (args.length != 1) { +;;; throw new Error('passnode selector method needs 1 argument'); +;;; } +}; +this.eval = function(args, node, defaultParameters) { + var value = defaultParameters[args[0]]; + if (typeof(value) == 'undefined') { + // notfound arguments will get null +;;; kukit.E = 'Nonexistent default parm "'+ key +'"'; + throw new Error(kukit.E); + } + nodes = [value]; + return nodes; +}; + }; sr.pproviderSelRegistry.register('passnode', _PassnodePP); @@ -84,34 +98,39 @@ * */ var _SelectorTypeRegistry = function () { + +this.initialize = function() { this.mapping = {}; - this.register = function(name, func) { - if (typeof(func) == 'undefined') { - throw new Error('Func is mandatory.'); - } -;;; if (this.mapping[name]) { -;;; // Do not allow redefinition -;;; kukit.logError('Error : redefinition attempt of selector ' + name); -;;; return; -;;; } - this.mapping[name] = func; - // Also register the selector param provider - var pp = sr.makeAnyPP(name); - sr.pproviderSelRegistry.register(name, pp); - }; - - this.get = function(name) { - if (! name) { - // if name is null or undefined or '', - // we use the default type. - name = this.defaultSelectorType; - } - var result = this.mapping[name]; -;;; if (typeof(result) == 'undefined') { -;;; throw new Error('Unknown selector type "' + name + '"'); -;;; } - return result; - }; +}; + +this.register = function(name, func) { + if (typeof(func) == 'undefined') { + throw new Error('Func is mandatory.'); + } +;;; if (this.mapping[name]) { +;;; // Do not allow redefinition +;;; kukit.logError('Error : redefinition attempt of selector ' + name); +;;; return; +;;; } + this.mapping[name] = func; + // Also register the selector param provider + var pp = sr.makeAnyPP(name); + sr.pproviderSelRegistry.register(name, pp); +}; + +this.get = function(name) { + if (! name) { + // if name is null or undefined or '', + // we use the default type. + name = this.defaultSelectorType; + } + var result = this.mapping[name]; +;;; if (typeof(result) == 'undefined') { +;;; throw new Error('Unknown selector type "' + name + '"'); +;;; } + return result; +}; +this.initialize.apply(this, arguments); }; _SelectorTypeRegistry.prototype.defaultSelectorType = 'css'; From gotcha at codespeak.net Tue Dec 25 01:13:53 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 01:13:53 +0100 (CET) Subject: [KSS-checkins] r50069 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071225001353.F2B841684E5@codespeak.net> Author: gotcha Date: Tue Dec 25 01:13:50 2007 New Revision: 50069 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Tue Dec 25 01:13:50 2007 @@ -2,5 +2,4 @@ eventreg.js kssparser.js -providerreg.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Tue Dec 25 01:13:50 2007 @@ -26,40 +26,42 @@ * * The parameter providers need to be registered here. */ - pr.ValueProviderRegistry = function () { - this.content = {}; - this.register = function(name, func) { - if (typeof(func) == 'undefined') { -;;; kukit.E = 'func argument is mandatory when registering a parameter' -;;; kukit.E += ' provider [ValueProviderRegistry.register].'; - throw new Error(kukit.E); - } -;;; if (this.content[name]) { -;;; // Do not allow redefinition -;;; var msg = 'Error : parameter provider [' + name; -;;; msg += '] already registered.'; -;;; kukit.logError(msg); -;;; return; -;;; } - this.content[name] = func; - }; - - this.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); - }; - - this.get = function(name) { - var func = this.content[name]; - if (! func) { -;;; kukit.E = 'Error : undefined parameter provider [' + name + '].'; - throw new Error(kukit.E); - } - return func; - }; +this.initialize = function() { + this.content = {}; +}; +this.register = function(name, func) { + if (typeof(func) == 'undefined') { +;;; kukit.E = 'func argument is mandatory when registering a parameter' +;;; kukit.E += ' provider [ValueProviderRegistry.register].'; + throw new Error(kukit.E); + } +;;; if (this.content[name]) { +;;; // Do not allow redefinition +;;; var msg = 'Error : parameter provider [' + name; +;;; msg += '] already registered.'; +;;; kukit.logError(msg); +;;; return; +;;; } + this.content[name] = func; +}; + +this.exists = function(name) { + var entry = this.content[name]; + return (typeof(entry) != 'undefined'); +}; + +this.get = function(name) { + var func = this.content[name]; + if (! func) { +;;; kukit.E = 'Error : undefined parameter provider [' + name + '].'; + throw new Error(kukit.E); + } + return func; +}; +this.initialize.apply(this, arguments); }; /* @@ -89,77 +91,88 @@ * class _IdentityPP */ var _IdentityPP = function() { - this.check = function(args) { - // check does not need to be used here actually. -;;; if (args.length != 1) { -;;; throw new Error('internal error, _IdentityPP needs 1 argument'); -;;; } - }; - - this.eval = function(args, node) { - return args[0]; - }; + +this.check = function(args) { + // check does not need to be used here actually. +;;; if (args.length != 1) { +;;; throw new Error('internal error, _IdentityPP needs 1 argument'); +;;; } +}; + +this.eval = function(args, node) { + return args[0]; +}; + }; /* * class _FormVarPP */ var _FormVarPP = function() { - this.check = function(args) { -;;; if (args.length != 2) { -;;; throw new Error('formVar method needs 2 arguments [formname, varname]'); -;;; } - }; - this.eval = function(args, node) { - return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), args[1]); - }; + +this.check = function(args) { +;;; if (args.length != 2) { +;;; throw new Error('formVar method needs 2 arguments [formname, varname]'); +;;; } +}; + +this.eval = function(args, node) { + return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), args[1]); +}; + }; /* * class _CurrentFormPP */ var _CurrentFormVarPP = function() { - this.check = function(args) { -;;; if (args.length != 0 && args.length != 1) { -;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]'); -;;; } - }; - this.eval = function(args, node) { - if (args.length == 1) { - return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), - args[0]); - } else { - // no form var name, just get the value of the node. - return kukit.fo.getValueOfFormElement(node); - } - }; + +this.check = function(args) { +;;; if (args.length != 0 && args.length != 1) { +;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]'); +;;; } +}; + +this.eval = function(args, node) { + if (args.length == 1) { + return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), + args[0]); + } else { + // no form var name, just get the value of the node. + return kukit.fo.getValueOfFormElement(node); + } +}; + }; /* * class _CurrentFormVarFromKssAttrPP */ var _CurrentFormVarFromKssAttrPP = function() { - this.check = function(args) { -;;; if (args.length != 1 && args.length != 2) { -;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument'; -;;; kukit.E += ' [attrname, [recurseParents]]'; -;;; throw new Error(kukit.E); -;;; } - }; - this.eval = function(args, node) { - var argname = args[0]; - var recurseParents = false; - if (args.length == 2) { -;;; kukit.E = '2nd attribute of currentFormVarForKssAttr must be a'; -;;; kukit.E += ' boolean'; - kukit.ut.evalBool(args[1], kukit.E); - recurseParents = args[1]; - } - var formvarname = kukit.dom.getRecursiveAttribute(node, argname, - recurseParents, kukit.dom.getKssAttribute); - return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), - formvarname); - }; + +this.check = function(args) { +;;; if (args.length != 1 && args.length != 2) { +;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument'; +;;; kukit.E += ' [attrname, [recurseParents]]'; +;;; throw new Error(kukit.E); +;;; } +}; + +this.eval = function(args, node) { + var argname = args[0]; + var recurseParents = false; + if (args.length == 2) { +;;; kukit.E = '2nd attribute of currentFormVarForKssAttr must be a'; +;;; kukit.E += ' boolean'; + kukit.ut.evalBool(args[1], kukit.E); + recurseParents = args[1]; + } + var formvarname = kukit.dom.getRecursiveAttribute(node, argname, + recurseParents, kukit.dom.getKssAttribute); + return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node), + formvarname); +}; + }; @@ -168,18 +181,21 @@ * class _FormPP */ var _FormPP = function() { - this.check = function(args) { -;;; if (args.length != 1) { -;;; throw new Error('form method needs 1 arguments [formname]'); -;;; } -;;; var msg = 'Deprecated the [form(formname)] parameter provider,'; -;;; msg += ' use [xxx-kssSubmitForm: form(formname)] instead !'; -;;; kukit.logWarning(msg); - }; - this.eval = function(args, node) { - return kukit.fo.getAllFormVars(new kukit.fo.NamedFormLocator(args[0]), - new kukit.ut.DictCollector()); - }; + +this.check = function(args) { +;;; if (args.length != 1) { +;;; throw new Error('form method needs 1 arguments [formname]'); +;;; } +;;; var msg = 'Deprecated the [form(formname)] parameter provider,'; +;;; msg += ' use [xxx-kssSubmitForm: form(formname)] instead !'; +;;; kukit.logWarning(msg); +}; + +this.eval = function(args, node) { + return kukit.fo.getAllFormVars(new kukit.fo.NamedFormLocator(args[0]), + new kukit.ut.DictCollector()); +}; + }; /* BBB. To be deprecated at 2007-08-15 */ @@ -187,137 +203,155 @@ * class _CurrentFormPP */ var _CurrentFormPP = function() { - this.check = function(args) { -;;; if (args.length != 0) { -;;; throw new Error('currentForm method needs no argument'); -;;; } -;;; var msg = 'Deprecated the [currentForm()] parameter provider,'; -;;; msg += ' use [xxx-kssSubmitForm: currentForm()] instead !'; -;;; kukit.logWarning(msg); - }; - this.eval = function(args, node) { - return kukit.fo.getAllFormVars(new kukit.fo.CurrentFormLocator(node), - new kukit.ut.DictCollector()); - }; + +this.check = function(args) { +;;; if (args.length != 0) { +;;; throw new Error('currentForm method needs no argument'); +;;; } +;;; var msg = 'Deprecated the [currentForm()] parameter provider,'; +;;; msg += ' use [xxx-kssSubmitForm: currentForm()] instead !'; +;;; kukit.logWarning(msg); +}; + +this.eval = function(args, node) { + return kukit.fo.getAllFormVars(new kukit.fo.CurrentFormLocator(node), + new kukit.ut.DictCollector()); +}; + }; /* * class _NodeAttrPP */ var _NodeAttrPP = function() { - this.check = function(args) { -;;; if (args.length != 1 && args.length != 2) { -;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,'; -;;; kukit.E += ' [recurseParents]).'; -;;; throw new Error(kukit.E); -;;; } -;;; if (args[0].toLowerCase() == 'style') { -;;; throw new Error('nodeAttr method does not accept [style] as attrname.'); -;;; } -;;; if (args[0].match(/[ ]/)) { -;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); -;;; } - }; - this.eval = function(args, node) { - var argname = args[0]; - var recurseParents = false; - if (args.length == 2) { - recurseParents = args[1]; -;;; kukit.E = '2nd attribute of nodeAttr must be a boolean.'; - kukit.ut.evalBool(recurseParents, kukit.E); - } - return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, - kukit.dom.getAttribute); - }; + +this.check = function(args) { +;;; if (args.length != 1 && args.length != 2) { +;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,'; +;;; kukit.E += ' [recurseParents]).'; +;;; throw new Error(kukit.E); +;;; } +;;; if (args[0].toLowerCase() == 'style') { +;;; throw new Error('nodeAttr method does not accept [style] as attrname.'); +;;; } +;;; if (args[0].match(/[ ]/)) { +;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); +;;; } +}; + +this.eval = function(args, node) { + var argname = args[0]; + var recurseParents = false; + if (args.length == 2) { + recurseParents = args[1]; +;;; kukit.E = '2nd attribute of nodeAttr must be a boolean.'; + kukit.ut.evalBool(recurseParents, kukit.E); + } + return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, + kukit.dom.getAttribute); +}; + }; /* * class _KssAttrPP */ var _KssAttrPP = function() { - this.check = function(args) { -;;; if (args.length != 1 && args.length != 2) { -;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,'; -;;; kukit.E += ' [recurseParents]).'; -;;; throw new Error(kukit.E); -;;; } -;;; if (args[0].match(/[ -]/)) { -;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; -;;; kukit.E += ' dashes or spaces.'; -;;; throw new Error(kukit.E); -;;; } - }; - this.eval = function(args, node) { - var argname = args[0]; - var recurseParents = false; - if (args.length == 2) { - recurseParents = args[1]; -;;; kukit.E = '2nd attribute of kssAttr must be a boolean.'; - kukit.ut.evalBool(recurseParents, kukit.E); - } - return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, - kukit.dom.getKssAttribute); - }; + +this.check = function(args) { +;;; if (args.length != 1 && args.length != 2) { +;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,'; +;;; kukit.E += ' [recurseParents]).'; +;;; throw new Error(kukit.E); +;;; } +;;; if (args[0].match(/[ -]/)) { +;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } +}; + +this.eval = function(args, node) { + var argname = args[0]; + var recurseParents = false; + if (args.length == 2) { + recurseParents = args[1]; +;;; kukit.E = '2nd attribute of kssAttr must be a boolean.'; + kukit.ut.evalBool(recurseParents, kukit.E); + } + return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, + kukit.dom.getKssAttribute); +}; + }; /* * class _NodeContentPP */ var _NodeContentPP = function() { - this.check = function(args) { -;;; if (args.length != 0 && args.length != 1) { -;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].'); -;;; } - }; - this.eval = function(args, node) { - var recursive = false; - if (args.length == 1) { - recursive = args[0]; - } - return kukit.dom.textContent(node, recursive); - }; + +this.check = function(args) { +;;; if (args.length != 0 && args.length != 1) { +;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].'); +;;; } +}; + +this.eval = function(args, node) { + var recursive = false; + if (args.length == 1) { + recursive = args[0]; + } + return kukit.dom.textContent(node, recursive); +}; + }; /* * class _StateVarPP */ var _StateVarPP = function() { - this.check = function(args) { -;;; if (args.length != 1) { -;;; throw new Error('stateVar method needs 1 argument [varname].'); -;;; } - }; - this.eval = function(args, node) { - var key = args[0]; - var value = kukit.engine.stateVariables[key]; - if (typeof(value) == 'undefined') { - // notfound arguments will get null -;;; kukit.E = 'Nonexistent statevar ['+ key +'].'; - throw new Error(kukit.E); - } - return value; - }; + +this.check = function(args) { +;;; if (args.length != 1) { +;;; throw new Error('stateVar method needs 1 argument [varname].'); +;;; } +}; + +this.eval = function(args, node) { + var key = args[0]; + var value = kukit.engine.stateVariables[key]; + if (typeof(value) == 'undefined') { + // notfound arguments will get null +;;; kukit.E = 'Nonexistent statevar ['+ key +'].'; + throw new Error(kukit.E); + } + return value; +}; + }; /* * class _PassPP */ var _PassPP = function() { - this.check = function(args) { -;;; if (args.length != 1) { -;;; throw new Error('pass method needs 1 argument [attrname].'); -;;; } - }; - this.eval = function(args, node, defaultParameters) { - var key = args[0]; - var value = defaultParameters[key]; - if (typeof(value) == 'undefined') { - // notfound arguments will get null -;;; kukit.E = 'Nonexistent default parm ['+ key +'].'; - throw new Error(kukit.E); - } - return value; - }; + +this.check = function(args) { +;;; if (args.length != 1) { +;;; throw new Error('pass method needs 1 argument [attrname].'); +;;; } +}; + +this.eval = function(args, node, defaultParameters) { + var key = args[0]; + var value = defaultParameters[key]; + if (typeof(value) == 'undefined') { + // notfound arguments will get null +;;; kukit.E = 'Nonexistent default parm ['+ key +'].'; + throw new Error(kukit.E); + } + return value; +}; + }; From reebalazs at codespeak.net Tue Dec 25 08:38:53 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 08:38:53 +0100 (CET) Subject: [KSS-checkins] r50070 - kukit/kukit.js/branch/ree-service-layer-and-refactoring Message-ID: <20071225073853.185D6168417@codespeak.net> Author: reebalazs Date: Tue Dec 25 08:38:52 2007 New Revision: 50070 Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ - copied from r50069, kukit/kukit.js/trunk/ Log: Branch off From reebalazs at codespeak.net Tue Dec 25 12:58:14 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:14 +0100 (CET) Subject: [KSS-checkins] r50071 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115814.D895B1684F4@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:12 2007 New Revision: 50071 Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Log: End of first changes - done before I created this repo. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js Tue Dec 25 12:58:12 2007 @@ -77,42 +77,13 @@ ;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; throw new Error(kukit.E); } - return _cssQuery(selector, inNodes); + return kukit.engine.coreinterface.cssQuery(selector, inNodes); }; /* - * Decide which query to use + * Helper for focusing */ -var _USE_BASE2 = (typeof(base2) != 'undefined'); -if (_USE_BASE2) { -;;;kukit.log('Using cssQuery from base2.'); - var _cssQuery = function(selector, inNodes) { - // global scope, always. - // This is very bad. However the binding makes sure that - // nodes once bound will never be bound again - // (also, noticed the following issue: cssQuery, when called - // on an element, does not check the element itself.) - var results = base2.DOM.Document.matchAll(document, selector); - var nodes = []; - for(var i = 0; i < results.length; i++) { - nodes.push(results.item(i)); - } - return nodes; - }; -} else { -;;;kukit.log('Using original cssQuery.'); - var _cssQuery = function(selector, inNodes) { - // global scope, always. - // This is very bad. However the binding makes sure that - // nodes once bound will never be bound again - // (also, noticed the following issue: cssQuery, when called - // on an element, does not check the element itself.) - var results = cssQuery(selector); - return results; - }; -}; - dom.focus = function(node) { tagName = node.tagName.toLowerCase(); if ((tagName == 'input') || (tagName == 'select') Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:12 2007 @@ -693,6 +693,10 @@ // XXX This will need refactoring. /// We would only want to lookup from our registry and not the other way around. +// +// own registry means eventsets need to be registered in the instance. (klass) +// +// _OperRegistry.prototype.processBindingEvents = function (binder) { var eventRegistry = kukit.eventsGlobalRegistry; Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- (empty file) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:12 2007 @@ -0,0 +1,262 @@ + +kukit.interfaces = new function() { /* BEGIN CLOSURE kukit.interfaces */ + +var InterfaceDescriptor = function(name, MethodDescriptor) { + // A parameters are the name of the interface, and + // the method descriptor class it uses. + // + this.name = name; + this.finalized = false; + this.registry = {}; + this.klass; + this.MethodDescriptor = MethodDescriptor; + + this.getMethodDescriptor = function(methodName) { + // assert prohibited names + if (methodName == 'Interfaces' || methodName.substr(0, 3) == 'get' || methodName == '_interface') { +;;; kukit.E = 'Method name "' + methodName + '" is prohibited, in interface ['; +;;; kukit.E += this.name + ']'; + throw new Error(kukit.E); + } + // create the descriptor on demand + var methodDescriptor; + methodDescriptor = this.registry[methodName]; + if (typeof(methodDescriptor) == 'undefined') { + // Use the registry in the instance, to look up the MethodDescriptor class + // for this method name + + // instantiate the descriptor + methodDescriptor = this.registry[methodName] = new this.MethodDescriptor(this, methodName); + } + return methodDescriptor; + }; + + /* Apply functions on method descriptors of the interface */ + + var _applyFunc = function(f, methodName, methodDescriptor, argArray, nextArg) { + var newArray = []; + newArray.push(methodName); + newArray.push(methodDescriptor); + for ( ;nextArg < argArray.length; nextArg++) { + newArray.push(argArray[nextArg]); + } + f.apply(null, newArray); + }; + + this.forEachMethod = function(f) { + // Execute f for the designated method. + // methodName and MethodDescriptor will be passed to f as parameters. + // Extra arguments will be passed in addition. + for (var methodName in this.registry) { + var methodDescriptor = this.registry[methodName]; + _applyFunc(f, methodName, methodDescriptor, arguments, 1); + } + }; + + this.finalize = function(klass, loader) { + // Check if we are finalized. + if (this.finalized) { +;;; kukit.E = 'Attempt to finalize already finalized plugin interface ['; +;;; kukit.E += this.name + ']'; + throw new Error(kukit.E); + } + // Finalize all methods. + this.forEachMethod(function(methodName, methodDescriptor) { + // Finalize them + var methodFunc = methodDescriptor.finalize(loader); + // store the functions on the class's prototype + klass.prototype[methodName] = methodFunc; + }); + // store myself (the interface descriptor) on the class + klass.prototype.interface = this; + // Set finalized state. + // We are finalized if the loader has no items to load. + // If there is no loader, we are finalized always. + this.finalized = ! loader || loader.empty(); +;;; if (this.finalized) { +;;; kukit.E = 'Finalizing interface [' + this.name + ']'; +;;; kukit.logDebug(kukit.E); +;;; } else { +;;; kukit.E = 'Postpone finalization of interface [' + this.name + '],'; +;;; kukit.E = ' and request sources [', loader.getSources() + ']'; +;;; kukit.logDebug(kukit.E); +;;; } + }; + +}; /* end InterfaceDescriptor */ + +this.Interfaces = function() { + + this.registry = {}; + + this.get = function(name, MethodDescriptor) { + // create the descriptor on demand + var interfaceDescriptor; + interfaceDescriptor = this.registry[name]; + if (typeof(interfaceDescriptor) == 'undefined') { + interfaceDescriptor = this.registry[name] = new InterfaceDescriptor(name, MethodDescriptor); + } else { + if (interfaceDescriptor.MethodDescriptor != MethodDescriptor) { +;;; kukit.E = 'Interface "' + name + '" already has a different method descriptor specified earlier.'; + throw new Error(kukit.E); + } + } + return interfaceDescriptor; + }; + +}; /* end Interfaces */ + +/* + * KSS service layer registry + */ + +this.ServiceMethodDescriptor = function(iface, methodName) { + + this.iface = iface; + this.methodName = methodName; + this.registry = {}; + this.preferredProviders = null; + + this.define = function(preferredProviders, checker, fallbackProvider) { + if (this.preferredProviders) { +;;; kukit.E = 'Attempt to double define method ['; +;;; kukit.E += this.methodName + '] on interface ['; +;;; kukit.E += this.iface.name + ']'; + throw new Error(kukit.E); + }; + this.preferredProviders = preferredProviders; + this.checker = checker; + this.fallbackProvider = fallbackProvider; + }; + + this.provide = function(providerName, providerVersion, getter) { + if (this.iface.finalized) { +;;; kukit.E = 'Attempt to provide implementation to method ['; +;;; kukit.E += this.methodName + '] on already finalized interface ['; +;;; kukit.E += this.iface.name + ']'; + throw new Error(kukit.E); + } else if (typeof(this.registry[providerName]) != 'undefined') { +;;; kukit.E = 'Double registration by [' + providerName + ']['; +;;; kukit.E += providerVersion; +;;; kukit.E += '] of method [' + this.methodName; +;;; kukit.E += '] in interface [' + this.iface.name + ']'; + throw new Error(kukit.E); + } + this.registry[providerName] = { + methodName: this.methodName, + providerName: providerName, + providerVersion: providerVersion, + getter: getter}; + }; + + this.finalize = function(loader) { + var func; + if (! this.preferredProviders) { +;;; kukit.E = 'Undefined method ['; +;;; kukit.E += this.methodName + '] on interface ['; +;;; kukit.E += this.iface.name + '], '; +;;; kukit.E += 'but the following were provided:'; +;;; kukit.E += this.registry + ']'; + throw new Error(kukit.E); + } + // loop through all preferred providers + for (var i = 0; i < this.preferredProviders.length; i++) { + var item = this.registry[this.preferredProviders[i]]; + // Did we have an item? + if (typeof(item) == 'undefined') { + continue; + } + // Execute the item's getter + func = item.getter(); + // Did it return the function? + if (func) { + // found it + break; + } + // if not, we continue with the next best choice. + } + if (! func) { + if (typeof(loader) != 'undefined') { + // We have a loading method. Let's add our needs. + loader.add(this.fallbackProvider); + // ... and simply go on. + } else { + // We raise an error. +;;; kukit.E = 'Could not finalize method ['; +;;; kukit.E += this.methodName + '] on interface ['; +;;; kukit.E += this.iface.name + '], because no provider found '; +;;; kukit.E += 'of the following preferences: ['; +;;; kukit.E += this.preferredProviders + ']'; + throw new Error(kukit.E); + } + } + if (this.checker) { + // if there is a checker, merge them together + var self = this; + return function() { + self.checker(null, arguments); + return func(null, arguments); + }; + } else { + // else, just store the function + return func; + } + }; + +}; /* end ServiceMethodDescriptor */ + + +/* + * KSS plugin registry + */ + +this.PluginMethodDescriptor = function(iface, methodName) { + + this.iface = iface; + this.methodName = methodName; + this.config = null; + + this.register = function(config) { + if (this.config != null) { +;;; kukit.E = 'Double registration by [' + providerName + ']['; +;;; kukit.E += providerVersion; +;;; kukit.E += '] of method [' + this.methodName; +;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; + throw new Error(kukit.E); + } + this.config = config; + }; + + this.finalize = function(loader) { + if (! this.config) { + return; + } + // Just return the registered value. + return this.config; + }; + +}; /* end PluginMethodDescriptor */ + + +/* + * Instantiation + */ + +// create singleton for interfaces +var _interfaces = new this.Interfaces(); + +// The following methods can acquire a given interface + +// wrap the function, since there are no bound methods in JS +this.get = function(name, MethodDescriptor) { + return _interfaces.get(name, MethodDescriptor); +}; +this.getService = function(name) { + return _interfaces.get(name, this.ServiceMethodDescriptor); +}; +this.getPlugin = function(name) { + return _interfaces.get(name, this.PluginMethodDescriptor); +}; + + +}(); /* END CLOSURE kukit.interfaces */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Tue Dec 25 12:58:12 2007 @@ -243,6 +243,12 @@ ;;; kukit.log('[initializeRules] is called twice.'); return; } +;;; kukit.log('Initializing interfaces.'); + // We finalize the core interface. + var klass = function() {}; + kukit.interfaces.get('core').finalize(klass); + var obj = new klass(); + this.coreinterface = obj ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept // as a global variable, but this needs refinement in the future. Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- (empty file) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Tue Dec 25 12:58:12 2007 @@ -0,0 +1,63 @@ + + + +new function() { // BEGIN CLOSURE service + + var core = kukit.interfaces.getService('core'); + core.getMethodDescriptor('cssQuery').define(['base2', 'cssQuery'], + // a parameter checker common for each implementation + function(selector, inNodes) { + // to eliminate possible errors + if (typeof(inNodes) != 'undefined' && inNodes == null) { +;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; + throw new Error(kukit.E); + } + }); + + // providers are also here now + + core.getMethodDescriptor('cssQuery').provide('cssQuery', '1.1', + function() { + // Detect if cssQuery is present + // + if (typeof(cssQuery) == 'undefined') { + return; + } + // return the method plug +;;; kukit.log('Using original cssQuery.'); + return function(selector, inNodes) { + // global scope, always. + // This is very bad. However the binding makes sure that + // nodes once bound will never be bound again + // (also, noticed the following issue: cssQuery, when called + // on an element, does not check the element itself.) + var results = cssQuery(selector); + return results; + }; + }); + + + core.getMethodDescriptor('cssQuery').provide('base2', '1.1', + function() { + // Detect if base2 is present + // + if (typeof(base2) == 'undefined') { + return; + } + // return the method plug +;;; kukit.log('Using cssQuery from base2.'); + return function(selector, inNodes) { + // global scope, always. + // This is very bad. However the binding makes sure that + // nodes once bound will never be bound again + var results = base2.DOM.Document.matchAll(document, selector); + var nodes = []; + for(var i = 0; i < results.length; i++) { + nodes.push(results.item(i)); + } + return nodes; + }; + }); + + +}() // END CLOSURE service Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html Tue Dec 25 12:58:12 2007 @@ -48,6 +48,8 @@ src="../kukit/utils.js"> + + + Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js Tue Dec 25 12:58:12 2007 @@ -23,6 +23,9 @@ testsuite.registerTest(kukit.KssParserTestCase); testsuite.registerTest(kukit.KssParserSelectorsTestCase); testsuite.registerTest(kukit.KssParserSelectorTestCase); + testsuite.registerTest(kukit.InterfacesTestCase); + testsuite.registerTest(kukit.ServiceInterfacesTestCase); + testsuite.registerTest(kukit.PluginInterfacesTestCase); testsuite.runSuite(); }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Tue Dec 25 12:58:12 2007 @@ -5,6 +5,7 @@ -f ../3rd_party/base2-dom-fp.js \ -f ../kukit/kukit.js \ -f ../kukit/utils.js \ + -f ../kukit/interfaces.js \ -f ../kukit/errors.js \ -f ../kukit/oper.js \ -f ../kukit/tokenizer.js \ @@ -20,9 +21,11 @@ -f ../kukit/commandprocessor.js \ -f ../kukit/selectorreg.js \ -f ../kukit/forms.js \ + -f ../kukit/service.js \ -f ../kukit/plugin.js \ -f test_utils.js \ -f test_requestmanager.js \ -f test_tokenizer.js \ -f test_kssparser.js \ + -f test_interfaces.js \ runtests.js Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- (empty file) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:12 2007 @@ -0,0 +1,465 @@ +/* +* Copyright (c) 2005-2007 +* Authors: KSS Project Contributors (see doc/CREDITS.txt) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +* 02111-1307, USA. +*/ + +if (typeof(kukit) == "undefined") { + var kukit = {}; +} + +kukit.InterfacesTestCaseBase = function() { + this.setUp = function() { + // work with our own object, not interfering + // kukit.interfaces + this.interfaces = new kukit.interfaces.Interfaces(); + }; +}; /* end InterfacesTestCase */ +kukit.InterfacesTestCaseBase.prototype = new kukit.UtilsTestCaseBase(); + +kukit.InterfacesTestCase = function() { + /* + * Plugin interfaces + */ + + var called = []; + + var MethodDescriptor = function(iface, methodName) { + this.iface = iface; + this.methodName = methodName; + this.doThis = function() { + called.push("doThis"); + } + this.doThat = function() { + called.push("doThat"); + } + this.finalize = function(loader) { + var signature = "FUNC " + this.methodName; + called.push(signature); + return signature; + } + }; + + this.testInterfaces = function() { + // We have a class, called C. + var C = function() {}; + // We can create a simple method descriptor for an interface we want. + // The method descriptor is managing the method's registration state + called = []; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummytest', MethodDescriptor); + // Let's get two methods + iface.getMethodDescriptor('fooMethod').doThis() + iface.getMethodDescriptor('barMethod').doThat() + // Check + this.assertListEquals(called, ['doThis', 'doThat']); + called = []; + // Ok. Now get the descriptors again... + iface.getMethodDescriptor('fooMethod').doThis() + iface.getMethodDescriptor('barMethod').doThat() + // Check + this.assertListEquals(called, ['doThis', 'doThat']); + called = []; + // + // Now let's iterate on all instantiated methods: + iface.forEachMethod(function(methodName, methodDescriptor) { + methodDescriptor.doThis() + }); + // Check + this.assertListEquals(called, ['doThis', 'doThis']); + called = []; + }; + + this.testFinalizeInterfaces = function() { + // We have a class, called C. + var C = function() {}; + // We can create a simple method descriptor for an interface we want. + // The method descriptor is managing the method's registration state + called = []; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummytest', MethodDescriptor); + // Let's get two methods + iface.getMethodDescriptor('fooMethod').doThis() + iface.getMethodDescriptor('barMethod').doThat() + // Check + this.assertListEquals(called, ['doThis', 'doThat']); + called = []; + // + // At this point we are also ready to finalize the interface. + iface.finalize(C) + // This calls finalize on all method descriptors. + this.assertListEquals(called, ['FUNC fooMethod', 'FUNC barMethod']); + called = []; + // At the same time it also set up these on the class prototype. + var o = new C(); + this.assert(o.fooMethod, 'FUNC fooMethod'); + this.assert(o.barMethod, 'FUNC barMethod'); + // ... so if the descriptor sets methodFunc on the + }; + + this.testTwoInterfaces = function() { + // Let's have a second method descriptor class + var MethodDescriptor2 = function(iface, methodName) { + this.iface = iface; + this.methodName = methodName; + this.finalize = function(loader) { + var signature = "IFACE2 " + this.methodName; + return signature; + } + }; + // We have a class, called C. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummytest', MethodDescriptor); + // We can get the same interface again... + this.interfaces.get('dummytest', MethodDescriptor); + // however not with a different descriptor class! + var self = this; + this.assertThrows(function() { + self.interfaces.get('dummytest', MethodDescriptor2); + }, + Error); + // + // On the other hand setting up a second interface is no problem. + var iface2 = this.interfaces.get('dummytest2', MethodDescriptor2); + }; + +}; /* end InterfacesTestCase */ +kukit.InterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); + + +kukit.ServiceInterfacesTestCase = function() { + this.name = 'kukit.ServiceInterfacesTestCase'; + /* + * Service interfaces + */ + + this.testServiceInterfaces = function() { + // We have a class, called C. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Define four methods, thie defines their necessity and preferred providers + iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + iface.getMethodDescriptor('second').define(['extralib', 'corelib']); + iface.getMethodDescriptor('third').define(['corelib']); + iface.getMethodDescriptor('fourth').define(['extralib']); + // + // somewhere else, provider "core" provides the methods: + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + iface.getMethodDescriptor('second').provide('corelib', '1.1', + function() {return function() {return 'second/core';}}); + iface.getMethodDescriptor('third').provide('corelib', '1.1', + function() {return function() {return 'third/core';}}); + // + // somewhere else, provider "extras" provides the methods: + iface.getMethodDescriptor('first').provide('extralib', '12.4', + function() {return function() {return 'first/extra';}}); + iface.getMethodDescriptor('second').provide('extralib', '12.4', + function() {return function() {return 'second/extra';}}); + iface.getMethodDescriptor('fourth').provide('extralib', '12.4', + function() {return function() {return 'fourth/extra';}}); + // + // Now finalize it. + iface.finalize(C); + // Create an instance... + var o = new C(); + // We can call the methods on it, + this.assert(o.first(), 'first/core'); + this.assert(o.second(), 'second/extra'); + this.assert(o.third(), 'third/core'); + this.assert(o.fourth(), 'fourth/extra'); + }; + + this.testChecker = function() { + // Test with a checker function. + // We have a class, called C. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // and a counter for the checker + var checker_counter = 0; + // Define three methods + iface.getMethodDescriptor('first').define(['corelib', 'extralib'], + function() {checker_counter++;}); + // + // somewhere else, core provides the methods: + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + // + // somewhere else, extras provides the methods: + iface.getMethodDescriptor('first').provide('extralib', '12.4', + function() {return function() {return 'first/extra';}}); + // + // Now finalize it. + iface.finalize(C); + var o = new C(); + // call it + this.assert(o.first(), 'first/core'); + // Check that the checker has been called. + this.assert(checker_counter, 1); + }; + + this.testReverseOrder = function() { + // Method creation also works in reverse order: + // a plugin first provides a method that another plugin later defines. + // We have a class, called C. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Provide the method first + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + // Define the method later + iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + // Now finalize it. + var C = function() {}; + iface.finalize(C); + // Create an instance... + var o = new C(); + // We can call the methods on it, + this.assert(o.first(), 'first/core'); + }; + + this.testFinalizeTwice = function() { + // An interface can only be finalized once. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Provide the method first + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + // Define the method later + iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + // Now finalize it. + var C = function() {}; + iface.finalize(C); + // Finalize it again. + this.assertThrows(function() { + iface.finalize(C); + }, + Error); + }; + + this.testNotDefined = function() { + // A method is provided but not defined. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Provide the method first + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + // Now finalize it. + var C = function() {}; + this.assertThrows(function() { + iface.finalize(C); + }, + Error) + }; + + this.testDoubleProvided = function() { + // A method cannot be provided twice by the same provider. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Provide the method first + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}); + // Now provide it for the second time. + this.assertThrows(function() { + iface.getMethodDescriptor('first').provide('corelib', '1.1', + function() {return function() {return 'first/core';}}) + }, + Error); + }; + + this.testDoubleDefined = function() { + // A method can only be defined once. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Define the method first + iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + // define it again. + this.assertThrows(function() { + iface.getMethodDescriptor('first').defineMethod(['corelib', 'extralib']) + }, + Error); + }; + + this.testNotProvided = function() { + // No preferred provider can be found for a method. + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Define the method first + iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + // Someone provides the method, but it's not good. + iface.getMethodDescriptor('first').provide('craplib', '1.1', + function() {return function() {return 'first/crap';}}); + // Now finalize it. + var C = function() {}; + this.assertThrows(function() { + iface.finalize(C); + }, + Error); + }; + + this.testWithLoader = function() { + // If no preferred providers are found, loaders will + // call up. + // Make a simple loader + var loader = new function() { + this.loaded = []; + this.add = function(src) { + this.loaded.push(src); + }; + this.empty = function(src) { + return ! this.loaded; + }; + this.getSources = function(src) { + return this.loaded; + }; + }(); + // Now, for the interface part + var C = function() {}; + var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Define the method with loader and fallback script + iface.getMethodDescriptor('first').define(['corelib', 'extralib'], null, '++resource++one'); + iface.getMethodDescriptor('second').define(['corelib', 'extralib'], null, '++resource++two'); + iface.getMethodDescriptor('third').define(['corelib', 'extralib'], null, '++resource++thr'); + // Someone provides the method, but it's not good. + iface.getMethodDescriptor('first').provide('craplib', '1.1', + function() {return function() {return 'first/crap';}}); + // Third will be satisfied. + iface.getMethodDescriptor('third').provide('extralib', '1.1', + function() {return function() {return 'third/extra';}}); + // Now finalize it. It goes without error. + iface.finalize(C, loader); + // We see the contents of the loader. Third is not in there. + this.assertListEquals(loader.loaded, ['++resource++one', '++resource++two'], 'Loaded contents differs.'); + // Third is actually working. + var o = new C(); + this.assert(o.third(), 'third/extra'); + // First and second are undefined. + this.assert(typeof(o.first), 'undefined'); + this.assert(typeof(o.second), 'undefined'); + // Now the loader can go to load the needed files... + // then it is supposed to re-finalize with and without a loader. Check if this is possible: + iface.finalize(C, loader); + // If we re-finalize without a loader, and the sources are still not loaded, + // we get an error: + this.assertThrows(function() { + iface.finalize(C); + }, + Error); + }; + +}; /* end ServiceInterfacesTestCase */ +kukit.ServiceInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); + + +kukit.PluginInterfacesTestCase = function() { + this.name = 'kukit.PluginInterfacesTestCase'; + /* + * Plugin interfaces + */ + + var M = function() { + this.bind = function(oper) {}; + }; + this.testPluginInterfaces = function() { + // We have a class, called C. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); + // somewhere else, core registers the methods: + iface.getMethodDescriptor('click').register({ + namespace: null, + name: 'click', + defaultMethod: null, + parmtypes: [ + ['preventDefault', 'bool', true], + ['allowBubbling', 'bool', false]]}); + iface.getMethodDescriptor('keydown').register({ + namespace: null, + name: 'keydown', + defaultMethod: null, + parmtypes: [ + ['preventDefault', 'bool', true], + ['allowBubbling', 'bool', false]]}); + iface.getMethodDescriptor('click').registerBindIteration({ + namespace: null, + names: ['click', 'timeout'], + iterName: 'Each', + binderClass: M; + bindMethodName: 'bind'; + // + // somewhere else, extras registers the methods: + iface.getMethodDescriptor('timeout').register({ + name: 'timeout', + defaultMethod: null, + parmtypes: [ + ['millis', 'int'], + ['renew', 'bool', false]]}); + // It needs a bind iterator even though it is a single + // group. + iface.getMethodDescriptor('timeout').registerBindIteration({ + namespace: null, + names: ['click', 'timeout'], + iterName: 'each', + bindMethodName: + + // + // Now finalize it. + iface.finalize(C); + // Create an instance... + var o = new C(); + // We can call the methods on it, + this.assert(o.click.binderMethod(), 'Binding click event.'); + this.assert(typeof(o.keydown.binderMethod()), 'undefined'); + this.assert(typeof(o.timeout.binderMethod()), 'undefined'); + }; + + this.testPluginNoDoubleReg = function() { + // No double registration for test plugins. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); + // somewhere else, core registers the methods: + iface.getMethodDescriptor('click').register({ + name: 'click', + binderMethod: function() {return "Binding click event.";}, + defaultMethod: function() {}, + parmtypes: [ + ['preventDefault', 'bool', true], + ['allowBubbling', 'bool', false]]}); + // But another providing attempt is punished by an Error. + this.assertThrows(function() { + iface.getMethodDescriptor('click').register({ + name: 'click', + binderMethod: function() {return "Binding click event.";}, + defaultMethod: function() {}, + parmtypes: [ + ['preventDefault', 'bool', true], + ['allowBubbling', 'bool', false]]}); + }, + Error); + }; + +}; /* end PluginInterfacesTestCase */ +kukit.PluginInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); + +if (typeof(testcase_registry) != 'undefined') { + testcase_registry.registerTestCase(kukit.InterfacesTestCase, 'kukit.InterfacesTestCase'); + testcase_registry.registerTestCase(kukit.ServiceInterfacesTestCase, 'kukit.ServiceInterfacesTestCase'); + testcase_registry.registerTestCase(kukit.PluginInterfacesTestCase, 'kukit.PluginInterfacesTestCase'); +} From reebalazs at codespeak.net Tue Dec 25 12:58:16 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:16 +0100 (CET) Subject: [KSS-checkins] r50072 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . tests Message-ID: <20071225115816.1058D1684FE@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:15 2007 New Revision: 50072 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Small fixes Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:15 2007 @@ -396,12 +396,13 @@ parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - iface.getMethodDescriptor('click').registerBindIteration({ + /*iface.getMethodDescriptor('click').registerBindIteration({ namespace: null, names: ['click', 'timeout'], iterName: 'Each', - binderClass: M; - bindMethodName: 'bind'; + binderClass: M, + bindMethodName: 'bind'}); + //*/ // // somewhere else, extras registers the methods: iface.getMethodDescriptor('timeout').register({ @@ -412,11 +413,12 @@ ['renew', 'bool', false]]}); // It needs a bind iterator even though it is a single // group. - iface.getMethodDescriptor('timeout').registerBindIteration({ + /*iface.getMethodDescriptor('timeout').registerBindIteration({ namespace: null, names: ['click', 'timeout'], - iterName: 'each', - bindMethodName: + iterName: 'Each', + bindMethodName: 'bind'}); + */ // // Now finalize it. @@ -424,9 +426,9 @@ // Create an instance... var o = new C(); // We can call the methods on it, - this.assert(o.click.binderMethod(), 'Binding click event.'); - this.assert(typeof(o.keydown.binderMethod()), 'undefined'); - this.assert(typeof(o.timeout.binderMethod()), 'undefined'); + //this.assert(o.click.binderMethodName, 'bind'); + //this.assert(o.keydown.binderMethodName, 'bind'); + //this.assert(o.timeout.binderMethodName, 'bind'); }; this.testPluginNoDoubleReg = function() { From reebalazs at codespeak.net Tue Dec 25 12:58:21 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:21 +0100 (CET) Subject: [KSS-checkins] r50073 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115821.52B9A1684FE@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:20 2007 New Revision: 50073 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Create interface for binderiterations, fix up tests. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:20 2007 @@ -23,6 +23,12 @@ var _eventClassCounter = 0; +// these together store the plugin resource information, about registered events +// there is two distinct registries, one for the actual events and one +// for specifying the binding sequence +var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); +var bindings = kukit.interfaces.get('bindings', kukit.interfaces.PluginMethodDescriptor); + /* * * class _EventRegistry Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:20 2007 @@ -218,9 +218,7 @@ this.register = function(config) { if (this.config != null) { -;;; kukit.E = 'Double registration by [' + providerName + ']['; -;;; kukit.E += providerVersion; -;;; kukit.E += '] of method [' + this.methodName; +;;; kukit.E = 'Double registration of method [' + this.methodName; ;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; throw new Error(kukit.E); } @@ -228,15 +226,60 @@ }; this.finalize = function(loader) { - if (! this.config) { - return; - } // Just return the registered value. return this.config; }; }; /* end PluginMethodDescriptor */ +/* + * BindIterationDescriptor + * + * We need this method descriptor 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 iterator 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. + */ +this.BindIterationDescriptor = function(iface, methodName) { + + this.iface = iface; + this.methodName = methodName; + this.config = null; + + this.register = function(config) { + // This is called on any method descriptors. + // Register config to all event names individually. + // Take names from the config. + for (var i = 0; i < config.names.length; i++) { + name = config.names[i]; + this.iface.getMethodDescriptor(name)._register(config); + } + }; + + this._register = function(config) { + if (this.config != null) { +;;; kukit.E = 'Double registration of method [' + this.methodName; +;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; + throw new Error(kukit.E); + } + this.config = config; + }; + + this.finalize = function(loader) { + // Just return the registered value. + return this.config; + }; + +}; /* end BindIterationDescriptor */ + + /* * Instantiation @@ -257,6 +300,9 @@ this.getPlugin = function(name) { return _interfaces.get(name, this.PluginMethodDescriptor); }; +this.getBindIteration = function(name) { + return _interfaces.get(name, this.BindIterationDescriptor); +}; }(); /* END CLOSURE kukit.interfaces */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:20 2007 @@ -380,49 +380,49 @@ // We have a class, called C. var C = function() {}; // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); + var events = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); + var binditerations = this.interfaces.get('dummybinditerations', kukit.interfaces.BindIterationDescriptor); // somewhere else, core registers the methods: - iface.getMethodDescriptor('click').register({ + events.getMethodDescriptor('click').register({ namespace: null, name: 'click', - defaultMethod: null, + defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - iface.getMethodDescriptor('keydown').register({ + events.getMethodDescriptor('keydown').register({ namespace: null, name: 'keydown', - defaultMethod: null, + defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - /*iface.getMethodDescriptor('click').registerBindIteration({ + binditerations.getMethodDescriptor('').register({ namespace: null, - names: ['click', 'timeout'], + names: ['click', 'keydown'], iterName: 'Each', binderClass: M, bindMethodName: 'bind'}); //*/ // // somewhere else, extras registers the methods: - iface.getMethodDescriptor('timeout').register({ + events.getMethodDescriptor('timeout').register({ name: 'timeout', - defaultMethod: null, + defaultMethodName: null, parmtypes: [ ['millis', 'int'], ['renew', 'bool', false]]}); // It needs a bind iterator even though it is a single // group. - /*iface.getMethodDescriptor('timeout').registerBindIteration({ + binditerations.getMethodDescriptor('').register({ namespace: null, - names: ['click', 'timeout'], + names: ['timeout'], iterName: 'Each', bindMethodName: 'bind'}); - */ - // // Now finalize it. - iface.finalize(C); + events.finalize(C); + binditerations.finalize(C); // Create an instance... var o = new C(); // We can call the methods on it, @@ -457,6 +457,29 @@ Error); }; + this.testBindIterationNoDoubleReg = function() { + // No double registration for test plugins. + var C = function() {}; + // Let's create a TestDummy interface. + var iface = this.interfaces.get('dummybinditeration', kukit.interfaces.BindIterationDescriptor); + // somewhere else, core registers the methods: + iface.getMethodDescriptor('').register({ + namespace: null, + names: ['click', 'timeout'], + iterName: 'Each', + binderClass: M, + bindMethodName: 'bind'}); + // But another providing attempt is punished by an Error. + this.assertThrows(function() { + iface.getMethodDescriptor('').register({ + namespace: null, + names: ['keyDown', 'timeout'], + iterName: 'Each', + bindMethodName: 'bind'}); + }, + Error); + }; + }; /* end PluginInterfacesTestCase */ kukit.PluginInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); From reebalazs at codespeak.net Tue Dec 25 12:58:25 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:25 +0100 (CET) Subject: [KSS-checkins] r50074 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115825.68F8F1684F5@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:25 2007 New Revision: 50074 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Refactor the event plugin registry. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:25 2007 @@ -23,12 +23,6 @@ var _eventClassCounter = 0; -// these together store the plugin resource information, about registered events -// there is two distinct registries, one for the actual events and one -// for specifying the binding sequence -var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); -var bindings = kukit.interfaces.get('bindings', kukit.interfaces.PluginMethodDescriptor); - /* * * class _EventRegistry @@ -46,9 +40,9 @@ * implements the binder. */ var _EventRegistry = function () { - this.content = {}; + //this.content = {}; this.classes = {}; - this.eventSets = []; + //this.eventSets = []; }; /* binder registration */ @@ -86,155 +80,69 @@ return func; }; -/* events (methods) registration helpers (not to be called directly) */ - -_EventRegistry.prototype._register = - function(namespace, eventName, klass, - bindMethodName, defaultActionMethodName, iterName) { - if (typeof(defaultActionMethodName) == 'undefined') { -;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // Find out the class name. (Not specified now.) - var className = klass.prototype.__className__; - if (typeof(className) == 'undefined') { - // Create a className, and register it too. - className = '' + _eventClassCounter; - _eventClassCounter += 1; - this.registerBinder(className, klass); - klass.prototype.__className__ = className; - } - if (!eventName) { -;;; kukit.E = '[eventName] argument cannot be empty when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - if (typeof(entry) != 'undefined') { - if (key[0] == '-') { - key = key.substring(1); - } -;;; kukit.E = 'Attempt to register key [' + key; -;;; kukit.E += '] twice when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // check bindMethodName and defaultActionMethodName - if (bindMethodName && ! klass.prototype[bindMethodName]) { -;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; -;;; kukit.E += '] is undefined for event [' + eventName; -;;; kukit.E += '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - if (defaultActionMethodName && ! klass.prototype[defaultActionMethodName]) { -;;; kukit.E = 'In _EventRegistry.register default action method ['; -;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; -;;; kukit.E += eventName + '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - // check the iterator. - if (! er.getBindIterator(iterName)) { -;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; -;;; kukit.E += iterName + '].'; - throw new Error(kukit.E); - } - // register it - this.content[key] = { - 'className': className, - 'bindMethodName': bindMethodName, - 'defaultActionMethodName': defaultActionMethodName, - 'iterName': iterName - }; -}; - -/* events (methods) binding [ForAll] registration */ - -_EventRegistry.prototype._registerEventSet = - function(namespace, names, iterName, bindMethodName) { - // At this name the values should be checked already. so this should - // be called _after_ _register. - this.eventSets.push({ - 'namespace': namespace, - 'names': names, - 'iterName': iterName, - 'bindMethodName': bindMethodName - }); -}; /* there are the actual registration methods, to be called from plugins */ _EventRegistry.prototype.register = - function(namespace, eventName, klass, bindMethodName, - defaultActionMethodName) { - this._register(namespace, eventName, klass, bindMethodName, - defaultActionMethodName, 'EachLegacy'); - this._registerEventSet(namespace, [eventName], 'EachLegacy', - bindMethodName); -}; - -_EventRegistry.prototype.unregister = - function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - delete this.content[key]; - var found = null; - for (var i=0; i < this.eventSets.length; i++) { - var eventSet = this.eventSets[i]; - if (eventSet['namespace'] == namespace) { - found = i; - break; - } - } - if (found != null) { - this.eventSets.splice(found, 1); - } + function(namespace, eventName, binderClass, bindMethodName, + bindMethodName, defaultActionMethodName) { + this.registerForAllEvents(namespace, eventName, binderClass, bindMethodName, + defaultActionMethodName, 'EachLegacy'); }; _EventRegistry.prototype.registerForAllEvents = - function(namespace, eventNames, klass, + function(namespace, eventNames, binderClass, bindMethodName, defaultActionMethodName, iterName) { + // Allow a single event name or a list of eventNames to be entered if (typeof(eventNames) == 'string') { eventNames = [eventNames]; } + // For each eventname, register the event itself. + // During this: + // In the new registry all event names are dash-namespaced, so please + // create them for us since they were not so in the earlier version. + var namespacedEventNames = []; for (var i=0; i 1) { -;;; kukit.E = 'In [_EventRegistry.register], [namespace] cannot have'; -;;; kukit.E += 'dashes.'; - throw new Error(kukit.E); - } - return namespace + '-' + eventName; -}; + if (namespace) { + eventName = namespace + '-' + eventName; + } + namespacedEventNames.push(eventName); + // register the event informataion + var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); + events.getMethodDescriptor(eventName).register({ + eventName: eventName, + defaultMethodName: null, + parmtypes: null // missing from this api. + }); + } + // Register the bind iteration + //this._registerEventSet(namespace, eventNames, iterName, bindMethodName); + var binditerations = kukit.interfaces.getBindIteration(); + binditerations.getMethodDescriptor('').register({ + namespace: namespace, + eventNames: namespacedEventNames, + iterName: iterName, + binderClass: binderClass, + bindMethodName: bindMethodName}); -_EventRegistry.prototype.exists = function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - return (typeof(entry) != 'undefined'); }; +// XXX This method should be deprc'd and from where it's called, +// the finalized class's properties should be accessed _EventRegistry.prototype.get = function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - if (typeof(entry) == 'undefined') { -;;; if (key.substr(0, 1) == '-') { -;;; key = key.substring(1); -;;; kukit.E = 'Error : undefined global event ['; -;;; kukit.E += key + '] (or maybe namespace is missing ?).'; -;;; } else { -;;; kukit.E = 'Error : undefined namespace or event in [' + key + '].'; -;;; } + //var key = this._getKey(namespace, eventName); + if (namespace) { + eventName = namespace + '-' + eventName; + } + // var entry = this.content[key]; + var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); + var entry = events.getMethodDescriptor(eventName) + if (! entry.config) { +;;; kukit.E = 'Error : undefined event [' + eventName + '].'; throw new Error(kukit.E); } - return entry; + return entry.config; }; kukit.eventsGlobalRegistry = new _EventRegistry(); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:25 2007 @@ -257,8 +257,8 @@ // This is called on any method descriptors. // Register config to all event names individually. // Take names from the config. - for (var i = 0; i < config.names.length; i++) { - name = config.names[i]; + for (var i = 0; i < config.eventNames.length; i++) { + name = config.eventNames[i]; this.iface.getMethodDescriptor(name)._register(config); } }; @@ -269,7 +269,28 @@ ;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; throw new Error(kukit.E); } + // Do some diagnostics // check the iterator. +;;; if (! kukit.er.getBindIterator(config.iterName)) { +;;; kukit.E = 'In BindIterationDescriptor.register: unknown bind iterator ['; +;;; kukit.E += config.iterName + '].'; +;;; throw new Error(kukit.E); +;;; } + + // store the config this.config = config; + + // Register binder class by its classname as well. + // XXX TODO + // Find out or generate the class name, + //var className = config.binderClass.prototype.__className__; + //if (typeof(className) == 'undefined') { + // // Create a className, and register it too. + // className = '' + _eventClassCounter; + // _eventClassCounter += 1; + // this.registerBinder(className, klass); + // klass.prototype.__className__ = className; + //} + }; this.finalize = function(loader) { @@ -285,24 +306,47 @@ * Instantiation */ -// create singleton for interfaces -var _interfaces = new this.Interfaces(); +this._createInterfaces = function() { + // create singleton for interfaces + this._interfaces = new this.Interfaces(); +}; +this._createInterfaces(); // The following methods can acquire a given interface // wrap the function, since there are no bound methods in JS this.get = function(name, MethodDescriptor) { - return _interfaces.get(name, MethodDescriptor); + return this._interfaces.get(name, MethodDescriptor); }; this.getService = function(name) { - return _interfaces.get(name, this.ServiceMethodDescriptor); + return this._interfaces.get(name, this.ServiceMethodDescriptor); }; this.getPlugin = function(name) { - return _interfaces.get(name, this.PluginMethodDescriptor); + return this._interfaces.get(name, this.PluginMethodDescriptor); }; this.getBindIteration = function(name) { - return _interfaces.get(name, this.BindIterationDescriptor); + // convenience, we use only 1 of this anyway + if (typeof(name) == 'undefined') { + name = 'binditerations'; + } + return this._interfaces.get(name, this.BindIterationDescriptor); }; +/* XXX If we want to use interfaces in a more placeful way, we can provide + * cloning ang merging to them. Since we don't really use them this way, + * the only support needed is for tests to establish a clean room. + * For this, we provide simple save and restore methods. These can + * be celled from setUp and tearDown of tests that want to provide their + * own interfaces setup. + */ + +this.cleanRoomSetUp = function(suite) { + this._saved_interfaces = this._interfaces; + // now create interfaces + this._createInterfaces(); +}; +this.cleanRoomTearDown = function(suite) { + this._interfaces = this._saved_interfaces; +}; }(); /* END CLOSURE kukit.interfaces */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:25 2007 @@ -384,22 +384,19 @@ var binditerations = this.interfaces.get('dummybinditerations', kukit.interfaces.BindIterationDescriptor); // somewhere else, core registers the methods: events.getMethodDescriptor('click').register({ - namespace: null, name: 'click', defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); events.getMethodDescriptor('keydown').register({ - namespace: null, name: 'keydown', defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); binditerations.getMethodDescriptor('').register({ - namespace: null, - names: ['click', 'keydown'], + eventNames: ['click', 'keydown'], iterName: 'Each', binderClass: M, bindMethodName: 'bind'}); @@ -415,8 +412,7 @@ // It needs a bind iterator even though it is a single // group. binditerations.getMethodDescriptor('').register({ - namespace: null, - names: ['timeout'], + eventNames: ['timeout'], iterName: 'Each', bindMethodName: 'bind'}); // @@ -435,21 +431,19 @@ // No double registration for test plugins. var C = function() {}; // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); - // somewhere else, core registers the methods: - iface.getMethodDescriptor('click').register({ + var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); + // somewhere a plugin registers something: + events.getMethodDescriptor('click').register({ name: 'click', - binderMethod: function() {return "Binding click event.";}, - defaultMethod: function() {}, + defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}); + ['allowBubbling', 'bool', false]]}); // But another providing attempt is punished by an Error. this.assertThrows(function() { - iface.getMethodDescriptor('click').register({ + events.getMethodDescriptor('click').register({ name: 'click', - binderMethod: function() {return "Binding click event.";}, - defaultMethod: function() {}, + defaultMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); @@ -464,17 +458,16 @@ var iface = this.interfaces.get('dummybinditeration', kukit.interfaces.BindIterationDescriptor); // somewhere else, core registers the methods: iface.getMethodDescriptor('').register({ - namespace: null, - names: ['click', 'timeout'], + eventNames: ['click', 'timeout'], iterName: 'Each', binderClass: M, bindMethodName: 'bind'}); // But another providing attempt is punished by an Error. this.assertThrows(function() { iface.getMethodDescriptor('').register({ - namespace: null, - names: ['keyDown', 'timeout'], + eventNames: ['keyDown', 'timeout'], iterName: 'Each', + binderClass: M, bindMethodName: 'bind'}); }, Error); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Tue Dec 25 12:58:25 2007 @@ -24,12 +24,28 @@ kukit.KssParserTestCaseBase = function() { this.setUp = function() { + // create a clean room interface registry + kukit.interfaces.cleanRoomSetUp(this); + // add my events kukit.eventsGlobalRegistry.register('dnd', 'drag', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); + kukit.pl.NativeEventBinder, null, null); + kukit.eventsGlobalRegistry.register(null, 'click', + kukit.pl.NativeEventBinder, null, null); + kukit.eventsGlobalRegistry.register(null, 'load', + kukit.pl.NativeEventBinder, null, null); + kukit.eventsGlobalRegistry.register(null, 'timeout', + kukit.pl.NativeEventBinder, null, null); + kukit.eventsGlobalRegistry.register(null, 'blur', + kukit.pl.NativeEventBinder, null, null); + kukit.eventsGlobalRegistry.register(null, 'keydown', + kukit.pl.NativeEventBinder, null, null); + // XXX the tests test at numerous occasion a non-existent + // event, so be careful when you add a new one. }; this.tearDown = function() { - kukit.eventsGlobalRegistry.unregister('dnd', 'drag'); + // Restore the original registry + kukit.interfaces.cleanRoomTearDown(this); }; this.assertKssParmValueEquals = function(a, b, reason) { @@ -1076,44 +1092,44 @@ txt= " document:clack "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined global event [clack] (or maybe namespace is missing ?).'); + 'Error : undefined event [clack].'); txt= " document:clack(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined global event [clack] (or maybe namespace is missing ?).'); + 'Error : undefined event [clack].'); } this.testKssSelectorWithRightEventAndMissingNamespace = function() { txt= " document:drag "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined global event [drag] (or maybe namespace is missing ?).'); + 'Error : undefined event [drag].'); txt= " document:drag(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined global event [drag] (or maybe namespace is missing ?).'); + 'Error : undefined event [drag].'); } this.testKssSelectorWithUndefinedNamespaceWhenNamespace = function() { txt= " document:dad-drag "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined namespace or event in [dad-drag].'); + 'Error : undefined event [dad-drag].'); txt= " document:dad-drag(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined namespace or event in [dad-drag].'); + 'Error : undefined event [dad-drag].'); } this.testKssSelectorWithUndefinedEventNameWhenNameSpace = function() { txt= " document:dnd-drog "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined namespace or event in [dnd-drog].'); + 'Error : undefined event [dnd-drog].'); txt= " document:dnd-drog(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined namespace or event in [dnd-drog].'); + 'Error : undefined event [dnd-drog].'); } }; From reebalazs at codespeak.net Tue Dec 25 12:58:30 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:30 +0100 (CET) Subject: [KSS-checkins] r50075 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115830.A1490168506@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:30 2007 New Revision: 50075 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Refactor the event registry - in progress Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Tue Dec 25 12:58:30 2007 @@ -139,7 +139,7 @@ ;;; }; ;;; err.kssSelectorError = function(message){ -;;; return setErrorInfo(null, 'RuleMergeError', message); +;;; return setErrorInfo(null, 'KssSelectorError', message); ;;; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:30 2007 @@ -38,49 +38,13 @@ * defaultActionMethodName = null: if there is no default action implemented * func must be a class (constructor) function, this is the class that * implements the binder. +* +* XXX EventRegistry becomes pure BBB, when the new javascript docstring registry +* is implemented. */ var _EventRegistry = function () { - //this.content = {}; - this.classes = {}; - //this.eventSets = []; -}; - -/* binder registration */ - -_EventRegistry.prototype.registerBinder = function(className, func) { - if (typeof(func) == 'undefined') { -;;; kukit.E = 'func argument is mandatory when registering an event'; -;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; - throw new Error(kukit.E); - } - if (this.classes[className]) { - // Do not allow redefinition -;;; var msg = 'Error : event class [' + className + '] already registered.'; -;;; kukit.logError(msg); - return; - - } - // Decorate and store the class - decorateEventBinderClass(func); - this.classes[className] = func; -}; - -_EventRegistry.prototype.existsBinder = function(className) { - var func = this.classes[className]; - return (typeof(func) != 'undefined'); }; -_EventRegistry.prototype.getBinderClass = function(className) { - var func = this.classes[className]; - if (! func) { - // not found -;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; - throw new Error(kukit.E); - } - return func; -}; - - /* there are the actual registration methods, to be called from plugins */ _EventRegistry.prototype.register = @@ -226,6 +190,12 @@ * * p.s. oper is not required to make it easy to adapt existing code * so we create a new oper below +* +* XXX New from kss 1.4: the event's name must stand with the full namespace +* (dashed) format, while in previous version the namespace was figured out +* from the binder instance; this server no purpose and is now removed +* during a simplification process. +* */ var _EventBinder__continueEvent__ = @@ -237,6 +207,7 @@ oper.node = node; if (node) { // if we found the binding, just use that + // XXX XXX var info = kukit.engine.binderInfoRegistry.getBinderInfoById( this.__binderId__); var newOper = info.bound.getBoundOperForNode(name, node); @@ -394,13 +365,19 @@ method.call(this, name, oper); }; -var decorateEventBinderClass = function(cls) { +this.decorateEventBinderClass = function(cls) { + // See if we are set up already? + if (cls.__decorated_for_kss__) { + return; + } cls.prototype.__continueEvent__ = _EventBinder__continueEvent__; cls.prototype.__continueEvent_allNodes__ = _EventBinder__continueEvent_allNodes__; cls.prototype._EventBinder_triggerEvent = _EventBinder_triggerEvent; cls.prototype._EventBinder_callMethod = _EventBinder_callMethod; cls.prototype.__makeFuncToBind__ = _EventBinder_makeFuncToBind; + // mark decorated + cls.prototype.__decorated_for_kss__ = true; }; /* Event instance registry @@ -416,23 +393,28 @@ }; er.BinderInfoRegistry.prototype.getOrCreateBinderInfo = - function (id, className, namespace) { + function (kssSelector) { + // We use the key as the selector's merge id. + var key = kssSelector.thisMergeId(); // Get or create the event. - var binderInfo = this.info[id]; + var binderInfo = this.info[key]; if (typeof(binderInfo) == 'undefined') { // Create a new event. ;;; var msg = 'Instantiating event id [' + id + '], className ['; ;;; msg += className + '], namespace [' + namespace + '].'; ;;; kukit.logDebug(msg); + + // + // The creation of binder instances happens from here. + // + + // XXX XXX var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); + + // Create the binder instance and the binder info var binder = new binderClass(); - binderInfo = this.info[id] = new _BinderInfo(binder); - // decorate it with id and class - binder.__binderId__ = id; - binder.__binderClassName__ = className; - binder.__eventNamespace__ = namespace; // store the bound rules //binder.__bound_rules__ = []; } else if (binderInfo.getBinder().__binderClassName__ != @@ -459,6 +441,7 @@ er.BinderInfoRegistry.prototype.getSingletonBinderInfoByName = function (namespace, name) { //Get className + // XXX XXX XXX var className = kukit.eventsGlobalRegistry.get(namespace, name).className; // Get an event. var id = er.makeId(namespace, className); @@ -823,18 +806,11 @@ } }; -er.makeId = function(namespace, name) { - if (namespace == null) { - namespace = ''; - } - return '@' + namespace + '@' + name; -}; - -er.makeMergeId = function(id, namespace, name) { - if (namespace == null) { - namespace = ''; - } - return id + '@' + namespace + '@' + name; +er.makeMergeId = function(id, name) { + // name cannot contain a @ + // id can be any string + // so the merge id will be unique + return name + '@' + id; }; }(); /// MODULE END Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:30 2007 @@ -276,21 +276,12 @@ ;;; throw new Error(kukit.E); ;;; } + // Decorate binder class. + kukit.er.decorateEventBinderClass(config.binderClass); + // store the config this.config = config; - // Register binder class by its classname as well. - // XXX TODO - // Find out or generate the class name, - //var className = config.binderClass.prototype.__className__; - //if (typeof(className) == 'undefined') { - // // Create a className, and register it too. - // className = '' + _eventClassCounter; - // _eventClassCounter += 1; - // this.registerBinder(className, klass); - // klass.prototype.__className__ = className; - //} - }; this.finalize = function(loader) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Tue Dec 25 12:58:30 2007 @@ -791,7 +791,11 @@ id = pseudotoken.value.arg.txt; } } - var name = pseudotoken.value.methodName; + // XXX We really don't use the name and the namespace + // separated here, so the following code could be removed + // and multi-level namespaces would be supported. + var origName = pseudotoken.value.methodName; + var name = origName; var splitname = name.split('-'); var namespace = null; if (splitname.length > 2) { @@ -805,8 +809,8 @@ } // Protect the error for better logging ;;; try { - this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, - namespace, id, ppid); + this.kssSelector = new kukit.rd.KssSelector(isEvent, css, origName, + id, ppid); ;;; } catch(e) { ;;; if (e.name == 'KssSelectorError') { ;;; // Log the message @@ -847,7 +851,6 @@ // Store event rules in the common list for (var i=0; i() can have only one parameter.', 000); }; + this.testValueProvidersInEventIdentificationCannotStandWithSpecialSelectors = function() { + txt= " document:clack(kssAttr(hello)) "; + cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, + 'KssSelectorError: KssSpecialSelector [document] must not stand with an event id acquired by value provider [kssAttr]'); + txt= " behaviour:clack(kssAttr(hello)) "; + cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, + 'KssSelectorError: KssSpecialSelector [behaviour] must not stand with an event id acquired by value provider [kssAttr]'); + }; + }; kukit.KssParserSelectorsTestCase.prototype = new kukit.KssParserTestCaseBase; From reebalazs at codespeak.net Tue Dec 25 12:58:36 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:36 +0100 (CET) Subject: [KSS-checkins] r50076 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115836.7ACE4168507@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:35 2007 New Revision: 50076 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Log: Continue with the events registry. - meanwhile, errors slightly fixed and errors can check for parsing errors more consistently. Also improve kssSelector: it holds the interface itself, so further operations should be based on that registry. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Tue Dec 25 12:58:35 2007 @@ -62,21 +62,26 @@ ;;; kw = {}; ;;; } this.kw = kw; -;;; this.message = name + ': ' + message; +;;; this.message = message; +;;; this.fullMessage = name + ': ' + message; ;;; var addMessage = true; - if (!e) { -;;; e = new Error(message); + if (! e) { +;;; e = new Error(this.fullMessage); ;;; addMessage = false; ;;; } else if (typeof(e) == "string") { -;;; kukit.E = 'Do not raise string exceptions, as we cannot '; +;;; kukit.E = 'Failed to preserve traceback information for error.' +;;; kukit.E += 'Do not raise string exceptions, as we cannot '; ;;; kukit.E += 'annotate them properly. Use: throw new Error(msg);'; - e = new Error(kukit.E); +;;; kukit.logWarning(kukit.E); + // We bundle the string-error into a real error, consequently, + // the original traceback will be lost. + e = new Error(e); } ;;; this.previous_info = e.info; e.name = name; e.info = this; ;;; if (addMessage) { -;;; var fullMessage = message + ' [' + e.message + ']'; +;;; var fullMessage = this.fullMessage + ' [' + e.message + ']'; ;;; // for FF, and Safari: ;;; e.message = fullMessage; ;;; // for IE, message is ignored, description is used. @@ -143,7 +148,9 @@ ;;; }; -;;; err.parsingError = function(message, cursor){ +// this is raised by the parser in case of errors +// it contains row/column information +;;; err.parsingError = function(message, cursor, err){ ;;; var kw = {} ;;; if (cursor) { ;;; kw.errpos = cursor.pos; @@ -155,11 +162,20 @@ ;;; kw.errrow = null; ;;; kw.errcol = null; ;;; } -;;; return setErrorInfo(null, 'ParsingError', message, kw); +;;; return setErrorInfo(err, 'ParsingError', message, kw); ;;; }; -/* Exceptions that re-throw (annotate) an already caught error */ +/* + * Exceptions that re-throw (annotate) an already thrown error + * + * These have purpose of adding some more generic explanation to the + * error, as well as adding more information. + * They only should get active in development mode. + * + * e.g. a ParsingError will become, after re-throwing: + * "Error parsing Kss at http://blah [ParsingError: ...]" + */ ;;; err.commandExecutionError = function(e, command){ ;;; var message = 'Command [' + command.name + '] failed'; @@ -177,11 +193,8 @@ ;;; }; -;;; err.undefinedEventError = function(e, message){ -;;; return setErrorInfo(e, 'UndefinedEventError', message); -;;; }; - - +;;; // this error protects and annotates all errors that +;;; // happen during KssRuleProcessor.parse. ;;; err.kssParsingError = function(e, url){ ;;; var kw = {url: url} ;;; var message = 'Error parsing KSS at ' + url; @@ -194,5 +207,14 @@ ;;; return setErrorInfo(e, 'EventSetupError', message); ;;; }; + +// any error that happens because the required information +// cannot be found in the plugin +err.pluginRegistryError = function(err, message) { + return setErrorInfo(null, 'PluginRegistryError', message); +}; + + + }(); /// MODULE END Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:35 2007 @@ -21,8 +21,6 @@ var er = this; -var _eventClassCounter = 0; - /* * * class _EventRegistry @@ -365,19 +363,26 @@ method.call(this, name, oper); }; +var _eventClassCounter = 0; + this.decorateEventBinderClass = function(cls) { // See if we are set up already? - if (cls.__decorated_for_kss__) { + var p = cls.prototype; + if (p.__decorated_for_kss__) { return; } - cls.prototype.__continueEvent__ = _EventBinder__continueEvent__; - cls.prototype.__continueEvent_allNodes__ = + // Put inherited methods on it + p.__continueEvent__ = _EventBinder__continueEvent__; + p.__continueEvent_allNodes__ = _EventBinder__continueEvent_allNodes__; - cls.prototype._EventBinder_triggerEvent = _EventBinder_triggerEvent; - cls.prototype._EventBinder_callMethod = _EventBinder_callMethod; - cls.prototype.__makeFuncToBind__ = _EventBinder_makeFuncToBind; + p._EventBinder_triggerEvent = _EventBinder_triggerEvent; + p._EventBinder_callMethod = _EventBinder_callMethod; + p.__makeFuncToBind__ = _EventBinder_makeFuncToBind; + // Generate a unique class name + p.__className__ = '' + _eventClassCounter; + _eventClassCounter ++; // mark decorated - cls.prototype.__decorated_for_kss__ = true; + p.__decorated_for_kss__ = true; }; /* Event instance registry @@ -393,9 +398,9 @@ }; er.BinderInfoRegistry.prototype.getOrCreateBinderInfo = - function (kssSelector) { + function (kssSelector, node) { // We use the key as the selector's merge id. - var key = kssSelector.thisMergeId(); + var key = kssSelector.getMergeId(); // Get or create the event. var binderInfo = this.info[key]; if (typeof(binderInfo) == 'undefined') { @@ -407,13 +412,11 @@ // // The creation of binder instances happens from here. // - - // XXX XXX - var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); + var binderClass = kssSelector.getBindIteration().binderClass; // Create the binder instance and the binder info var binder = new binderClass(); - binderInfo = this.info[id] = new _BinderInfo(binder); + binderInfo = this.info[key] = new _BinderInfo(binder); // store the bound rules //binder.__bound_rules__ = []; @@ -806,11 +809,4 @@ } }; -er.makeMergeId = function(id, name) { - // name cannot contain a @ - // id can be any string - // so the merge id will be unique - return name + '@' + id; -}; - }(); /// MODULE END Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Tue Dec 25 12:58:35 2007 @@ -807,14 +807,20 @@ name = splitname[1]; namespace = splitname[0]; } + // XXX The interfaces for the selector can be taken from a given interface + // registry. We use kukit.interfaces now which will make it operate on + // the global registry. + var interfaces = kukit.interfaces._interfaces; // Protect the error for better logging ;;; try { this.kssSelector = new kukit.rd.KssSelector(isEvent, css, origName, - id, ppid); + id, ppid, interfaces); ;;; } catch(e) { -;;; if (e.name == 'KssSelectorError') { +;;; if (e.name == 'KssSelectorError' || e.name == 'PluginRegistryError') { ;;; // Log the message -;;; this.emitError(e.toString()); +;;; // This will add line and column information to these errors. +;;; kukit.E = 'Error during parsing KSS'; +;;; this.emitWrappedError(e, kukit.E); ;;; } else { ;;; throw e; ;;; } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:58:35 2007 @@ -24,7 +24,7 @@ /* * class KssSelector */ -kukit.rd.KssSelector = function(isEvent, css, name, id, ppid) { +kukit.rd.KssSelector = function(isEvent, css, name, id, ppid, interfaces) { this.isEventSelector = isEvent; this.isMethodSelector = ! isEvent; // XXX GC row and column are wrong... @@ -53,32 +53,34 @@ ;;; } this.css = css; this.name = name; - this.className = null; this.id = id; this.ppid = ppid; - this.prepareId(); + this.mergeId = null; + this.bindIteration = null; // finish up the KSS on it // XXX We should not have this here, because this disables testing the parser // standalone, without a plugin registry. Original behaviour // should be reverted instead. - this.checkRegistry(); + // + // Perform checking based on the registry + this.checkRegistry(interfaces); }; -kukit.rd.KssSelector.prototype.checkRegistry = function() { +kukit.rd.KssSelector.prototype.checkRegistry = function(interfaces) { // Sets up id and class on the selector, based on registration info - // XXX GC instead of relying on exceptions, test if key exists - try { - kukit.eventsGlobalRegistry.get( - null, this.name); - } catch(e) { - throw kukit.err.parsingError(e.message); - } -}; - -kukit.rd.KssSelector.prototype.prepareId = function() { + // This will throw errors if the event is not in the registry. + // + // It will also bind the selector to operate on this registry + // ie. lookups are used from there. + // + // Store theinterfaces. + this.interfaces = interfaces; // We prepare the id a bit. If there is no ppid specified, // we can already produce the mergeId here. + // This is called from init. if (this.ppid == null) { + // We have no value provider. All we have is a static string, + // or nothing which means a singleton binder instance (id = ''). if (this.id == null) { // singleton for class // singleton will have an id '' @@ -86,13 +88,42 @@ } // Also set the merge id. The rules with the same merge // id should be merged on the same node. - this.mergeId = kukit.er.makeMergeId(this.id, this.name); + // Statically setting it here means we never have to look + // at it depending on nodes. + // This step will access the interfaces already + // by calling getBindIteration. + this.mergeId = this.getMergeId(); + } else { + // We have a value provider for the id. We cannot set the + // merge id for this selector, but we can make sure the bind + // iteration info is fetched and cached. It will also + // signal error when the event does not take of any binding + // iteration. + this.getBindIteration(); } + // + // Now we check the plugin part of the registry: this may not be + // necessary but this way we reject an event which has the binder + // set up, but has no actual event information. +;;; // We wrap all errors as pluginRegistryError. +;;; try { + // XXX TODO cicrumvent the get + kukit.eventsGlobalRegistry.get( + null, this.name); +;;; } catch(e) { +;;; if (! e.name != 'PluginRegistryError') { +;;; kukit.E = 'undefined event [' + this.name + '].'; +;;; throw kukit.err.pluginRegistryError(e, kukit.E); +;;; } +;;; } +}; + +kukit.rd.KssSelector.prototype.prepareId = function() { }; kukit.rd.KssSelector.prototype.getId = function(node) { // Gives the id depending on a node. - if (this.id) { + if (this.ppid == null) { // Statically set. return this.id; } else { @@ -110,15 +141,41 @@ } }; +kukit.rd.KssSelector.prototype.getBindIteration = function() { + // Returns the bind iteration set up for this kss selector. This + // depends on the event name only, but it needs access to the + // registry, so we cache this result. + if (! this.bindIteration) { + // Look up the binder class from the registry. + var events = this.interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor); + var entry = events.getMethodDescriptor(this.name); + if (! entry.config) { +;;; kukit.E = 'undefined or unbindable event (no iteration found) [' + this.name + '].'; + throw kukit.err.pluginRegistryError(null, kukit.E); + } + // cache the binder class + this.bindIteration = entry.config; + } + return this.bindIteration; +}; + kukit.rd.KssSelector.prototype.getMergeId = function(node) { // Gives the merge id depending on a node. + // In case the mergeId is statically set, it dies not + // depend on the node. if (this.mergeId) { // Statically set. return this.mergeId; } else { - // Evaluate it. + // Evaluate the id depending on the node. var id = this.getId(node); - return kukit.er.makeMergeId(id, this.name); + // Get the binder class name + var className = this.getBindIteration().binderClass.prototype.__className__; + // finally compile the actual id: + // name cannot contain a @ + // id can be any string + // so the merge id will be unique + return className + '@' + name + '@' + id; } }; @@ -295,14 +352,6 @@ } }; -kukit.rd.EventRule.prototype.getBinderInfo = function(node) { - // Figure out what will be the "state id" for the kss event rule. - var id = this.kssSelector.getId(node); - // Gets the event instance for the rule. - return kukit.engine.binderInfoRegistry.getOrCreateBinderInfo( - this.kssSelector); -}; - /* * bind(node) : calls binder hook on event instance. * These hooks are tried in order, if succeeds it must return true: @@ -318,9 +367,11 @@ this.store(node); // Creation of the binding oper var oper = new kukit.op.Oper(); - var binderInfo = this.getBinderInfo(node); + var binderInfo = kukit.engine.binderInfoRegistry.getOrCreateBinderInfo( + this.kssSelector, node); oper.node = node; oper.eventRule = this; + // Gets the event instance for the rule. oper.binder = binderInfo.binder; oper.parms = this.parms; // mark on the instance as bound @@ -794,6 +845,7 @@ ;;; } // Merge into the corresponding category // mergeId must be set on kss selector already. + // XXX we pass no node to getMergedId eventRule.mergeIntoDict(dict, eventRule.kssSelector.getMergeId()); }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js Tue Dec 25 12:58:35 2007 @@ -29,11 +29,16 @@ kukit.tk._TokenBase.prototype.emitError = function(msg) { // Use the start position of the token for the error report. -;;; var marker = this.cursor.makeMarker(this.startpos); -;;; throw kukit.err.parsingError(msg, marker); +;;; this.emitWrappedError(null, msg); throw new Error(kukit.E); }; +;;; kukit.tk._TokenBase.prototype.emitWrappedError = function(e, msg) { +;;; // Use the start position of the token for the error report. +;;; var marker = this.cursor.makeMarker(this.startpos); +;;; throw kukit.err.parsingError(msg, marker, e); +;;; }; + kukit.tk._TokenBase.prototype.updateFinished = function() { if (! this.finished && this.cursor.text.length == this.cursor.pos) { if (this.isTopLevelParser) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Tue Dec 25 12:58:35 2007 @@ -143,7 +143,7 @@ txt= " /* comments; */ apples and /* more comments and*/ oranges ;"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, - //'Wrong value : [/* comments; */ apples and /* more comments and*/ oranges ;] cannot have spaces.', 62); + //'Wrong value : [/* comments; */ apples and /* more comments and*/ oranges ;].', 62); 'Wrong value : [apples and oranges] cannot have spaces.', 62); // in string, multiword ok even in method @@ -158,7 +158,7 @@ txt= "a'b c'"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, - 'Wrong value : unallowed characters [a] before a string', 6); + 'Wrong value : unallowed characters [a] before a string.', 6); // Not ok txt= "'a''b c'"; @@ -235,12 +235,12 @@ txt= " 'formVar'(x, y)"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.PropValue, cursor, null, true, - 'Wrong value : unallowed characters after the property', 16); + 'Wrong value : unallowed characters after the property.', 16); txt= "formVar(x, y) xxx"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.PropValue, cursor, null, true, - 'Wrong value : unallowed characters after the property', 17); + 'Wrong value : unallowed characters after the property.', 17); }; this.testEventValueSimple = function() { @@ -360,7 +360,7 @@ txt= "(a, b c )"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.MethodArgs, cursor, kukit.kssp.openParent, true, - 'Wrong method argument [b c] : value cannot have spaces', 9); + 'Wrong method argument [b c] : value cannot have spaces (if needed, quote it as a string).', 9); txt= "(a, b 'x' )"; cursor = new kukit.tk.Cursor(txt); @@ -841,7 +841,7 @@ var txt= "a:dnd-drag-toomuch(hello)"; var cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Wrong event selector [dnd-drag-toomuch] : qualifier should be : or :' + 'Wrong event selector [dnd-drag-toomuch] : qualifier should be : or :-.' , 25); // maybe in std css space is not allowed in the parents, @@ -1060,48 +1060,48 @@ txt= " document:clack "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [clack].'); + 'undefined or unbindable event (no iteration found) [clack].'); txt= " div#x:clack(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [clack].'); + 'undefined or unbindable event (no iteration found) [clack].'); txt= " document:clack(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [clack].'); + 'undefined or unbindable event (no iteration found) [clack].'); } this.testKssSelectorWithRightEventAndMissingNamespace = function() { txt= " document:drag "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [drag].'); + 'undefined or unbindable event (no iteration found) [drag].'); txt= " document:drag(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [drag].'); + 'undefined or unbindable event (no iteration found) [drag].'); } this.testKssSelectorWithUndefinedNamespaceWhenNamespace = function() { txt= " document:dad-drag "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [dad-drag].'); + 'undefined or unbindable event (no iteration found) [dad-drag].'); txt= " document:dad-drag(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [dad-drag].'); + 'undefined or unbindable event (no iteration found) [dad-drag].'); } this.testKssSelectorWithUndefinedEventNameWhenNameSpace = function() { txt= " document:dnd-drog "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [dnd-drog].'); + 'undefined or unbindable event (no iteration found) [dnd-drog].'); txt= " document:dnd-drog(hello) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Error : undefined event [dnd-drog].'); + 'undefined or unbindable event (no iteration found) [dnd-drog].'); } }; @@ -1255,17 +1255,15 @@ this.testSingleSelectorWithFirstComma = function() { var txt= ",a:dnd-drag(hello),"; var cursor = new kukit.tk.Cursor(txt); - var msg = 'Wrong event selector : missing event'; this.assertParsingError(kukit.kssp.KssSelectors, cursor, null, true, - msg, 1); + 'Wrong event selector : missing event qualifier : or :().'); } this.testSingleSelectorWithMiddleComma = function() { var txt= "a:dnd-drag(hello),,p:click"; var cursor = new kukit.tk.Cursor(txt); - var msg = 'Wrong event selector : missing event'; this.assertParsingError(kukit.kssp.KssSelectors, cursor, null, true, - msg, 1); + 'Wrong event selector : missing event qualifier : or :().'); } this.testSingleSelectorWithAdditionalComma = function() { @@ -1279,9 +1277,8 @@ this.testSingleSelectorWithAdditionalCommas = function() { var txt= "a:dnd-drag(hello),,"; var cursor = new kukit.tk.Cursor(txt); - var msg = 'Wrong event selector : missing event'; this.assertParsingError(kukit.kssp.KssSelectors, cursor, null, true, - msg, 1); + 'Wrong event selector : missing event qualifier : or :().'); } this.testEventRulesWithMultipleSelectors = function() { @@ -1440,11 +1437,11 @@ txt= " document:clack(kssAttr(hello)) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'KssSelectorError: KssSpecialSelector [document] must not stand with an event id acquired by value provider [kssAttr]'); + 'KssSpecialSelector [document] must not stand with an event id acquired by value provider [kssAttr]'); txt= " behaviour:clack(kssAttr(hello)) "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'KssSelectorError: KssSpecialSelector [behaviour] must not stand with an event id acquired by value provider [kssAttr]'); + 'KssSpecialSelector [behaviour] must not stand with an event id acquired by value provider [kssAttr]'); }; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Tue Dec 25 12:58:35 2007 @@ -53,14 +53,31 @@ new pclass(cursor, tokenClass, eofOk); } catch(e) { exc = e; + // We have two errors we have to look for. ParsingError is raised + // by the parser and contains row/column information. if (e.name != 'ParsingError') { throw e; } } this.assertNotEquals(exc, null, 'Should have thrown a ParsingError exception.'); - //this.assertEquals(exc.name, 'ParsingError'); + // + var info = exc.info; + // Assert the text of the error. if (typeof(errtxt) != 'undefined') { - this.assertEquals(exc.message.substr(0, errtxt.length), errtxt); + // We are only interested for the ultimate error message + // thas is, here we ignore the annotations we might have put on the message + while (info.previous_info) { + // go through the chain of error annotations + info = info.previous_info; + } + var exc_message = info.message; + // Take off possible row column message from the end - we check that differently + var match = exc_message.match(RegExp(/^(.*), at row \d+, column \d+$/)); + if (match) { + exc_message = match[1]; + } + // assert it now + this.assertEquals(exc_message, errtxt); } if (typeof(errpos) != 'undefined') { // XXX Do not check the error position now. This should be fixed however @@ -95,7 +112,8 @@ // it does not work at least for IE 6.0.2800.1106 if (typeof(exc.number) == 'number') { // IE - this.assertEquals(exc.description, 'Error happened'); + this.assertEquals(exc.description, 'ParsingError: Error happened'); + this.assertEquals(exc.info.message, 'Error happened'); } else { // toString result is browser dependent. // colon in FF @@ -104,7 +122,8 @@ var toString = exc.toString(); this.assertTrue(toString.indexOf('ParsingError') != -1, '"ParsingError" not in toString() : ' + toString); this.assertTrue(toString.indexOf('Error happened') != -1, '"Error happened" not in toString() : ' + toString); - this.assertEquals(exc.message, 'Error happened'); + this.assertEquals(exc.message, 'ParsingError: Error happened'); + this.assertEquals(exc.info.message, 'Error happened'); }; this.assertEquals(exc.errpos, null); this.assertEquals(exc.errrow, null); @@ -129,7 +148,8 @@ // it does not work at least for IE 6.0.2800.1106 if (typeof(exc.number) == 'number') { // IE - this.assertEquals(exc.description, 'Error happened, at row 3, column 4'); + this.assertEquals(exc.description, 'ParsingError: Error happened, at row 3, column 4'); + this.assertEquals(exc.info.message, 'Error happened, at row 3, column 4'); } else { // toString result is browser dependent. // colon in FF @@ -138,7 +158,8 @@ var toString = exc.toString(); this.assertTrue(toString.indexOf('ParsingError') != -1, '"ParsingError" not in toString() : ' + toString); this.assertTrue(toString.indexOf('Error happened, at row 3, column 4') != -1, '"Error happened, at row 3, column 4" not in toString() : ' + toString); - this.assertEquals(exc.message, 'Error happened, at row 3, column 4'); + this.assertEquals(exc.message, 'ParsingError: Error happened, at row 3, column 4'); + this.assertEquals(exc.info.message, 'Error happened, at row 3, column 4'); }; this.assertEquals(exc.info.kw.errpos, 13); this.assertEquals(exc.info.kw.errrow, 3); @@ -164,7 +185,7 @@ this.assertEquals(parser.result[0].symbol, 'fraction'); this.assertEquals(parser.result[0].txt, 'abc def'); - this.assertParsingError(pf, cursor, null, false, 'Unexpected EOF'); + this.assertParsingError(pf, cursor, null, false, 'Unexpected EOF.'); var txt="abc{def"; var cursor = new kukit.tk.Cursor(txt); From reebalazs at codespeak.net Tue Dec 25 12:58:42 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:42 +0100 (CET) Subject: [KSS-checkins] r50077 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115842.59FE4168508@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:42 2007 New Revision: 50077 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Simplify interfaces. Now finalization is done in a singleton which is automatically stored on interfaces. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js Tue Dec 25 12:58:42 2007 @@ -77,7 +77,7 @@ ;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; throw new Error(kukit.E); } - return kukit.engine.coreinterface.cssQuery(selector, inNodes); + return kukit.global.core.cssQuery(selector, inNodes); }; /* Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:42 2007 @@ -71,7 +71,7 @@ } namespacedEventNames.push(eventName); // register the event informataion - var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); + var events = kukit.interfaces.global.get('events', kukit.interfaces.PluginMethodDescriptor); events.getMethodDescriptor(eventName).register({ eventName: eventName, defaultMethodName: null, @@ -80,7 +80,7 @@ } // Register the bind iteration //this._registerEventSet(namespace, eventNames, iterName, bindMethodName); - var binditerations = kukit.interfaces.getBindIteration(); + var binditerations = kukit.interfaces.global.get('binditerations', kukit.interfaces.BindIterationDescriptor); binditerations.getMethodDescriptor('').register({ namespace: namespace, eventNames: namespacedEventNames, @@ -98,7 +98,7 @@ eventName = namespace + '-' + eventName; } // var entry = this.content[key]; - var events = kukit.interfaces.get('events', kukit.interfaces.PluginMethodDescriptor); + var events = kukit.interfaces.global.get('events', kukit.interfaces.PluginMethodDescriptor); var entry = events.getMethodDescriptor(eventName) if (! entry.config) { ;;; kukit.E = 'Error : undefined event [' + eventName + '].'; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:42 2007 @@ -1,10 +1,67 @@ kukit.interfaces = new function() { /* BEGIN CLOSURE kukit.interfaces */ -var InterfaceDescriptor = function(name, MethodDescriptor) { +/* + * Kukit interfaces + * + * Warning: this is not comparable with Zope interfaces. It has much smaller + * scope and aims at a different use case. + * + * We want a way to initialize a "set of attributes". These can be + * the registered vents, actions, etc., or methods of a service interface. + * The initialization of these attributes depends only on what javascript + * code is present and how it is defining these interfaces. + * + * The atributes or methods have method descriptors that can get their + * methods called and have a state that represents offers and demands on + * that given attribute or method. + * + * In case of an action plugin, this is just storing registry info keyed by + * the action name. However in case of a service interface, different components + * may provide the requested item, and the final value of the method is decided + * at finalization and all this logic is handled by the method descriptor. + * In case of service interfaces, this allows that "define service" + * and "provide service" sections can be in different javascript files (plugins), + * and the final outcome is independent of the order of their execution. + * + * The order in which this is made is irrelevant, after kukit.interfaces is + * included. + * + * An interface needs to be finalized before being used, and all + * methods will be finalized this time as well. + * + * After being finalized, all named interfaces can be accessed from + * the interfaces object, e.g.: + * + * interfaces.events.click - is an event's registry + * interfaces.actions.setAttr - is an action's registry + * interfaces.core.cssQuery - is a core service method + * interfaces.core.forEach - is a core service method + * + * + * This is not an API. It _can_ be used for generic purpose in any + * component, though. + * + * Kukit sets up the following interfaces for itself. The finalization + * of these interfaces is done by kukit at the beginning of bootstrap. + * + * name class + * ---- ----- + * core core services kukit.interfaces.ServiceMethodDescriptor + * events kss event name registry kukit.interfaces.PluginMethodDescriptor + * binditerations kss event binding reg. kukit.interfaces.BindIterationDescriptor + * actions kss action registry kukit.interfaces.PluginMethodDescriptor + * selectors kss selector registry kukit.interfaces.PluginMethodDescriptor + * valueproviders value provider registry kukit.interfaces.PluginMethodDescriptor + * + * For more information, see ../tests/test_interfaces.js . + * + */ +var InterfaceDescriptor = function(interfaces, name, MethodDescriptor) { // A parameters are the name of the interface, and // the method descriptor class it uses. // + this.interfaces = interfaces; this.name = name; this.finalized = false; this.registry = {}; @@ -53,7 +110,12 @@ } }; - this.finalize = function(klass, loader) { + this.finalize = function(singleton, loader) { + // singleton: the singleton we want to finalize on. + // loader (optional): use it for all operations + // (this means we never get errors but the loader + // will be set up to load missing resources) + // // Check if we are finalized. if (this.finalized) { ;;; kukit.E = 'Attempt to finalize already finalized plugin interface ['; @@ -62,13 +124,13 @@ } // Finalize all methods. this.forEachMethod(function(methodName, methodDescriptor) { - // Finalize them - var methodFunc = methodDescriptor.finalize(loader); - // store the functions on the class's prototype - klass.prototype[methodName] = methodFunc; + // finalize the functions and store them on the singleton + singleton[methodName] = methodDescriptor.finalize(loader); }); - // store myself (the interface descriptor) on the class - klass.prototype.interface = this; + // store myself (the interface descriptor) on the singleton + singleton.interface = this; + // Store the singleton itself on interfaces + this.interfaces[this.name] = singleton; // Set finalized state. // We are finalized if the loader has no items to load. // If there is no loader, we are finalized always. @@ -94,7 +156,7 @@ var interfaceDescriptor; interfaceDescriptor = this.registry[name]; if (typeof(interfaceDescriptor) == 'undefined') { - interfaceDescriptor = this.registry[name] = new InterfaceDescriptor(name, MethodDescriptor); + interfaceDescriptor = this.registry[name] = new InterfaceDescriptor(this, name, MethodDescriptor); } else { if (interfaceDescriptor.MethodDescriptor != MethodDescriptor) { ;;; kukit.E = 'Interface "' + name + '" already has a different method descriptor specified earlier.'; @@ -297,31 +359,14 @@ * Instantiation */ -this._createInterfaces = function() { +this._createGlobalInterfaces = function() { // create singleton for interfaces - this._interfaces = new this.Interfaces(); + this.global = new this.Interfaces(); }; -this._createInterfaces(); +this._createGlobalInterfaces(); // The following methods can acquire a given interface -// wrap the function, since there are no bound methods in JS -this.get = function(name, MethodDescriptor) { - return this._interfaces.get(name, MethodDescriptor); -}; -this.getService = function(name) { - return this._interfaces.get(name, this.ServiceMethodDescriptor); -}; -this.getPlugin = function(name) { - return this._interfaces.get(name, this.PluginMethodDescriptor); -}; -this.getBindIteration = function(name) { - // convenience, we use only 1 of this anyway - if (typeof(name) == 'undefined') { - name = 'binditerations'; - } - return this._interfaces.get(name, this.BindIterationDescriptor); -}; /* XXX If we want to use interfaces in a more placeful way, we can provide * cloning ang merging to them. Since we don't really use them this way, @@ -332,12 +377,18 @@ */ this.cleanRoomSetUp = function(suite) { - this._saved_interfaces = this._interfaces; + this._saved_global = this.global; // now create interfaces - this._createInterfaces(); + this._createGlobalInterfaces(); }; +this.cleanRoomFinalize = function(suite) { + // Need to finalize these interfaces + this.global.get('events', this.PluginMethodDescriptor).finalize({}); + this.global.get('binditerations', this.BindIterationDescriptor).finalize({}); +}; + this.cleanRoomTearDown = function(suite) { - this._interfaces = this._saved_interfaces; + this.global = this.saved_global; }; }(); /* END CLOSURE kukit.interfaces */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Tue Dec 25 12:58:42 2007 @@ -810,7 +810,7 @@ // XXX The interfaces for the selector can be taken from a given interface // registry. We use kukit.interfaces now which will make it operate on // the global registry. - var interfaces = kukit.interfaces._interfaces; + var interfaces = kukit.interfaces.global; // Protect the error for better logging ;;; try { this.kssSelector = new kukit.rd.KssSelector(isEvent, css, origName, Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Tue Dec 25 12:58:42 2007 @@ -234,9 +234,6 @@ this.binderInfoRegistry.processBindingEvents(); }; - - - ku.Engine.prototype.initializeRules = function() { if (window.kukitRulesInitializing || window.kukitRulesInitialized) { // Refuse to initialize a second time. @@ -245,10 +242,10 @@ } ;;; kukit.log('Initializing interfaces.'); // We finalize the core interface. - var klass = function() {}; - kukit.interfaces.get('core').finalize(klass); - var obj = new klass(); - this.coreinterface = obj + var interfaces = kukit.interfaces.global; + interfaces.get('core', kukit.interfaces.ServiceMethodDescriptor).finalize({}); + interfaces.get('events', kukit.interfaces.PluginDescriptor).finalize({}); + interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor).finalize({}); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept // as a global variable, but this needs refinement in the future. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:58:42 2007 @@ -147,8 +147,8 @@ // registry, so we cache this result. if (! this.bindIteration) { // Look up the binder class from the registry. - var events = this.interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor); - var entry = events.getMethodDescriptor(this.name); + var iterations = this.interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor); + var entry = iterations.getMethodDescriptor(this.name); if (! entry.config) { ;;; kukit.E = 'undefined or unbindable event (no iteration found) [' + this.name + '].'; throw kukit.err.pluginRegistryError(null, kukit.E); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Tue Dec 25 12:58:42 2007 @@ -3,7 +3,8 @@ new function() { // BEGIN CLOSURE service - var core = kukit.interfaces.getService('core'); + var core = kukit.interfaces.global.get('core', kukit.interfaces.ServiceMethodDescriptor); + core.getMethodDescriptor('cssQuery').define(['base2', 'cssQuery'], // a parameter checker common for each implementation function(selector, inNodes) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:42 2007 @@ -31,6 +31,7 @@ kukit.InterfacesTestCaseBase.prototype = new kukit.UtilsTestCaseBase(); kukit.InterfacesTestCase = function() { + this.name = 'kukit.InterfacesTestCase'; /* * Plugin interfaces */ @@ -54,8 +55,6 @@ }; this.testInterfaces = function() { - // We have a class, called C. - var C = function() {}; // We can create a simple method descriptor for an interface we want. // The method descriptor is managing the method's registration state called = []; @@ -84,8 +83,8 @@ }; this.testFinalizeInterfaces = function() { - // We have a class, called C. - var C = function() {}; + // We have a singleton, called s. + var s = {}; // We can create a simple method descriptor for an interface we want. // The method descriptor is managing the method's registration state called = []; @@ -99,14 +98,13 @@ called = []; // // At this point we are also ready to finalize the interface. - iface.finalize(C) + iface.finalize(s); // This calls finalize on all method descriptors. this.assertListEquals(called, ['FUNC fooMethod', 'FUNC barMethod']); called = []; // At the same time it also set up these on the class prototype. - var o = new C(); - this.assert(o.fooMethod, 'FUNC fooMethod'); - this.assert(o.barMethod, 'FUNC barMethod'); + this.assertEquals(this.interfaces.dummytest.fooMethod, 'FUNC fooMethod'); + this.assertEquals(this.interfaces.dummytest.barMethod, 'FUNC barMethod'); // ... so if the descriptor sets methodFunc on the }; @@ -148,8 +146,8 @@ */ this.testServiceInterfaces = function() { - // We have a class, called C. - var C = function() {}; + // We have a singleton, called s. + var s = {}; // Let's create a TestDummy interface. var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Define four methods, thie defines their necessity and preferred providers @@ -175,20 +173,18 @@ function() {return function() {return 'fourth/extra';}}); // // Now finalize it. - iface.finalize(C); - // Create an instance... - var o = new C(); + iface.finalize(s); // We can call the methods on it, - this.assert(o.first(), 'first/core'); - this.assert(o.second(), 'second/extra'); - this.assert(o.third(), 'third/core'); - this.assert(o.fourth(), 'fourth/extra'); + this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); + this.assertEquals(this.interfaces.dummytest.second(), 'second/extra'); + this.assertEquals(this.interfaces.dummytest.third(), 'third/core'); + this.assertEquals(this.interfaces.dummytest.fourth(), 'fourth/extra'); }; this.testChecker = function() { // Test with a checker function. - // We have a class, called C. - var C = function() {}; + // We have a singleton, called s. + var s = {}; // Let's create a TestDummy interface. var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // and a counter for the checker @@ -206,19 +202,18 @@ function() {return function() {return 'first/extra';}}); // // Now finalize it. - iface.finalize(C); - var o = new C(); + iface.finalize(s); // call it - this.assert(o.first(), 'first/core'); + this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); // Check that the checker has been called. - this.assert(checker_counter, 1); + this.assertEquals(checker_counter, 1); }; this.testReverseOrder = function() { // Method creation also works in reverse order: // a plugin first provides a method that another plugin later defines. - // We have a class, called C. - var C = function() {}; + // We have a singleton, called s. + var s = {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Provide the method first iface.getMethodDescriptor('first').provide('corelib', '1.1', @@ -226,17 +221,14 @@ // Define the method later iface.getMethodDescriptor('first').define(['corelib', 'extralib']); // Now finalize it. - var C = function() {}; - iface.finalize(C); - // Create an instance... - var o = new C(); + iface.finalize(s); // We can call the methods on it, - this.assert(o.first(), 'first/core'); + this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); }; this.testFinalizeTwice = function() { // An interface can only be finalized once. - var C = function() {}; + var s = {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Provide the method first iface.getMethodDescriptor('first').provide('corelib', '1.1', @@ -244,33 +236,30 @@ // Define the method later iface.getMethodDescriptor('first').define(['corelib', 'extralib']); // Now finalize it. - var C = function() {}; - iface.finalize(C); + iface.finalize(s); // Finalize it again. this.assertThrows(function() { - iface.finalize(C); + iface.finalize(s); }, Error); }; this.testNotDefined = function() { // A method is provided but not defined. - var C = function() {}; + var s = {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Provide the method first iface.getMethodDescriptor('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // Now finalize it. - var C = function() {}; this.assertThrows(function() { - iface.finalize(C); + iface.finalize(s); }, Error) }; this.testDoubleProvided = function() { // A method cannot be provided twice by the same provider. - var C = function() {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Provide the method first iface.getMethodDescriptor('first').provide('corelib', '1.1', @@ -285,7 +274,6 @@ this.testDoubleDefined = function() { // A method can only be defined once. - var C = function() {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Define the method first iface.getMethodDescriptor('first').define(['corelib', 'extralib']); @@ -298,7 +286,7 @@ this.testNotProvided = function() { // No preferred provider can be found for a method. - var C = function() {}; + var s = {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Define the method first iface.getMethodDescriptor('first').define(['corelib', 'extralib']); @@ -306,9 +294,8 @@ iface.getMethodDescriptor('first').provide('craplib', '1.1', function() {return function() {return 'first/crap';}}); // Now finalize it. - var C = function() {}; this.assertThrows(function() { - iface.finalize(C); + iface.finalize(s); }, Error); }; @@ -330,7 +317,7 @@ }; }(); // Now, for the interface part - var C = function() {}; + var s = {}; var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); // Define the method with loader and fallback script iface.getMethodDescriptor('first').define(['corelib', 'extralib'], null, '++resource++one'); @@ -343,22 +330,21 @@ iface.getMethodDescriptor('third').provide('extralib', '1.1', function() {return function() {return 'third/extra';}}); // Now finalize it. It goes without error. - iface.finalize(C, loader); + iface.finalize(s, loader); // We see the contents of the loader. Third is not in there. this.assertListEquals(loader.loaded, ['++resource++one', '++resource++two'], 'Loaded contents differs.'); // Third is actually working. - var o = new C(); - this.assert(o.third(), 'third/extra'); + this.assertEquals(this.interfaces.dummytest.third(), 'third/extra'); // First and second are undefined. - this.assert(typeof(o.first), 'undefined'); - this.assert(typeof(o.second), 'undefined'); + this.assertEquals(typeof(this.interfaces.dummytest.first), 'undefined'); + this.assertEquals(typeof(this.interfaces.dummytest.second), 'undefined'); // Now the loader can go to load the needed files... // then it is supposed to re-finalize with and without a loader. Check if this is possible: - iface.finalize(C, loader); + iface.finalize(s, loader); // If we re-finalize without a loader, and the sources are still not loaded, // we get an error: this.assertThrows(function() { - iface.finalize(C); + iface.finalize(s); }, Error); }; @@ -377,10 +363,8 @@ this.bind = function(oper) {}; }; this.testPluginInterfaces = function() { - // We have a class, called C. - var C = function() {}; // Let's create a TestDummy interface. - var events = this.interfaces.get('dummyevent', kukit.interfaces.PluginMethodDescriptor); + var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); var binditerations = this.interfaces.get('dummybinditerations', kukit.interfaces.BindIterationDescriptor); // somewhere else, core registers the methods: events.getMethodDescriptor('click').register({ @@ -418,19 +402,17 @@ bindMethodName: 'bind'}); // // Now finalize it. - events.finalize(C); - binditerations.finalize(C); - // Create an instance... - var o = new C(); + events.finalize({}); + binditerations.finalize({}); // We can call the methods on it, - //this.assert(o.click.binderMethodName, 'bind'); - //this.assert(o.keydown.binderMethodName, 'bind'); - //this.assert(o.timeout.binderMethodName, 'bind'); + this.assertEquals(this.interfaces.dummyevents.click.defaultMethodName, null); + this.assertEquals(this.interfaces.dummyevents.keydown.defaultMethodName, null); + this.assertEquals(this.interfaces.dummyevents.timeout.defaultMethodName, null); + this.assertEquals(this.interfaces.dummybinditerations.timeout.iterName, 'Each'); }; this.testPluginNoDoubleReg = function() { // No double registration for test plugins. - var C = function() {}; // Let's create a TestDummy interface. var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); // somewhere a plugin registers something: @@ -454,7 +436,6 @@ this.testBindIterationNoDoubleReg = function() { // No double registration for test plugins. - var C = function() {}; // Let's create a TestDummy interface. var iface = this.interfaces.get('dummybinditeration', kukit.interfaces.BindIterationDescriptor); // somewhere else, core registers the methods: Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Tue Dec 25 12:58:42 2007 @@ -41,6 +41,9 @@ kukit.pl.NativeEventBinder, null, null); // XXX the tests test at numerous occasion a non-existent // event, so be careful when you add a new one. + // + // finalize the interfaces we just set up + kukit.interfaces.cleanRoomFinalize(this); }; this.tearDown = function() { From reebalazs at codespeak.net Tue Dec 25 12:58:46 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:46 +0100 (CET) Subject: [KSS-checkins] r50078 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071225115846.B0AB016850A@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:46 2007 New Revision: 50078 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Small name changes Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:46 2007 @@ -39,8 +39,11 @@ * * XXX EventRegistry becomes pure BBB, when the new javascript docstring registry * is implemented. +* */ var _EventRegistry = function () { + // XXX There is no actual registry here any more, just + // emulating the old methods with the interfaces registry. }; /* there are the actual registration methods, to be called from plugins */ @@ -79,7 +82,8 @@ }); } // Register the bind iteration - //this._registerEventSet(namespace, eventNames, iterName, bindMethodName); + // This will specify the set of events that will be bound together, + // with the specified iterator var binditerations = kukit.interfaces.global.get('binditerations', kukit.interfaces.BindIterationDescriptor); binditerations.getMethodDescriptor('').register({ namespace: namespace, @@ -90,23 +94,6 @@ }; -// XXX This method should be deprc'd and from where it's called, -// the finalized class's properties should be accessed -_EventRegistry.prototype.get = function(namespace, eventName) { - //var key = this._getKey(namespace, eventName); - if (namespace) { - eventName = namespace + '-' + eventName; - } - // var entry = this.content[key]; - var events = kukit.interfaces.global.get('events', kukit.interfaces.PluginMethodDescriptor); - var entry = events.getMethodDescriptor(eventName) - if (! entry.config) { -;;; kukit.E = 'Error : undefined event [' + eventName + '].'; - throw new Error(kukit.E); - } - return entry.config; -}; - kukit.eventsGlobalRegistry = new _EventRegistry(); /* XXX deprecated methods, to be removed asap */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:46 2007 @@ -127,8 +127,6 @@ // finalize the functions and store them on the singleton singleton[methodName] = methodDescriptor.finalize(loader); }); - // store myself (the interface descriptor) on the singleton - singleton.interface = this; // Store the singleton itself on interfaces this.interfaces[this.name] = singleton; // Set finalized state. @@ -147,7 +145,7 @@ }; /* end InterfaceDescriptor */ -this.Interfaces = function() { +this.NamedInterfaces = function() { this.registry = {}; @@ -166,7 +164,7 @@ return interfaceDescriptor; }; -}; /* end Interfaces */ +}; /* end NamedInterfaces */ /* * KSS service layer registry @@ -361,7 +359,7 @@ this._createGlobalInterfaces = function() { // create singleton for interfaces - this.global = new this.Interfaces(); + this.global = new this.NamedInterfaces(); }; this._createGlobalInterfaces(); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:58:46 2007 @@ -105,17 +105,11 @@ // Now we check the plugin part of the registry: this may not be // necessary but this way we reject an event which has the binder // set up, but has no actual event information. -;;; // We wrap all errors as pluginRegistryError. -;;; try { - // XXX TODO cicrumvent the get - kukit.eventsGlobalRegistry.get( - null, this.name); -;;; } catch(e) { -;;; if (! e.name != 'PluginRegistryError') { -;;; kukit.E = 'undefined event [' + this.name + '].'; -;;; throw kukit.err.pluginRegistryError(e, kukit.E); -;;; } -;;; } + var events = this.interfaces.events[this.name]; + if (typeof(events) == 'undefined') { +;;; kukit.E = 'Error : undefined event [' + this.name + '].'; + throw kukit.err.pluginRegistryError(null, kukit.E); + } }; kukit.rd.KssSelector.prototype.prepareId = function() { @@ -147,14 +141,11 @@ // registry, so we cache this result. if (! this.bindIteration) { // Look up the binder class from the registry. - var iterations = this.interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor); - var entry = iterations.getMethodDescriptor(this.name); - if (! entry.config) { + this.bindIteration = this.interfaces.binditerations[this.name]; + if (typeof(this.bindIteration) == 'undefined') { ;;; kukit.E = 'undefined or unbindable event (no iteration found) [' + this.name + '].'; throw kukit.err.pluginRegistryError(null, kukit.E); } - // cache the binder class - this.bindIteration = entry.config; } return this.bindIteration; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:58:46 2007 @@ -25,7 +25,7 @@ this.setUp = function() { // work with our own object, not interfering // kukit.interfaces - this.interfaces = new kukit.interfaces.Interfaces(); + this.interfaces = new kukit.interfaces.NamedInterfaces(); }; }; /* end InterfacesTestCase */ kukit.InterfacesTestCaseBase.prototype = new kukit.UtilsTestCaseBase(); From reebalazs at codespeak.net Tue Dec 25 12:58:49 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:49 +0100 (CET) Subject: [KSS-checkins] r50079 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115849.57B33168512@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:49 2007 New Revision: 50079 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Log: Comment out late binder Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:58:49 2007 @@ -273,6 +273,13 @@ * postpone binding of actions until called first time * */ + +/* + * XXX Late binder is not needed any more: + * the same need is better fulfilled by bind iterators. + * By commenting it out I want to demonstrate that it's not + * used anyway + var _LateBinder = function(binder, name, node) { this.binder = binder; this.name = name; @@ -306,6 +313,8 @@ } this.boundEvent(); }; +*/ + var _EventBinder_triggerEvent = function(name, oper) { // Private. Called from __continueEvent__ or from main event execution. From reebalazs at codespeak.net Tue Dec 25 12:58:52 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:52 +0100 (CET) Subject: [KSS-checkins] r50080 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115852.6FA9B168516@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:51 2007 New Revision: 50080 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Log: Small typo causing problem at bootstrap Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Tue Dec 25 12:58:51 2007 @@ -244,7 +244,7 @@ // We finalize the core interface. var interfaces = kukit.interfaces.global; interfaces.get('core', kukit.interfaces.ServiceMethodDescriptor).finalize({}); - interfaces.get('events', kukit.interfaces.PluginDescriptor).finalize({}); + interfaces.get('events', kukit.interfaces.PluginMethodDescriptor).finalize({}); interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor).finalize({}); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept From reebalazs at codespeak.net Tue Dec 25 12:58:56 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:58:56 +0100 (CET) Subject: [KSS-checkins] r50081 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115856.1136C168516@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:58:55 2007 New Revision: 50081 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Log: Fix interface access from cssQuery call Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js Tue Dec 25 12:58:55 2007 @@ -77,7 +77,7 @@ ;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; throw new Error(kukit.E); } - return kukit.global.core.cssQuery(selector, inNodes); + return kukit.interfaces.global.core.cssQuery(selector, inNodes); }; /* Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 12:58:55 2007 @@ -54,6 +54,8 @@ * selectors kss selector registry kukit.interfaces.PluginMethodDescriptor * valueproviders value provider registry kukit.interfaces.PluginMethodDescriptor * + * They are initialized into kukit.interfaces.global. + * * For more information, see ../tests/test_interfaces.js . * */ From reebalazs at codespeak.net Tue Dec 25 12:59:00 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:00 +0100 (CET) Subject: [KSS-checkins] r50082 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115900.7F372168519@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:00 2007 New Revision: 50082 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Log: Make kukit run with the full binding cycle. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Tue Dec 25 12:59:00 2007 @@ -183,12 +183,11 @@ ;;; }; -;;; err.eventBindError = function(e, eventNames, eventNamespaces){ +;;; err.eventBindError = function(e, eventNames){ ;;; var kw = {}; ;;; kw.eventNames = eventNames; -;;; kw.eventNamespaces = eventNamespaces; ;;; var message = 'When binding event name(s) [' + eventNames; -;;; message += '] in namespace [' + eventNamespaces + '].'; +;;; message += '].'; ;;; return setErrorInfo(e, 'EventBindError', message, kw); ;;; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:00 2007 @@ -50,7 +50,7 @@ _EventRegistry.prototype.register = function(namespace, eventName, binderClass, bindMethodName, - bindMethodName, defaultActionMethodName) { + defaultActionMethodName) { this.registerForAllEvents(namespace, eventName, binderClass, bindMethodName, defaultActionMethodName, 'EachLegacy'); }; @@ -86,7 +86,6 @@ // with the specified iterator var binditerations = kukit.interfaces.global.get('binditerations', kukit.interfaces.BindIterationDescriptor); binditerations.getMethodDescriptor('').register({ - namespace: namespace, eventNames: namespacedEventNames, iterName: iterName, binderClass: binderClass, @@ -344,13 +343,12 @@ /* (default) method call handling */ -var _EventBinder_callMethod = function(namespace, name, oper, methodName) { +var _EventBinder_callMethod = function(name, oper, methodName) { // hidden method for calling just a method and checking that is exists. // (called from oper) var method = this[methodName]; if (! method) { ;;; kukit.E = 'Could not trigger event name [' + name; -;;; kukit.E += '] on namespace [' + namespace; ;;; kukit.E += '], because the method [' + methodName + '] does not exist.'; throw new Error(kukit.E); } @@ -393,36 +391,31 @@ this.info = {}; }; +/* This is used to force creation of binder info and instance for + * a given kss selector on a node. + * The binder info is returned, it contains binding information + * and a reference link to the actual binder instance. + */ er.BinderInfoRegistry.prototype.getOrCreateBinderInfo = function (kssSelector, node) { // We use the key as the selector's merge id. var key = kssSelector.getMergeId(); - // Get or create the event. + // Get or create the binder and the binder info. var binderInfo = this.info[key]; if (typeof(binderInfo) == 'undefined') { - // Create a new event. -;;; var msg = 'Instantiating event id [' + id + '], className ['; -;;; msg += className + '], namespace [' + namespace + '].'; -;;; kukit.logDebug(msg); - // // The creation of binder instances happens from here. // + //kukit.logWarning(kssSelector.getBindIteration()); var binderClass = kssSelector.getBindIteration().binderClass; +;;; var msg = 'Instantiating event binder with id [' + kssSelector.getId() + '], className ['; +;;; msg += binderClass.prototype.__className__ + '].'; +;;; kukit.logDebug(msg); + // Create the binder instance and the binder info var binder = new binderClass(); binderInfo = this.info[key] = new _BinderInfo(binder); - - // store the bound rules - //binder.__bound_rules__ = []; - } else if (binderInfo.getBinder().__binderClassName__ != - className) { - // just paranoia -;;; kukit.E = 'Conflicting class for event id [' + id + '], ['; -;;; kukit.E += binderInfo.getBinder().__binderClassName__; -;;; kukit.E += '] != [' + className + '].'; - throw new Error(kukit.E); } return binderInfo; }; @@ -437,11 +430,15 @@ return binderInfo; }; +/* Not used from kukit actually */ +/* er.BinderInfoRegistry.prototype.getSingletonBinderInfoByName = function (namespace, name) { //Get className - // XXX XXX XXX - var className = kukit.eventsGlobalRegistry.get(namespace, name).className; + if (namespace) { + name = namespace + '-' + name; + } + kukit.eventsGlobalRegistry.get(namespace, name).className; // Get an event. var id = er.makeId(namespace, className); var binderInfo = this.info[id]; @@ -452,6 +449,7 @@ } return binderInfo; }; +*/ er.BinderInfoRegistry.prototype.startBindingPhase = function () { // At the end of the binding phase, we want to process our events. This @@ -590,24 +588,33 @@ // XXX This will need refactoring. /// We would only want to lookup from our registry and not the other way around. // -// own registry means eventsets need to be registered in the instance. (klass) -// -// _OperRegistry.prototype.processBindingEvents = function (binder) { - var eventRegistry = kukit.eventsGlobalRegistry; - for (var i=0; i < eventRegistry.eventSets.length; i++) { - var eventSet = eventRegistry.eventSets[i]; - // Only process binding events (and ignore non-binding ones) - if (eventSet.bindMethodName) { - if (binder.__eventNamespace__ == eventSet.namespace) { - // Process the binding event set. - // This will call the actual bindmethods - // according to the specified iterator. - var iterator = er.getBindIterator(eventSet.iterName); - iterator.call(this, eventSet, binder); - } - } + var interfaces = kukit.interfaces.global; + // Let's see all our events in a cycle. + processed = {}; + for (var eventName in interfaces.binditerations) { + // We only iterate an event once and we greedily iterate + // all events which are in the same eventset - so we may + // get here by this event name already processed. + if (processed[eventName]) { + continue; + } + // One iteration consists of more events. Process all these. + var iteration = interfaces.binditerations[eventName]; + // Let's exit if this element does not exist + // (the interface registry finalizes invalid methods to undefined) + if (! iteration) { + continue; + } + var eventSet = iteration.eventNames; + // Make sure we exclude this element, + for (var i=0; i Author: reebalazs Date: Tue Dec 25 12:59:02 2007 New Revision: 50083 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js Log: Fix the case of default actions Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js Tue Dec 25 12:59:02 2007 @@ -242,11 +242,8 @@ // valid, even if it received no parms in the eventRule, // in which case it is not present as an action. // - // XXX XXX XXX XXX XXX - return false; - var kssevent = kukit.eventsGlobalRegistry.get( - this.getEventNamespace(), this.getEventName()) - var methodName = kssevent.defaultActionMethodName; + var interface = kukit.interfaces.global; + var methodName = interface.events[name].defaultActionMethodName; return (typeof methodName != 'undefined'); } else return false; From reebalazs at codespeak.net Tue Dec 25 12:59:06 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:06 +0100 (CET) Subject: [KSS-checkins] r50084 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115906.4A33016851B@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:05 2007 New Revision: 50084 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Log: Refactor event binding on an instance: previously we iterated on all known eventsets, now we only visit the events actually set up in the binder instance. May be a bigger difference with lots of registered events. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:05 2007 @@ -361,6 +361,9 @@ this.decorateEventBinderClass = function(cls) { // See if we are set up already? + // XXX XXX this will cause a problem if classes + // are inherited from each other... then classNames + // would not be set... hmm... var p = cls.prototype; if (p.__decorated_for_kss__) { return; @@ -593,7 +596,11 @@ var interfaces = kukit.interfaces.global; // Let's see all our events in a cycle. processed = {}; - for (var eventName in interfaces.binditerations) { + // We iterate through the event names in this binder instance only. + // However we process the event names in groups according + // to the bind iterations registry. This means processing will + // "steal" event names that come later. + for (var eventName in this.infoPerName) { // We only iterate an event once and we greedily iterate // all events which are in the same eventset - so we may // get here by this event name already processed. @@ -601,6 +608,7 @@ continue; } // One iteration consists of more events. Process all these. + // (One of these is eventName itself, but we need not care.) var iteration = interfaces.binditerations[eventName]; // Let's exit if this element does not exist // (the interface registry finalizes invalid methods to undefined) @@ -608,7 +616,8 @@ continue; } var eventSet = iteration.eventNames; - // Make sure we exclude this element, + // Make sure we exclude these event names + // from further processing. for (var i=0; i Author: reebalazs Date: Tue Dec 25 12:59:10 2007 New Revision: 50085 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Make it work with event-binder demo Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:10 2007 @@ -77,7 +77,7 @@ var events = kukit.interfaces.global.get('events', kukit.interfaces.PluginMethodDescriptor); events.getMethodDescriptor(eventName).register({ eventName: eventName, - defaultMethodName: null, + defaultActionMethodName: defaultActionMethodName, parmtypes: null // missing from this api. }); } @@ -258,13 +258,6 @@ ;;; kukit.logDebug('Event [' + name + '] executed on ' + executed + ' nodes.'); }; -var _EventBinder_makeFuncToBind = function(name, node) { - var executor = new er._LateBinder(this, name, node); - return function() { - executor.executeActions(); - }; -}; - /* * * class _LateBinder @@ -279,6 +272,13 @@ * By commenting it out I want to demonstrate that it's not * used anyway +var _EventBinder_makeFuncToBind = function(name, node) { + var executor = new er._LateBinder(this, name, node); + return function() { + executor.executeActions(); + }; +}; + var _LateBinder = function(binder, name, node) { this.binder = binder; this.name = name; @@ -361,25 +361,27 @@ this.decorateEventBinderClass = function(cls) { // See if we are set up already? - // XXX XXX this will cause a problem if classes - // are inherited from each other... then classNames - // would not be set... hmm... - var p = cls.prototype; - if (p.__decorated_for_kss__) { + // We make a mark not on the class prototype, + // but on the class itself. This will make + // sure inherited classes get a distinct class name. + if (cls.__decorated_for_kss__) { return; } + var p = cls.prototype; // Put inherited methods on it p.__continueEvent__ = _EventBinder__continueEvent__; p.__continueEvent_allNodes__ = _EventBinder__continueEvent_allNodes__; p._EventBinder_triggerEvent = _EventBinder_triggerEvent; p._EventBinder_callMethod = _EventBinder_callMethod; - p.__makeFuncToBind__ = _EventBinder_makeFuncToBind; +// p.__makeFuncToBind__ = _EventBinder_makeFuncToBind; // only used by LateBinder atm // Generate a unique class name p.__className__ = '' + _eventClassCounter; _eventClassCounter ++; - // mark decorated - p.__decorated_for_kss__ = true; + // mark decorated. We store the class there + // so we can decide if this class has been + // decorated or not. + cls.__decorated_for_kss__ = true; }; /* Event instance registry @@ -402,7 +404,7 @@ er.BinderInfoRegistry.prototype.getOrCreateBinderInfo = function (kssSelector, node) { // We use the key as the selector's merge id. - var key = kssSelector.getMergeId(); + var key = kssSelector.getBindKey(node); // Get or create the binder and the binder info. var binderInfo = this.info[key]; if (typeof(binderInfo) == 'undefined') { @@ -412,7 +414,7 @@ //kukit.logWarning(kssSelector.getBindIteration()); var binderClass = kssSelector.getBindIteration().binderClass; -;;; var msg = 'Instantiating event binder with id [' + kssSelector.getId() + '], className ['; +;;; var msg = 'Instantiating event binder with id [' + kssSelector.getId(node) + '], className ['; ;;; msg += binderClass.prototype.__className__ + '].'; ;;; kukit.logDebug(msg); @@ -696,11 +698,12 @@ }; _OperRegistry.prototype.callBindMethod = - function (iteration, binder, p1, p2, p3, p4, p5, p6) { + function (iteration, binder, p1, p2, p3, p4, p5) { + // get the method itself var method = binder[iteration.bindMethodName]; // Protect the binding for better logging ;;; try { - method.call(binder, p1, p2, p3, p4, p5, p6); + method.call(binder, p1, p2, p3, p4, p5); ;;; } catch(e) { ;;; kukit.E = kukit.err.eventBindError(e, iteration.eventNames); ;;; throw new Error(kukit.E); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js Tue Dec 25 12:59:10 2007 @@ -243,7 +243,7 @@ // in which case it is not present as an action. // var interface = kukit.interfaces.global; - var methodName = interface.events[name].defaultActionMethodName; + var methodName = interface.events[this.getEventName()].defaultActionMethodName; return (typeof methodName != 'undefined'); } else return false; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:59:10 2007 @@ -55,7 +55,11 @@ this.name = name; this.id = id; this.ppid = ppid; + // mergeId and bindKey store bindings on a given interface, + // in case this can be statically decided ie. there is + // no value provider used to define the id. this.mergeId = null; + this.bindKey = null; this.bindIteration = null; // finish up the KSS on it // XXX We should not have this here, because this disables testing the parser @@ -92,6 +96,7 @@ // at it depending on nodes. // This step will access the interfaces already // by calling getBindIteration. + this.bindKey = this.getBindKey(); this.mergeId = this.getMergeId(); } else { // We have a value provider for the id. We cannot set the @@ -152,11 +157,30 @@ kukit.rd.KssSelector.prototype.getMergeId = function(node) { // Gives the merge id depending on a node. - // In case the mergeId is statically set, it dies not + // This id will identify what other rules this rule can merge + // with, if they match on the same node. Only rules with the same + // merge id will match. Therefore the merge id contains the bind key, + // plus the event name. + // In case the mergeId is statically set, it does not // depend on the node. if (this.mergeId) { // Statically set. return this.mergeId; + } else { + return this.name + '@' + this.getBindKey(node); + } +}; + +kukit.rd.KssSelector.prototype.getBindKey = function(node) { + // Gives the bind key depending on a node. + // This key identifies the binder instance on which + // selector will operate. Therefore it consists of the + // classname and the event id. + // In case the mergeId is statically set, it does not + // depend on the node. + if (this.bindKey) { + // Statically set. + return this.bindKey; } else { // Evaluate the id depending on the node. var id = this.getId(node); @@ -166,11 +190,12 @@ // name cannot contain a @ // id can be any string // so the merge id will be unique - return className + '@' + this.name + '@' + id; + return className + '@' + id; } }; + /* * Kss parameter values. There are two kinds: text and method. * @@ -501,9 +526,11 @@ // Execute the default action in case of there is one but there were no // parms so it was actually not entered as an action object // otherwise, it would have been executed from action.execute already + // XXX This part will go away, as we want to make default actions + // explicitely needed in kss. if (typeof(this.content['default']) == 'undefined') { // this is conditional: if there is no default method, it's skipped. - var name = oper.eventRule.kssSelector.name; + var name = oper.getEventName(); // Execution with no parms. (XXX ?) oper = oper.clone({'parms': {}}); oper.executeDefaultAction(name, true); @@ -665,7 +692,7 @@ switch (this.type) { case 'D': { // Default action. - var name = oper.eventRule.kssSelector.name; + var name = oper.getEventName(); oper.executeDefaultAction(name); } break; case 'S': { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Tue Dec 25 12:59:10 2007 @@ -369,13 +369,13 @@ // somewhere else, core registers the methods: events.getMethodDescriptor('click').register({ name: 'click', - defaultMethodName: null, + defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); events.getMethodDescriptor('keydown').register({ name: 'keydown', - defaultMethodName: null, + defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); @@ -389,7 +389,7 @@ // somewhere else, extras registers the methods: events.getMethodDescriptor('timeout').register({ name: 'timeout', - defaultMethodName: null, + defaultActionMethodName: null, parmtypes: [ ['millis', 'int'], ['renew', 'bool', false]]}); @@ -405,9 +405,9 @@ events.finalize({}); binditerations.finalize({}); // We can call the methods on it, - this.assertEquals(this.interfaces.dummyevents.click.defaultMethodName, null); - this.assertEquals(this.interfaces.dummyevents.keydown.defaultMethodName, null); - this.assertEquals(this.interfaces.dummyevents.timeout.defaultMethodName, null); + this.assertEquals(this.interfaces.dummyevents.click.defaultActionMethodName, null); + this.assertEquals(this.interfaces.dummyevents.keydown.defaultActionMethodName, null); + this.assertEquals(this.interfaces.dummyevents.timeout.defaultActionMethodName, null); this.assertEquals(this.interfaces.dummybinditerations.timeout.iterName, 'Each'); }; @@ -418,7 +418,7 @@ // somewhere a plugin registers something: events.getMethodDescriptor('click').register({ name: 'click', - defaultMethodName: null, + defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); @@ -426,7 +426,7 @@ this.assertThrows(function() { events.getMethodDescriptor('click').register({ name: 'click', - defaultMethodName: null, + defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); @@ -444,15 +444,31 @@ iterName: 'Each', binderClass: M, bindMethodName: 'bind'}); - // But another providing attempt is punished by an Error. - this.assertThrows(function() { - iface.getMethodDescriptor('').register({ - eventNames: ['keyDown', 'timeout'], - iterName: 'Each', - binderClass: M, - bindMethodName: 'bind'}); - }, - Error); + // Suppose we have now a binder class that is a + // subclass of the previous one. In this case, + // it is essential to check that they got a different + // className. + var MSub = function() { + this.bind2 = function(oper) {}; + }; + MSub.prototype = new M(); + iface.getMethodDescriptor('').register({ + eventNames: ['keydown', 'keypress'], + iterName: 'Each', + binderClass: MSub, + bindMethodName: 'bind'}); + // initialize + iface.finalize({}); + // Check that our classes are set as expected. + this.assert(this.interfaces.dummybinditeration.click.binderClass, M); + this.assert(this.interfaces.dummybinditeration.timeout.binderClass, M); + this.assert(this.interfaces.dummybinditeration.keydown.binderClass, MSub); + this.assert(this.interfaces.dummybinditeration.keypress.binderClass, MSub); + // Check that both classes have a class name. + this.assert(M.prototype.__className__); + this.assert(MSub.prototype.__className__); + // Check the two classes have distinct class names + this.assertNotEquals(M.prototype.__className__, MSub.prototype.__className__); }; }; /* end PluginInterfacesTestCase */ From reebalazs at codespeak.net Tue Dec 25 12:59:14 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:14 +0100 (CET) Subject: [KSS-checkins] r50086 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115914.DC20D1684F9@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:14 2007 New Revision: 50086 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Log: Fix binding on given binder id-s. Now the more_selectors test is working. All tests GREEN! Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:14 2007 @@ -190,11 +190,14 @@ var oper = new kukit.op.Oper(); oper.node = node; if (node) { - // if we found the binding, just use that - // XXX XXX - var info = kukit.engine.binderInfoRegistry.getBinderInfoById( - this.__binderId__); - var newOper = info.bound.getBoundOperForNode(name, node); + + // XXX the global registry is use + var binderInfoRegistry = kukit.engine.binderInfoRegistry; + // Get the binder info. + var key = this.__bindKey__; + var binderInfo = binderInfoRegistry.info[key]; + + var newOper = binderInfo.bound.getBoundOperForNode(name, node); if (newOper) { oper = newOper; } @@ -241,9 +244,15 @@ // Normal rules. If any of those match, execute them too // each on the node that it selects - not on the original node. var oper = new kukit.op.Oper(); - var info = kukit.engine.binderInfoRegistry.getBinderInfoById( - this.__binderId__); - var opers = info.bound.getBoundOpers(name); + + // XXX the global registry is use + var binderInfoRegistry = kukit.engine.binderInfoRegistry; + // Get the binder info. + var key = this.__bindKey__; + var binderInfo = binderInfoRegistry.info[key]; + + // Get opers and trigger the event on each + var opers = binderInfo.bound.getBoundOpers(name); for (var i=0; i following Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:59:14 2007 @@ -877,9 +877,11 @@ ;;; throw new Error('Unknown method rule category [' + category + '].'); ;;; } // look up the rule - // XXX XXX XXX - var id = binder.__binderId__; - var mergeId = kukit.er.makeMergeId(id, name); + // + // Generate its merge id from the bindkey and event name + var bindKey = binder.__bindKey__; + // XXX TODO refactor this with kssSelector + var mergeId = name + '@' + bindKey; var mergedRule = dict[mergeId]; if (typeof(mergedRule) == 'undefined') { // no error, just return null. From reebalazs at codespeak.net Tue Dec 25 12:59:18 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:18 +0100 (CET) Subject: [KSS-checkins] r50087 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115918.40FCE1684F9@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:17 2007 New Revision: 50087 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js Log: Convert core plugins to use Each bind iterator instead of EachLegacy. Since these plugins called makeExecuteActionsHook themselves, it resulted in double calling each time, since the EachLegacy iterator needed to prefetch them. This may break third party plugin code that reuses unpublished internals from plugins.js. (Most particularly, the more_selectors demo needed to be updated as well.) Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:17 2007 @@ -746,7 +746,6 @@ // This calls the bind method by each bound oper one by one. -// Eventname and funcToBind are passed too. // this is the preferred ([Each]) way. Parameters are different from EachLegacy. _OperRegistry.prototype._iterateEach = function (iteration, binder) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js Tue Dec 25 12:59:17 2007 @@ -139,46 +139,53 @@ }; kukit.pl.NativeEventBinder.prototype.__bind__node = - function(name, func_to_bind, oper) { + function(oper) { ;;; if (oper.node == null) { -;;; throw new Error('Native event [' + name + '] must be bound to a node.'); +;;; throw new Error('Native event [' + oper.getEventName() + '] must be bound to a node.'); ;;; } - this.__bind__(name, func_to_bind, oper); + this.__bind__(oper); }; kukit.pl.NativeEventBinder.prototype.__bind__nodeorwindow = - function(name, func_to_bind, oper) { + function(oper) { if (oper.node == null) { oper.node = window; } - this.__bind__(name, func_to_bind, oper); + this.__bind__(oper); }; kukit.pl.NativeEventBinder.prototype.__bind__window = - function(name, func_to_bind, oper) { + function(oper) { ;;; if (oper.node != null) { -;;; throw new Error('Native event [' + name + '] must not be bound to a node.'); +;;; throw new Error('Native event [' + oper.getEventName() + '] must not be bound to a node.'); ;;; } oper.node = window; - this.__bind__(name, func_to_bind, oper); + this.__bind__(oper); }; kukit.pl.NativeEventBinder.prototype.__bind__nodeordocument = - function(name, func_to_bind, oper) { + function(oper) { if (oper.node == null) { oper.node = document; } - this.__bind__(name, func_to_bind, oper); + this.__bind__(oper); }; kukit.pl.NativeEventBinder.prototype.__bind__ = - function(name, func_to_bind, oper) { + function(oper, name) { ;;; oper.componentName = 'native event binding'; oper.evaluateParameters([], {'preventdefault': '', 'allowbubbling': '', 'preventbubbling': ''}); oper.evalBool('preventdefault'); oper.evalBool('allowbubbling'); oper.evalBool('preventbubbling'); + // name makes it possible to inherit this method and + // bind it physically to a given browser event + if (typeof(name) == 'undefined') { + // Event name is normally acquired from the oper. + name = oper.getEventName(); + } + // if (oper.parms.preventdefault) { if (name != 'click') { ;;; kukit.E = 'In native events only the click event can have'; @@ -195,8 +202,6 @@ // (in case of allowbubbling we have to apply it to all clicks, as there // might be a link inside that we cannot detect on the current node) // - // XXX not needed since we have the legacy name parameter: - // var name = oper.getEventName(); if (oper.parms.preventdefault && kukit.HAVE_SAFARI && (oper.parms.allowbubbling || name == 'click' && oper.node.tagName.toLowerCase() == 'a')) { @@ -207,7 +212,7 @@ }; kukit.pl.NativeEventBinder.prototype.__bind_key__ = - function(name, func_to_bind, oper) { + function(oper) { ;;; oper.componentName = 'native key event binding'; oper.evaluateParameters([], {'preventdefault': 'true', 'allowbubbling': '', @@ -287,42 +292,42 @@ * Unsupported are those with absolute no hope to work in a cross browser way * Preventdefault is only allowed for click and key events, currently */ -kukit.eventsGlobalRegistry.register(null, 'blur', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'focus', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'resize', kukit.pl.NativeEventBinder, - '__bind__nodeorwindow', null); -kukit.eventsGlobalRegistry.register(null, 'click', kukit.pl.NativeEventBinder, - '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'dblclick', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'mousedown', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mouseup', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mousemove', - kukit.pl.NativeEventBinder, '__bind__nodeordocument', null); -kukit.eventsGlobalRegistry.register(null, 'mouseover', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'mouseout', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'change', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'reset', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'select', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'submit', - kukit.pl.NativeEventBinder, '__bind__node', null); -kukit.eventsGlobalRegistry.register(null, 'keydown', - kukit.pl.NativeEventBinder, '__bind_key__', null); -kukit.eventsGlobalRegistry.register(null, 'keypress', - kukit.pl.NativeEventBinder, '__bind_key__', null); -kukit.eventsGlobalRegistry.register(null, 'keyup', - kukit.pl.NativeEventBinder, '__bind_key__', null); -//kukit.eventsGlobalRegistry.register(null, 'unload', -// kukit.pl.NativeEventBinder, '__bind__window', null); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'blur', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'focus', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'resize', kukit.pl.NativeEventBinder, + '__bind__nodeorwindow', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'click', kukit.pl.NativeEventBinder, + '__bind__nodeordocument', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'dblclick', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'mousedown', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'mouseup', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'mousemove', + kukit.pl.NativeEventBinder, '__bind__nodeordocument', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'mouseover', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'mouseout', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'change', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'reset', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'select', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'submit', + kukit.pl.NativeEventBinder, '__bind__node', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'keydown', + kukit.pl.NativeEventBinder, '__bind_key__', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'keypress', + kukit.pl.NativeEventBinder, '__bind_key__', null, 'Each'); +kukit.eventsGlobalRegistry.registerForAllEvents(null, 'keyup', + kukit.pl.NativeEventBinder, '__bind_key__', null, 'Each'); +//kukit.eventsGlobalRegistry.registerForAllEvents(null, 'unload', +// kukit.pl.NativeEventBinder, '__bind__window', null, 'Each'); /* * class TimeoutEventBinder From reebalazs at codespeak.net Tue Dec 25 12:59:21 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:21 +0100 (CET) Subject: [KSS-checkins] r50088 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115921.31C581684FE@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:20 2007 New Revision: 50088 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Log: Fix a remaining namespace in logging code Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Tue Dec 25 12:59:20 2007 @@ -333,16 +333,13 @@ oper.eventRule.actions.execute(oper); } else { // In case there is no event rule, just call the default event action. - var namespace = this.__eventNamespace__; -;;; var msg = 'Calling implicit event [' + name + '] on namespace ['; -;;; msg += namespace + '].'; +;;; var msg = 'Calling implicit event [' + name + '].'; ;;; kukit.logDebug(msg); var success = oper.executeDefaultAction(name, true); if (! success) { // instead of the standard message give more specific reason: // either way we should have executed something... ;;; kukit.E = 'Could not trigger event name [' + name; -;;; kukit.E += '] on namespace [' + namespace; ;;; kukit.E += '], because there is neither an explicit KSS rule,'; ;;; kukit.E += ' nor a default method'; throw new Error(kukit.E); @@ -605,9 +602,6 @@ rulesPerNode[name] = oper; }; -// XXX This will need refactoring. -/// We would only want to lookup from our registry and not the other way around. -// _OperRegistry.prototype.processBindingEvents = function (binder) { var interfaces = kukit.interfaces.global; From reebalazs at codespeak.net Tue Dec 25 12:59:24 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 12:59:24 +0100 (CET) Subject: [KSS-checkins] r50089 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225115924.1E1CD168506@codespeak.net> Author: reebalazs Date: Tue Dec 25 12:59:23 2007 New Revision: 50089 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Log: Refactor the composition of merge id (composeMergeId) Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Tue Dec 25 12:59:23 2007 @@ -22,6 +22,17 @@ kukit.rd = {}; /* + * Function constructMergeId + * + * Puts together the unique merge id from the (event) nams + * and the bind key. The bind key can have any characters since + * it contains the id. + */ +kukit.rd.constructMergeId = function(name, bindKey) { + return name + '@' + bindKey; +}; + +/* * class KssSelector */ kukit.rd.KssSelector = function(isEvent, css, name, id, ppid, interfaces) { @@ -167,7 +178,7 @@ // Statically set. return this.mergeId; } else { - return this.name + '@' + this.getBindKey(node); + return kukit.rd.constructMergeId(this.name, this.getBindKey(node)); } }; @@ -880,8 +891,7 @@ // // Generate its merge id from the bindkey and event name var bindKey = binder.__bindKey__; - // XXX TODO refactor this with kssSelector - var mergeId = name + '@' + bindKey; + var mergeId = kukit.rd.constructMergeId(name, bindKey); var mergedRule = dict[mergeId]; if (typeof(mergedRule) == 'undefined') { // no error, just return null. From reebalazs at codespeak.net Tue Dec 25 13:01:37 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 13:01:37 +0100 (CET) Subject: [KSS-checkins] r50090 - kukit/kss.core/branch/ree-service-layer-and-refactoring Message-ID: <20071225120137.CDF231684ED@codespeak.net> Author: reebalazs Date: Tue Dec 25 13:01:37 2007 New Revision: 50090 Added: kukit/kss.core/branch/ree-service-layer-and-refactoring/ - copied from r50089, kukit/kss.core/trunk/ Log: Branch off From reebalazs at codespeak.net Tue Dec 25 13:06:18 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 13:06:18 +0100 (CET) Subject: [KSS-checkins] r50091 - in kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core: . docs plugins/core/demo Message-ID: <20071225120618.AE4471684D1@codespeak.net> Author: reebalazs Date: Tue Dec 25 13:06:18 2007 New Revision: 50091 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/ (props changed) kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/EXTERNALS.TXT kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/docs/HISTORY.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js Log: Adjust resources for new javascript sources Necessary changes in more_selectors demo (eachlegacy -> each iterator) Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/EXTERNALS.TXT (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/EXTERNALS.TXT Tue Dec 25 13:06:18 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/trunk/ +kukit http://codespeak.net/svn/kukit/kukit.js/branch/ree-service-layer-and-refactoring Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml Tue Dec 25 13:06:18 2007 @@ -27,6 +27,7 @@ files=" kukit/kukit/kukit.js kukit/kukit/utils.js + kukit/kukit/interfaces.js kukit/kukit/errors.js kukit/kukit/oper.js kukit/kukit/tokenizer.js @@ -42,6 +43,7 @@ kukit/kukit/commandprocessor.js kukit/kukit/selectorreg.js kukit/kukit/forms.js + kukit/kukit/service.js kukit/kukit/plugin.js" name="kukit.js" compress_level="safe" @@ -52,6 +54,7 @@ files=" kukit/kukit/kukit.js kukit/kukit/utils.js + kukit/kukit/interfaces.js kukit/kukit/errors.js kukit/kukit/oper.js kukit/kukit/tokenizer.js @@ -67,6 +70,7 @@ kukit/kukit/commandprocessor.js kukit/kukit/selectorreg.js kukit/kukit/forms.js + kukit/kukit/service.js kukit/kukit/plugin.js" name="kukit-devel.js" compress_level="devel" @@ -78,6 +82,7 @@ Author: reebalazs Date: Tue Dec 25 13:13:51 2007 New Revision: 50092 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt Log: Add history entries Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt Tue Dec 25 13:13:51 2007 @@ -6,6 +6,33 @@ - ... + - Add service layers. Refactor plugin binding. + + Refactor event binding and registries. + + refactor processBindingEvents to make it iterate + on the binding sequence in a more efficient way. + + Eliminate namespaces from refactored code. + From this point fully namespaced names must be + used and supposed everywhere. This may need some + plugin code upgraded but only those that use + unpublished internals. + (Fully namespaced event names are needed in + __continueEvent__, __continueAllEvents__ methods.) + Exception from this are the "soon to be legacy" + globalEventRegistry.register and registerForAllEvents + methods which keeps namespace and name. + + Convert core plugins to use Each bind iterator instead of + EachLegacy. Since these plugins called makeExecuteActionsHook + themselves, it resulted in double calling each time, + since the EachLegacy iterator needed to prefetch them. + This may break third party plugin code that reuses unpublished + internals from plugins.js. (Most particularly, the more_selectors + demo needed to be updated as well.) + [ree] + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) From gotcha at codespeak.net Tue Dec 25 15:36:05 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 15:36:05 +0100 (CET) Subject: [KSS-checkins] r50093 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071225143605.E158F16844A@codespeak.net> Author: gotcha Date: Tue Dec 25 15:36:04 2007 New Revision: 50093 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Tue Dec 25 15:36:04 2007 @@ -1,5 +1,4 @@ files where indentation has to be undone and initialize needs to be done -eventreg.js kssparser.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Tue Dec 25 15:36:04 2007 @@ -40,202 +40,205 @@ * implements the binder. * */ -var _EventRegistry = function () { +var _EventRegistry = function() { + +this.initialize = function() { this.content = {}; this.classes = {}; this.eventSets = []; +}; /* binder registration */ - this.registerBinder = function(className, klass) { - if (typeof(klass) == 'undefined') { -;;; kukit.E = 'klass argument is mandatory when registering an event'; -;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; - throw new Error(kukit.E); - } - if (this.classes[className]) { - // Do not allow redefinition -;;; var msg = 'Error : event class [' + className + '] already registered.'; -;;; kukit.logError(msg); - return; - - } - klass.prototype = new _EventBinder(); - klass.prototype.__className__ = className; - var newKlass = function() {}; - newKlass.prototype = new klass(); - this.classes[className] = newKlass; - }; - - this.existsBinder = function(className) { - var klass = this.classes[className]; - return (typeof(klass) != 'undefined'); - }; - - this.getBinderClass = function(className) { - var klass = this.classes[className]; - if (! klass) { - // not found -;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; - throw new Error(kukit.E); - } - return klass; - }; - - /* events (methods) registration helpers (not to be called directly) */ - - this._register = function(namespace, eventName, klass, - bindMethodName, defaultActionMethodName, iterName) { - if (typeof(defaultActionMethodName) == 'undefined') { -;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // Find out the class name. (Not specified now.) - var className = klass.prototype.__className__; - if (typeof(className) == 'undefined') { - // Create a className, and register it too. - className = '' + _eventClassCounter; - _eventClassCounter += 1; - this.registerBinder(className, klass); - } - var binderKlass = this.getBinderClass(className); - if (!eventName) { -;;; kukit.E = '[eventName] argument cannot be empty when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - if (typeof(entry) != 'undefined') { - if (key[0] == '-') { - key = key.substring(1); - } -;;; kukit.E = 'Attempt to register key [' + key; -;;; kukit.E += '] twice when registering'; -;;; kukit.E += ' an event with [_EventRegistry.register].'; - throw new Error(kukit.E); - } - // check bindMethodName and defaultActionMethodName - if (bindMethodName && ! binderKlass.prototype[bindMethodName]) { -;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; -;;; kukit.E += '] is undefined for event [' + eventName; -;;; kukit.E += '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - if (defaultActionMethodName && ! binderKlass.prototype[defaultActionMethodName]) { -;;; kukit.E = 'In _EventRegistry.register default action method ['; -;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; -;;; kukit.E += eventName + '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - // check the iterator. - if (! er.getBindIterator(iterName)) { -;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; -;;; kukit.E += iterName + '].'; - throw new Error(kukit.E); - } - // register it - this.content[key] = { - 'className': className, - 'bindMethodName': bindMethodName, - 'defaultActionMethodName': defaultActionMethodName, - 'iterName': iterName - }; - }; - - /* events (methods) binding [ForAll] registration */ - - this._registerEventSet = - function(namespace, names, iterName, bindMethodName) { - // At this name the values should be checked already. so this should - // be called _after_ _register. - this.eventSets.push({ - 'namespace': namespace, - 'names': names, - 'iterName': iterName, - 'bindMethodName': bindMethodName - }); - }; - - /* there are the actual registration methods, to be called from plugins */ - - this.register = - function(namespace, eventName, klass, bindMethodName, - defaultActionMethodName) { - this._register(namespace, eventName, klass, bindMethodName, - defaultActionMethodName, 'EachLegacy'); - this._registerEventSet(namespace, [eventName], 'EachLegacy', - bindMethodName); - }; - - this.unregister = - function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - delete this.content[key]; - var found = null; - for (var i=0; i < this.eventSets.length; i++) { - var eventSet = this.eventSets[i]; - if (eventSet['namespace'] == namespace) { - found = i; - break; - } - } - if (found != null) { - this.eventSets.splice(found, 1); +this.registerBinder = function(className, klass) { + if (typeof(klass) == 'undefined') { +;;; kukit.E = 'klass argument is mandatory when registering an event'; +;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; + throw new Error(kukit.E); + } + if (this.classes[className]) { + // Do not allow redefinition +;;; var msg = 'Error : event class [' + className + '] already registered.'; +;;; kukit.logError(msg); + return; + + } + klass.prototype = new _EventBinder(); + klass.prototype.__className__ = className; + var newKlass = function() {}; + newKlass.prototype = new klass(); + this.classes[className] = newKlass; +}; + +this.existsBinder = function(className) { + var klass = this.classes[className]; + return (typeof(klass) != 'undefined'); +}; + +this.getBinderClass = function(className) { + var klass = this.classes[className]; + if (! klass) { + // not found +;;; kukit.E = 'Error : undefined event setup type [' + className + '].'; + throw new Error(kukit.E); } - }; + return klass; +}; - this.registerForAllEvents = - function(namespace, eventNames, klass, - bindMethodName, defaultActionMethodName, iterName) { - if (typeof(eventNames) == 'string') { - eventNames = [eventNames]; - } - for (var i=0; i 1) { -;;; kukit.E = 'In [_EventRegistry.register], [namespace] cannot have'; -;;; kukit.E += 'dashes.'; - throw new Error(kukit.E); +this._register = function(namespace, eventName, klass, + bindMethodName, defaultActionMethodName, iterName) { + if (typeof(defaultActionMethodName) == 'undefined') { +;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; + throw new Error(kukit.E); + } + // Find out the class name. (Not specified now.) + var className = klass.prototype.__className__; + if (typeof(className) == 'undefined') { + // Create a className, and register it too. + className = '' + _eventClassCounter; + _eventClassCounter += 1; + this.registerBinder(className, klass); + } + var binderKlass = this.getBinderClass(className); + if (!eventName) { +;;; kukit.E = '[eventName] argument cannot be empty when registering'; +;;; kukit.E += ' an event with [_EventRegistry.register].'; + throw new Error(kukit.E); + } + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + if (typeof(entry) != 'undefined') { + if (key[0] == '-') { + key = key.substring(1); + } +;;; kukit.E = 'Attempt to register key [' + key; +;;; kukit.E += '] twice when registering'; +;;; kukit.E += ' an event with [_EventRegistry.register].'; + throw new Error(kukit.E); + } + // check bindMethodName and defaultActionMethodName + if (bindMethodName && ! binderKlass.prototype[bindMethodName]) { +;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; +;;; kukit.E += '] is undefined for event [' + eventName; +;;; kukit.E += '] namespace [' + namespace + '].'; + throw new Error(kukit.E); + } + if (defaultActionMethodName && ! binderKlass.prototype[defaultActionMethodName]) { +;;; kukit.E = 'In _EventRegistry.register default action method ['; +;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; +;;; kukit.E += eventName + '] namespace [' + namespace + '].'; + throw new Error(kukit.E); + } + // check the iterator. + if (! er.getBindIterator(iterName)) { +;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; +;;; kukit.E += iterName + '].'; + throw new Error(kukit.E); + } + // register it + this.content[key] = { + 'className': className, + 'bindMethodName': bindMethodName, + 'defaultActionMethodName': defaultActionMethodName, + 'iterName': iterName + }; +}; + +/* events (methods) binding [ForAll] registration */ + +this._registerEventSet = + function(namespace, names, iterName, bindMethodName) { + // At this name the values should be checked already. so this should + // be called _after_ _register. + this.eventSets.push({ + 'namespace': namespace, + 'names': names, + 'iterName': iterName, + 'bindMethodName': bindMethodName + }); +}; + +/* there are the actual registration methods, to be called from plugins */ + +this.register = + function(namespace, eventName, klass, bindMethodName, + defaultActionMethodName) { + this._register(namespace, eventName, klass, bindMethodName, + defaultActionMethodName, 'EachLegacy'); + this._registerEventSet(namespace, [eventName], 'EachLegacy', + bindMethodName); +}; + +this.unregister = + function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + delete this.content[key]; + var found = null; + for (var i=0; i < this.eventSets.length; i++) { + var eventSet = this.eventSets[i]; + if (eventSet['namespace'] == namespace) { + found = i; + break; } - return namespace + '-' + eventName; - }; + } + if (found != null) { + this.eventSets.splice(found, 1); + } +}; - this.exists = function(namespace, eventName) { - var key = this._getKey(namespace, eventName); - var entry = this.content[key]; - return (typeof(entry) != 'undefined'); - }; +this.registerForAllEvents = + function(namespace, eventNames, klass, + bindMethodName, defaultActionMethodName, iterName) { + if (typeof(eventNames) == 'string') { + eventNames = [eventNames]; + } + for (var i=0; i 1) { +;;; kukit.E = 'In [_EventRegistry.register], [namespace] cannot have'; +;;; kukit.E += 'dashes.'; + throw new Error(kukit.E); + } + return namespace + '-' + eventName; +}; - this.getBinderClassByEventNamespace = function(namespace, eventName) { - return this.getBinderClass(this.get(namespace, eventName).className); - }; +this.exists = function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + return (typeof(entry) != 'undefined'); +}; + +this.get = function(namespace, eventName) { + var key = this._getKey(namespace, eventName); + var entry = this.content[key]; + if (typeof(entry) == 'undefined') { +;;; if (key.substr(0, 1) == '-') { +;;; key = key.substring(1); +;;; kukit.E = 'Error : undefined global event ['; +;;; kukit.E += key + '] (or maybe namespace is missing ?).'; +;;; } else { +;;; kukit.E = 'Error : undefined namespace or event in [' + key + '].'; +;;; } + throw new Error(kukit.E); + } + return entry; +}; +this.getBinderClassByEventNamespace = function(namespace, eventName) { + return this.getBinderClass(this.get(namespace, eventName).className); +}; +this.initialize.apply(this, arguments); }; @@ -262,51 +265,49 @@ * postpone binding of actions until called first time * */ -var _LateBinder = function(binder, name, node) { +var _LateBinder = function() { + +this.initialize = function(binder, name, node) { this.binder = binder; this.name = name; this.node = node; this.boundEvent = null; +}; - this.executeActions = function() { - if (! this.boundEvent) { -;;; var msg = 'Attempt of late binding for event [' + this.name; -;;; msg += '], node [' + this.node.nodeName + '].'; -;;; kukit.log(msg); - if (kukit.hasFirebug) { - kukit.log(this.node); - } - var info = kukit.engine.binderInfoRegistry.getBinderInfoById( - this.binder.__binderId__); - var oper = info.bound.getBoundOperForNode(this.name, this.node); - if (oper) { - // (if eventRule is null here, we could still have the default - // method, so go on.) - oper.parms = {}; - this.boundEvent = function() { - this.binder.triggerEvent(this.name, oper); - }; -;;; kukit.log('Node bound.'); - } else { -;;; kukit.logWarning('No node bound.'); - this.boundEvent = function() {}; - } +this.executeActions = function() { + if (! this.boundEvent) { +;;; var msg = 'Attempt of late binding for event [' + this.name; +;;; msg += '], node [' + this.node.nodeName + '].'; +;;; kukit.log(msg); + if (kukit.hasFirebug) { + kukit.log(this.node); } - this.boundEvent(); - }; + var info = kukit.engine.binderInfoRegistry.getBinderInfoById( + this.binder.__binderId__); + var oper = info.bound.getBoundOperForNode(this.name, this.node); + if (oper) { + // (if eventRule is null here, we could still have the default + // method, so go on.) + oper.parms = {}; + this.boundEvent = function() { + this.binder.triggerEvent(this.name, oper); + }; +;;; kukit.log('Node bound.'); + } else { +;;; kukit.logWarning('No node bound.'); + this.boundEvent = function() {}; + } + } + this.boundEvent(); +}; +this.initialize.apply(this, arguments); }; /* * -* class EventBinder -* -* poor man's subclassing -* This is called automatically on registration, to dress -* up the event class with the necessary methods +* class _EventBinder * -*/ - -/* Provide callins on the state instance that execute a given +* Provide callins on the state instance that execute a given * continuation event. * Parameters will be the ones specified in the call + * those defined in the rule will be added too. (Parameters can @@ -420,7 +421,7 @@ ;;; var msg = 'Deprecated [__continueEvent__],'; ;;; msg += 'use [continueEvent] instead !'; ;;; kukit.logWarning(msg); -this.continueEvent(name, node, defaultParameters); + this.continueEvent(name, node, defaultParameters); }; this.continueEventAllNodes = function(name, defaultParameters) { @@ -452,7 +453,7 @@ ;;; var msg = 'Deprecated [__continueEvent_allNodes__],'; ;;; msg += 'use [continueEventAllNodes] instead !'; ;;; kukit.logWarning(msg); -this.continueEventAllNodes(name, defaultParameters); + this.continueEventAllNodes(name, defaultParameters); }; this.makeFuncToBind = function(name, node) { @@ -466,11 +467,11 @@ ;;; var msg = 'Deprecated [__makeFuncToBind__],'; ;;; msg += 'use [makeFuncToBind] instead !'; ;;; kukit.logWarning(msg); -this.makeFuncToBind(name, node); + this.makeFuncToBind(name, node); }; this.triggerEvent = function(name, oper) { - // Private. Called from __continueEvent__ or from main event execution. + // Private. Called from continueEvent or from main event execution. oper.binder = this; if (oper.eventRule) { // Call the actions, if we had an event rule. @@ -499,7 +500,7 @@ ;;; var msg = 'Deprecated [_EventBinder_triggerEvent],'; ;;; msg += 'use [triggerEvent] instead !'; ;;; kukit.logWarning(msg); -this.triggerEvent(name, oper); + this.triggerEvent(name, oper); }; /* (default) method call handling */ @@ -523,10 +524,11 @@ ;;; var msg = 'Deprecated [_EventBinder_callMethod],'; ;;; msg += 'use [callMethod] instead !'; ;;; kukit.logWarning(msg); -this.callMethod(namespace, name, oper, methodName); + this.callMethod(namespace, name, oper, methodName); }; }; + /* Event instance registry * * class BinderInfoRegistry @@ -534,85 +536,88 @@ * used in run-time to keep track of the event instances * */ +er.BinderInfoRegistry = function() { -er.BinderInfoRegistry = function () { +this.initialize = function() { this.info = {}; +}; - this.getOrCreateBinderInfo = - function (id, className, namespace) { - // Get or create the event. - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { - // Create a new event. -;;; var msg = 'Instantiating event id [' + id + '], className ['; -;;; msg += className + '], namespace [' + namespace + '].'; -;;; kukit.logDebug(msg); - var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); - var binder = new binderClass(); - - binderInfo = this.info[id] = new _BinderInfo(binder); - - // decorate it with id and class - binder.__binderId__ = id; - binder.__binderClassName__ = className; - binder.__eventNamespace__ = namespace; - // store the bound rules - //binder.__bound_rules__ = []; - } else if (binderInfo.getBinder().__binderClassName__ != - className) { - // just paranoia -;;; kukit.E = 'Conflicting class for event id [' + id + '], ['; -;;; kukit.E += binderInfo.getBinder().__binderClassName__; -;;; kukit.E += '] != [' + className + '].'; - throw new Error(kukit.E); - } - return binderInfo; - }; +this.getOrCreateBinderInfo = + function (id, className, namespace) { + // Get or create the event. + var binderInfo = this.info[id]; + if (typeof(binderInfo) == 'undefined') { + // Create a new event. +;;; var msg = 'Instantiating event id [' + id + '], className ['; +;;; msg += className + '], namespace [' + namespace + '].'; +;;; kukit.logDebug(msg); + var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className); + var binder = new binderClass(); + + binderInfo = this.info[id] = new _BinderInfo(binder); - this.getBinderInfoById = function (id) { - // Get an event. - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { -;;; kukit.E = 'Event with id [' + id + '] not found.'; - throw new Error(kukit.E); - } - return binderInfo; - }; + // decorate it with id and class + binder.__binderId__ = id; + binder.__binderClassName__ = className; + binder.__eventNamespace__ = namespace; + // store the bound rules + //binder.__bound_rules__ = []; + } else if (binderInfo.getBinder().__binderClassName__ != + className) { + // just paranoia +;;; kukit.E = 'Conflicting class for event id [' + id + '], ['; +;;; kukit.E += binderInfo.getBinder().__binderClassName__; +;;; kukit.E += '] != [' + className + '].'; + throw new Error(kukit.E); + } + return binderInfo; +}; - this.getSingletonBinderInfoByName = - function (namespace, name) { - //Get className - var className = kukit.eventsGlobalRegistry.get(namespace, name).className; - // Get an event. - var id = er.makeId(namespace, className); - var binderInfo = this.info[id]; - if (typeof(binderInfo) == 'undefined') { -;;; kukit.E = 'Singleton event with namespace [' + namespace; -;;; kukit.E += '] and (event) name [' + name + '] not found.'; - throw new Error(kukit.E); - } - return binderInfo; - }; +this.getBinderInfoById = function (id) { + // Get an event. + var binderInfo = this.info[id]; + if (typeof(binderInfo) == 'undefined') { +;;; kukit.E = 'Event with id [' + id + '] not found.'; + throw new Error(kukit.E); + } + return binderInfo; +}; - this.startBindingPhase = function () { - // At the end of the binding phase, we want to process our events. This - // must include all the binder instances we bound in this phase. - for (var id in this.info) { - var binderInfo = this.info[id]; - // process binding on this instance. - binderInfo.startBindingPhase(); - } - }; +this.getSingletonBinderInfoByName = + function (namespace, name) { + //Get className + var className = kukit.eventsGlobalRegistry.get(namespace, name).className; + // Get an event. + var id = er.makeId(namespace, className); + var binderInfo = this.info[id]; + if (typeof(binderInfo) == 'undefined') { +;;; kukit.E = 'Singleton event with namespace [' + namespace; +;;; kukit.E += '] and (event) name [' + name + '] not found.'; + throw new Error(kukit.E); + } + return binderInfo; +}; - this.processBindingEvents = function () { - // At the end of the binding phase, we want to process our events. This - // must include all the binder instances we bound in this phase. - for (var id in this.info) { - var binderInfo = this.info[id]; - // process binding on this instance. - binderInfo.processBindingEvents(); - } - }; +this.startBindingPhase = function () { + // At the end of the binding phase, we want to process our events. This + // must include all the binder instances we bound in this phase. + for (var id in this.info) { + var binderInfo = this.info[id]; + // process binding on this instance. + binderInfo.startBindingPhase(); + } +}; + +this.processBindingEvents = function () { + // At the end of the binding phase, we want to process our events. This + // must include all the binder instances we bound in this phase. + for (var id in this.info) { + var binderInfo = this.info[id]; + // process binding on this instance. + binderInfo.processBindingEvents(); + } +}; +this.initialize.apply(this, arguments); }; /* @@ -622,43 +627,45 @@ * various binding info. Follows the workflow of the binding in different stages. * */ +var _BinderInfo = function() { -var _BinderInfo = function (binder) { +this.initialize = function(binder) { this.binder = binder; this.bound = new _OperRegistry(); + this.startBindingPhase(); +}; - this.getBinder = function () { - return this.binder; - }; - - this.startBindingPhase = function () { - // The binding phase starts and it has the information for - // the currently on-bound events. - this.binding = new _OperRegistry(); - }; - - this.bindOper = function (oper) { - // We mark a given oper. This means a binding on the binder - // for given event, node and eventRule (containing event namespace, - // name, and evt- parms.) - // - // first see if it can go to already bound ones - this.bound.checkOperBindable(oper); - // then register it properly to the binding events - this.binding.bindOper(oper); - }; +this.getBinder = function () { + return this.binder; +}; - this.processBindingEvents = function () { - // We came to the end of the binding phase. Now we process all our binding - // events, This will do the actual binding on the browser side. - this.binding.processBindingEvents(this.binder); - // Now we to add these to the new ones. - this.binding.propagateTo(this.bound); - // Delete them from the registry, to protect against accidents. - this.binding = null; - }; +this.startBindingPhase = function () { + // The binding phase starts and it has the information for + // the currently on-bound events. + this.binding = new _OperRegistry(); +}; - this.startBindingPhase(); +this.bindOper = function (oper) { + // We mark a given oper. This means a binding on the binder + // for given event, node and eventRule (containing event namespace, + // name, and evt- parms.) + // + // first see if it can go to already bound ones + this.bound.checkOperBindable(oper); + // then register it properly to the binding events + this.binding.bindOper(oper); +}; + +this.processBindingEvents = function () { + // We came to the end of the binding phase. Now we process all our binding + // events, This will do the actual binding on the browser side. + this.binding.processBindingEvents(this.binder); + // Now we to add these to the new ones. + this.binding.propagateTo(this.bound); + // Delete them from the registry, to protect against accidents. + this.binding = null; +}; +this.initialize.apply(this, arguments); }; var _iterators = {}; @@ -817,134 +824,135 @@ * a given event setup phase. * */ -var _OperRegistry = function () { +var _OperRegistry = function() { + +this.initialize = function() { this.infoPerName = {}; this.infoPerNode = {}; +}; - // XXX we can do this without full cloning, more efficiently. - this.propagateTo = function (newreg) { - for (var key in this.infoPerName) { - var rulesPerName = this.infoPerName[key]; - for (var name in rulesPerName) { - var oper = rulesPerName[name]; - newreg.bindOper(oper); - } +// XXX we can do this without full cloning, more efficiently. +this.propagateTo = function (newreg) { + for (var key in this.infoPerName) { + var rulesPerName = this.infoPerName[key]; + for (var name in rulesPerName) { + var oper = rulesPerName[name]; + newreg.bindOper(oper); } - }; + } +}; - this.checkOperBindable = - function (oper, name, nodeHash) { - // Check if the binding with this oper could be done. - // Throw exception otherwise. - // - // Remark. We need different check and bind method, - // because we need to bind to the currently - // processed nodes, but we need to check duplication - // in all the previously bound nodes. - var info = this.infoPerName; - // name and nodeHash are for speedup. - if (typeof(nodeHash) == 'undefined') { - name = oper.eventRule.kssSelector.name; - nodeHash = kukit.rd.hashNode(oper.node); - } - var rulesPerName = info[name]; - if (typeof(rulesPerName) == 'undefined') { - // Create an empty list. - rulesPerName = info[name] = {}; - } else if (typeof(rulesPerName[nodeHash]) != 'undefined') { -;;; kukit.E = 'Mismatch in bind registry,[ ' + name; -;;; kukit.E += '] already bound to node in this instance.'; - throw new Error(kukit.E); - } - return rulesPerName; - }; - - this.bindOper = function (oper) { - // Marks binding between binder, eventName, node. - var name = oper.eventRule.kssSelector.name; - var nodeHash = kukit.rd.hashNode(oper.node); - var rulesPerName = this.checkOperBindable(oper, name, nodeHash); - rulesPerName[nodeHash] = oper; - // also store per node info - var rulesPerNode = this.infoPerNode[nodeHash]; - if (typeof(rulesPerNode) == 'undefined') { - // Create an empty list. - rulesPerNode = this.infoPerNode[nodeHash] = {}; - } - rulesPerNode[name] = oper; - }; +this.checkOperBindable = + function (oper, name, nodeHash) { + // Check if the binding with this oper could be done. + // Throw exception otherwise. + // + // Remark. We need different check and bind method, + // because we need to bind to the currently + // processed nodes, but we need to check duplication + // in all the previously bound nodes. + var info = this.infoPerName; + // name and nodeHash are for speedup. + if (typeof(nodeHash) == 'undefined') { + name = oper.eventRule.kssSelector.name; + nodeHash = kukit.rd.hashNode(oper.node); + } + var rulesPerName = info[name]; + if (typeof(rulesPerName) == 'undefined') { + // Create an empty list. + rulesPerName = info[name] = {}; + } else if (typeof(rulesPerName[nodeHash]) != 'undefined') { +;;; kukit.E = 'Mismatch in bind registry,[ ' + name; +;;; kukit.E += '] already bound to node in this instance.'; + throw new Error(kukit.E); + } + return rulesPerName; +}; + +this.bindOper = function (oper) { + // Marks binding between binder, eventName, node. + var name = oper.eventRule.kssSelector.name; + var nodeHash = kukit.rd.hashNode(oper.node); + var rulesPerName = this.checkOperBindable(oper, name, nodeHash); + rulesPerName[nodeHash] = oper; + // also store per node info + var rulesPerNode = this.infoPerNode[nodeHash]; + if (typeof(rulesPerNode) == 'undefined') { + // Create an empty list. + rulesPerNode = this.infoPerNode[nodeHash] = {}; + } + rulesPerNode[name] = oper; +}; - // XXX This will need refactoring. - /// We would only want to lookup from our registry and not the other way around. - this.processBindingEvents = - function (binder) { - var eventRegistry = kukit.eventsGlobalRegistry; - for (var i=0; i < eventRegistry.eventSets.length; i++) { - var eventSet = eventRegistry.eventSets[i]; - // Only process binding events (and ignore non-binding ones) - if (eventSet.bindMethodName) { - if (binder.__eventNamespace__ == eventSet.namespace) { - // Process the binding event set. - // This will call the actual bindmethods - // according to the specified iterator. - var iterator = er.getBindIterator(eventSet.iterName); - iterator.call(this, eventSet, binder); - } +// XXX This will need refactoring. +/// We would only want to lookup from our registry and not the other way around. +this.processBindingEvents = + function (binder) { + var eventRegistry = kukit.eventsGlobalRegistry; + for (var i=0; i < eventRegistry.eventSets.length; i++) { + var eventSet = eventRegistry.eventSets[i]; + // Only process binding events (and ignore non-binding ones) + if (eventSet.bindMethodName) { + if (binder.__eventNamespace__ == eventSet.namespace) { + // Process the binding event set. + // This will call the actual bindmethods + // according to the specified iterator. + var iterator = er.getBindIterator(eventSet.iterName); + iterator.call(this, eventSet, binder); } } - }; + } +}; - // XXX The following methods will probably disappear as iterators - // replace their functionality. +// XXX The following methods will probably disappear as iterators +// replace their functionality. - this.getBoundOperForNode = function (name, node) { - // Get the oper that is bound to a given eventName - // to a node in this binder - // returns null, if there is no such oper. - var rulesPerName = this.infoPerName[name]; - if (typeof(rulesPerName) == 'undefined') { - return null; - } - var nodeHash = kukit.rd.hashNode(node); - var oper = rulesPerName[nodeHash]; - if (typeof(oper) == 'undefined') { - return null; - } - // Return it - return oper; - }; +this.getBoundOperForNode = function (name, node) { + // Get the oper that is bound to a given eventName + // to a node in this binder + // returns null, if there is no such oper. + var rulesPerName = this.infoPerName[name]; + if (typeof(rulesPerName) == 'undefined') { + return null; + } + var nodeHash = kukit.rd.hashNode(node); + var oper = rulesPerName[nodeHash]; + if (typeof(oper) == 'undefined') { + return null; + } + // Return it + return oper; +}; - this.getBoundOpers = function (name) { - // Get the opers bound to a given eventName (to any node) - // in this binder - var opers = []; - var rulesPerName = this.infoPerName[name]; - if (typeof(rulesPerName) != 'undefined') { - // take the values as a list - for (var nodeHash in rulesPerName) { - opers.push(rulesPerName[nodeHash]); - } +this.getBoundOpers = function (name) { + // Get the opers bound to a given eventName (to any node) + // in this binder + var opers = []; + var rulesPerName = this.infoPerName[name]; + if (typeof(rulesPerName) != 'undefined') { + // take the values as a list + for (var nodeHash in rulesPerName) { + opers.push(rulesPerName[nodeHash]); } - // Return it - return opers; - }; - - - this.callBindMethod = - function (eventSet, binder, p1, p2, p3, p4, p5, p6) { - var method = binder[eventSet.bindMethodName]; - // Protect the binding for better logging -;;; try { - method.call(binder, p1, p2, p3, p4, p5, p6); -;;; } catch(e) { -;;; var names = eventSet.names; -;;; var namespace = eventSet.namespace; -;;; kukit.E = kukit.err.eventBindError(e, names, namespace); -;;; throw new Error(kukit.E); -;;; } - }; - + } + // Return it + return opers; +}; +this.callBindMethod = + function (eventSet, binder, p1, p2, p3, p4, p5, p6) { + var method = binder[eventSet.bindMethodName]; + // Protect the binding for better logging +;;; try { + method.call(binder, p1, p2, p3, p4, p5, p6); +;;; } catch(e) { +;;; var names = eventSet.names; +;;; var namespace = eventSet.namespace; +;;; kukit.E = kukit.err.eventBindError(e, names, namespace); +;;; throw new Error(kukit.E); +;;; } +}; +this.initialize.apply(this, arguments); }; er.makeId = function(namespace, name) { From gotcha at codespeak.net Tue Dec 25 16:28:51 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 16:28:51 +0100 (CET) Subject: [KSS-checkins] r50094 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071225152851.C20951684DA@codespeak.net> Author: gotcha Date: Tue Dec 25 16:28:49 2007 New Revision: 50094 Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Log: unindent and initialize Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original) +++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Tue Dec 25 16:28:49 2007 @@ -1,4 +1,3 @@ files where indentation has to be undone and initialize needs to be done -kssparser.js tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Tue Dec 25 16:28:49 2007 @@ -47,33 +47,34 @@ * class Document */ var _Document = function() { - this.process = function() { - this.eventRules = []; - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - while (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - var key = context.txt; - if (! key) { - break; - } - this.expectToken(context, kukit.kssp.Block); - var block = context.token; - var rules = block.parseSelectors(key); - this.addRules(rules); - } - this.result = []; - this.txt = ''; - }; - this.addRules = function(rules) { - // Create the event rules. - for(var i=0; i-: - // evt---: -;;; if (splitkey.length < 3) { -;;; kukit.E = 'Wrong rule key : "' + key + '". '; -;;; kukit.E += 'KSS rule key must be "-"'; -;;; kukit.E += ' or "--" or '; -;;; kukit.E += '"evt--" or '; -;;; kukit.E += '"evt---".'; -;;; this.emitError(kukit.E); -;;; } - var eventNamespace; - var eventName; - var eventKey; - var eventFullName; - if (splitkey.length == 3) { - // evt--: - eventName = splitkey[1]; - eventKey = splitkey[2]; - eventFullName = eventName; - } else { - // evt---: - eventNamespace = splitkey[1]; - eventName = splitkey[2]; - eventKey = splitkey[3]; - eventFullName = eventNamespace + '-' + eventName; - } -;;; if (value.isMethod != false) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed as value for '; -;;; kukit.E += 'evt-[-]- keys.'; -;;; this.emitError(kukit.E); -;;; } - var eventParameters = this.eventFullNames[eventFullName]; - if (typeof(eventParameters) == 'undefined') { - this.eventFullNames[eventFullName] = {}; - eventParameters = this.eventFullNames[eventFullName]; - } - eventParameters[eventKey] = value.txt; - }; - - this.addActionDeclaration = function(key, splitkey, value) { - // action-server: - // action-client: - // action-client: - - // action-cancel: - // action-cancel: - -;;; if (splitkey.length != 2) { -;;; kukit.E = 'Wrong key [' + key + '] : '; -;;; kukit.E += 'action- keys can have only one dash.'; -;;; this.emitError(kukit.E); -;;; } -;;; if (value.isMethod != false) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed for action- keys.'; -;;; this.emitError(kukit.E); -;;; } - var atab = {'server': 'S', 'client': 'C', 'cancel': 'X'}; - var actionType = atab[splitkey[1]]; -;;; if (! actionType) { -;;; kukit.E = 'Wrong key [' + key + '] : '; -;;; kukit.E += 'qualifier in action- keys must be '; -;;; kukit.E += '"server" or "client" or "cancel".'; -;;; this.emitError(kukit.E); -;;; } -;;; // force value to be or - -;;; var splitvalue = value.txt.split('-'); -;;; if (splitvalue.length > 2) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value must be or '; -;;; kukit.E += '- for action- keys.'; -;;; this.emitError(kukit.E); -;;; } - // set it - var action = this.actions.getOrCreateAction(value.txt); - if (actionType != 'X' || action.type == null) { - action.setType(actionType); - } else { - this.actions.deleteAction(value.txt); - } - }; - - this.addActionError = function(action, key, value) { - // -error: - // default-error: -;;; if (value.isMethod == true) { -;;; kukit.E = 'Wrong value for key [' + key + '] : '; -;;; kukit.E += 'value providers are not '; -;;; kukit.E += 'allowed for -error keys.'; -;;; this.emitError(kukit.E); -;;; } - action.setError(value.txt); - // also create the action for the error itself. - var err_action = this.actions.getOrCreateAction(value.txt); - err_action.setType('E'); - }; - - this.addActionParameter = function(action, key, value) { - var ppRegistries = { - '': kukit.pprovidersGlobalRegistry, - 'kssSelector': kukit.sr.pproviderSelRegistry, - 'kssSubmitForm': kukit.fo.pproviderFormRegistry - }; - - // -: - // default-: - // - // value may be either txt or method parms, - // and they get stored with the wrapper. - // - // Check the syntax of the value at this point. - // This will also set the value providers on the value - // (from check). - // - // Figure out which registry to use. - var registry = ppRegistries[key]; - if (typeof(registry) == 'undefined') { - // use default pproviders - registry = ppRegistries['']; - } - // - try { - // Check also sets the value provider on the value. - value.check(registry); - } catch(e) { -;;; kukit.E = 'Error in value : ' + e + '.'; + if (! found){ +;;; kukit.E = 'Wrong value for evt-[-] [' + eventFullName + '] : '; +;;; kukit.E += '- should exist in the event of the selectors.'; this.emitError(kukit.E); } - action.parms[key] = value; - }; - - this.addDeclaration = function(key, value) { - // p.s. value is here a KssXxParm. In most cases we check and unwrap it. - // the keys look like this: - // - // evt--: - // evt---: - // - // action-server: - // action-client: - // action-client: - - // action-cancel: - // action-cancel: - - // + } + if (! hasFullNames){ + for(var i=0; i< parser.selectors.length; ++i) { + var kssSelector = parser.selectors[i]; + eventRule = new kukit.rd.EventRule(kssSelector, + {}, this.actions); + results.push(eventRule); + } + } + return results; +}; + +this.addEventDeclaration = function(key, splitkey, value) { + + // evt--: + // evt---: +;;; if (splitkey.length < 3) { +;;; kukit.E = 'Wrong rule key : "' + key + '". '; +;;; kukit.E += 'KSS rule key must be "-"'; +;;; kukit.E += ' or "--" or '; +;;; kukit.E += '"evt--" or '; +;;; kukit.E += '"evt---".'; +;;; this.emitError(kukit.E); +;;; } + var eventNamespace; + var eventName; + var eventKey; + var eventFullName; + if (splitkey.length == 3) { + // evt--: + eventName = splitkey[1]; + eventKey = splitkey[2]; + eventFullName = eventName; + } else { + // evt---: + eventNamespace = splitkey[1]; + eventName = splitkey[2]; + eventKey = splitkey[3]; + eventFullName = eventNamespace + '-' + eventName; + } +;;; if (value.isMethod != false) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed as value for '; +;;; kukit.E += 'evt-[-]- keys.'; +;;; this.emitError(kukit.E); +;;; } + var eventParameters = this.eventFullNames[eventFullName]; + if (typeof(eventParameters) == 'undefined') { + this.eventFullNames[eventFullName] = {}; + eventParameters = this.eventFullNames[eventFullName]; + } + eventParameters[eventKey] = value.txt; +}; + +this.addActionDeclaration = function(key, splitkey, value) { + // action-server: + // action-client: + // action-client: - + // action-cancel: + // action-cancel: - +;;; if (splitkey.length != 2) { +;;; kukit.E = 'Wrong key [' + key + '] : '; +;;; kukit.E += 'action- keys can have only one dash.'; +;;; this.emitError(kukit.E); +;;; } +;;; if (value.isMethod != false) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed for action- keys.'; +;;; this.emitError(kukit.E); +;;; } + var atab = {'server': 'S', 'client': 'C', 'cancel': 'X'}; + var actionType = atab[splitkey[1]]; +;;; if (! actionType) { +;;; kukit.E = 'Wrong key [' + key + '] : '; +;;; kukit.E += 'qualifier in action- keys must be '; +;;; kukit.E += '"server" or "client" or "cancel".'; +;;; this.emitError(kukit.E); +;;; } +;;; // force value to be or - +;;; var splitvalue = value.txt.split('-'); +;;; if (splitvalue.length > 2) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value must be or '; +;;; kukit.E += '- for action- keys.'; +;;; this.emitError(kukit.E); +;;; } + // set it + var action = this.actions.getOrCreateAction(value.txt); + if (actionType != 'X' || action.type == null) { + action.setType(actionType); + } else { + this.actions.deleteAction(value.txt); + } +}; + +this.addActionError = function(action, key, value) { + // -error: + // default-error: +;;; if (value.isMethod == true) { +;;; kukit.E = 'Wrong value for key [' + key + '] : '; +;;; kukit.E += 'value providers are not '; +;;; kukit.E += 'allowed for -error keys.'; +;;; this.emitError(kukit.E); +;;; } + action.setError(value.txt); + // also create the action for the error itself. + var err_action = this.actions.getOrCreateAction(value.txt); + err_action.setType('E'); +}; + +this.addActionParameter = function(action, key, value) { + var ppRegistries = { + '': kukit.pprovidersGlobalRegistry, + 'kssSelector': kukit.sr.pproviderSelRegistry, + 'kssSubmitForm': kukit.fo.pproviderFormRegistry + }; + + // -: + // default-: + // + // value may be either txt or method parms, + // and they get stored with the wrapper. + // + // Check the syntax of the value at this point. + // This will also set the value providers on the value + // (from check). + // + // Figure out which registry to use. + var registry = ppRegistries[key]; + if (typeof(registry) == 'undefined') { + // use default pproviders + registry = ppRegistries['']; + } + // + try { + // Check also sets the value provider on the value. + value.check(registry); + } catch(e) { +;;; kukit.E = 'Error in value : ' + e + '.'; + this.emitError(kukit.E); + } + action.parms[key] = value; +}; + +this.addDeclaration = function(key, value) { + // p.s. value is here a KssXxParm. In most cases we check and unwrap it. + // the keys look like this: + // + // evt--: + // evt---: + // + // action-server: + // action-client: + // action-client: - + // action-cancel: + // action-cancel: - + // + // -: + // --: + // -error: + // --error: + // + // default-: + // default-error: + // + var splitkey = key.split('-'); +;;; if (splitkey.length < 2 || splitkey.length > 4) { +;;; kukit.E = 'Wrong rule key : "' + key + '". '; +;;; kukit.E += 'KSS rule key must be "-" or '; +;;; kukit.E += '"--" or '; +;;; kukit.E += '"evt--" or '; +;;; kukit.E += '"evt---".'; +;;; this.emitError(kukit.E); +;;; } + var name = splitkey[0]; + if (name == 'evt') { + this.addEventDeclaration(key, splitkey, value); + } else if (name == 'action') { + this.addActionDeclaration(key, splitkey, value); + } else { // -: // --: // -error: // --error: - // // default-: // default-error: - // - var splitkey = key.split('-'); -;;; if (splitkey.length < 2 || splitkey.length > 4) { -;;; kukit.E = 'Wrong rule key : "' + key + '". '; -;;; kukit.E += 'KSS rule key must be "-" or '; -;;; kukit.E += '"--" or '; -;;; kukit.E += '"evt--" or '; -;;; kukit.E += '"evt---".'; -;;; this.emitError(kukit.E); -;;; } - var name = splitkey[0]; - if (name == 'evt') { - this.addEventDeclaration(key, splitkey, value); - } else if (name == 'action') { - this.addActionDeclaration(key, splitkey, value); - } else { + var actionName; + var actionKey; + if (splitkey.length == 2) { // -: - // --: // -error: - // --error: // default-: // default-error: - var actionName; - var actionKey; - if (splitkey.length == 2) { - // -: - // -error: - // default-: - // default-error: - actionName = splitkey[0]; - actionKey = splitkey[1]; - } else { - // --: - // --error: - actionName = splitkey[0] + '-' + splitkey[1]; - actionKey = splitkey[2]; - } - var action = this.actions.getOrCreateAction(actionName); - if (actionKey == 'error') { - this.addActionError(action, key, value); - } else { - this.addActionParameter(action, actionKey, value); - } + actionName = splitkey[0]; + actionKey = splitkey[1]; + } else { + // --: + // --error: + actionName = splitkey[0] + '-' + splitkey[1]; + actionKey = splitkey[2]; } - }; + var action = this.actions.getOrCreateAction(actionName); + if (actionKey == 'error') { + this.addActionError(action, key, value); + } else { + this.addActionParameter(action, actionKey, value); + } + } +}; + }; kssp.Block = kukit.tk.mkParser('block', { ";": 'new kukit.kssp.semicolon(this.cursor)', @@ -385,60 +390,64 @@ */ var _PropValue = function() { - this.process = function() { - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - this.txt = ''; - var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { - // The previous txt must be all whitespace. - if (txt) { -;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; -;;; kukit.E += ' before a string.'; - this.emitError(kukit.E); - } - // the next one must be a string. - this.expectToken(context, kukit.kssp.String); - this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) { - // see if not empty and has no spaces in it - if (! txt || txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : method name [' + txt + '] cannot '; -;;; kukit.E += 'have spaces.'; - this.emitError(kukit.E); - } - // the next one must be the rules - this.expectToken(context, kukit.kssp.MethodArgs); - this.value = new this.valueClass(txt, context.token.args); - } else { - // not a string or method: check if we allowed multiword. - if (! this.multiword_allowed && txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; - this.emitError(kukit.E); - } - this.produceTxt(txt); +this.process = function() { + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.txt = ''; + var txt = context.txt; + if (this.notInTokens(context, kukit.kssp.String)) { + // The previous txt must be all whitespace. + if (txt) { +;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; +;;; kukit.E += ' before a string.'; + this.emitError(kukit.E); } - // see what's after - if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.nextTokenIndex < this.result.length || context.txt) { -;;; kukit.E = 'Wrong value : unallowed characters after '; -;;; kukit.E += 'the property.'; - this.emitError(kukit.E); - } + // the next one must be a string. + this.expectToken(context, kukit.kssp.String); + this.produceTxt(context.token.txt); + } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) { + // see if not empty and has no spaces in it + if (! txt || txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : method name [' + txt + '] cannot '; +;;; kukit.E += 'have spaces.'; + this.emitError(kukit.E); } - this.result = []; - }; + // the next one must be the rules + this.expectToken(context, kukit.kssp.MethodArgs); + this.value = new this.valueClass(txt, context.token.args); + } else { + // not a string or method: check if we allowed multiword. + if (! this.multiword_allowed && txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; + this.emitError(kukit.E); + } + this.produceTxt(txt); + } + // see what's after + if (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + // we have to be at the end and have no text after + if (context.nextTokenIndex < this.result.length || context.txt) { +;;; kukit.E = 'Wrong value : unallowed characters after '; +;;; kukit.E += 'the property.'; + this.emitError(kukit.E); + } + } + this.result = []; +}; + +this.initialize = function() { this.multiword_allowed = true; this.valueClass = kukit.rd.KssMethodValue; - this.produceTxt = function(txt) { - // txt parms are returned embedded - this.value = new kukit.rd.KssTextValue(txt); - }; }; +this.produceTxt = function(txt) { + // txt parms are returned embedded + this.value = new kukit.rd.KssTextValue(txt); +}; +this.initialize.apply(this, arguments); +}; kssp.PropValue = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', @@ -458,11 +467,16 @@ * PropValue in method cannot have method-style vars. */ var _PropValueInMethod = function() { + +this.initialize = function() { this.multiword_allowed = false; - this.produceTxt = function(txt) { - // txt parms are returned unwrapped - this.txt = txt; - }; +}; + +this.produceTxt = function(txt) { + // txt parms are returned unwrapped + this.txt = txt; +}; +this.initialize.apply(this, arguments); }; _PropValueInMethod.prototype = new _PropValue(); kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { @@ -483,62 +497,67 @@ * */ var _EventValue = function() { + +this.initialize = function() { this.multiword_allowed = false; - this.process = function() { - // Parse all tokens (including first and last) - var context = {'nextTokenIndex': 0}; +}; + +this.process = function() { + // Parse all tokens (including first and last) + var context = {'nextTokenIndex': 0}; + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.txt = ''; + var txt = context.txt; + if (this.notInTokens(context, kukit.kssp.String)) { + // The previous txt must be all whitespace. + if (txt) { +;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; +;;; kukit.E += ' before a string.'; + this.emitError(kukit.E); + } + // the next one must be a string. + this.expectToken(context, kukit.kssp.String); + this.produceTxt(context.token.txt); + } else if (this.notInTokens(context, kukit.kssp.openParent)) { + this.expectToken(context, kukit.kssp.openParent); + this.expectToken(context, kukit.kssp.PropValue); + this.value = new kukit.rd.KssEventValue(txt, context.token.value); this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - this.txt = ''; - var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { - // The previous txt must be all whitespace. - if (txt) { -;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; -;;; kukit.E += ' before a string.'; - this.emitError(kukit.E); - } - // the next one must be a string. - this.expectToken(context, kukit.kssp.String); - this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.openParent)) { - this.expectToken(context, kukit.kssp.openParent); - this.expectToken(context, kukit.kssp.PropValue); - this.value = new kukit.rd.KssEventValue(txt, context.token.value); - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.txt) { -;;; kukit.E = 'Wrong event selector : [' + context.txt; -;;; kukit.E += '] is not expected before the closing'; -;;; kukit.E += ' parenthesis. :() can have'; -;;; kukit.E += ' only one parameter.'; - this.emitError(kukit.E); - } - // eat up everything before the closing parent - this.expectToken(context, kukit.kssp.closeParent); - } else { - // not a string or method: check if we allowed multiword. - if (! this.multiword_allowed && txt.indexOf(' ') != -1) { -;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; - this.emitError(kukit.E); - } - this.produceTxt(txt); + // we have to be at the end and have no text after + if (context.txt) { +;;; kukit.E = 'Wrong event selector : [' + context.txt; +;;; kukit.E += '] is not expected before the closing'; +;;; kukit.E += ' parenthesis. :() can have'; +;;; kukit.E += ' only one parameter.'; + this.emitError(kukit.E); } - // see what's after - if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.nextTokenIndex < this.result.length || context.txt) { -;;; kukit.E = 'Excess characters after the property value'; - this.emitError(kukit.E); - } + // eat up everything before the closing parent + this.expectToken(context, kukit.kssp.closeParent); + } else { + // not a string or method: check if we allowed multiword. + if (! this.multiword_allowed && txt.indexOf(' ') != -1) { +;;; kukit.E = 'Wrong value : [' + txt + '] cannot have spaces.'; + this.emitError(kukit.E); } - this.result = []; - }; + this.produceTxt(txt); + } + // see what's after + if (context.nextTokenIndex < this.result.length) { + this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + // we have to be at the end and have no text after + if (context.nextTokenIndex < this.result.length || context.txt) { +;;; kukit.E = 'Excess characters after the property value'; + this.emitError(kukit.E); + } + } + this.result = []; +}; - this.produceTxt = function(txt) { - // txt parms are returned embedded - this.value = new kukit.rd.KssEventValue(txt, null); - }; +this.produceTxt = function(txt) { + // txt parms are returned embedded + this.value = new kukit.rd.KssEventValue(txt, null); +}; +this.initialize.apply(this, arguments); }; kssp.EventValue = kukit.tk.mkParser('propValue', { "{": 'this.emitAndReturn()', @@ -558,13 +577,15 @@ * class String */ var _String = function() { - this.process = function() { - // collect up the value of the string, omitting the quotes - this.txt = ''; - for (var i=1; i= 0) { - var token = this.result[tokenIndex]; - switch (token.symbol) { - case kukit.tk.Fraction.prototype.symbol: { - // if all spaces, go to previous one - if (token.txt.match(/^[\r\n\t ]*$/) != null) { - tokenIndex -= 1; - } else { -;;; kukit.E = 'Wrong event selector : missing event '; -;;; kukit.E += 'qualifier : '; -;;; kukit.E += 'or :().'; - this.emitError(kukit.E); - } - } break; - case kukit.kssp.Comment.prototype.symbol: { + +this.process = function() { + var name; + var namespace = null; + var id = null; + var tokenIndex = this.result.length - 1; + // Find the method parms and calculate the end of css parms. (RL) + var cycle = true; + while (cycle && tokenIndex >= 0) { + var token = this.result[tokenIndex]; + switch (token.symbol) { + case kukit.tk.Fraction.prototype.symbol: { + // if all spaces, go to previous one + if (token.txt.match(/^[\r\n\t ]*$/) != null) { tokenIndex -= 1; - } break; - default: { - cycle = false; - } break; - } - } - // Now we found the token that must be . - tokenIndex -= 2; - if (tokenIndex < 0 - || (this.result[tokenIndex+2].symbol != - kukit.kssp.EventValue.prototype.symbol) - || (this.result[tokenIndex+1].symbol != - kukit.kssp.colon.prototype.symbol) - || (this.result[tokenIndex].symbol != - kukit.tk.Fraction.prototype.symbol)) { -;;; kukit.E = 'Wrong event selector : missing event qualifier '; -;;; kukit.E += ': or :().'; - this.emitError(kukit.E); - } - // See that the last fraction does not end with space. - var lasttoken = this.result[tokenIndex]; - var commatoken = this.result[tokenIndex+1]; - var pseudotoken = this.result[tokenIndex+2]; - var txt = lasttoken.txt; - if (txt.match(/[\r\n\t ]$/) != null) { -;;; kukit.E = 'Wrong event selector :'; -;;; kukit.E += ' space before the colon.'; - this.emitError(kukit.E); - } - if (! pseudotoken.value.methodName) { -;;; kukit.E = 'Wrong event selector :'; -;;; kukit.E += ' event name cannot have spaces.'; - this.emitError(kukit.E); - } - css = this.cursor.text.substring(this.startpos, commatoken.startpos); - // Decide if we have an event or a method selector. - // We have a method selector if a single word "document" or "behaviour". - var singleword = css.replace(/[\r\n\t ]/g, ' '); - if (singleword && singleword.charAt(0) == ' ') { - singleword = singleword.substring(1); - } - var isEvent = (singleword != 'document' && singleword != 'behaviour'); - if (! isEvent) { - // just store the single word, in case of event selectors - css = singleword; - } - // create the selector. - var id = null; - var ppid = null; - if (pseudotoken.value.arg) { - // We have something in the parentheses after the event name. - if (pseudotoken.value.arg.isMethod) { - // we have a param provider here. Just store. - ppid = pseudotoken.value.arg; - // Check its syntax too. - ppid.check(kukit.pprovidersGlobalRegistry); - } else { - // just an id. Express in txt. - id = pseudotoken.value.arg.txt; - } + } else { +;;; kukit.E = 'Wrong event selector : missing event '; +;;; kukit.E += 'qualifier : '; +;;; kukit.E += 'or :().'; + this.emitError(kukit.E); + } + } break; + case kukit.kssp.Comment.prototype.symbol: { + tokenIndex -= 1; + } break; + default: { + cycle = false; + } break; + } + } + // Now we found the token that must be . + tokenIndex -= 2; + if (tokenIndex < 0 + || (this.result[tokenIndex+2].symbol != + kukit.kssp.EventValue.prototype.symbol) + || (this.result[tokenIndex+1].symbol != + kukit.kssp.colon.prototype.symbol) + || (this.result[tokenIndex].symbol != + kukit.tk.Fraction.prototype.symbol)) { +;;; kukit.E = 'Wrong event selector : missing event qualifier '; +;;; kukit.E += ': or :().'; + this.emitError(kukit.E); + } + // See that the last fraction does not end with space. + var lasttoken = this.result[tokenIndex]; + var commatoken = this.result[tokenIndex+1]; + var pseudotoken = this.result[tokenIndex+2]; + var txt = lasttoken.txt; + if (txt.match(/[\r\n\t ]$/) != null) { +;;; kukit.E = 'Wrong event selector :'; +;;; kukit.E += ' space before the colon.'; + this.emitError(kukit.E); + } + if (! pseudotoken.value.methodName) { +;;; kukit.E = 'Wrong event selector :'; +;;; kukit.E += ' event name cannot have spaces.'; + this.emitError(kukit.E); + } + css = this.cursor.text.substring(this.startpos, commatoken.startpos); + // Decide if we have an event or a method selector. + // We have a method selector if a single word "document" or "behaviour". + var singleword = css.replace(/[\r\n\t ]/g, ' '); + if (singleword && singleword.charAt(0) == ' ') { + singleword = singleword.substring(1); + } + var isEvent = (singleword != 'document' && singleword != 'behaviour'); + if (! isEvent) { + // just store the single word, in case of event selectors + css = singleword; + } + // create the selector. + var id = null; + var ppid = null; + if (pseudotoken.value.arg) { + // We have something in the parentheses after the event name. + if (pseudotoken.value.arg.isMethod) { + // we have a param provider here. Just store. + ppid = pseudotoken.value.arg; + // Check its syntax too. + ppid.check(kukit.pprovidersGlobalRegistry); + } else { + // just an id. Express in txt. + id = pseudotoken.value.arg.txt; } - var name = pseudotoken.value.methodName; - var splitname = name.split('-'); - var namespace = null; - if (splitname.length > 2) { -;;; kukit.E = 'Wrong event selector [' + name + '] : '; -;;; kukit.E += 'qualifier should be : or '; -;;; kukit.E += ':-.'; - this.emitError(kukit.E); - } else if (splitname.length == 2) { - name = splitname[1]; - namespace = splitname[0]; - } - // Protect the error for better logging -;;; try { - this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, - namespace, id, ppid, kukit.eventsGlobalRegistry); -;;; } catch(e) { -;;; if (e.name == 'KssSelectorError') { -;;; // Log the message -;;; this.emitError(e.toString()); -;;; } else { -;;; throw e; -;;; } + } + var name = pseudotoken.value.methodName; + var splitname = name.split('-'); + var namespace = null; + if (splitname.length > 2) { +;;; kukit.E = 'Wrong event selector [' + name + '] : '; +;;; kukit.E += 'qualifier should be : or '; +;;; kukit.E += ':-.'; + this.emitError(kukit.E); + } else if (splitname.length == 2) { + name = splitname[1]; + namespace = splitname[0]; + } + // Protect the error for better logging +;;; try { + this.kssSelector = new kukit.rd.KssSelector(isEvent, css, name, + namespace, id, ppid, kukit.eventsGlobalRegistry); +;;; } catch(e) { +;;; if (e.name == 'KssSelectorError') { +;;; // Log the message +;;; this.emitError(e.toString()); +;;; } else { +;;; throw e; ;;; } - this.txt = ''; - this.result = []; - }; +;;; } + this.txt = ''; + this.result = []; +}; + }; kssp.KssSelector = kukit.tk.mkParser('kssselector', { ":": '[new kukit.kssp.colon(this.cursor), new ' + @@ -881,39 +912,43 @@ * Rule processor that interfaces with kukit core */ kssp.KssRuleProcessor = function(href) { + +this.initialize = function() { this.href = href; this.loaded = false; this.rules = []; +}; - this.load = function() { - // Opera does not support getDomDocument.load, so we use XMLHttpRequest - var domDoc = new XMLHttpRequest(); - domDoc.open("GET", this.href, false); - domDoc.send(null); - this.txt = domDoc.responseText; - this.loaded = true; - }; - - this.parse = function() { -;;; try { - //Build a parser and parse the text into it - var cursor = new kukit.tk.Cursor(this.txt); - var parser = new kukit.kssp.Document(cursor, null, true); - // Store event rules in the common list - for (var i=0; i Author: gotcha Date: Tue Dec 25 16:40:44 2007 New Revision: 50095 Removed: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: unindent and initialize Deleted: /kukit/kukit.js/branch/finish-closures/kukit/TODO.txt ============================================================================== --- /kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Tue Dec 25 16:40:44 2007 +++ (empty file) @@ -1,3 +0,0 @@ -files where indentation has to be undone and initialize needs to be done - -tokenizer.js Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Tue Dec 25 16:40:44 2007 @@ -29,23 +29,24 @@ */ tk._TokenBase = function() { - this.emitError = function(msg) { - // Use the start position of the token for the error report. -;;; var marker = this.cursor.makeMarker(this.startpos); -;;; throw kukit.err.parsingError(msg, marker); - throw new Error(kukit.E); - }; +this.emitError = function(msg) { + // Use the start position of the token for the error report. +;;; var marker = this.cursor.makeMarker(this.startpos); +;;; throw kukit.err.parsingError(msg, marker); + throw new Error(kukit.E); +}; - this.updateFinished = function() { - if (! this.finished && this.cursor.text.length == this.cursor.pos) { - if (this.isTopLevelParser) { - this.finished = true; - } else { -;;; kukit.E = 'Unexpected EOF.'; - this.emitError(kukit.E); - } +this.updateFinished = function() { + if (! this.finished && this.cursor.text.length == this.cursor.pos) { + if (this.isTopLevelParser) { + this.finished = true; + } else { +;;; kukit.E = 'Unexpected EOF.'; + this.emitError(kukit.E); } - }; + } +}; + }; @@ -54,136 +55,136 @@ */ tk._ParserBase = function() { - this.emitAndReturn = function(token) { - // handle return to the next level - this.finished = true; - return token; - }; +this.emitAndReturn = function(token) { + // handle return to the next level + this.finished = true; + return token; +}; - this.nextStep = function() { - var table = this.table - var cursor = this.cursor; - // Search for symbol according to table. - var best_pos = cursor.text.length; - var best_symbol = null; - for (var symbol in table) { - var pos = cursor.text.indexOf(symbol, cursor.pos); - if (pos != -1 && pos < best_pos) { - best_pos = pos; - best_symbol = symbol; +this.nextStep = function() { + var table = this.table + var cursor = this.cursor; + // Search for symbol according to table. + var best_pos = cursor.text.length; + var best_symbol = null; + for (var symbol in table) { + var pos = cursor.text.indexOf(symbol, cursor.pos); + if (pos != -1 && pos < best_pos) { + best_pos = pos; + best_symbol = symbol; + } + } + // eat up till the symbol found (of EOF) + if (best_pos > cursor.pos) { + this.result.push(new tk.Fraction(cursor, best_pos)); + cursor.pos = best_pos; + } + if (best_symbol) { + // found a symbol, handle that + // make the token and push it + var tokens = eval(table[best_symbol]); + if (typeof(tokens) != 'undefined') { + if (typeof(tokens.length) == 'undefined') { + tokens = [tokens]; } - } - // eat up till the symbol found (of EOF) - if (best_pos > cursor.pos) { - this.result.push(new tk.Fraction(cursor, best_pos)); - cursor.pos = best_pos; - } - if (best_symbol) { - // found a symbol, handle that - // make the token and push it - var tokens = eval(table[best_symbol]); - if (typeof(tokens) != 'undefined') { - if (typeof(tokens.length) == 'undefined') { - tokens = [tokens]; - } - for (var i=0; i= this.result.length) { -;;; kukit.E = 'Missing token : [' + symbol + '].'; - this.emitError(kukit.E); - } else if (this.result[i].symbol != symbol) { -;;; kukit.E = 'Unexpected token : [' + this.result[i].symbol; -;;; kukit.E += '] found, [' + symbol + '] was expected.'; - this.emitError(kukit.E); - } - } else { - if (i >= this.result.length) { -;;; kukit.E = 'Missing token.'; - this.emitError(kukit.E); - } +this.expectToken = function(context, token) { + var i = context.nextTokenIndex; + if (token) { + var symbol = token.prototype.symbol; + if (i >= this.result.length) { +;;; kukit.E = 'Missing token : [' + symbol + '].'; + this.emitError(kukit.E); + } else if (this.result[i].symbol != symbol) { +;;; kukit.E = 'Unexpected token : [' + this.result[i].symbol; +;;; kukit.E += '] found, [' + symbol + '] was expected.'; + this.emitError(kukit.E); } - context.token = this.result[i]; - context.nextTokenIndex += 1; - }; + } else { + if (i >= this.result.length) { +;;; kukit.E = 'Missing token.'; + this.emitError(kukit.E); + } + } + context.token = this.result[i]; + context.nextTokenIndex += 1; +}; - this.resultIsNullOrNotToken = - function(token, currentValue) { - return (!token || currentValue.symbol != token.prototype.symbol); - }; +this.resultIsNullOrNotToken = + function(token, currentValue) { + return (!token || currentValue.symbol != token.prototype.symbol); +}; - this.notInTokens = - function(context, token1, token2, token3, token4) { - var i = context.nextTokenIndex; - var currentValue = this.result[i]; - return !( - (i >= this.result.length) || - (this.resultIsNullOrNotToken(token1, currentValue) && - this.resultIsNullOrNotToken(token2, currentValue) && - this.resultIsNullOrNotToken(token3, currentValue) && - this.resultIsNullOrNotToken(token4, currentValue)) - ); - }; +this.notInTokens = + function(context, token1, token2, token3, token4) { + var i = context.nextTokenIndex; + var currentValue = this.result[i]; + return !( + (i >= this.result.length) || + (this.resultIsNullOrNotToken(token1, currentValue) && + this.resultIsNullOrNotToken(token2, currentValue) && + this.resultIsNullOrNotToken(token3, currentValue) && + this.resultIsNullOrNotToken(token4, currentValue)) + ); +}; - this.digestTxt = - function(context, token1, token2, token3, token4) { - // digests the txt from the tokens, ignores given token - // plus whitespace removal - this.digestExactTxt(context, token1, token2, token3, token4); - context.txt = this.removeWhitespacesAndTrim(context.txt); - }; +this.digestTxt = + function(context, token1, token2, token3, token4) { + // digests the txt from the tokens, ignores given token + // plus whitespace removal + this.digestExactTxt(context, token1, token2, token3, token4); + context.txt = this.removeWhitespacesAndTrim(context.txt); +}; - this.digestExactTxt = - function(context, token1, token2, token3, token4) { - // digests the txt from the tokens, ignores given token - // exact value: no whitespace removal - var result = ''; - while (this.notInTokens(context, token1, token2, token3, token4)) { - result += this.result[context.nextTokenIndex].txt; - context.nextTokenIndex ++; - } - context.txt = result; - }; +this.digestExactTxt = + function(context, token1, token2, token3, token4) { + // digests the txt from the tokens, ignores given token + // exact value: no whitespace removal + var result = ''; + while (this.notInTokens(context, token1, token2, token3, token4)) { + result += this.result[context.nextTokenIndex].txt; + context.nextTokenIndex ++; + } + context.txt = result; +}; +this.removeWhitespaces = function(txt) { + // removes ws but leaves leading and trailing one + if (txt != ' ') { //speedup only + txt = txt.replace(/[\r\n\t ]+/g, ' '); + } + return txt; +}; + +this.removeWhitespacesAndTrim = function(txt) { + txt = this.removeWhitespaces(txt); + // XXX Strange thing is: following replace works from + // tests and the original demo, but with kukitportlet demo + // it breaks. Someone stinks! + //txt = txt.replace(/^ /, ''); + if (txt && txt.charAt(0) == ' ') { + txt = txt.substr(1); + } + txt = txt.replace(/ $/, ''); + return txt; +}; - this.removeWhitespaces = function(txt) { - // removes ws but leaves leading and trailing one - if (txt != ' ') { //speedup only - txt = txt.replace(/[\r\n\t ]+/g, ' '); - } - return txt; - }; - - this.removeWhitespacesAndTrim = function(txt) { - txt = this.removeWhitespaces(txt); - // XXX Strange thing is: following replace works from - // tests and the original demo, but with kukitportlet demo - // it breaks. Someone stinks! - //txt = txt.replace(/^ /, ''); - if (txt && txt.charAt(0) == ' ') { - txt = txt.substr(1); - } - txt = txt.replace(/ $/, ''); - return txt; - }; }; tk._ParserBase.prototype = new tk._TokenBase(); @@ -191,12 +192,16 @@ /* * class Fraction */ -tk.Fraction = function(cursor, endpos) { +tk.Fraction = function() { + +this.initialize = function(cursor, endpos) { this.txt = cursor.text.substring(cursor.pos, endpos); this.startpos = cursor.pos; this.endpos = cursor.pos; this.finished = true; }; +this.initialize.apply(this, arguments); +}; tk.Fraction.prototype.symbol = 'fraction'; @@ -258,46 +263,50 @@ /* * class Cursor */ -tk.Cursor = function(txt) { +tk.Cursor = function() { + +this.initialize = function(txt) { this.text = txt; this.pos = 0; +}; - this.makeMarker = function(pos) { - // create a cursor to mark this position - var cursor = new tk.Cursor(); - cursor.text = this.text; - cursor.pos = pos; - // Calculate the row and column information on the cursor - cursor.calcRowCol(); - return cursor; - }; +this.makeMarker = function(pos) { + // create a cursor to mark this position + var cursor = new tk.Cursor(); + cursor.text = this.text; + cursor.pos = pos; + // Calculate the row and column information on the cursor + cursor.calcRowCol(); + return cursor; +}; - this.getRowCol = function(pos) { - // Gets the row, col information for the position. - if (typeof(pos) == 'undefined') { - pos = this.pos; - } - var index = 0; - var row = 1; - var next = 0; - while (true) { - next = this.text.indexOf('\n', index); - if (next == -1 || next >= pos) { - break; - } - index = next + 1; - row += 1; - } - var col = pos - index + 1; - return {'row': row, 'col': col}; - }; +this.getRowCol = function(pos) { + // Gets the row, col information for the position. + if (typeof(pos) == 'undefined') { + pos = this.pos; + } + var index = 0; + var row = 1; + var next = 0; + while (true) { + next = this.text.indexOf('\n', index); + if (next == -1 || next >= pos) { + break; + } + index = next + 1; + row += 1; + } + var col = pos - index + 1; + return {'row': row, 'col': col}; +}; - this.calcRowCol = function(pos) { - // Calculates row and column information on the cursor. - var rowcol = this.getRowCol(); - this.row = rowcol.row; - this.col = rowcol.col; - }; +this.calcRowCol = function(pos) { + // Calculates row and column information on the cursor. + var rowcol = this.getRowCol(); + this.row = rowcol.row; + this.col = rowcol.col; +}; +this.initialize.apply(this, arguments); }; }(); /// MODULE END From gotcha at codespeak.net Tue Dec 25 16:41:07 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 16:41:07 +0100 (CET) Subject: [KSS-checkins] r50096 - kukit/kukit.js/branch/finish-closures/doc Message-ID: <20071225154107.CBADF1684EB@codespeak.net> Author: gotcha Date: Tue Dec 25 16:41:07 2007 New Revision: 50096 Modified: kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt Log: branch ready to merge Modified: kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/finish-closures/doc/HISTORY.txt Tue Dec 25 16:41:07 2007 @@ -4,7 +4,8 @@ kukit.js - 1.4dev Unreleased - - ... + - Refactor code towards module and class closures + [gotcha] - Fix multiple selection form fields marshalling on Safari From reebalazs at codespeak.net Tue Dec 25 16:50:30 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Tue, 25 Dec 2007 16:50:30 +0100 (CET) Subject: [KSS-checkins] r50097 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071225155030.C6F7E1684E8@codespeak.net> Author: reebalazs Date: Tue Dec 25 16:50:29 2007 New Revision: 50097 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Log: Move actions and commands to the new registry Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js Tue Dec 25 16:50:29 2007 @@ -27,7 +27,6 @@ * The local event actions need to be registered here. */ var ActionRegistry = function () { - this.content = {}; }; ActionRegistry.prototype.register = function(name, func) { @@ -36,24 +35,15 @@ ;;; kukit.E += ' [ActionRegistry.register].'; ;;; throw new Error(kukit.E); ;;;} - if (this.content[name]) { - // Do not allow redefinition -;;; kukit.logError('Error : action [' + name + '] already registered.'); - return; - } - this.content[name] = func; -}; - -ActionRegistry.prototype.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); + var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); + actions.getMethodDescriptor(name).register(func); }; ActionRegistry.prototype.get = function(name) { - var func = this.content[name]; + var func = kukit.interfaces.global.actions[name]; if (! func) { // not found -;;; kukit.E = 'Error : undefined local action [' + name + '].'; +;;; kukit.E = 'Error : undefined client action [' + name + '].'; throw Error(kukit.E); } return func; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Tue Dec 25 16:50:29 2007 @@ -27,7 +27,6 @@ * class _CommandRegistry */ var _CommandRegistry = function () { - this.commands = {}; }; /* @@ -46,34 +45,60 @@ */ _CommandRegistry.prototype.registerFromAction = function(srcname, factory, name) { - if (typeof(name) == 'undefined') { - // allows to set a different name as the action name, - // usable for backward - // compatibility setups - name = srcname; - } + var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); + // // register a given action as a command, using the given vactor - var f = kukit.actionsGlobalRegistry.get(srcname); - factory(name, f); + var descriptor = actions.getMethodDescriptor(srcname); + if (! descriptor.config) { +;;; 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(descriptor.config); + // 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.getMethodDescriptor(name).register(descriptor.config); + // only declare the command class if it's missing + if (typeof(descriptor.config.commandClass) == 'undefined') { + this._register(name, commandClass, descriptor); + } + } else { + // This is the normal case - just register it + this._register(srcname, commandClass, descriptor); + } + +}; + +_CommandRegistry.prototype.register = function(name, commandClass) { + var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); + var descriptor = actions.getMethodDescriptor(name); + this._register(name, commandClass, descriptor); }; -_CommandRegistry.prototype.register = function(name, klass) { - if (this.commands[name]) { +_CommandRegistry.prototype._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) { // Do not allow redefinition -;;; var msg = 'ValueError : command [' + name + '] is already registered.'; -;;; kukit.logError(msg); - return; +;;; kukit.E = 'command [' + name + '] is already defined, in CommandRegistry.register.'; + throw Error(kukit.E); } - this.commands[name] = klass; + // Store the command class on the config + descriptor.config.commandClass = commandClass; }; _CommandRegistry.prototype.get = function(name) { - var klass = this.commands[name]; -;;;if (! klass) { + var action = kukit.interfaces.global.actions[name]; + var klass = action.commandClass; + if (! klass) { ;;; // not found -;;; var msg = 'ValueError : no command registered under [' + name + '].'; -;;; kukit.logError(msg); -;;; } +;;; kukit.E = 'undefined command [' + name + ']'; + throw Error(kukit.E); + } return klass; }; @@ -140,24 +165,24 @@ } }; -cr.makeSelectorCommand = function(name, executeOnSingleNode) { +cr.makeSelectorCommand = function(executeOnSingleNode) { var commandClass = function() {}; commandClass.prototype = { execute: _executeCommand, executeOnScope: _executeCommandOnSelector, executeOnSingleNode: executeOnSingleNode }; - kukit.commandsGlobalRegistry.register(name, commandClass); + return commandClass; }; -cr.makeGlobalCommand = function(name, executeOnce) { +cr.makeGlobalCommand = function(executeOnce) { var commandClass = function() {}; commandClass.prototype = { execute: _executeCommand, executeOnScope: executeOnce, executeOnSingleNode: executeOnce }; - kukit.commandsGlobalRegistry.register(name, commandClass); + return commandClass; }; }(); /// MODULE END Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Tue Dec 25 16:50:29 2007 @@ -124,6 +124,8 @@ ;;; kukit.E += this.name + ']'; throw new Error(kukit.E); } +;;; kukit.E = 'Finalizing interface [' + this.name + ']'; +;;; kukit.logDebug(kukit.E); // Finalize all methods. this.forEachMethod(function(methodName, methodDescriptor) { // finalize the functions and store them on the singleton @@ -135,10 +137,7 @@ // We are finalized if the loader has no items to load. // If there is no loader, we are finalized always. this.finalized = ! loader || loader.empty(); -;;; if (this.finalized) { -;;; kukit.E = 'Finalizing interface [' + this.name + ']'; -;;; kukit.logDebug(kukit.E); -;;; } else { +;;; if (! this.finalized) { ;;; kukit.E = 'Postpone finalization of interface [' + this.name + '],'; ;;; kukit.E = ' and request sources [', loader.getSources() + ']'; ;;; kukit.logDebug(kukit.E); @@ -387,6 +386,8 @@ // Need to finalize these interfaces this.global.get('events', this.PluginMethodDescriptor).finalize({}); this.global.get('binditerations', this.BindIterationDescriptor).finalize({}); + // this is not strictly necessary, as we don't get as far as execution + this.global.get('actions', this.PluginMethodDescriptor).finalize({}); }; this.cleanRoomTearDown = function(suite) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Tue Dec 25 16:50:29 2007 @@ -240,12 +240,13 @@ ;;; kukit.log('[initializeRules] is called twice.'); return; } -;;; kukit.log('Finalizing interfaces.'); // We finalize the core interface. var interfaces = kukit.interfaces.global; interfaces.get('core', kukit.interfaces.ServiceMethodDescriptor).finalize({}); interfaces.get('events', kukit.interfaces.PluginMethodDescriptor).finalize({}); interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor).finalize({}); + interfaces.get('actions', kukit.interfaces.PluginMethodDescriptor).finalize({}); +;;; kukit.log('All interfaces finalized.'); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept // as a global variable, but this needs refinement in the future. From gotcha at codespeak.net Tue Dec 25 17:49:52 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 17:49:52 +0100 (CET) Subject: [KSS-checkins] r50098 - in kukit/kss.core/trunk: docs kss/core/docs Message-ID: <20071225164952.F0D90168456@codespeak.net> Author: gotcha Date: Tue Dec 25 17:49:51 2007 New Revision: 50098 Added: kukit/kss.core/trunk/docs/ kukit/kss.core/trunk/docs/HISTORY.txt - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/HISTORY.txt kukit/kss.core/trunk/docs/INSTALL.txt - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/INSTALL.txt kukit/kss.core/trunk/docs/LICENSE.txt - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/LICENSE.txt kukit/kss.core/trunk/docs/TODO.txt - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/TODO.txt kukit/kss.core/trunk/docs/tutorial_part2.rst - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/tutorial_part2.rst Removed: kukit/kss.core/trunk/kss/core/docs/HISTORY.txt kukit/kss.core/trunk/kss/core/docs/INSTALL.txt kukit/kss.core/trunk/kss/core/docs/LICENSE.txt kukit/kss.core/trunk/kss/core/docs/TODO.txt kukit/kss.core/trunk/kss/core/docs/tutorial_part2.rst Log: undo move of files Deleted: /kukit/kss.core/trunk/kss/core/docs/HISTORY.txt ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/HISTORY.txt Tue Dec 25 17:49:51 2007 +++ (empty file) @@ -1,134 +0,0 @@ -Changelog for kss.core - - (name of developer listed in brackets) - -kss.core - 1.4dev Unreleased - - - ... - - - Fix multiple selection form fields - marshalling on Safari - (fixes #22 in kssproject) - and on IE. - [ree] - - - Fix error fallback handling - [ree] - - - Implement loglevels based on cookies - Add handling of log levels to the kss mode view - [ree] - - - Moved the core demos to this package from kss.demo. - They are now located under the core plugin. - [ree] - - - Implement event binding based on the ids fetched - dynamically from the dom, by value providers. - [ree] - - - Changed kukit payload to encode HTML content of CDATA. - This was necessary because us a supposed bug in FF, that - prevented us to use base2 (xpath selection did not work - on inserted elements, due to namespace issues.) - Get rid of forceToDom, make sure all plugins accept html - parameters as strings. - [ree] - -kss.core - 1.2 Released 2007-08-17 - - - Refactored js code. - [gotcha] - -kss.core - 1.2-rc2 Released 2007-07-27 - - - Prepare for release. - [ree] - - - when attrname is kssattr:xxx, IE chokes on certain nodes - [gotcha] - - - fix form marshalling - [gotcha] - -kss.core - 1.2-rc1.1 - - - Prepare for release. - Identical with 1.2-rc1, just created for consistent versions. - [ree] - -kss.core - 1.2-rc1 - - - Deprecated addClassName, removeClassName actions and - commands in favour of addClass and removeClass. - Deprecated "name" and "classname" parameter in addClass, - removeClass, toggleClass actions and commands in favour of - "value". - [ree] - - - implement new packing directives and two disctint - versions of the javascript (development and production), - this is achieved from javascript with the ;;; marker - Also add the @@kss_devel_mode/ui view for changing - the development mode from the browser. - [ree] - - - Add the passnode selector that can be used to access - the value of a default parm passed programmatically - from the event (via makeActionOper) - [ree] - - - Add action moveNodeAsLastChild - [ree] - - - Death to Azax (... long live KSS)! - Removing last traces of the old name from the sources - [gotcha] - - - Changed querying for css selectors to base2 instead of - cssQuery. Base2 is supposed to be a lot faster than - the old cssQuery. Usage is alternating, if base2 is - present that one is used, otherwise it uses the old - cssQuery code which stays the default. - [jvloothuis, ree] - - - Add moveNodeBefore action (presumably missing) - [ree] - - - Refactor load event, separate iload and load events. - The new event binder handles both events together. A - new parameter, evt-iload-autodetect is introduced, if - this is false we don't use detection but the iframe - must cooperate on telling us wnen we are done. There - is deprecation warning issued for the load events, if - bound on an iframe, in which case an iload event must - be used. - [ree] - - - refactor event binding to allow different iterators to bind - events in a binder instance, matching the need of the events. - [ree] - -kss.core - 1.2-beta2 - - - Make the binding of the nodes together in one batch - [ree] - - - added kssSubmitForm action parameter - and deprecation - [ree] - -kss.core - 1.2-beta1 - - - Prepare for release - [ree] - -kss.core - 1.2-alpha2 - - - Merge in Philikon's refactorization - Move docs to doc/ - [ree] - - - Initial package structure. - [zopeskel] - Deleted: /kukit/kss.core/trunk/kss/core/docs/INSTALL.txt ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/INSTALL.txt Tue Dec 25 17:49:51 2007 +++ (empty file) @@ -1,13 +0,0 @@ -kss.core Installation -===================== - - * When you're reading this you have probably already run - ``easy_install kss.core``. Find out how to install setuptools - (and EasyInstall) here: - http://peak.telecommunity.com/DevCenter/EasyInstall - - * Copy the files called ``kss/core/kss.core-configure.zcml`` - and ``kss/core/kss.core-meta.zcml`` in the - ``/path/to/instance/etc/package-includes`` directory. - *You do not need to do this if you use kss with Plone.* - Deleted: /kukit/kss.core/trunk/kss/core/docs/LICENSE.txt ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/LICENSE.txt Tue Dec 25 17:49:51 2007 +++ (empty file) @@ -1,24 +0,0 @@ - kss.core is copyright KSS Project Contributors - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA. - - - - - Third party modules come with different licenses, see individual files - - BeautifulSoup.py is licensed with PSF, Copyright (c) 2004-2006 Leonard Richardson - - Firebug Lite is licensed under Mozilla Public License 1.1 Deleted: /kukit/kss.core/trunk/kss/core/docs/TODO.txt ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/TODO.txt Tue Dec 25 17:49:51 2007 +++ (empty file) @@ -1,2 +0,0 @@ - - Deleted: /kukit/kss.core/trunk/kss/core/docs/tutorial_part2.rst ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/tutorial_part2.rst Tue Dec 25 17:49:51 2007 +++ (empty file) @@ -1,383 +0,0 @@ -This tutorial is the direct continuation of the `first part`_. We will -learn how to specify server side actions and finally complete our first useful -AJAX example. - -.. _first part: http://kukit.org/documentation/tutorials/begin-with-kss - -Creating a server action ------------------------- - -Until now, we called a client action (alert) from our event. This was good to -test if our event was triggered. However, in a typical AJAX pattern, we want to -call a server action. - -Server actions are implemented as methods on the server. They could be any kind -of callable methods, including python scripts, and this is what we will do -first. Besides doing whatever is necessary for the business -logic, the task of the server method is to assemble a sequence of commands. -These commands are marshalled back to the client to be executed there. A -command is a call to DOM manipulation client code. A command can (in most -cases, should) have a selector, to set the scope of nodes on which the command -is executed, and a set of parameters for execution. - -Although existing components come with implemented server action methods, it is -easy to create a custom one since it requires only python skills. Let's create -a python script (`response1`) in the custom skin : - -:: - - # import Through-The-Web(TTW) API - from kss.core.ttwapi import startKSSCommands - from kss.core.ttwapi import getKSSCommandSet - from kss.core.ttwapi import renderKSSCommands - - # start a view for commands - startKSSCommands(context, context.REQUEST) - - # add a command - core = getKSSCommandSet('core') - core.replaceInnerHTML('#portal-siteactions', '

    We did it!

    ') - - # render the commands - return renderKSSCommands() - -After the imports, we initialize the view that will hold the KSS commands that -we want to send back to the client. - -Then we add a command. The name of the command is `replaceInnerHTML`. This is -one of our most useful commands : it simply replaces the contents of the -selected html nodes with some html string. - -To specify which nodes will be selected, the command also needs a selector: in -this example, a standard CSS selector. We choose to replace the portal actions -of a Plone portal that are on the top of the page - but we could choose any -other element as well. - -The `replaceInnerHTML` method is accessed through a command set. Since we have -a pluggable system, we need to refer to the component that defines the methods, -in this case, the `'core'` command set. - -In the last line, the `renderKSSCommands` call is mandatory : it will generate -the response payload from the accumulated commands. To look at this payload, -let's access this method directly from the browser : -`http://localhost:8080/plone/front-page/response1`. -We will see "We did it!" on the screen, but let's have a more careful look at -the source of the response : - -:: - - - - - We did it!]]> - - - < - -This is an XML response, where we can see how commands and parameters are -actually marshalled. When the response is interpreted by the kss engine, it -will execute the commands with the given parameters. - -Calling the server action -------------------------- - -Now, we have finished to build our server action; we want to call it from our -kss style sheet. We replace our previous kss event rule with the following -one : - -:: - - a.navTreeCurrentItem:click { - evt-click-preventdefault: True; - action-server: response1; - } - -The `action-server` line specifies the name of the remote method to call : -`response1` (since this is how we named our python script). The script will be -called on the context url of the page we are at. - -Let's reload the page so that the new kss comes into effect. Open the -loggingpane. Then press the "Home" line in the navtree portlet. It works! We -can see the site actions replaced with our text. Also notice that a few things -have been logged to the loggingpane : - -:: - - ... - DEBUG: RequestManager Notify server http://localhost:8080/plone/front-page/response1, rid=0 (RQ: 1 OUT, 0 WAI) - DEBUG: RequestManager Received result with rid=0 (RQ: 0 OUT, 0 WAI) - INFO: Parse commands - DEBUG: Number of commands: 1 - DEBUG: Selector type: default (css), selector : "#portal-siteactions", selected nodes:1 - DEBUG: Command Name: replaceInnerHTML - ... - -This gives a lot of information about what happened in the client : - -- the server is notified, -- the response is received, -- it is parsed successfully, -- it contains one command, -- the command selects 1 node to act on. - -Now let's change our command response in the following way : - -:: - - ... - from DateTime import DateTime - - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s' % DateTime() - core.replaceInnerHTML('#portal-siteactions', content) - ... - -This way, the current time is sent back by the server on each click and we can -see that something happens. - -It is interesting to note that we did not need to reload the page in order to -see the effect of this change. Because we only made changes on the server, we -did not need to load anything new on the client side. So we can continue to -debug from the already loaded page and this will work even through server -restarts. - -What happens if the server-side script has an error, or the client does not get -a correct response for some reason ? In this case, we will see this in the -loggingpane : - -:: - - DEBUG: RequestManager Notify server http://localhost:8080/tutorial/front-page/response1, rid=3 (RQ: 1 OUT, 0 WAI) - DEBUG: RequestManager Received result with rid=3 (RQ: 0 OUT, 0 WAI) - ERROR: Request failed at url http://localhost:8080/tutorial/front-page/response1, rid=3 - -The error `Request failed` indicates that we have to turn to the server to -debug the problem. Our best friend, the zope error log will tell us about the -actual problem. - -Server action parameters ------------------------- - -Like client actions, server actions can also accept parameters. The parameters -will be sent to the server as form variables. Zope publisher can then pass them -as usual keyword parameters to our python script. Let's render a parameter -coming from the client. We add parameter `mymessage` to the python script. Then -modify the script : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - core.replaceInnerHTML('#portal-siteactions', content) - ... - - -We modify our kss rule to actually send the parameter from the client : - -:: - - a.navTreeCurrentItem:click { - evt-click-preventdefault: True; - action-server: response1; - response1-mymessage: "Hello Plone!"; - } - -The key `response1-mymessage` is built identically to how we did it with the -client action. We use the name of the action first and then, following the -dash, the name of the parameter. This time, because we change the stylesheet, -we need to reload the page before testing by clicking on the bound node. - -To understand better how all this is working, let's enter a second rule in the -kss : - -:: - - ul#portal-globalnav li a:click { - evt-click-preventdefault: True; - action-server: response1; - response1-mymessage: "clicked on global nav"; - } - -This shows some new things. First, you can see that you can use any css -selector in a rule. In this case, the selector will select all globalnav tab -links. If you reload the page, you will notice that if you click on any of -those links, different content is replaced because different parameter are -passed to the server. - -If you take a look at the loggingpane after the page reload, you can see -something like this : - -:: - - INFO: Initializing kss - ... - INFO: Count of KSS links: 1 - INFO: Start loading and processing http://localhost:8080/plone/portal_css/Plone%20Default/tutor-cachekey9967.kss resource type kss - DEBUG: EventRule #0: a.navTreeCurrentItem EVENT=click - DEBUG: EventRule #1: ul#portal-globalnav li a EVENT=click - INFO: Finished loading and processing http://localhost:8080/plone/portal_css/Plone%20Default/tutor-cachekey9967.kss resource type kss in 35 + 29 ms - INFO: Starting setting up events for document - DEBUG: EventRule #0 mergeid @@0@@click selected 1 nodes - DEBUG: EventRule #1 mergeid @@0@@click selected 4 nodes - DEBUG: Binding 0 special rules in grand total - DEBUG: instantiating event id=@@0, classname=0, namespace=null - DEBUG: Binding to 5 nodes in grand total - ... - -This shows that the second rule is also in effect now. Moreover, it has -selected 4 nodes (or however many globalnav tabs you have). A lot of other -information is also logged, it should not worry you at the moment. - -Different command selector --------------------------- - -Until now, in our command, we used the default css selector. It is possible to -use other types of selectors, like a html id selector. Let's modify our command -in the following way : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - selector = core.getHtmlIdSelector('portal-personaltools'), - core.replaceInnerHTML(selector, content) - ... - -What an HTML id selector selects should be obvious. Reload the page and -exercise... - -Commands can also select multiple nodes : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - selector = core.getCssSelector('dt.portletHeader a'), - core.replaceInnerHTML(selector, content) - ... - -The css selector `dt.portletHeader a` selects all portlet headers in the page, -so the replacement will be executed not on one node but on many nodes (as can -also be seen in the loggingpane). Try clicking the `Home` link in the navtree, -or any of the globalnav tabs to see the effect. - -You can also add multiple commands : each of them will be executed, in the -order they have within the payload. - -One thing is important to note. If a command selects no nodes, it is not an -error : the behaviour designed in this case is that nothing happens. This is in -line with the usual logic of css selectors in style sheets. - -Using a different event ------------------------ - -So far we have only used the `click` event: let's try with another one, -`timeout`. The `timeout` event does not directly map to a browser event but it -is a (conceptual) kss event. This shows that in kss anything can be an event -and how an event binds itself is freely implementable. - -Let's add the following rule to the end of our kss file (altogether we will -have 3 rules then) : - -:: - - document:timeout { - evt-timeout-delay: 8000; - action-server: response1; - response1-mymessage: "from timeout"; - } - -The `timeout` event implements a recurring timeout tick. It has a `delay` -parameter that specifies the time in milliseconds. In this case, the event will -be triggered each 8 seconds over and over again. The event calls the server -action that we already have but with a different parameter. - -The `timeout` event does not really need a node as binding scope. This is why -we use `document` instead of a css selector as we did until now. This is a -special kss selector that is an extension to css and simply means : bind this -event exactly once when the document loads, with a scope of no nodes but the -document itself. - -If you reload the page you will notice that clicks work as before, however, -every 8 seconds, the timeout event will trigger and do a replacement on the -required nodes. - -There are some more advanced issues that this example opens and we will show -more about them in the next tutorials. - -*Congratulations!* - -You have completed your first kss tutorial, learned the basics and now you are -able to start some experimentation on your own. Or, just sit back and relax. - -Server-side commands - the zope3 way ------------------------------------- - -A python script may not be the most proper implementation of a server method. -Plone community is moving towards zope3 style development : the suggested way -is to use a browser view (multiadapter). Previously, you have created a demo -product, now create a python module `demoview.py` in the product root directory -on the filesystem : - -:: - - from kss.core import KSSView - from datetime import datetime - - class DemoView(KSSView): - - def response1(self, mymessage): - # build HTML - content = '

    We did it!

    %s at %s

    ' - date = str(datetime.now()) - content = content % (mymessage, date) - - # KSS specific calls - core = self.getCommandSet('core') - core.replaceInnerHTML('#portal-siteactions', content) - return self.render() - -We inherit our view from `KSSView`. It inherits from Five's `BrowserView`. - -It is maybe time to explain how the `ttwapi` uses those views. - -- `startKSSCommands` does the instantiation of a `KSSView`. -- `getKSSCommandSet` is the call equivalent to `self.getCommandSet`. -- `renderKSSCommands` calls `self.render`. - -To be able to use the method, you need to add the following to your -`configure.zcml` file : - -:: - - - -The interface that the view is bound to is one setup by `kss.core` on all -portal objects. You could also use directly the interfaces defined by Plone 2.5 -directly, however that would not work on Plone 2.1 so we offer a few "wrapper -interfaces" like the one in this example. - -If you still have the `response1` python script from the begin of this -tutorial, do not forget to rename it. Now it is time to restart Zope. If -everything goes well, the page functions as previously but you can see from the -replacement message that the new method is operating on your page. - -Remember, when you are working with browser views, you must restart Zope each -time you want to test the changes made in the view code. - From gotcha at codespeak.net Tue Dec 25 17:52:23 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 17:52:23 +0100 (CET) Subject: [KSS-checkins] r50099 - in kukit/kss.core/trunk: docs kss/core/docs Message-ID: <20071225165223.0FB57168456@codespeak.net> Author: gotcha Date: Tue Dec 25 17:52:23 2007 New Revision: 50099 Added: kukit/kss.core/trunk/docs/LICENSE.GPL - copied unchanged from r50097, kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL Removed: kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL Log: undo move of files Deleted: /kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL ============================================================================== --- /kukit/kss.core/trunk/kss/core/docs/LICENSE.GPL Tue Dec 25 17:52:23 2007 +++ (empty file) @@ -1,222 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS From gotcha at codespeak.net Tue Dec 25 17:56:33 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 17:56:33 +0100 (CET) Subject: [KSS-checkins] r50100 - in kukit/kss.core/branch/1.2: docs kss/core/docs Message-ID: <20071225165633.6CC411684D7@codespeak.net> Author: gotcha Date: Tue Dec 25 17:56:33 2007 New Revision: 50100 Added: kukit/kss.core/branch/1.2/docs/ kukit/kss.core/branch/1.2/docs/HISTORY.txt - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt kukit/kss.core/branch/1.2/docs/INSTALL.txt - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/INSTALL.txt kukit/kss.core/branch/1.2/docs/LICENSE.GPL - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.GPL kukit/kss.core/branch/1.2/docs/LICENSE.txt - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.txt kukit/kss.core/branch/1.2/docs/TODO.txt - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/TODO.txt kukit/kss.core/branch/1.2/docs/tutorial_part2.rst - copied unchanged from r50099, kukit/kss.core/branch/1.2/kss/core/docs/tutorial_part2.rst Removed: kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt kukit/kss.core/branch/1.2/kss/core/docs/INSTALL.txt kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.GPL kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.txt kukit/kss.core/branch/1.2/kss/core/docs/TODO.txt kukit/kss.core/branch/1.2/kss/core/docs/tutorial_part2.rst Log: undo move of files Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/HISTORY.txt Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,135 +0,0 @@ -Changelog for kss.core - - (name of developer listed in brackets) - -kss.core - 1.2dev Unreleased - - - ... - -kss.core - 1.2.4 Released 2007-12-06 - - - Fix multiple selection form fields - marshalling on Safari - (fixes #22 in kssproject) - and on IE. - [ree] - - - Fix error fallback handling - [ree] - - - Implement loglevels based on cookies - Add handling of log levels to the kss mode view - [ree] - -kss.core - 1.2.3 Released 2007-11-08 - -kss.core - 1.2.2 Released 2007-10-05 - - - some code for firekiss - [gotcha] - -kss.core - 1.2.1 Released 2007-09-10 - - - Prepare for release. - [ree] - - - minor bug fixes - [ree, jfroche] - -kss.core - 1.2 Released 2007-08-17 - - - Refactored js code. - [gotcha] - -kss.core - 1.2-rc2 Released 2007-07-27 - - - Prepare for release. - [ree] - - - when attrname is kssattr:xxx, IE chokes on certain nodes - [gotcha] - - - fix form marshalling - [gotcha] - -kss.core - 1.2-rc1.1 - - - Prepare for release. - Identical with 1.2-rc1, just created for consistent versions. - [ree] - -kss.core - 1.2-rc1 - - - Deprecated addClassName, removeClassName actions and - commands in favour of addClass and removeClass. - Deprecated "name" and "classname" parameter in addClass, - removeClass, toggleClass actions and commands in favour of - "value". - [ree] - - - implement new packing directives and two disctint - versions of the javascript (development and production), - this is achieved from javascript with the ;;; marker - Also add the @@kss_devel_mode/ui view for changing - the development mode from the browser. - [ree] - - - Add the passnode selector that can be used to access - the value of a default parm passed programmatically - from the event (via makeActionOper) - [ree] - - - Add action moveNodeAsLastChild - [ree] - - - Death to Azax (... long live KSS)! - Removing last traces of the old name from the sources - [gotcha] - - - Changed querying for css selectors to base2 instead of - cssQuery. Base2 is supposed to be a lot faster than - the old cssQuery. Usage is alternating, if base2 is - present that one is used, otherwise it uses the old - cssQuery code which stays the default. - [jvloothuis, ree] - - - Add moveNodeBefore action (presumably missing) - [ree] - - - Refactor load event, separate iload and load events. - The new event binder handles both events together. A - new parameter, evt-iload-autodetect is introduced, if - this is false we don't use detection but the iframe - must cooperate on telling us wnen we are done. There - is deprecation warning issued for the load events, if - bound on an iframe, in which case an iload event must - be used. - [ree] - - - refactor event binding to allow different iterators to bind - events in a binder instance, matching the need of the events. - [ree] - -kss.core - 1.2-beta2 - - - Make the binding of the nodes together in one batch - [ree] - - - added kssSubmitForm action parameter - and deprecation - [ree] - -kss.core - 1.2-beta1 - - - Prepare for release - [ree] - -kss.core - 1.2-alpha2 - - - Merge in Philikon's refactorization - Move docs to doc/ - [ree] - - - Initial package structure. - [zopeskel] - Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/INSTALL.txt ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/INSTALL.txt Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,13 +0,0 @@ -kss.core Installation -===================== - - * When you're reading this you have probably already run - ``easy_install kss.core``. Find out how to install setuptools - (and EasyInstall) here: - http://peak.telecommunity.com/DevCenter/EasyInstall - - * Copy the files called ``kss/core/kss.core-configure.zcml`` - and ``kss/core/kss.core-meta.zcml`` in the - ``/path/to/instance/etc/package-includes`` directory. - *You do not need to do this if you use kss with Plone.* - Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.GPL ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.GPL Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,222 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.txt ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/LICENSE.txt Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,24 +0,0 @@ - kss.core is copyright KSS Project Contributors - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA. - - - - - Third party modules come with different licenses, see individual files - - BeautifulSoup.py is licensed with PSF, Copyright (c) 2004-2006 Leonard Richardson - - Firebug Lite is licensed under Mozilla Public License 1.1 Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/TODO.txt ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/TODO.txt Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,2 +0,0 @@ - - Deleted: /kukit/kss.core/branch/1.2/kss/core/docs/tutorial_part2.rst ============================================================================== --- /kukit/kss.core/branch/1.2/kss/core/docs/tutorial_part2.rst Tue Dec 25 17:56:33 2007 +++ (empty file) @@ -1,384 +0,0 @@ -This tutorial is the direct continuation of the `first part`_. We will -learn how to specify server side actions and finally complete our first useful -AJAX example. - -.. _first part: http://kukit.org/documentation/tutorials/begin-with-kss - -Creating a server action ------------------------- - -Until now, we called a client action (alert) from our event. This was good to -test if our event was triggered. However, in a typical AJAX pattern, we want to -call a server action. - -Server actions are implemented as methods on the server. They could be any kind -of callable methods, including python scripts, and this is what we will do -first. Besides doing whatever is necessary for the business -logic, the task of the server method is to assemble a sequence of commands. -These commands are marshalled back to the client to be executed there. A -command is a call to DOM manipulation client code. A command can (in most -cases, should) have a selector, to set the scope of nodes on which the command -is executed, and a set of parameters for execution. - -Although existing components come with implemented server action methods, it is -easy to create a custom one since it requires only python skills. Let's create -a python script (`response1`) in the custom skin : - -:: - - # import Through-The-Web(TTW) API - from kss.core.ttwapi import startKSSCommands - from kss.core.ttwapi import getKSSCommandSet - from kss.core.ttwapi import renderKSSCommands - - # start a view for commands - startKSSCommands(context, context.REQUEST) - - # add a command - core = getKSSCommandSet('core') - core.replaceInnerHTML('#portal-siteactions', '

    We did it!

    ') - - # render the commands - return renderKSSCommands() - -After the imports, we initialize the view that will hold the KSS commands that -we want to send back to the client. - -Then we add a command. The name of the command is `replaceInnerHTML`. This is -one of our most useful commands : it simply replaces the contents of the -selected html nodes with some html string. - -To specify which nodes will be selected, the command also needs a selector: in -this example, a standard CSS selector. We choose to replace the portal actions -of a Plone portal that are on the top of the page - but we could choose any -other element as well. - -The `replaceInnerHTML` method is accessed through a command set. Since we have -a pluggable system, we need to refer to the component that defines the methods, -in this case, the `'core'` command set. - -In the last line, the `renderKSSCommands` call is mandatory : it will generate -the response payload from the accumulated commands. To look at this payload, -let's access this method directly from the browser : -`http://localhost:8080/plone/front-page/response1`. -We will see "We did it!" on the screen, but let's have a more careful look at -the source of the response : - -:: - - - - - -

    We did it!

    -
    -
    - - -This is an XML response, where we can see how commands and parameters are -actually marshalled. When the response is interpreted by the kss engine, it -will execute the commands with the given parameters. - -Calling the server action -------------------------- - -Now, we have finished to build our server action; we want to call it from our -kss style sheet. We replace our previous kss event rule with the following -one : - -:: - - a.navTreeCurrentItem:click { - evt-click-preventdefault: True; - action-server: response1; - } - -The `action-server` line specifies the name of the remote method to call : -`response1` (since this is how we named our python script). The script will be -called on the context url of the page we are at. - -Let's reload the page so that the new kss comes into effect. Open the -loggingpane. Then press the "Home" line in the navtree portlet. It works! We -can see the site actions replaced with our text. Also notice that a few things -have been logged to the loggingpane : - -:: - - ... - DEBUG: RequestManager Notify server http://localhost:8080/plone/front-page/response1, rid=0 (RQ: 1 OUT, 0 WAI) - DEBUG: RequestManager Received result with rid=0 (RQ: 0 OUT, 0 WAI) - INFO: Parse commands - DEBUG: Number of commands: 1 - DEBUG: Selector type: default (css), selector : "#portal-siteactions", selected nodes:1 - DEBUG: Command Name: replaceInnerHTML - ... - -This gives a lot of information about what happened in the client : - -- the server is notified, -- the response is received, -- it is parsed successfully, -- it contains one command, -- the command selects 1 node to act on. - -Now let's change our command response in the following way : - -:: - - ... - from DateTime import DateTime - - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s' % DateTime() - core.replaceInnerHTML('#portal-siteactions', content) - ... - -This way, the current time is sent back by the server on each click and we can -see that something happens. - -It is interesting to note that we did not need to reload the page in order to -see the effect of this change. Because we only made changes on the server, we -did not need to load anything new on the client side. So we can continue to -debug from the already loaded page and this will work even through server -restarts. - -What happens if the server-side script has an error, or the client does not get -a correct response for some reason ? In this case, we will see this in the -loggingpane : - -:: - - DEBUG: RequestManager Notify server http://localhost:8080/tutorial/front-page/response1, rid=3 (RQ: 1 OUT, 0 WAI) - DEBUG: RequestManager Received result with rid=3 (RQ: 0 OUT, 0 WAI) - ERROR: Request failed at url http://localhost:8080/tutorial/front-page/response1, rid=3 - -The error `Request failed` indicates that we have to turn to the server to -debug the problem. Our best friend, the zope error log will tell us about the -actual problem. - -Server action parameters ------------------------- - -Like client actions, server actions can also accept parameters. The parameters -will be sent to the server as form variables. Zope publisher can then pass them -as usual keyword parameters to our python script. Let's render a parameter -coming from the client. We add parameter `mymessage` to the python script. Then -modify the script : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - core.replaceInnerHTML('#portal-siteactions', content) - ... - - -We modify our kss rule to actually send the parameter from the client : - -:: - - a.navTreeCurrentItem:click { - evt-click-preventdefault: True; - action-server: response1; - response1-mymessage: "Hello Plone!"; - } - -The key `response1-mymessage` is built identically to how we did it with the -client action. We use the name of the action first and then, following the -dash, the name of the parameter. This time, because we change the stylesheet, -we need to reload the page before testing by clicking on the bound node. - -To understand better how all this is working, let's enter a second rule in the -kss : - -:: - - ul#portal-globalnav li a:click { - evt-click-preventdefault: True; - action-server: response1; - response1-mymessage: "clicked on global nav"; - } - -This shows some new things. First, you can see that you can use any css -selector in a rule. In this case, the selector will select all globalnav tab -links. If you reload the page, you will notice that if you click on any of -those links, different content is replaced because different parameter are -passed to the server. - -If you take a look at the loggingpane after the page reload, you can see -something like this : - -:: - - INFO: Initializing kss - ... - INFO: Count of KSS links: 1 - INFO: Start loading and processing http://localhost:8080/plone/portal_css/Plone%20Default/tutor-cachekey9967.kss resource type kss - DEBUG: EventRule #0: a.navTreeCurrentItem EVENT=click - DEBUG: EventRule #1: ul#portal-globalnav li a EVENT=click - INFO: Finished loading and processing http://localhost:8080/plone/portal_css/Plone%20Default/tutor-cachekey9967.kss resource type kss in 35 + 29 ms - INFO: Starting setting up events for document - DEBUG: EventRule #0 mergeid @@0@@click selected 1 nodes - DEBUG: EventRule #1 mergeid @@0@@click selected 4 nodes - DEBUG: Binding 0 special rules in grand total - DEBUG: instantiating event id=@@0, classname=0, namespace=null - DEBUG: Binding to 5 nodes in grand total - ... - -This shows that the second rule is also in effect now. Moreover, it has -selected 4 nodes (or however many globalnav tabs you have). A lot of other -information is also logged, it should not worry you at the moment. - -Different command selector --------------------------- - -Until now, in our command, we used the default css selector. It is possible to -use other types of selectors, like a html id selector. Let's modify our command -in the following way : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - selector = core.getHtmlIdSelector('portal-personaltools'), - core.replaceInnerHTML(selector, content) - ... - -What an HTML id selector selects should be obvious. Reload the page and -exercise... - -Commands can also select multiple nodes : - -:: - - ... - # add a command - core = getKSSCommandSet('core') - content = '

    We did it!

    %s at %s' % (mymessage, DateTime())) - selector = core.getCssSelector('dt.portletHeader a'), - core.replaceInnerHTML(selector, content) - ... - -The css selector `dt.portletHeader a` selects all portlet headers in the page, -so the replacement will be executed not on one node but on many nodes (as can -also be seen in the loggingpane). Try clicking the `Home` link in the navtree, -or any of the globalnav tabs to see the effect. - -You can also add multiple commands : each of them will be executed, in the -order they have within the payload. - -One thing is important to note. If a command selects no nodes, it is not an -error : the behaviour designed in this case is that nothing happens. This is in -line with the usual logic of css selectors in style sheets. - -Using a different event ------------------------ - -So far we have only used the `click` event: let's try with another one, -`timeout`. The `timeout` event does not directly map to a browser event but it -is a (conceptual) kss event. This shows that in kss anything can be an event -and how an event binds itself is freely implementable. - -Let's add the following rule to the end of our kss file (altogether we will -have 3 rules then) : - -:: - - document:timeout { - evt-timeout-delay: 8000; - action-server: response1; - response1-mymessage: "from timeout"; - } - -The `timeout` event implements a recurring timeout tick. It has a `delay` -parameter that specifies the time in milliseconds. In this case, the event will -be triggered each 8 seconds over and over again. The event calls the server -action that we already have but with a different parameter. - -The `timeout` event does not really need a node as binding scope. This is why -we use `document` instead of a css selector as we did until now. This is a -special kss selector that is an extension to css and simply means : bind this -event exactly once when the document loads, with a scope of no nodes but the -document itself. - -If you reload the page you will notice that clicks work as before, however, -every 8 seconds, the timeout event will trigger and do a replacement on the -required nodes. - -There are some more advanced issues that this example opens and we will show -more about them in the next tutorials. - -*Congratulations!* - -You have completed your first kss tutorial, learned the basics and now you are -able to start some experimentation on your own. Or, just sit back and relax. - -Server-side commands - the zope3 way ------------------------------------- - -A python script may not be the most proper implementation of a server method. -Plone community is moving towards zope3 style development : the suggested way -is to use a browser view (multiadapter). Previously, you have created a demo -product, now create a python module `demoview.py` in the product root directory -on the filesystem : - -:: - - from kss.core import KSSView - from datetime import datetime - - class DemoView(KSSView): - - def response1(self, mymessage): - # build HTML - content = '

    We did it!

    %s at %s

    ' - date = str(datetime.now()) - content = content % (mymessage, date) - - # KSS specific calls - core = self.getCommandSet('core') - core.replaceInnerHTML('#portal-siteactions', content) - return self.render() - -We inherit our view from `KSSView`. It inherits from Five's `BrowserView`. - -It is maybe time to explain how the `ttwapi` uses those views. - -- `startKSSCommands` does the instantiation of a `KSSView`. -- `getKSSCommandSet` is the call equivalent to `self.getCommandSet`. -- `renderKSSCommands` calls `self.render`. - -To be able to use the method, you need to add the following to your -`configure.zcml` file : - -:: - - - -The interface that the view is bound to is one setup by `kss.core` on all -portal objects. You could also use directly the interfaces defined by Plone 2.5 -directly, however that would not work on Plone 2.1 so we offer a few "wrapper -interfaces" like the one in this example. - -If you still have the `response1` python script from the begin of this -tutorial, do not forget to rename it. Now it is time to restart Zope. If -everything goes well, the page functions as previously but you can see from the -replacement message that the new method is operating on your page. - -Remember, when you are working with browser views, you must restart Zope each -time you want to test the changes made in the view code. - From gotcha at codespeak.net Tue Dec 25 17:58:44 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 17:58:44 +0100 (CET) Subject: [KSS-checkins] r50101 - in kukit/kss.demo/trunk: docs kss/demo/docs Message-ID: <20071225165844.827D51684D7@codespeak.net> Author: gotcha Date: Tue Dec 25 17:58:44 2007 New Revision: 50101 Added: kukit/kss.demo/trunk/docs/ - copied from r50100, kukit/kss.demo/trunk/kss/demo/docs/ Removed: kukit/kss.demo/trunk/kss/demo/docs/ Log: undo move of files From gotcha at codespeak.net Tue Dec 25 17:59:23 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 17:59:23 +0100 (CET) Subject: [KSS-checkins] r50102 - in kukit/kss.demo/branch/1.2: docs kss/demo/docs Message-ID: <20071225165923.DC35B1684D7@codespeak.net> Author: gotcha Date: Tue Dec 25 17:59:23 2007 New Revision: 50102 Added: kukit/kss.demo/branch/1.2/docs/ - copied from r50101, kukit/kss.demo/branch/1.2/kss/demo/docs/ Removed: kukit/kss.demo/branch/1.2/kss/demo/docs/ Log: undo move of files From gotcha at codespeak.net Tue Dec 25 18:54:45 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Tue, 25 Dec 2007 18:54:45 +0100 (CET) Subject: [KSS-checkins] r50109 - kukit/kukit.js/branch/finish-closures/tests Message-ID: <20071225175445.0DB531684D7@codespeak.net> Author: gotcha Date: Tue Dec 25 18:54:44 2007 New Revision: 50109 Modified: kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js Log: fix tokenizer tests Modified: kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js Tue Dec 25 18:54:44 2007 @@ -77,6 +77,7 @@ this.name = 'kukit.TokenizerTestCase'; this.setUp = function() { + this.Dummy = function() {}; }; this.testException = function() { @@ -156,7 +157,9 @@ var pf = kukit.tk.mkParser('block', { '[': 'this.emitAndReturn(new kukit.tk.openBracket(this.cursor))', '{': 'new kukit.tk.openBrace(this.cursor)' - }); + }, + this.Dummy + ); var parser = new pf(cursor, null, true); this.assertEquals(parser.finished, true); @@ -193,12 +196,16 @@ kukit.tk.global = kukit.tk.mkParser('global', { '[': 'new kukit.tk.openBracket(this.cursor)', '{': 'new kukit.tk.inside(this.cursor, kukit.tk.openBrace)' - }); + }, + this.Dummy + ); kukit.tk.inside = kukit.tk.mkParser('inside', { '[': 'new kukit.tk.wrappedBracket(this.cursor)', '}': 'this.emitAndReturn(new kukit.tk.closeBrace(this.cursor))' - }); + }, + this.Dummy + ); var parser = new kukit.tk.global(cursor, null, true); //this.printDebug(parser); @@ -259,36 +266,43 @@ kukit.tk.global = kukit.tk.mkParser('global', { "'": 'new kukit.tk.string(this.cursor, kukit.tk.quote)' - }); - + }, + this.Dummy + ); + var _String = function() { + this.process = function() { + // collect up the value of the string, omitting the quotes + this.txt = ''; + for (var i=1; i Author: gotcha Date: Tue Dec 25 19:03:40 2007 New Revision: 50110 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js Log: fix needed for kssparser tests Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Tue Dec 25 19:03:40 2007 @@ -468,17 +468,15 @@ */ var _PropValueInMethod = function() { -this.initialize = function() { - this.multiword_allowed = false; -}; - this.produceTxt = function(txt) { // txt parms are returned unwrapped this.txt = txt; }; -this.initialize.apply(this, arguments); + }; _PropValueInMethod.prototype = new _PropValue(); +// this assignment needs to remain after initialization of _PropValue +_PropValueInMethod.multiword_allowed = false; kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', Modified: kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js Tue Dec 25 19:03:40 2007 @@ -30,11 +30,11 @@ rm._rid = 0; /* -* class _RequestItem +* class RequestItem * * Request item. Encapsulates the sendout function and data. */ -var _RequestItem = function() { +rm.RequestItem = function() { this.initialize = function(sendHook, url, timeoutHook, timeout, now) { if (typeof(now) == 'undefined') { @@ -81,14 +81,14 @@ }; /* -* class _TimerQueue +* class TimerQueue * * the send queue. This handles timeouts, and executes * a callback for timed out items. * Callback is called with the request item as parameter. */ -var _TimerQueue = function() { +rm.TimerQueue = function() { this.initialize = function(callback) { this.callback = callback; @@ -166,7 +166,7 @@ var timeoutItem = function(item) { self.timeoutItem(item); }; - this.timerQueue = new _TimerQueue(timeoutItem); + this.timerQueue = new rm.TimerQueue(timeoutItem); if (typeof(name) == 'undefined') { name = null; } @@ -350,7 +350,7 @@ // Default value of timeout timeout = this.sendingTimeout; } - var item = new _RequestItem(sendHook, url, timeoutHook, timeout, + var item = new rm.RequestItem(sendHook, url, timeoutHook, timeout, now); // Start timing the item immediately this.timerQueue.push(item); From gotcha at codespeak.net Wed Dec 26 13:09:00 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 26 Dec 2007 13:09:00 +0100 (CET) Subject: [KSS-checkins] r50121 - in kukit/kukit.js/branch/finish-closures: kukit tests Message-ID: <20071226120900.61B8516844C@codespeak.net> Author: gotcha Date: Wed Dec 26 13:08:58 2007 New Revision: 50121 Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js Log: make test_requestmanager pass : remove default value for max number of requests reorder initialization parameters Modified: kukit/kukit.js/branch/finish-closures/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kukit.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kukit.js Wed Dec 26 13:08:58 2007 @@ -66,7 +66,7 @@ // State vars storage. This can be used from kss via a method. this.stateVariables = {}; // instantiate request manager - this.requestManager = new kukit.rm.RequestManager(); + this.requestManager = new kukit.rm.RequestManager(4); this.binderInfoRegistry = new kukit.er.BinderInfoRegistry(); // instantiate a load scheduler this.loadScheduler = new kukit.rd.LoadActions(); Modified: kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/requestmanager.js Wed Dec 26 13:08:58 2007 @@ -30,11 +30,11 @@ rm._rid = 0; /* -* class RequestItem +* class _RequestItem * * Request item. Encapsulates the sendout function and data. */ -rm.RequestItem = function() { +var _RequestItem = function() { this.initialize = function(sendHook, url, timeoutHook, timeout, now) { if (typeof(now) == 'undefined') { @@ -80,15 +80,21 @@ this.initialize.apply(this, arguments); }; +rm.TestRequestItem = function() { +kukit.logWarning('Use class [rm.TestRequestItem] only in tests !'); +this.initialize.apply(this, arguments); +}; +rm.TestRequestItem.prototype = new _RequestItem(); + /* -* class TimerQueue +* class _TimerQueue * * the send queue. This handles timeouts, and executes * a callback for timed out items. * Callback is called with the request item as parameter. */ -rm.TimerQueue = function() { +var _TimerQueue = function() { this.initialize = function(callback) { this.callback = callback; @@ -153,12 +159,19 @@ this.initialize.apply(this, arguments); }; +rm.TestTimerQueue = function() { +kukit.logWarning('Use class [rm.TestTimerQueue] only in tests !'); +this.initialize.apply(this, arguments); +}; +rm.TestTimerQueue.prototype = new _TimerQueue(); + + /* * class RequestManager */ rm.RequestManager = function () { -this.initialize = function (name, maxNr, schedulerClass) { +this.initialize = function (maxNr, name, schedulerClass) { // schedulerClass is mainly provided for debugging... this.waitingQueue = new kukit.ut.FifoQueue(); this.sentNr = 0; @@ -166,7 +179,7 @@ var timeoutItem = function(item) { self.timeoutItem(item); }; - this.timerQueue = new rm.TimerQueue(timeoutItem); + this.timerQueue = new _TimerQueue(timeoutItem); if (typeof(name) == 'undefined') { name = null; } @@ -192,8 +205,6 @@ // sending timeout in millisecs this.sendingTimeout = 8000; - // max request number - this.maxNr = 4; }; ;;; this.getInfo = function() { @@ -350,7 +361,7 @@ // Default value of timeout timeout = this.sendingTimeout; } - var item = new rm.RequestItem(sendHook, url, timeoutHook, timeout, + var item = new _RequestItem(sendHook, url, timeoutHook, timeout, now); // Start timing the item immediately this.timerQueue.push(item); Modified: kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js (original) +++ kukit/kukit.js/branch/finish-closures/tests/test_requestmanager.js Wed Dec 26 13:08:58 2007 @@ -45,14 +45,14 @@ expired.push(item); }; // Push items at different timepoints, with same timeout - q = new kukit.rm.TimerQueue(cbe); - var i1 = new kukit.rm.RequestItem(null, 1, null, 10000, 1000); + q = new kukit.rm.TestTimerQueue(cbe); + var i1 = new kukit.rm.TestRequestItem(null, 1, null, 10000, 1000); q.push(i1); - var i2 = new kukit.rm.RequestItem(null, 2, null, 10000, 2000); + var i2 = new kukit.rm.TestRequestItem(null, 2, null, 10000, 2000); q.push(i2); - var i3 = new kukit.rm.RequestItem(null, 3, null, 10000, 3000); + var i3 = new kukit.rm.TestRequestItem(null, 3, null, 10000, 3000); q.push(i3); - var i4 = new kukit.rm.RequestItem(null, 4, null, 10000, 4000); + var i4 = new kukit.rm.TestRequestItem(null, 4, null, 10000, 4000); q.push(i4); this.assertEquals(q.count, 4); // pop 2, 4 @@ -79,7 +79,7 @@ this.testNormalSend = function() { // Test a simple send situation - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; @@ -116,7 +116,7 @@ this.testSendWithTimeouts = function() { // Test a simple timeout situation - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; @@ -161,7 +161,7 @@ this.testSendWithQueuedTimeout = function() { // Test timeout with queues not sent out - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; @@ -203,7 +203,7 @@ this.testSendWithQueuedSwallowed = function() { // If the queued element is timed out, it it not sent out - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; @@ -246,7 +246,7 @@ this.testAllTimedOut = function() { // If all elements are timed out - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; @@ -284,7 +284,7 @@ this.testTimeoutHooks = function() { // Test if timeout hook(s) are called - var rm = new kukit.rm.RequestManager(null, 2, kukit.DummyScheduler); + var rm = new kukit.rm.RequestManager(2, null, kukit.DummyScheduler); this.assertRmQueues(rm, 0, 0); // queues var sent = []; From gotcha at codespeak.net Wed Dec 26 15:02:19 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 26 Dec 2007 15:02:19 +0100 (CET) Subject: [KSS-checkins] r50123 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071226140219.1C31816850B@codespeak.net> Author: gotcha Date: Wed Dec 26 15:02:17 2007 New Revision: 50123 Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: semicolons ease debugging Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Wed Dec 26 15:02:17 2007 @@ -43,8 +43,8 @@ } else { ;;; kukit.E = 'Unexpected EOF.'; this.emitError(kukit.E); - } - } + }; + }; }; }; @@ -72,13 +72,13 @@ if (pos != -1 && pos < best_pos) { best_pos = pos; best_symbol = symbol; - } - } + }; + }; // eat up till the symbol found (of EOF) if (best_pos > cursor.pos) { this.result.push(new tk.Fraction(cursor, best_pos)); cursor.pos = best_pos; - } + }; if (best_symbol) { // found a symbol, handle that // make the token and push it @@ -86,12 +86,12 @@ if (typeof(tokens) != 'undefined') { if (typeof(tokens.length) == 'undefined') { tokens = [tokens]; - } + }; for (var i=0; i Author: gotcha Date: Wed Dec 26 15:05:21 2007 New Revision: 50124 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Log: all tests pass again Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Wed Dec 26 15:05:21 2007 @@ -468,15 +468,17 @@ */ var _PropValueInMethod = function() { +this.initialize = function() { + this.multiword_allowed = false; +}; + this.produceTxt = function(txt) { // txt parms are returned unwrapped this.txt = txt; }; - +this.initialize.apply(this, arguments); }; -_PropValueInMethod.prototype = new _PropValue(); // this assignment needs to remain after initialization of _PropValue -_PropValueInMethod.multiword_allowed = false; kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { ";": 'this.emitAndReturn()', "}": 'this.emitAndReturn()', @@ -489,6 +491,7 @@ }, _PropValueInMethod ); +kssp.PropValueInMethod.prototype.process = kssp.PropValue.prototype.process; /* * class EventValue From gotcha at codespeak.net Wed Dec 26 15:33:46 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 26 Dec 2007 15:33:46 +0100 (CET) Subject: [KSS-checkins] r50125 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071226143346.ACB3A168456@codespeak.net> Author: gotcha Date: Wed Dec 26 15:33:45 2007 New Revision: 50125 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Log: include selenium test for ecmaunit testrunner Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html Wed Dec 26 15:33:45 2007 @@ -0,0 +1,59 @@ + + + +ecma_tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ecma_tests
    open/demo/@@kukittestsuite/runner.html
    assertTextPresentRun Testcases
    clickcss=a[href="javascript:runTestCases();"]
    assertText//div[@id='kukit.UtilsTestCase']/divOK!
    assertText//div[@id='kukit.RequestManagerTestCase']/divOK!
    assertText//div[@id='kukit.TokenizerTestCase']/divOK!
    assertText//div[@id='kukit.KssParserTestCase']/divOK!
    assertText//div[@id='kukit.KssParserSelectorTestCase']/divOK!
    assertText//div[@id='kukit.KssParserSelectorsTestCase']/divOK!
    + + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Wed Dec 26 15:33:45 2007 @@ -15,6 +15,9 @@ +
    Ecmaunit tests + + Basic commands @@ -73,6 +76,9 @@ + Ecmaunit tests + + Basic commands From gotcha at codespeak.net Wed Dec 26 15:34:23 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 26 Dec 2007 15:34:23 +0100 (CET) Subject: [KSS-checkins] r50126 - kukit/kukit.js/branch/finish-closures/tests Message-ID: <20071226143423.34080168467@codespeak.net> Author: gotcha Date: Wed Dec 26 15:34:22 2007 New Revision: 50126 Modified: kukit/kukit.js/branch/finish-closures/tests/unittestUtilities.js Log: help for selenium Modified: kukit/kukit.js/branch/finish-closures/tests/unittestUtilities.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/unittestUtilities.js (original) +++ kukit/kukit.js/branch/finish-closures/tests/unittestUtilities.js Wed Dec 26 15:34:22 2007 @@ -94,6 +94,7 @@ // append testcase section var placeHolder = document.createElement("div"); placeHolder.className = "placeholder"; + placeHolder.id = name; var link = createLink(name, name+" Results", true); var header = document.createElement("h3"); header.appendChild(link); From gotcha at codespeak.net Wed Dec 26 20:17:50 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Wed, 26 Dec 2007 20:17:50 +0100 (CET) Subject: [KSS-checkins] r50127 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071226191750.167C1168512@codespeak.net> Author: gotcha Date: Wed Dec 26 20:17:49 2007 New Revision: 50127 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: death to eval Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Wed Dec 26 20:17:49 2007 @@ -43,6 +43,45 @@ /* Parsers */ +/* Helpers */ + +var _emitAndReturn = function(parser) { + return parser.emitAndReturn(); +}; + +var _mkEmitAndReturnToken = function(klass) { + return function(parser) { + var token = new klass(parser.cursor); + return parser.emitAndReturn(token); + }; +}; + +var _mkReturnToken = function(klass) { + return function(parser) { + return new klass(parser.cursor); + }; +}; + +var _returnComment = function(parser) { + return new kssp.Comment(parser.cursor, kssp.openComment) +}; + +var _returnString = function(parser) { + return new kssp.String(parser.cursor, kssp.quote) +}; + +var _returnString2 = function(parser) { + return new kssp.String2(parser.cursor, kssp.dquote) +}; + +var _returnMethodArgs = function(parser) { + return new kssp.MethodArgs(parser.cursor, kssp.openParent) +}; + +var _returnBackslashed = function(parser) { + return new kssp.Backslashed(parser.cursor, kssp.backslash) +}; + /* * class Document */ @@ -53,12 +92,12 @@ // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; while (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); var key = context.txt; if (! key) { break; } - this.expectToken(context, kukit.kssp.Block); + this.expectToken(context, kssp.Block); var block = context.token; var rules = block.parseSelectors(key); this.addRules(rules); @@ -76,8 +115,10 @@ }; kssp.Document = kukit.tk.mkParser('document', { - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', - "{": 'new kukit.kssp.Block(this.cursor, kukit.kssp.openBrace)' + "\/\*": _returnComment, + "{": function(parser) { + return new kssp.Block(parser.cursor, kssp.openBrace) + } }, _Document ); @@ -95,7 +136,7 @@ }; kssp.Comment = kukit.tk.mkParser('comment', { // it's not 100% good, but will do - "\*\/": 'this.emitAndReturn(new kukit.kssp.closeComment(this.cursor))' + "\*\/": _mkEmitAndReturnToken(kssp.closeComment) }, _Comment ); @@ -112,17 +153,17 @@ // Parse all tokens (except first and last) var context = {'nextTokenIndex': 1}; while (context.nextTokenIndex < this.result.length-1) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); var key = context.txt; if (! key) { break; } - this.expectToken(context, kukit.kssp.colon); - this.expectToken(context, kukit.kssp.PropValue); + this.expectToken(context, kssp.colon); + this.expectToken(context, kssp.PropValue); // store the wrapped prop this.addDeclaration(key, context.token.value); if (context.nextTokenIndex == this.result.length-1) break; - this.expectToken(context, kukit.kssp.semicolon); + this.expectToken(context, kssp.semicolon); } this.result = []; this.txt = ''; @@ -131,7 +172,7 @@ this.parseSelectors = function(key) { // Parse the part in an embedded parser var cursor = new kukit.tk.Cursor(key + ' '); - var parser = new kukit.kssp.KssSelectors(cursor, null, true); + var parser = new kssp.KssSelectors(cursor, null, true); var results = []; var hasFullNames = false; for(var eventFullName in this.eventFullNames) { @@ -378,9 +419,12 @@ }; kssp.Block = kukit.tk.mkParser('block', { - ";": 'new kukit.kssp.semicolon(this.cursor)', - ":": '[new kukit.kssp.colon(this.cursor), new kukit.kssp.PropValue(this.cursor)]', - "}": 'this.emitAndReturn(new kukit.kssp.closeBrace(this.cursor))' + ";": _mkReturnToken(kssp.semicolon), + ":": function(parser) { + return [new kssp.colon(parser.cursor), + new kssp.PropValue(parser.cursor)] + }, + "}": _mkEmitAndReturnToken(kssp.closeBrace) }, _Block ); @@ -393,10 +437,10 @@ this.process = function() { // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); this.txt = ''; var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { + if (this.notInTokens(context, kssp.String)) { // The previous txt must be all whitespace. if (txt) { ;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; @@ -404,9 +448,9 @@ this.emitError(kukit.E); } // the next one must be a string. - this.expectToken(context, kukit.kssp.String); + this.expectToken(context, kssp.String); this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.MethodArgs)) { + } else if (this.notInTokens(context, kssp.MethodArgs)) { // see if not empty and has no spaces in it if (! txt || txt.indexOf(' ') != -1) { ;;; kukit.E = 'Wrong value : method name [' + txt + '] cannot '; @@ -414,7 +458,7 @@ this.emitError(kukit.E); } // the next one must be the rules - this.expectToken(context, kukit.kssp.MethodArgs); + this.expectToken(context, kssp.MethodArgs); this.value = new this.valueClass(txt, context.token.args); } else { // not a string or method: check if we allowed multiword. @@ -426,7 +470,7 @@ } // see what's after if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); // we have to be at the end and have no text after if (context.nextTokenIndex < this.result.length || context.txt) { ;;; kukit.E = 'Wrong value : unallowed characters after '; @@ -449,14 +493,14 @@ this.initialize.apply(this, arguments); }; kssp.PropValue = kukit.tk.mkParser('propValue', { - ";": 'this.emitAndReturn()', - "}": 'this.emitAndReturn()', - ")": 'this.emitAndReturn()', - ",": 'this.emitAndReturn()', - "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', - '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)', - "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)' + ";": _emitAndReturn, + "}": _emitAndReturn, + ")": _emitAndReturn, + ",": _emitAndReturn, + "'": _returnString, + '"': _returnString2, + "\/\*": _returnComment, + "(": _returnMethodArgs }, _PropValue ); @@ -480,14 +524,14 @@ }; // this assignment needs to remain after initialization of _PropValue kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { - ";": 'this.emitAndReturn()', - "}": 'this.emitAndReturn()', - ")": 'this.emitAndReturn()', - "]": 'this.emitAndReturn()', - ",": 'this.emitAndReturn()', - "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', - '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' + ";": _emitAndReturn, + "}": _emitAndReturn, + ")": _emitAndReturn, + "]": _emitAndReturn, + ",": _emitAndReturn, + "'": _returnString, + '"': _returnString2, + "\/\*": _returnComment }, _PropValueInMethod ); @@ -506,10 +550,10 @@ this.process = function() { // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); this.txt = ''; var txt = context.txt; - if (this.notInTokens(context, kukit.kssp.String)) { + if (this.notInTokens(context, kssp.String)) { // The previous txt must be all whitespace. if (txt) { ;;; kukit.E = 'Wrong value : unallowed characters [' + txt + ']'; @@ -517,13 +561,13 @@ this.emitError(kukit.E); } // the next one must be a string. - this.expectToken(context, kukit.kssp.String); + this.expectToken(context, kssp.String); this.produceTxt(context.token.txt); - } else if (this.notInTokens(context, kukit.kssp.openParent)) { - this.expectToken(context, kukit.kssp.openParent); - this.expectToken(context, kukit.kssp.PropValue); + } else if (this.notInTokens(context, kssp.openParent)) { + this.expectToken(context, kssp.openParent); + this.expectToken(context, kssp.PropValue); this.value = new kukit.rd.KssEventValue(txt, context.token.value); - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); // we have to be at the end and have no text after if (context.txt) { ;;; kukit.E = 'Wrong event selector : [' + context.txt; @@ -533,7 +577,7 @@ this.emitError(kukit.E); } // eat up everything before the closing parent - this.expectToken(context, kukit.kssp.closeParent); + this.expectToken(context, kssp.closeParent); } else { // not a string or method: check if we allowed multiword. if (! this.multiword_allowed && txt.indexOf(' ') != -1) { @@ -544,7 +588,7 @@ } // see what's after if (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); // we have to be at the end and have no text after if (context.nextTokenIndex < this.result.length || context.txt) { ;;; kukit.E = 'Excess characters after the property value'; @@ -561,15 +605,18 @@ this.initialize.apply(this, arguments); }; kssp.EventValue = kukit.tk.mkParser('propValue', { - "{": 'this.emitAndReturn()', - " ": 'this.emitAndReturn()', - "\t": 'this.emitAndReturn()', - "\n": 'this.emitAndReturn()', - "\r": 'this.emitAndReturn()', - "\/\*": 'this.emitAndReturn()', - ":": 'this.emitAndReturn()', - "(": '[new kukit.kssp.openParent(this.cursor), new kukit.kssp.PropValue(this.cursor)]', - ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))' + "{": _emitAndReturn, + " ": _emitAndReturn, + "\t": _emitAndReturn, + "\n": _emitAndReturn, + "\r": _emitAndReturn, + "\/\*": _emitAndReturn, + ":": _emitAndReturn, + "(": function(parser) { + return [new kssp.openParent(parser.cursor), + new kssp.PropValue(parser.cursor)] + }, + ")": _mkEmitAndReturnToken(kssp.closeParent) }, _EventValue ); @@ -589,8 +636,8 @@ }; kssp.String = kukit.tk.mkParser('string', { - "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', - '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' + "'": _mkEmitAndReturnToken(kssp.quote), + '\x5c': _returnBackslashed }, _String ); @@ -599,8 +646,8 @@ * class String2 */ kssp.String2 = kukit.tk.mkParser('string', { - '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))', - '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' + '"': _mkEmitAndReturnToken(kssp.dquote), + '\x5c': _returnBackslashed }, _String ); @@ -620,8 +667,8 @@ }; kssp.StringInSelector = kukit.tk.mkParser('string', { - "'": 'this.emitAndReturn(new kukit.kssp.quote(this.cursor))', - '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' + "'": _mkEmitAndReturnToken(kssp.quote), + '\x5c': _returnBackslashed }, _StringInSelector ); @@ -630,8 +677,8 @@ * class String2InSelector */ kssp.String2InSelector = kukit.tk.mkParser('string', { - '"': 'this.emitAndReturn(new kukit.kssp.dquote(this.cursor))', - '\x5c': 'new kukit.kssp.Backslashed(this.cursor, kukit.kssp.backslash)' + '"': _mkEmitAndReturnToken(kssp.dquote), + '\x5c': _returnBackslashed }, _StringInSelector ); @@ -677,13 +724,13 @@ // Parse all tokens (except first and last) var context = {'nextTokenIndex': 1}; while (context.nextTokenIndex < this.result.length-1) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment); var value = context.txt; if (! value) { // allow to bail out after widow , if (context.nextTokenIndex == this.result.length-1) break; // here be a string then. - this.expectToken(context, kukit.kssp.String); + this.expectToken(context, kssp.String); value = context.token.txt; } else { // Just a value, must be one word then. @@ -697,8 +744,8 @@ var valueClass; var args; var providedValue; - if (this.notInTokens(context, kukit.kssp.MethodArgs)){ - this.expectToken(context, kukit.kssp.MethodArgs); + if (this.notInTokens(context, kssp.MethodArgs)){ + this.expectToken(context, kssp.MethodArgs); valueClass = kukit.rd.KssMethodValue; args = context.token.args; providedValue = new valueClass(value, args); @@ -710,7 +757,7 @@ } this.args.push(providedValue); if (context.nextTokenIndex == this.result.length-1) break; - this.expectToken(context, kukit.kssp.comma); + this.expectToken(context, kssp.comma); } this.result = []; this.txt = ''; @@ -718,17 +765,16 @@ }; kssp.MethodArgs = kukit.tk.mkParser('methodargs', { - "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', - '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', - ",": 'new kukit.kssp.comma(this.cursor)', - ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))', - "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' + "'": _returnString, + '"': _returnString2, + ",": _mkReturnToken(kssp.comma), + ")": _mkEmitAndReturnToken(kssp.closeParent), + "(": _returnMethodArgs, + "\/\*": _returnComment }, _MethodArgs ); - /* * class KssSelectors * @@ -745,13 +791,13 @@ // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; while (context.nextTokenIndex < this.result.length) { - this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment, - kukit.kssp.String, kukit.kssp.String2); + this.digestTxt(context, kukit.tk.Fraction, kssp.Comment, + kssp.String, kssp.String2); var cursor = new kukit.tk.Cursor(context.txt + ' ') - var parser = new kukit.kssp.KssSelector(cursor, null, true); + var parser = new kssp.KssSelector(cursor, null, true); this.selectors.push(parser.kssSelector); if (context.nextTokenIndex == this.result.length) break; - this.expectToken(context, kukit.kssp.comma); + this.expectToken(context, kssp.comma); if (context.nextTokenIndex == this.result.length) { ;;; kukit.E = 'Wrong event selector : trailing comma'; this.emitError(kukit.E); @@ -763,11 +809,15 @@ }; kssp.KssSelectors = kukit.tk.mkParser('kssselectors', { - "'": 'new kukit.kssp.StringInSelector(this.cursor, kukit.kssp.quote)', - '"': 'new kukit.kssp.String2InSelector(this.cursor, kukit.kssp.dquote)', - ",": 'new kukit.kssp.comma(this.cursor)', - "{": 'this.emitAndReturn()', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' + "'": function(parser) { + return new kssp.StringInSelector(parser.cursor, kssp.quote) + }, + '"': function(parser) { + return new kssp.String2InSelector(parser.cursor, kssp.dquote) + }, + ",": _mkReturnToken(kssp.comma), + "{": _emitAndReturn, + "\/\*": _returnComment }, _KssSelectors ); @@ -806,7 +856,7 @@ this.emitError(kukit.E); } } break; - case kukit.kssp.Comment.prototype.symbol: { + case kssp.Comment.prototype.symbol: { tokenIndex -= 1; } break; default: { @@ -818,9 +868,9 @@ tokenIndex -= 2; if (tokenIndex < 0 || (this.result[tokenIndex+2].symbol != - kukit.kssp.EventValue.prototype.symbol) + kssp.EventValue.prototype.symbol) || (this.result[tokenIndex+1].symbol != - kukit.kssp.colon.prototype.symbol) + kssp.colon.prototype.symbol) || (this.result[tokenIndex].symbol != kukit.tk.Fraction.prototype.symbol)) { ;;; kukit.E = 'Wrong event selector : missing event qualifier '; @@ -899,10 +949,12 @@ }; kssp.KssSelector = kukit.tk.mkParser('kssselector', { - ":": '[new kukit.kssp.colon(this.cursor), new ' + - 'kukit.kssp.EventValue(this.cursor)]', - "{": 'this.emitAndReturn()', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' + ":": function(parser) { + return [new kssp.colon(parser.cursor), + new kssp.EventValue(parser.cursor)] + }, + "{": _emitAndReturn, + "\/\*": _returnComment }, _KssSelector ); @@ -933,7 +985,7 @@ ;;; try { //Build a parser and parse the text into it var cursor = new kukit.tk.Cursor(this.txt); - var parser = new kukit.kssp.Document(cursor, null, true); + var parser = new kssp.Document(cursor, null, true); // Store event rules in the common list for (var i=0; i Author: reebalazs Date: Fri Dec 28 12:16:47 2007 New Revision: 50148 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/docs/HISTORY.txt kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/binderids/binderids.kss Log: Modify the binderids test a bit, give a second parameter to kssAttr that is triggering a problem fixed on the branch. The issue is also tested from ecma, so this is not critical, just safer this way. Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/docs/HISTORY.txt Fri Dec 28 12:16:47 2007 @@ -5,12 +5,17 @@ kss.core - 1.4dev Unreleased - ... - - - Add service layers. Refactor plugin binding. + + - Add a general registry for interfaces. + + Add service layers. Refactor event binding and registries. - refactor processBindingEvents to make it iterate + Move event, action, command, selector, valueprovider + plugin registries into the interfaces registry, + + Refactor processBindingEvents to make it iterate on the binding sequence in a more efficient way. Eliminate namespaces from refactored code. @@ -31,6 +36,11 @@ This may break third party plugin code that reuses unpublished internals from plugins.js. (Most particularly, the more_selectors demo needed to be updated as well.) + + Fix the issue that happened with value providers used for getting + the event binder id, + e.g. #div:click(kssAttr(blah, true) got wrongfully cut into + two places and considered as two broken selectors. [ree] - Fix multiple selection form fields Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/binderids/binderids.kss ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/binderids/binderids.kss (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/binderids/binderids.kss Fri Dec 28 12:16:47 2007 @@ -13,7 +13,7 @@ alert-message: "manual2"; } -.buttons.bindable_by_parm:click(kssAttr(binderid)) { +.buttons.bindable_by_parm:click(kssAttr(binderid, false)) { action-client: alert; alert-message: kssAttr(binderid); } From reebalazs at codespeak.net Fri Dec 28 12:41:03 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:41:03 +0100 (CET) Subject: [KSS-checkins] r50149 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071228114103.998A8168487@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:41:02 2007 New Revision: 50149 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js Log: Base value providers on registry. Also clean the parameter evaluation a bit, now all values incl. text are always wrapped. - in progress... Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Fri Dec 28 12:41:02 2007 @@ -206,6 +206,11 @@ ;;; return setErrorInfo(e, 'EventSetupError', message); ;;; }; +;;; err.valueProviderError = function(e, message){ +;;; var message = 'Error checking value provider'; +;;; return setErrorInfo(e, 'ValueProviderError', message); +;;; }; + // any error that happens because the required information // cannot be found in the plugin Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Fri Dec 28 12:41:02 2007 @@ -429,7 +429,7 @@ // Annotate the bind key on the binder instance // the bind key consists of the (generated) classname, and the kss id // of the binder. - binder.__bindKey__ = kssSelector.getBindKey(); + binder.__bindKey__ = key; } return binderInfo; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js Fri Dec 28 12:41:02 2007 @@ -305,11 +305,12 @@ // fieldUpdateRegistry is a public service, available to all components // that want to be notified when kss wants to use a field value. this.fieldUpdateRegistry = new _FieldUpdateRegistry(); - + // Registry of the pprovider functions for kssSubmitForm -fo.pproviderFormRegistry = new kukit.pr.ValueProviderRegistry(); +fo.pproviderFormRegistry = new kukit.pr.ValueProviderRegistry( + kukit.interfaces.global.get('formproviders', kukit.interfaces.PluginMethodDescriptor)); // form, currentForm will provide identical functions to those // in normal parameters Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 12:41:02 2007 @@ -67,12 +67,11 @@ this.name = name; this.finalized = false; this.registry = {}; - this.klass; this.MethodDescriptor = MethodDescriptor; this.getMethodDescriptor = function(methodName) { // assert prohibited names - if (methodName == 'Interfaces' || methodName.substr(0, 3) == 'get' || methodName == '_interface') { + if (methodName == 'get' || methodName == 'registry') { ;;; kukit.E = 'Method name "' + methodName + '" is prohibited, in interface ['; ;;; kukit.E += this.name + ']'; throw new Error(kukit.E); @@ -151,6 +150,12 @@ this.registry = {}; this.get = function(name, MethodDescriptor) { +;;; // Check for missing parameter; this will cause an error later anyway. +;;; if (! MethodDescriptor) { +;;; kukit.E = 'NamedInterfaces.get is called for interface ['; +;;; kukit.E += name + '] without a MethodDescriptor parameter.'; +;;; throw new Error(kukit.E); +;;; } // create the descriptor on demand var interfaceDescriptor; interfaceDescriptor = this.registry[name]; @@ -388,6 +393,8 @@ this.global.get('binditerations', this.BindIterationDescriptor).finalize({}); // this is not strictly necessary, as we don't get as far as execution this.global.get('actions', this.PluginMethodDescriptor).finalize({}); + this.global.get('valueproviders', this.PluginMethodDescriptor).finalize({}); + this.global.get('selectors', this.PluginMethodDescriptor).finalize({}); }; this.cleanRoomTearDown = function(suite) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:41:02 2007 @@ -266,10 +266,10 @@ } kukit.kssp.Block.prototype.addActionParameter = function(action, key, value) { - var ppRegistries = { - '': kukit.pprovidersGlobalRegistry, - 'kssSelector': kukit.sr.pproviderSelRegistry, - 'kssSubmitForm': kukit.fo.pproviderFormRegistry + var interfaceForAction = { + '': kukit.interfaces.global.valueproviders, + 'kssSelector': kukit.interfaces.global.selectorproviders, + 'kssSubmitForm': kukit.interfaces.global.formproviders }; // -: @@ -283,19 +283,20 @@ // (from check). // // Figure out which registry to use. - var registry = ppRegistries[key]; - if (typeof(registry) == 'undefined') { - // use default pproviders - registry = ppRegistries['']; + var iface = interfaceForAction[key]; + if (typeof(iface) == 'undefined') { + // for all other actions: + // use default value pproviders + iface = interfaceForAction['']; } // - try { +;;; try { // Check also sets the value provider on the value. - value.check(registry); - } catch(e) { -;;; kukit.E = 'Error in value : ' + e + '.'; - this.emitError(kukit.E); - } + value.check(iface); +;;; } catch(e) { +;;; kukit.E = 'Error in value provider for parameter [' + key + '].'; +;;; kukit.err.valueProviderError(e, kukit.E); +;;; } action.parms[key] = value; } @@ -450,8 +451,8 @@ kukit.kssp.PropValueInMethod.prototype.process = kukit.kssp.PropValue.prototype.process; kukit.kssp.PropValueInMethod.prototype.produceTxt = function(txt) { - // txt parms are returned unwrapped - this.txt = txt; + // txt parms are returned embedded + this.value = new kukit.rd.KssTextValue(txt); }; /* @@ -490,7 +491,12 @@ } else if (this.notInTokens(context, kukit.kssp.openParent)) { this.expectToken(context, kukit.kssp.openParent); this.expectToken(context, kukit.kssp.PropValue); - this.value = new kukit.rd.KssEventValue(txt, context.token.value); + // Create the event binder id + // as a method value with a single parameter + // to be evaluated later + // At this moment context.token.value contains an object with + // check and evaluate methods. + this.value = new kukit.rd.KssMethodValue(txt, [context.token.value]); this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); // we have to be at the end and have no text after if (context.txt) { @@ -524,7 +530,7 @@ kukit.kssp.EventValue.prototype.produceTxt = function(txt) { // txt parms are returned embedded - this.value = new kukit.rd.KssEventValue(txt, null); + this.value = new kukit.rd.KssTextValue(txt); }; /* @@ -631,19 +637,14 @@ this.emitError(kukit.E); } } - var valueClass; - var args; var providedValue; if (this.notInTokens(context, kukit.kssp.MethodArgs)){ this.expectToken(context, kukit.kssp.MethodArgs); - valueClass = kukit.rd.KssMethodValue; - args = context.token.args; + var valueClass = kukit.rd.KssMethodValue; + var args = context.token.args; providedValue = new valueClass(value, args); } else { - // XXX This should be wrapped too ! - //valueClass = kukit.rd.KssTextValue; - //providedValue = new valueClass(value); - providedValue = value; + providedValue = new kukit.rd.KssTextValue(value); } this.args.push(providedValue); if (context.nextTokenIndex == this.result.length-1) break; @@ -759,9 +760,10 @@ ;;; kukit.E += ' space before the colon.'; this.emitError(kukit.E); } - if (! pseudotoken.value.methodName) { + if ((! pseudotoken.value.isMethod && ! pseudotoken.value.txt) || + (pseudotoken.value.isMethod && ! pseudotoken.value.methodName)) { ;;; kukit.E = 'Wrong event selector :'; -;;; kukit.E += ' event name cannot have spaces.'; +;;; kukit.E += ' event name must exist.'; this.emitError(kukit.E); } css = this.cursor.text.substring(this.startpos, commatoken.startpos); @@ -776,26 +778,40 @@ // just store the single word, in case of event selectors css = singleword; } + // XXX The interfaces for the selector can be taken from a given interface + // registry. We use kukit.interfaces now which will make it operate on + // the global registry. (This value is also passed to the KssSelector + // upon its creation.) + var interfaces = kukit.interfaces.global; // create the selector. var id = null; var ppid = null; - if (pseudotoken.value.arg) { - // We have something in the parentheses after the event name. - if (pseudotoken.value.arg.isMethod) { - // we have a param provider here. Just store. - ppid = pseudotoken.value.arg; - // Check its syntax too. - ppid.check(kukit.pprovidersGlobalRegistry); + // Process the pseudotoken + // it is like: click(1) or sdnd-drag(kssAttr(poolid)) + var eventName; + if (pseudotoken.value.isMethod) { + eventName = pseudotoken.value.methodName; + var args = pseudotoken.value.args; + // XXX TODO check that there is only 1 arg? Should already be checked. + var arg = args[0]; + // Check it in every case. + // always check as value provider + arg.check(interfaces.valueproviders); + if (arg.isMethod) { + // store it as ppid + ppid = arg; } else { // just an id. Express in txt. - id = pseudotoken.value.arg.txt; + id = arg.txt; } + } else { + eventName = pseudotoken.value.txt; } + // // XXX We really don't use the name and the namespace // separated here, so the following code could be removed // and multi-level namespaces would be supported. - var origName = pseudotoken.value.methodName; - var name = origName; + var name = eventName; var splitname = name.split('-'); var namespace = null; if (splitname.length > 2) { @@ -807,13 +823,9 @@ name = splitname[1]; namespace = splitname[0]; } - // XXX The interfaces for the selector can be taken from a given interface - // registry. We use kukit.interfaces now which will make it operate on - // the global registry. - var interfaces = kukit.interfaces.global; // Protect the error for better logging ;;; try { - this.kssSelector = new kukit.rd.KssSelector(isEvent, css, origName, + this.kssSelector = new kukit.rd.KssSelector(isEvent, css, eventName, id, ppid, interfaces); ;;; } catch(e) { ;;; if (e.name == 'KssSelectorError' || e.name == 'PluginRegistryError') { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Fri Dec 28 12:41:02 2007 @@ -246,6 +246,9 @@ interfaces.get('events', kukit.interfaces.PluginMethodDescriptor).finalize({}); interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor).finalize({}); interfaces.get('actions', kukit.interfaces.PluginMethodDescriptor).finalize({}); + interfaces.get('valueproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); + interfaces.get('formproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); + interfaces.get('selectorproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); ;;; kukit.log('All interfaces finalized.'); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js Fri Dec 28 12:41:02 2007 @@ -25,8 +25,8 @@ * The parameter providers need to be registered here. */ -kukit.pr.ValueProviderRegistry = function () { - this.content = {}; +kukit.pr.ValueProviderRegistry = function (iface) { + this.iface = iface; }; kukit.pr.ValueProviderRegistry.prototype.register = function(name, func) { @@ -35,37 +35,12 @@ ;;; kukit.E += ' provider [ValueProviderRegistry.register].'; throw new Error(kukit.E); } -;;; if (this.content[name]) { -;;; // Do not allow redefinition -;;; var msg = 'Error : parameter provider [' + name; -;;; msg += '] already registered.'; -;;; kukit.logError(msg); -;;; return; -;;; } - this.content[name] = func; -}; - -kukit.pr.ValueProviderRegistry.prototype.exists = function(name) { - var entry = this.content[name]; - return (typeof(entry) != 'undefined'); -}; - -kukit.pr.ValueProviderRegistry.prototype.get = function(name) { - var func = this.content[name]; - if (! func) { - // not found - if (name == '') { - // default provider for the strings - return kukit.pr.IdentityPP; - } else { -;;; kukit.E = 'Error : undefined parameter provider [' + name + '].'; - throw new Error(kukit.E); - } - } - return func; + var descriptor = this.iface.getMethodDescriptor(name); + descriptor.register(func); }; -kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry(); +kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry( + kukit.interfaces.global.get('valueproviders', kukit.interfaces.PluginMethodDescriptor)); /* * Register the core parameter providers @@ -210,12 +185,6 @@ ;;; kukit.E += ' [recurseParents]).'; ;;; throw new Error(kukit.E); ;;; } -;;; if (args[0].toLowerCase() == 'style') { -;;; throw new Error('nodeAttr method does not accept [style] as attrname.'); -;;; } -;;; if (args[0].match(/[ ]/)) { -;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); -;;; } }, eval: function(args, node) { var argname = args[0]; @@ -225,6 +194,14 @@ ;;; kukit.E = '2nd attribute of nodeAttr must be a boolean.'; kukit.ut.evalBool(recurseParents, kukit.E); } + if (args[0].toLowerCase() == 'style') { +;;; kukit.E = 'nodeAttr method does not accept [style] as attrname.'; + throw new Error(kukit.E); + } + if (args[0].match(/[ ]/)) { +;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); + throw new Error(kukit.E); + } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getAttribute); } @@ -239,11 +216,6 @@ ;;; kukit.E += ' [recurseParents]).'; ;;; throw new Error(kukit.E); ;;; } -;;; if (args[0].match(/[ -]/)) { -;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; -;;; kukit.E += ' dashes or spaces.'; -;;; throw new Error(kukit.E); -;;; } }, eval: function(args, node) { var argname = args[0]; @@ -253,6 +225,11 @@ ;;; kukit.E = '2nd attribute of kssAttr must be a boolean.'; kukit.ut.evalBool(recurseParents, kukit.E); } + if (args[0].match(/[ -]/)) { +;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; +;;; kukit.E += ' dashes or spaces.'; + throw new Error(kukit.E); + } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getKssAttribute); } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Fri Dec 28 12:41:02 2007 @@ -44,10 +44,6 @@ ;;; var msg = 'Kss selector must have a name.'; ;;; throw kukit.err.kssSelectorError(msg); ;;; } -;;; if (name.indexOf('@') != -1) { -;;; var msg = 'Kss selector name must not contain @: [' + name + '].'; -;;; throw kukit.err.kssSelectorError(msg); -;;; } ;;; if (! isEvent) { ;;; // method rule ;;; if (css != 'document' && css != 'behaviour') { @@ -138,7 +134,7 @@ return this.id; } else { // Evaluate it. - var id = this.ppid.pprovider.eval(this.ppid.args, node, {}); + var id = this.ppid.evaluate(node, {}); // check that the id is not empty or null! if (! id) { ;;; kukit.E = 'Did not get a valid state id, when evaluated'; @@ -227,9 +223,9 @@ kukit.rd.KssTextValue.prototype.isMethod = false; -kukit.rd.KssTextValue.prototype.check = function(registry) { +kukit.rd.KssTextValue.prototype.check = function(iface) { // use the IdentityPP provider. - this.pprovider = new (registry.get(''))(); + this.pprovider = new (iface[''])(); }; kukit.rd.KssTextValue.prototype.evaluate = @@ -241,7 +237,7 @@ }; /* -* class KssTextValue +* class KssMethodValue */ kukit.rd.KssMethodValue = function(methodName, args) { // A method parameter in the format @@ -252,60 +248,38 @@ kukit.rd.KssMethodValue.prototype.isMethod = true; -kukit.rd.KssMethodValue.prototype.check = function(registry) { +kukit.rd.KssMethodValue.prototype.check = function(iface) { // Check syntax - var f = registry.get(this.methodName); + var f = iface[this.methodName]; + // XXX TODO not found error? this.pprovider = new f(); + // Check the providers, this will give diagnostics errors + // in case something is wrong with the parameters. + // Checking is also needed in production mode. + // XXX We use global interfaces + var interfaces = kukit.interfaces.global; + var valueproviders = interfaces.valueproviders; for(i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO - var arg = this.args[i]; - if(arg.check){ - // With the recursion we always use the global - // provider registry - arg.check(kukit.pprovidersGlobalRegistry); - } + // With the recursion we always use the + // value provider registry from the same interfaces + this.args[i].check(valueproviders); } +;;; // Checking of the value provider itself (nr of args) ;;; this.pprovider.check(this.args); }; kukit.rd.KssMethodValue.prototype.evaluate = function(node, defaultParameters) { - // First recursivly evaluate all arguments + // First recursively evaluate all arguments var newArgs = []; for(var i=0; i < this.args.length; i++){ - // XXX We treat text values separetly because - // they are now currently wrapped as KssTextValue - // (as they should). TODO var arg = this.args[i]; - if(arg.evaluate){ - newArgs.push(arg.evaluate(node, defaultParameters)); - } else { - newArgs.push(arg); - } + newArgs.push(arg.evaluate(node, defaultParameters)); } // return the value return this.pprovider.eval(newArgs, node, defaultParameters); }; -/* -* class KssEventValue -*/ -kukit.rd.KssEventValue = function(methodName, arg) { - // A method parameter in the format - // methodname(v1) - // can be also: - // methodname(methodname2(v2)) - // in both cases, arg is KssTextValue, or KssMethodValue - this.methodName = methodName; - this.arg = arg; -}; - -kukit.rd.KssEventValue.prototype.isMethod = true; - -kukit.rd.KssEventValue.prototype.check = function() { -}; kukit.rd.EventRuleNr = 0; // just a counter Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js Fri Dec 28 12:41:02 2007 @@ -21,7 +21,8 @@ // Registry of the pprovider functions for selecting -kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry(); +kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry( + kukit.interfaces.global.get('selectorproviders', kukit.interfaces.PluginMethodDescriptor)); // XXX XXX XXX // this will provide an arbitrary selector, and is designed to @@ -92,9 +93,12 @@ kukit.sr.SelectorTypeRegistry.prototype.defaultSelectorType = 'css'; kukit.sr.SelectorTypeRegistry.prototype.register = function(name, func) { - if (typeof(func) == 'undefined') { - throw new Error('Func is mandatory.'); - } +;;; // Check func parameter: diagnostics only, as this will cause +;;; // an error later anyway. +;;; if (typeof(func) == 'undefined') { +;;; kukit.E = 'Func is mandatory in SelectorTypeRegistry.register.'; +;;; throw new Error(kukit.E); +;;; } ;;; if (this.mapping[name]) { ;;; // Do not allow redefinition ;;; kukit.logError('Error : redefinition attempt of selector ' + name); From reebalazs at codespeak.net Fri Dec 28 12:41:08 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:41:08 +0100 (CET) Subject: [KSS-checkins] r50150 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114108.CB6661684CE@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:41:08 2007 New Revision: 50150 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Fix tests to fullow changes during the simplification of the text values. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Fri Dec 28 12:41:08 2007 @@ -201,13 +201,12 @@ ;;; }; -;;; err.eventSetupError = function(e, message){ +;;; err.eventSetupError = function(e){ ;;; var message = 'Error setting up events'; ;;; return setErrorInfo(e, 'EventSetupError', message); ;;; }; ;;; err.valueProviderError = function(e, message){ -;;; var message = 'Error checking value provider'; ;;; return setErrorInfo(e, 'ValueProviderError', message); ;;; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/forms.js Fri Dec 28 12:41:08 2007 @@ -309,8 +309,7 @@ // Registry of the pprovider functions for kssSubmitForm -fo.pproviderFormRegistry = new kukit.pr.ValueProviderRegistry( - kukit.interfaces.global.get('formproviders', kukit.interfaces.PluginMethodDescriptor)); +fo.pproviderFormRegistry = new kukit.pr.ValueProviderRegistry('formproviders'); // form, currentForm will provide identical functions to those // in normal parameters Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 12:41:08 2007 @@ -393,8 +393,9 @@ this.global.get('binditerations', this.BindIterationDescriptor).finalize({}); // this is not strictly necessary, as we don't get as far as execution this.global.get('actions', this.PluginMethodDescriptor).finalize({}); + this.global.get('formproviders', this.PluginMethodDescriptor).finalize({}); this.global.get('valueproviders', this.PluginMethodDescriptor).finalize({}); - this.global.get('selectors', this.PluginMethodDescriptor).finalize({}); + this.global.get('selectorproviders', this.PluginMethodDescriptor).finalize({}); }; this.cleanRoomTearDown = function(suite) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:41:08 2007 @@ -286,7 +286,7 @@ var iface = interfaceForAction[key]; if (typeof(iface) == 'undefined') { // for all other actions: - // use default value pproviders + // use default value providers iface = interfaceForAction['']; } // @@ -295,7 +295,7 @@ value.check(iface); ;;; } catch(e) { ;;; kukit.E = 'Error in value provider for parameter [' + key + '].'; -;;; kukit.err.valueProviderError(e, kukit.E); +;;; throw kukit.err.valueProviderError(e, kukit.E); ;;; } action.parms[key] = value; } @@ -476,7 +476,7 @@ // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - this.txt = ''; + //this.txt = ''; var txt = context.txt; if (this.notInTokens(context, kukit.kssp.String)) { // The previous txt must be all whitespace. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js Fri Dec 28 12:41:08 2007 @@ -25,8 +25,8 @@ * The parameter providers need to be registered here. */ -kukit.pr.ValueProviderRegistry = function (iface) { - this.iface = iface; +kukit.pr.ValueProviderRegistry = function (name) { + this.name = name }; kukit.pr.ValueProviderRegistry.prototype.register = function(name, func) { @@ -35,12 +35,14 @@ ;;; kukit.E += ' provider [ValueProviderRegistry.register].'; throw new Error(kukit.E); } - var descriptor = this.iface.getMethodDescriptor(name); + // Always use the global interfaces to get the descriptor. + var iface = kukit.interfaces.global.get(this.name, + kukit.interfaces.PluginMethodDescriptor); + var descriptor = iface.getMethodDescriptor(name); descriptor.register(func); }; -kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry( - kukit.interfaces.global.get('valueproviders', kukit.interfaces.PluginMethodDescriptor)); +kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry('valueproviders'); /* * Register the core parameter providers Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Fri Dec 28 12:41:08 2007 @@ -251,9 +251,15 @@ kukit.rd.KssMethodValue.prototype.check = function(iface) { // Check syntax var f = iface[this.methodName]; - // XXX TODO not found error? + // Check if the method name really existed. + if (! f) { +;;; kukit.E = 'Undefined value provider ['; +;;; kukit.E += this.methodName + ']'; + throw new Error(kukit.E); + } + // Create the provider checker and evaluator object this.pprovider = new f(); - // Check the providers, this will give diagnostics errors + // Check the providers, this will give errors // in case something is wrong with the parameters. // Checking is also needed in production mode. // XXX We use global interfaces Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js Fri Dec 28 12:41:08 2007 @@ -21,8 +21,8 @@ // Registry of the pprovider functions for selecting -kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry( - kukit.interfaces.global.get('selectorproviders', kukit.interfaces.PluginMethodDescriptor)); // XXX XXX XXX +// XXX XXX XXX TODO factor this with selector reg +kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry('selectorproviders'); // this will provide an arbitrary selector, and is designed to Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 12:41:08 2007 @@ -24,9 +24,15 @@ kukit.KssParserTestCaseBase = function() { this.setUp = function() { - // create a clean room interface registry kukit.interfaces.cleanRoomSetUp(this); - // add my events + // + // XXX Important remark when you extend the setup + // + // The tests test at numerous occasion a non-existent + // event, so be careful when you add a new one. + // create a clean room interface registry + // + // Add somw events kukit.eventsGlobalRegistry.register('dnd', 'drag', kukit.pl.NativeEventBinder, null, null); kukit.eventsGlobalRegistry.register(null, 'click', @@ -39,8 +45,19 @@ kukit.pl.NativeEventBinder, null, null); kukit.eventsGlobalRegistry.register(null, 'keydown', kukit.pl.NativeEventBinder, null, null); - // XXX the tests test at numerous occasion a non-existent - // event, so be careful when you add a new one. + // + // Create the identity value provider, this is needed + // at least to evaluate strings. + kukit.pprovidersGlobalRegistry.register('', kukit.pr.IdentityPP); + // Create other value providers + kukit.pprovidersGlobalRegistry.register('kssAttr', kukit.pr.KssAttrPP); + kukit.pprovidersGlobalRegistry.register('formVar', kukit.pr.FormVarPP); + kukit.pprovidersGlobalRegistry.register('nodeAttr', kukit.pr.NodeAttrPP); + // + //Create some selectors + //XXX this is temporary untul the selectors registry is finished + kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP); + kukit.sr.pproviderSelRegistry.register('htmlid', kukit.sr.AnyPP); // // finalize the interfaces we just set up kukit.interfaces.cleanRoomFinalize(this); @@ -94,31 +111,31 @@ var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'apple'); + this.assertEquals(parser.value.txt, 'apple'); txt= "'a string';"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); + this.assertEquals(parser.value.txt, 'a string'); txt= '"a string";'; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); + this.assertEquals(parser.value.txt, 'a string'); txt= '"a \\"string";'; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a "string'); + this.assertEquals(parser.value.txt, 'a "string'); txt= " /* valid */ 'a string' /* here*/ /*and*/ /*there*/;"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); + this.assertEquals(parser.value.txt, 'a string'); txt= " in /* valid */ 'a string';"; cursor = new kukit.tk.Cursor(txt); @@ -154,7 +171,7 @@ cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.PropValueInMethod(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'b c'); + this.assertEquals(parser.value.txt, 'b c'); this.assertEquals(parser.parms, null); // Not ok @@ -210,7 +227,9 @@ this.assertEquals(parser.finished, true); this.assertEquals(parser.value.isMethod, true); this.assertEquals(parser.value.methodName, 'formVar'); - this.assertListEquals(parser.value.args, ['x', 'y']); + this.assertEquals(parser.value.args.length, 2); + this.assertEquals(parser.value.args[0].txt, 'x'); + this.assertEquals(parser.value.args[1].txt, 'y'); // params ok txt= "formVar(x, y)"; @@ -219,7 +238,9 @@ this.assertEquals(parser.finished, true); this.assertEquals(parser.value.isMethod, true); this.assertEquals(parser.value.methodName, 'formVar'); - this.assertListEquals(parser.value.args, ['x', 'y']); + this.assertEquals(parser.value.args.length, 2); + this.assertEquals(parser.value.args[0].txt, 'x'); + this.assertEquals(parser.value.args[1].txt, 'y'); //ok txt= " formVar (x, y)"; @@ -228,7 +249,9 @@ this.assertEquals(parser.finished, true); this.assertEquals(parser.value.isMethod, true); this.assertEquals(parser.value.methodName, 'formVar'); - this.assertListEquals(parser.value.args, ['x', 'y']); + this.assertEquals(parser.value.args.length, 2); + this.assertEquals(parser.value.args[0].txt, 'x'); + this.assertEquals(parser.value.args[1].txt, 'y'); txt= " a formVar(x, y)"; cursor = new kukit.tk.Cursor(txt); @@ -252,7 +275,8 @@ var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); - this.assertEquals(parser.value.methodName, 'b'); + this.assertEquals(parser.value.isMethod, false); + this.assertEquals(parser.value.txt, 'b'); }; this.testEventValueMultiword = function() { @@ -262,7 +286,8 @@ var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); this.assertEquals(cursor.pos, 1); - this.assertEquals(parser.value.methodName, 'b'); + this.assertEquals(parser.value.isMethod, false); + this.assertEquals(parser.value.txt, 'b'); }; this.testEventValueStartsWithSpace = function() { @@ -272,7 +297,8 @@ var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); this.assertEquals(cursor.pos, 0); - this.assertEquals(parser.value.methodName, ''); + this.assertEquals(parser.value.isMethod, false); + this.assertEquals(parser.value.txt, ''); }; this.testEventValueWithComment = function() { @@ -282,7 +308,8 @@ var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); this.assertEquals(cursor.pos, 6); - this.assertEquals(parser.value.methodName, 'apples'); + this.assertEquals(parser.value.isMethod, false); + this.assertEquals(parser.value.txt, 'apples'); }; this.testEventValueWithBinderId = function() { @@ -291,9 +318,11 @@ var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); + this.assertEquals(parser.value.isMethod, true); this.assertEquals(parser.value.methodName, 'click'); - this.assertEquals(parser.value.arg.isMethod, false); - this.assertEquals(parser.value.arg.txt, 'x'); + this.assertEquals(parser.value.args.length, 1); + this.assertEquals(parser.value.args[0].isMethod, false); + this.assertEquals(parser.value.args[0].txt, 'x'); // more then 1 args not ok (but we check it only from kss selector) //txt= "drag(x, y)"; @@ -312,10 +341,14 @@ var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.EventValue(cursor, null, true); this.assertEquals(parser.finished, true); + this.assertEquals(parser.value.isMethod, true); this.assertEquals(parser.value.methodName, 'click'); - this.assertEquals(parser.value.arg.isMethod, true); - this.assertEquals(parser.value.arg.methodName, 'kssAttr'); - this.assertListEquals(parser.value.arg.args, ['x']); + this.assertEquals(parser.value.args.length, 1); + this.assertEquals(parser.value.args[0].isMethod, true); + this.assertEquals(parser.value.args[0].methodName, 'kssAttr'); + this.assertEquals(parser.value.args[0].args.length, 1); + this.assertEquals(parser.value.args[0].args[0].isMethod, false); + this.assertEquals(parser.value.args[0].args[0].txt, 'x'); }; this.testEventValueWithValueProviderRejectsAccessValues = function() { @@ -334,31 +367,41 @@ var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); - this.assertListEquals(parser.args, ['a', 'b']); + this.assertEquals(parser.args.length, 2); + this.assertEquals(parser.args[0].txt, 'a'); + this.assertEquals(parser.args[1].txt, 'b'); txt= "('a', /* to annoy you */ \"b\")"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); - this.assertListEquals(parser.args, ['a', 'b']); + this.assertEquals(parser.args.length, 2); + this.assertEquals(parser.args[0].txt, 'a'); + this.assertEquals(parser.args[1].txt, 'b'); txt= "(' a multi', /* to annoy you */ \"b multi \")"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); - this.assertListEquals(parser.args, [' a multi','b multi ']); + this.assertEquals(parser.args.length, 2); + this.assertEquals(parser.args[0].txt, ' a multi'); + this.assertEquals(parser.args[1].txt, 'b multi '); txt= "('a', /*comment*/ /* to annoy you */ \"b\")"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); - this.assertListEquals(parser.args, ['a', 'b']); + this.assertEquals(parser.args.length, 2); + this.assertEquals(parser.args[0].txt, 'a'); + this.assertEquals(parser.args[1].txt, 'b'); txt= "(a, b, )"; cursor = new kukit.tk.Cursor(txt); parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); - this.assertListEquals(parser.args, ['a', 'b']); + this.assertEquals(parser.args.length, 2); + this.assertEquals(parser.args[0].txt, 'a'); + this.assertEquals(parser.args[1].txt, 'b'); txt= "(a, b c )"; cursor = new kukit.tk.Cursor(txt); @@ -378,10 +421,13 @@ var parser = new kukit.kssp.MethodArgs(cursor, kukit.kssp.openParent, true); this.assertEquals(parser.finished, true); this.assertEquals(parser.args.length, 2); - this.assertEquals(parser.args[0], 'a'); + this.assertEquals(parser.args[0].isMethod, false); + this.assertEquals(parser.args[0].txt, 'a'); this.assertEquals(parser.args[1].isMethod, true); this.assertEquals(parser.args[1].methodName, 'b'); - this.assertListEquals(parser.args[1].args, ['c', 'd']); + this.assertEquals(parser.args[1].args.length, 2); + this.assertEquals(parser.args[1].args[0].txt, 'c'); + this.assertEquals(parser.args[1].args[1].txt, 'd'); }; this.testEmptyDoc = function() { @@ -544,7 +590,9 @@ this.assertEquals(action.name, 'kukitGetPreviousMonth'); this.assertEquals(action.error, null); this.assertKssParmEquals(action.parms, { - 'member': new kukit.rd.KssMethodValue('formVar', ['edit', 'f_member']) + 'member': new kukit.rd.KssMethodValue('formVar', + [new kukit.rd.KssTextValue('edit'), + new kukit.rd.KssTextValue('f_member')]) }); // rule 4 @@ -580,7 +628,8 @@ this.assertEquals(action.name, 'clickedButton'); this.assertEquals(action.error, null); this.assertKssParmEquals(action.parms, { - 'id': new kukit.rd.KssMethodValue('nodeAttr', ['id']) + 'id': new kukit.rd.KssMethodValue('nodeAttr', + [new kukit.rd.KssTextValue('f_member')]) }); // rule 6 @@ -682,7 +731,8 @@ this.assertKssParmEquals(action.parms, { 'name': new kukit.rd.KssTextValue('backgroundColor'), 'value': new kukit.rd.KssTextValue('#FFa0a0'), - 'kssSelector': new kukit.rd.KssMethodValue('htmlid', ['button_2']) + 'kssSelector': new kukit.rd.KssMethodValue('htmlid', + [new kukit.rd.KssTextValue('button_2')]) }); // rule 11 @@ -724,10 +774,15 @@ this.assertEquals(action.error, null); var formVar = action.parms.member; this.assertEquals(formVar.methodName, 'formVar'); - this.assertEquals(formVar.args[0], 'edit'); + this.assertEquals(formVar.args.length, 2); + this.assertEquals(formVar.args[0].isMethod, false); + this.assertEquals(formVar.args[0].txt, 'edit'); var kssAttr = formVar.args[1]; + this.assertEquals(kssAttr.isMethod, true); this.assertEquals(kssAttr.methodName, 'kssAttr'); - this.assertListEquals(kssAttr.args, ['foo']); + this.assertEquals(kssAttr.args.length, 1); + this.assertEquals(kssAttr.args[0].isMethod, false); + this.assertEquals(kssAttr.args[0].txt, 'foo'); // rule 13 // #button-one:click(kssAttr(widannoy)) {\n" @@ -740,7 +795,8 @@ this.assertEquals(rule.kssSelector.name, 'click'); this.assertEquals(rule.kssSelector.id, null); this.assertEquals(rule.kssSelector.ppid.methodName, 'kssAttr'); - this.assertListEquals(rule.kssSelector.ppid.args, ['widannoy']); + this.assertEquals(rule.kssSelector.ppid.args.length, 1); + this.assertEquals(rule.kssSelector.ppid.args[0].txt, 'widannoy'); action = rule.actions.content['alert']; this.assertEquals(action.type, 'C'); this.assertEquals(action.name, 'alert'); @@ -1045,7 +1101,7 @@ txt= "document: "; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Wrong event selector : event name cannot have spaces.', 10); + 'Wrong event selector : event name must exist.', 10); // also, "behaviour:" works txt= " behaviour:click(hello) "; @@ -1413,7 +1469,8 @@ this.assertEquals(parser.kssSelector.name, 'click'); this.assertEquals(parser.kssSelector.id, null); this.assertEquals(parser.kssSelector.ppid.methodName, 'kssAttr'); - this.assertListEquals(parser.kssSelector.ppid.args, ['hello']); + this.assertEquals(parser.kssSelector.ppid.args.length, 1); + this.assertEquals(parser.kssSelector.ppid.args[0].txt, 'hello'); }; this.testValueProvidersInEventIdentification2 = function() { @@ -1426,7 +1483,9 @@ this.assertEquals(parser.kssSelector.name, 'click'); this.assertEquals(parser.kssSelector.id, null); this.assertEquals(parser.kssSelector.ppid.methodName, 'kssAttr'); - this.assertListEquals(parser.kssSelector.ppid.args, ['hello', 'true']); + this.assertEquals(parser.kssSelector.ppid.args.length, 2); + this.assertEquals(parser.kssSelector.ppid.args[0].txt, 'hello'); + this.assertEquals(parser.kssSelector.ppid.args[1].txt, 'true'); }; this.testValueProvidersInEventIdentificationRejectsMoreParameters = function() { From reebalazs at codespeak.net Fri Dec 28 12:41:31 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:41:31 +0100 (CET) Subject: [KSS-checkins] r50151 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114131.69D071684CE@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:41:30 2007 New Revision: 50151 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Fix handling of value provider error during parsing, provide a test that unknown value provider causes error identify an error (Unexpected EOF if there are more parameters of the provider in the binder id identification) provide a test for it. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Fri Dec 28 12:41:30 2007 @@ -148,6 +148,17 @@ ;;; }; +/* + * Exceptions that re-throw (annotate) an already thrown error + * + * These have purpose of adding some more generic explanation to the + * error, as well as adding more information. + * They only should get active in development mode. + * + * e.g. a ParsingError will become, after re-throwing: + * "Error parsing Kss at http://blah [ParsingError: ...]" + */ + // this is raised by the parser in case of errors // it contains row/column information ;;; err.parsingError = function(message, cursor, err){ @@ -165,18 +176,6 @@ ;;; return setErrorInfo(err, 'ParsingError', message, kw); ;;; }; - -/* - * Exceptions that re-throw (annotate) an already thrown error - * - * These have purpose of adding some more generic explanation to the - * error, as well as adding more information. - * They only should get active in development mode. - * - * e.g. a ParsingError will become, after re-throwing: - * "Error parsing Kss at http://blah [ParsingError: ...]" - */ - ;;; err.commandExecutionError = function(e, command){ ;;; var message = 'Command [' + command.name + '] failed'; ;;; return setErrorInfo(e, 'CommandExecutionError', message); @@ -206,11 +205,6 @@ ;;; return setErrorInfo(e, 'EventSetupError', message); ;;; }; -;;; err.valueProviderError = function(e, message){ -;;; return setErrorInfo(e, 'ValueProviderError', message); -;;; }; - - // any error that happens because the required information // cannot be found in the plugin err.pluginRegistryError = function(err, message) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:41:30 2007 @@ -295,7 +295,7 @@ value.check(iface); ;;; } catch(e) { ;;; kukit.E = 'Error in value provider for parameter [' + key + '].'; -;;; throw kukit.err.valueProviderError(e, kukit.E); +;;; this.emitWrappedError(e, kukit.E); ;;; } action.parms[key] = value; } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 12:41:30 2007 @@ -268,7 +268,7 @@ this.assertParsingError(kukit.kssp.PropValue, cursor, null, true, 'Wrong value : unallowed characters after the property.', 17); }; - + this.testEventValueSimple = function() { // Parsing event value var txt= "b"; @@ -806,6 +806,18 @@ }; + this.testValueProviderUnregistered = function() { + // An unregistered value provider + var txt= "" + +"div#update-area:click {\n" + +" action-server: getCurrentTime;\n" + +" getCurrentTime-effect: noSuchProvider(a, b, c); \n" + +"}\n"; + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + 'Error in value provider for parameter [effect].'); + }; + this.testActionErrorParameters = function() { var txt= "" @@ -1505,6 +1517,21 @@ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, 'KssSpecialSelector [behaviour] must not stand with an event id acquired by value provider [kssAttr]'); }; + + this.testValueProvidersInEventIdentificationCanHaveTwoAttributes = function() { + // A value provider can have two attributes. + // Nothing special - it should just work. + var txt= "" + +"div#update-area:click(kssAttr(a, true)) {\n" + +" action-server: getCurrentTime;\n" + +" getCurrentTime-effect: kssAttr; \n" + +"}\n"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + ///this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // 'Error in value provider for parameter [effect].'); + }; }; From reebalazs at codespeak.net Fri Dec 28 12:41:36 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:41:36 +0100 (CET) Subject: [KSS-checkins] r50152 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114136.C74141684D5@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:41:35 2007 New Revision: 50152 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Fix selectors parsing with commas in the middle This caused a problem with value providers for getting the event binder id, like xxx:click(kssAttr(blah, true)) Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:41:35 2007 @@ -651,7 +651,10 @@ this.expectToken(context, kukit.kssp.comma); } this.result = []; - this.txt = ''; + // MethodArgs now also must produce a txt, this is used in embedded + // parsing from KssSelectors. + // Just use the original text. + this.txt = this.cursor.text.slice(this.startpos, this.endpos); }; /* @@ -666,6 +669,8 @@ kukit.kssp.KssSelectors = kukit.tk.mkParser('kssselectors', { "'": 'new kukit.kssp.StringInSelector(this.cursor, kukit.kssp.quote)', '"': 'new kukit.kssp.String2InSelector(this.cursor, kukit.kssp.dquote)', + // XXX Merging hint: next line is new. + "(": 'new kukit.kssp.MethodArgs(this.cursor, kukit.kssp.openParent)', ",": 'new kukit.kssp.comma(this.cursor)', "{": 'this.emitAndReturn()', "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' @@ -675,9 +680,15 @@ // Parse all tokens (including first and last) var context = {'nextTokenIndex': 0}; while (context.nextTokenIndex < this.result.length) { + // All the tokens in which we want to ignore detecting the ',' + // inside, must be digested here. + // We ignore all strings, comments and MethodArgs (a, b, c) this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment, - kukit.kssp.String, kukit.kssp.String2); - var cursor = new kukit.tk.Cursor(context.txt + ' ') + kukit.kssp.String, kukit.kssp.String2, kukit.kssp.MethodArgs); + // We do not take text accumulated in the digest buffer, as + // for MetodArgs, 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 kukit.kssp.KssSelector(cursor, null, true); this.selectors.push(parser.kssSelector); if (context.nextTokenIndex == this.result.length) break; @@ -794,9 +805,15 @@ var args = pseudotoken.value.args; // XXX TODO check that there is only 1 arg? Should already be checked. var arg = args[0]; - // Check it in every case. - // always check as value provider - arg.check(interfaces.valueproviders); +;;; // We annotate the error, to give parsing information to it. +;;; try { + // Check it in every case. + // always check as value provider + arg.check(interfaces.valueproviders); +;;; } catch(e) { +;;; kukit.E = 'Error in value provider for event binder id.'; +;;; this.emitWrappedError(e, kukit.E); +;;; } if (arg.isMethod) { // store it as ppid ppid = arg; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Fri Dec 28 12:41:35 2007 @@ -254,8 +254,8 @@ // Check if the method name really existed. if (! f) { ;;; kukit.E = 'Undefined value provider ['; -;;; kukit.E += this.methodName + ']'; - throw new Error(kukit.E); +;;; kukit.E += this.methodName + '].'; + throw kukit.err.pluginRegistryError(null, kukit.E); } // Create the provider checker and evaluator object this.pprovider = new f(); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/tokenizer.js Fri Dec 28 12:41:35 2007 @@ -135,7 +135,7 @@ }; kukit.tk._ParserBase.prototype.notInTokens = - function(context, token1, token2, token3, token4) { + function(context, token1, token2, token3, token4, token5) { var i = context.nextTokenIndex; var currentValue = this.result[i]; return !( @@ -143,24 +143,25 @@ (this.resultIsNullOrNotToken(token1, currentValue) && this.resultIsNullOrNotToken(token2, currentValue) && this.resultIsNullOrNotToken(token3, currentValue) && - this.resultIsNullOrNotToken(token4, currentValue)) + this.resultIsNullOrNotToken(token4, currentValue) && + this.resultIsNullOrNotToken(token5, currentValue)) ); }; kukit.tk._ParserBase.prototype.digestTxt = - function(context, token1, token2, token3, token4) { + function(context, token1, token2, token3, token4, token5) { // digests the txt from the tokens, ignores given token // plus whitespace removal - this.digestExactTxt(context, token1, token2, token3, token4); + this.digestExactTxt(context, token1, token2, token3, token4, token5); context.txt = this.removeWhitespacesAndTrim(context.txt); }; kukit.tk._ParserBase.prototype.digestExactTxt = - function(context, token1, token2, token3, token4) { + function(context, token1, token2, token3, token4, token5) { // digests the txt from the tokens, ignores given token // exact value: no whitespace removal var result = ''; - while (this.notInTokens(context, token1, token2, token3, token4)) { + while (this.notInTokens(context, token1, token2, token3, token4, token5)) { result += this.result[context.nextTokenIndex].txt; context.nextTokenIndex ++; } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 12:41:35 2007 @@ -351,7 +351,21 @@ this.assertEquals(parser.value.args[0].args[0].txt, 'x'); }; - this.testEventValueWithValueProviderRejectsAccessValues = function() { + this.testEventValueWithValueProvider2 = function() { + // methods ok + var txt= "click(kssAttr(hello, true ))"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.EventValue(cursor, null, true); + }; + + this.testEventValueWithValueProvider3 = function() { + // methods ok + var txt= "click(kssAttr(hello, true ))"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.EventValue(cursor, null, true); + }; + + this.testEventValueWithValueProviderRejectsExcessValues = function() { // no more values in the method var txt= "click(kssAttr(x), aaa)"; var cursor = new kukit.tk.Cursor(txt); @@ -815,7 +829,7 @@ +"}\n"; var cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.Document, cursor, null, true, - 'Error in value provider for parameter [effect].'); + 'Undefined value provider [noSuchProvider].'); }; this.testActionErrorParameters = function() { @@ -1500,6 +1514,13 @@ this.assertEquals(parser.kssSelector.ppid.args[1].txt, 'true'); }; + this.testValueProvidersInEventIdentification3 = function() { + var txt= "a:click(kssAttr(hello, true))"; + var src = new kukit.tk.Cursor(txt); + var src = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.KssSelector(src, null, true); + }; + this.testValueProvidersInEventIdentificationRejectsMoreParameters = function() { var txt= "a:drag(kssAttr(hello), xxx)"; var src = new kukit.tk.Cursor(txt); @@ -1517,22 +1538,46 @@ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, 'KssSpecialSelector [behaviour] must not stand with an event id acquired by value provider [kssAttr]'); }; - + + this.testValueProvidersInEventIdentificationWithCommaInString = function() { + // A value provider can have two attributes. + // The parser must not separate the selector at the comma. + var txt= "" + +"div#update-area:click(',') {\n" + +" action-server: getCurrentTime;\n" + +" getCurrentTime-effect: klah; \n" + +"}\n"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + }; + this.testValueProvidersInEventIdentificationCanHaveTwoAttributes = function() { // A value provider can have two attributes. - // Nothing special - it should just work. + // The parser must not separate the selector at the comma. var txt= "" - +"div#update-area:click(kssAttr(a, true)) {\n" + +"div#update-area:click(kssAttr(hello, true)) {\n" +" action-server: getCurrentTime;\n" - +" getCurrentTime-effect: kssAttr; \n" + +" getCurrentTime-effect: blah; \n" +"}\n"; var cursor = new kukit.tk.Cursor(txt); var parser = new kukit.kssp.Document(cursor, null, true); this.assertEquals(parser.finished, true); - ///this.assertParsingError(kukit.kssp.Document, cursor, null, true, - // 'Error in value provider for parameter [effect].'); }; + this.testValueProvidersInEventIdentificationWithUnregistered = function() { + // A value provider must be registered. + var txt= "" + +"div#update-area:click(unDefinedValueProvider(hello, true)) {\n" + +" action-server: getCurrentTime;\n" + +" getCurrentTime-effect: blah; \n" + +"}\n"; + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + 'Undefined value provider [unDefinedValueProvider].'); + }; + + }; kukit.KssParserSelectorsTestCase.prototype = new kukit.KssParserTestCaseBase; From reebalazs at codespeak.net Fri Dec 28 12:42:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:42:01 +0100 (CET) Subject: [KSS-checkins] r50153 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114201.4779E1684E9@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:42:00 2007 New Revision: 50153 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Fix for the case of zero or more then 1 event binder ids in the kss selector This should be prohibited. There must be a single binder id value. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:42:00 2007 @@ -468,8 +468,9 @@ "\r": 'this.emitAndReturn()', "\/\*": 'this.emitAndReturn()', ":": 'this.emitAndReturn()', - "(": '[new kukit.kssp.openParent(this.cursor), new kukit.kssp.PropValue(this.cursor)]', - ")": 'this.emitAndReturn(new kukit.kssp.closeParent(this.cursor))' + // Hint for merging: next two lines changed + "(": "this.emitAndReturn([new kukit.kssp.openParent(this.cursor), new kukit.kssp.PropValue(this.cursor), new kukit.kssp.closeParent(this.cursor)])", + ")": 'this.emitAndReturn()' }); kukit.kssp.EventValue.prototype.multiword_allowed = false; kukit.kssp.EventValue.prototype.process = function() { @@ -491,21 +492,20 @@ } else if (this.notInTokens(context, kukit.kssp.openParent)) { this.expectToken(context, kukit.kssp.openParent); this.expectToken(context, kukit.kssp.PropValue); + // Specifically handle the case of zero parameter, () here. In this + // case PropValue evaluates to '', Do not allow this. + var value = context.token.value; + if (! value.isMethod && value.txt == '') { +;;; kukit.E = 'Event binder id must be specified in the parenthesis.'; + this.emitError(kukit.E); + } // Create the event binder id // as a method value with a single parameter // to be evaluated later // At this moment context.token.value contains an object with // check and evaluate methods. - this.value = new kukit.rd.KssMethodValue(txt, [context.token.value]); + this.value = new kukit.rd.KssMethodValue(txt, [value]); this.digestTxt(context, kukit.tk.Fraction, kukit.kssp.Comment); - // we have to be at the end and have no text after - if (context.txt) { -;;; kukit.E = 'Wrong event selector : [' + context.txt; -;;; kukit.E += '] is not expected before the closing'; -;;; kukit.E += ' parenthesis. :() can have'; -;;; kukit.E += ' only one parameter.'; - this.emitError(kukit.E); - } // eat up everything before the closing parent this.expectToken(context, kukit.kssp.closeParent); } else { @@ -803,7 +803,8 @@ if (pseudotoken.value.isMethod) { eventName = pseudotoken.value.methodName; var args = pseudotoken.value.args; - // XXX TODO check that there is only 1 arg? Should already be checked. + // We do not need to check that argss has exactly one element, + // since this is already assured by the parser syntax. var arg = args[0]; ;;; // We annotate the error, to give parsing information to it. ;;; try { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 12:42:00 2007 @@ -370,9 +370,7 @@ var txt= "click(kssAttr(x), aaa)"; var cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.EventValue, cursor, null, true, - 'Wrong event selector : [,] is not expected before the closing parenthesis. :() can have only one parameter.', 000); - - // XXX add more failing cases, maybe? + 'Unexpected token : [,] found, [)] was expected.'); }; this.testMethodArgs = function() { @@ -978,14 +976,14 @@ txt= "a:click('hello', bello)"; cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Wrong event selector : [,] is not expected before the closing parenthesis. :() can have only one parameter.', 22); + 'Unexpected token : [,] found, [)] was expected.'); - // zero params: not std css but tolerated + // zero params: is not tolerated now. There must be exactly 1 parameter. txt= "a:click()"; cursor = new kukit.tk.Cursor(txt); - parser = new kukit.kssp.KssSelector(cursor, null, true); this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, - 'Wrong event selector : missing event qualifier : or :().', 8); + 'Event binder id must be specified in the parenthesis.'); + //'Wrong event selector : missing event qualifier : or :().', 8); txt= " (hello)"; cursor = new kukit.tk.Cursor(txt); @@ -1481,7 +1479,25 @@ var cursor = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.Document, cursor, null, true, 'Wrong value for evt-[-] [dnd-drag] : - should exist in the event of the selectors.', 6); - } + }; + + this.testEventIdentificationHasOneParameter = function() { + // The event identification stands as a single parameter. + // No list of ids is allowed. + var txt= "a:click(hello, true)"; + var src = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.KssSelector, src, null, true, + 'Unexpected token : [,] found, [)] was expected.'); + }; + + this.testEventIdentificationHasOneParameter2 = function() { + // The event identification stands as a single parameter. + // Zero parameter is not allowed.. + var txt= "a:click()"; + var src = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.KssSelector, src, null, true, + 'Event binder id must be specified in the parenthesis.'); + }; this.testValueProvidersInEventIdentification = function() { // Param providers within the event identification @@ -1525,7 +1541,7 @@ var txt= "a:drag(kssAttr(hello), xxx)"; var src = new kukit.tk.Cursor(txt); this.assertParsingError(kukit.kssp.KssSelector, src, null, true, - 'Wrong event selector : [,] is not expected before the closing parenthesis. :() can have only one parameter.', 000); + 'Unexpected token : [,] found, [)] was expected.'); }; this.testValueProvidersInEventIdentificationCannotStandWithSpecialSelectors = function() { From reebalazs at codespeak.net Fri Dec 28 12:42:06 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:42:06 +0100 (CET) Subject: [KSS-checkins] r50154 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114206.CD54F1684ED@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:42:06 2007 New Revision: 50154 Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Log: Change valueproviders to store a registry object intead of just the classname, meanwhile neexed to fix the chaining of the error exceptions, suffitient tests provided as well. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/errors.js Fri Dec 28 12:42:06 2007 @@ -77,6 +77,20 @@ // the original traceback will be lost. e = new Error(e); } + // If there is no info on the error object, we need to + // create an initial info for that error, to have the + // full chain of annotations available, including the ultimate + // message. +;;; if (addMessage && ! e.info) { +;;; // We are just starting with an error that has not +;;; // been annotated yet. +;;; // In this case we will give it an annotation +;;; e.info = new ErrorAnnotation(); +;;; e.info.name = e.name; +;;; e.info.message = e.message; +;;; e.info.fullMessage = e.message; +;;; e.info.kw = {}; +;;; } ;;; this.previous_info = e.info; e.name = name; e.info = this; @@ -90,23 +104,35 @@ return e; }; ;;; -;;; this._logRecursive = function() { -;;; kukit.logError(this.message); +;;; this._iterateInfo = function(yield) { +;;; yield.call(this, this.message); ;;; if (this.previous_info) { -;;; this.previous_info._logRecursive(); +;;; this.previous_info._iterateInfo(yield); ;;; } ;;; }; ;;; +;;; this.getInfoChain = function() { +;;; result = []; +;;; this._iterateInfo(function(msg) { +;;; result.push(msg); +;;; }); +;;; return result; +;;; }; +;;; ;;; this.log = function() { ;;; // This is for debugging only, normal error handling ;;; // does not use it. ;;; kukit.logFatal('KSS error, stack information follows:'); +;;; this._iterateInfo(function(msg) { +;;; kukit.logError(msg); +;;; }); ;;; this._logRecursive(); ;;; }; }; -var setErrorInfo = function(e, name, message, kw) { +// setErrorInfo needs to be global, for ecma testing +var setErrorInfo = err.setErrorInfo = function(e, name, message, kw) { return new ErrorAnnotation().constructError(e, name, message, kw); }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js Fri Dec 28 12:42:06 2007 @@ -39,7 +39,7 @@ var iface = kukit.interfaces.global.get(this.name, kukit.interfaces.PluginMethodDescriptor); var descriptor = iface.getMethodDescriptor(name); - descriptor.register(func); + descriptor.register({providerClass: func}); }; kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry('valueproviders'); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js Fri Dec 28 12:42:06 2007 @@ -225,7 +225,7 @@ kukit.rd.KssTextValue.prototype.check = function(iface) { // use the IdentityPP provider. - this.pprovider = new (iface[''])(); + this.pprovider = new (iface['']).providerClass(); }; kukit.rd.KssTextValue.prototype.evaluate = @@ -252,13 +252,13 @@ // Check syntax var f = iface[this.methodName]; // Check if the method name really existed. - if (! f) { + if (! f || ! f.providerClass) { ;;; kukit.E = 'Undefined value provider ['; ;;; kukit.E += this.methodName + '].'; throw kukit.err.pluginRegistryError(null, kukit.E); } // Create the provider checker and evaluator object - this.pprovider = new f(); + this.pprovider = new f.providerClass(); // Check the providers, this will give errors // in case something is wrong with the parameters. // Checking is also needed in production mode. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html Fri Dec 28 12:42:06 2007 @@ -89,6 +89,7 @@ + Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js Fri Dec 28 12:42:06 2007 @@ -26,6 +26,7 @@ testsuite.registerTest(kukit.InterfacesTestCase); testsuite.registerTest(kukit.ServiceInterfacesTestCase); testsuite.registerTest(kukit.PluginInterfacesTestCase); + testsuite.registerTest(kukit.ErrorsTestCase); testsuite.runSuite(); }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Fri Dec 28 12:42:06 2007 @@ -28,4 +28,5 @@ -f test_tokenizer.js \ -f test_kssparser.js \ -f test_interfaces.js \ + -f test_errors.js \ runtests.js Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js ============================================================================== --- (empty file) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js Fri Dec 28 12:42:06 2007 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2007 +* Authors: KSS Project Contributors (see doc/CREDITS.txt) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +* 02111-1307, USA. +*/ + +if (typeof(kukit) == "undefined") { + var kukit = {}; +} + +kukit.ErrorsTestCase = function() { + this.name = 'kukit.ErrorsTestCase'; + + this.setUp = function() { + }; + + this.testCreateGenuineError = function() { + // Create a genuine error message. + // An error message of a given type can be created on the fly. + var E = kukit.err.setErrorInfo(null, 'MyError', 'Something went wrong', {a:1, b:2}); + // Check that error has the message + this.assertEquals(E.message, 'MyError: Something went wrong'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Something went wrong']); + this.assertDictEquals(E.info.kw, {a:1, b:2}); + }; + + this.testCreateErrorFromTxt = function() { + // Create an annotated error from text. + // XXX this works but gives warning: this way we cannot preserve the traceback. + var orig_txt = "Original error"; + var E = kukit.err.setErrorInfo(orig_txt, 'MyError', 'Something went wrong', {a:1, b:2}); + // Check that error has the message + this.assertEquals(E.message, 'MyError: Something went wrong [Original error]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Something went wrong', + 'Original error']); + this.assertDictEquals(E.info.kw, {a:1, b:2}); + }; + + this.testCreateErrorFromRawError = function() { + // Create an annotated error from a raw, unannorated error. + var orig_err = new Error("Original error"); + var E = kukit.err.setErrorInfo(orig_err, 'MyError', 'Something went wrong', {a:1, b:2}); + // Check that error has the message + this.assertEquals(E.message, 'MyError: Something went wrong [Original error]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Something went wrong', + 'Original error']); + this.assertDictEquals(E.info.kw, {a:1, b:2}); + }; + + this.testCreateErrorFromAnnotatedError = function() { + // Create an error from an annotated error message. + // this message is a genuine error created by us + // create chain of errors + var orig_err = kukit.err.setErrorInfo(null, 'MyError', 'Something went wrong', {a:1, b:2}); + var E = kukit.err.setErrorInfo(orig_err, 'YourError', 'Wrong here too', {a:2, b:3}); + // Check that error has the message + this.assertEquals(E.message, 'YourError: Wrong here too [MyError: Something went wrong]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Wrong here too', + 'Something went wrong']); + this.assertDictEquals(E.info.kw, {a:2, b:3}); + }; + + this.testCreateErrorFromAnnotatedError2 = function() { + // Create an error from an annotated error message. + // this message is a string error + // create chain of errors + var orig_txt = "Original error"; + var err1 = kukit.err.setErrorInfo(orig_txt, 'MyError', 'Something went wrong', {a:1, b:2}); + var E = kukit.err.setErrorInfo(err1, 'YourError', 'Wrong here too', {a:2, b:3}); + // Check that error has the message + this.assertEquals(E.message, 'YourError: Wrong here too [MyError: Something went wrong [Original error]]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Wrong here too', + 'Something went wrong', + 'Original error']); + this.assertDictEquals(E.info.kw, {a:2, b:3}); + }; + + this.testCreateErrorFromAnnotatedError3 = function() { + // Create an error from an annotated error message. + // This message is an unannotated error object + // create chain of errors + var orig_err = new Error("Original error"); + var err1 = kukit.err.setErrorInfo(orig_err, 'MyError', 'Something went wrong', {a:1, b:2}); + var E = kukit.err.setErrorInfo(err1, 'YourError', 'Wrong here too', {a:2, b:3}); + // Check that error has the message + this.assertEquals(E.message, 'YourError: Wrong here too [MyError: Something went wrong [Original error]]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Wrong here too', + 'Something went wrong', + 'Original error']); + this.assertDictEquals(E.info.kw, {a:2, b:3}); + }; + + this.testCreateErrorManyLevels = function() { + // Many levels together + // create chain of errors + var orig_err = new Error("Original error"); + var err1 = kukit.err.setErrorInfo(orig_err, 'Error1', 'Wrong 1', {a:1, b:2}); + var err2 = kukit.err.setErrorInfo(err1, 'Error2', 'Wrong 2', {a:2, b:3}); + var err3 = kukit.err.setErrorInfo(err2, 'Error3', 'Wrong 3', {a:3, b:4}); + var err4 = kukit.err.setErrorInfo(err3, 'Error4', 'Wrong 4', {a:4, b:5}); + var E = kukit.err.setErrorInfo(err3, 'Error5', 'Wrong 5', {a:5, b:6}); + // Check that error has the message + this.assertEquals(E.message, + 'Error5: Wrong 5 [Error4: Wrong 4 [Error3: Wrong 3 [Error2: Wrong 2 [Error1: Wrong 1 [Original error]]]]]'); + this.assertNotEquals(typeof(E.info), 'undefined'); + this.assertListEquals(E.info.getInfoChain(), [ + 'Wrong 5', + 'Wrong 4', + 'Wrong 3', + 'Wrong 2', + 'Wrong 1', + 'Original error']); + this.assertDictEquals(E.info.kw, {a:5, b:6}); + }; + + + + + +}; + +kukit.ErrorsTestCase.prototype = new kukit.UtilsTestCaseBase; + +if (typeof(testcase_registry) != 'undefined') { + testcase_registry.registerTestCase(kukit.ErrorsTestCase, 'kukit.ErrorsTestCase'); +} From reebalazs at codespeak.net Fri Dec 28 12:42:14 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:42:14 +0100 (CET) Subject: [KSS-checkins] r50155 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071228114214.788751684EE@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:42:13 2007 New Revision: 50155 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Log: Change actions to store a registry object intead of just the function. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js Fri Dec 28 12:42:13 2007 @@ -36,17 +36,17 @@ ;;; throw new Error(kukit.E); ;;;} var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); - actions.getMethodDescriptor(name).register(func); + actions.getMethodDescriptor(name).register({actionFunc: func}); }; ActionRegistry.prototype.get = function(name) { - var func = kukit.interfaces.global.actions[name]; - if (! func) { + var reg = kukit.interfaces.global.actions[name]; + if (! reg || ! reg.actionFunc) { // not found ;;; kukit.E = 'Error : undefined client action [' + name + '].'; throw Error(kukit.E); } - return func; + return reg.actionFunc; }; kukit.actionsGlobalRegistry = new ActionRegistry(); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Fri Dec 28 12:42:13 2007 @@ -54,7 +54,7 @@ throw Error(kukit.E); } // Set a command of the required class for the action - var commandClass = factory(descriptor.config); + var commandClass = factory(descriptor.config.actionFunc); // Allow to set a different name (used for BBB) if (typeof(name) != 'undefined') { // Add the BBB config if there is not From reebalazs at codespeak.net Fri Dec 28 12:42:31 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:42:31 +0100 (CET) Subject: [KSS-checkins] r50156 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228114231.7BFBA1684F3@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:42:30 2007 New Revision: 50156 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Fix interfaces in a way that unregistered plugins are not finalized. This allows the applicaton to assume that if it finds a plugin, its config is returned. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 12:42:30 2007 @@ -127,8 +127,14 @@ ;;; kukit.logDebug(kukit.E); // Finalize all methods. this.forEachMethod(function(methodName, methodDescriptor) { - // finalize the functions and store them on the singleton - singleton[methodName] = methodDescriptor.finalize(loader); + // finalize the attributes and store them on the singleton + // + // Get the finalized value for this attribute + var value = methodDescriptor.finalize(loader); + if (typeof(value) != 'undefined') { + // Set the attribute on the singleton + singleton[methodName] = value; + }; }); // Store the singleton itself on interfaces this.interfaces[this.name] = singleton; @@ -282,10 +288,13 @@ this.iface = iface; this.methodName = methodName; - this.config = null; + // Set the config to undefined, this means that methods + // that were fetched but not registered during the configuration, + // will not be finalized. + this.config = undefined; this.register = function(config) { - if (this.config != null) { + if (typeof(this.config) != 'undefined') { ;;; kukit.E = 'Double registration of method [' + this.methodName; ;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; throw new Error(kukit.E); @@ -295,6 +304,10 @@ this.finalize = function(loader) { // Just return the registered value. + // If register was not called, we will return undefined, + // which means the method will not be finalized on the + // interface. This makes sure that if the registry is found, + // it will for sure have a value. return this.config; }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Fri Dec 28 12:42:30 2007 @@ -471,6 +471,20 @@ this.assertNotEquals(M.prototype.__className__, MSub.prototype.__className__); }; + this.testOnlyRegisteredPluginsAreFinalized = function() { + // We assure that if a method descriptor is get but it is not registered, + // it will not be finalized on the configuration. + // Let's create a TestDummy interface. + var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); + // Just call up the method descriptor: this will create it with config=null. + events.getMethodDescriptor('click'); + // finalize + events.finalize({}); + // 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.interfaces.dummyevents.click), 'undefined'); + }; + }; /* end PluginInterfacesTestCase */ kukit.PluginInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); From reebalazs at codespeak.net Fri Dec 28 12:42:37 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:42:37 +0100 (CET) Subject: [KSS-checkins] r50157 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . doc kukit tests Message-ID: <20071228114237.CBEE81684F4@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:42:37 2007 New Revision: 50157 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Make selectors use the interfaces. With this, all plugin registry in kss is reusing interfaces. All ecma and selenium tests are GREEN, ecma tests in browser still broken. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt Fri Dec 28 12:42:37 2007 @@ -6,11 +6,16 @@ - ... - - Add service layers. Refactor plugin binding. + - Add a general registry for interfaces. + + Add service layers. Refactor event binding and registries. - refactor processBindingEvents to make it iterate + Move event, action, command, selector, valueprovider + plugin registries into the interfaces registry, + + Refactor processBindingEvents to make it iterate on the binding sequence in a more efficient way. Eliminate namespaces from refactored code. @@ -31,6 +36,11 @@ This may break third party plugin code that reuses unpublished internals from plugins.js. (Most particularly, the more_selectors demo needed to be updated as well.) + + Fix the issue that happened with value providers used for getting + the event binder id, + e.g. #div:click(kssAttr(blah, true) got wrongfully cut into + two places and considered as two broken selectors. [ree] - Fix multiple selection form fields Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Fri Dec 28 12:42:37 2007 @@ -139,17 +139,21 @@ }; var _executeCommandOnSelector = function(oper) { - var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType); + var info = kukit.interfaces.global.selectors[this.selectorType]; + // Check if the selector name really exists. + if (! info || ! info.selectorFunc) { +;;; kukit.E = 'Undefined selector ['; +;;; kukit.E += this.methodName + '].'; + throw kukit.err.pluginRegistryError(null, kukit.E); + } // When applying the selection, the original event target will be used // as a starting point for the selection. - var nodes = selfunc(this.selector, oper.orignode, {}); + var nodes = info.selectorFunc(this.selector, oper.orignode, {}); ;;;var printType; ;;;if (this.selectorType) { ;;; printType = this.selectorType; ;;;} else { -;;; printType = 'default ('; -;;; printType += kukit.selectorTypesGlobalRegistry.defaultSelectorType; -;;; printType += ')'; +;;; printType = 'default (css)'; ;;;} ;;;var msg = 'Selector type [' + printType + '], selector ['; ;;;msg += this.selector + '], selected nodes [' + nodes.length + '].'; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 12:42:37 2007 @@ -408,7 +408,7 @@ this.global.get('actions', this.PluginMethodDescriptor).finalize({}); this.global.get('formproviders', this.PluginMethodDescriptor).finalize({}); this.global.get('valueproviders', this.PluginMethodDescriptor).finalize({}); - this.global.get('selectorproviders', this.PluginMethodDescriptor).finalize({}); + this.global.get('selectors', this.PluginMethodDescriptor).finalize({}); }; this.cleanRoomTearDown = function(suite) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Fri Dec 28 12:42:37 2007 @@ -268,7 +268,7 @@ kukit.kssp.Block.prototype.addActionParameter = function(action, key, value) { var interfaceForAction = { '': kukit.interfaces.global.valueproviders, - 'kssSelector': kukit.interfaces.global.selectorproviders, + 'kssSelector': kukit.interfaces.global.selectors, 'kssSubmitForm': kukit.interfaces.global.formproviders }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Fri Dec 28 12:42:37 2007 @@ -248,7 +248,7 @@ interfaces.get('actions', kukit.interfaces.PluginMethodDescriptor).finalize({}); interfaces.get('valueproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); interfaces.get('formproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); - interfaces.get('selectorproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); + interfaces.get('selectors', kukit.interfaces.PluginMethodDescriptor).finalize({}); ;;; kukit.log('All interfaces finalized.'); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js Fri Dec 28 12:42:37 2007 @@ -985,7 +985,7 @@ ;;; var msg = 'Deprecated the [executeCommand] action, use [kssSelector] in a standard action!'; ;;; kukit.logWarning(msg); oper.evaluateParameters(['name', 'selector'], - {'selectorType': null}, + {'selectorType': ''}, '', true); var parms = oper.parms; // marshall it, the rest of the parms will be passed Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js Fri Dec 28 12:42:37 2007 @@ -19,15 +19,12 @@ kukit.sr = {}; -// Registry of the pprovider functions for selecting - -// XXX XXX XXX TODO factor this with selector reg -kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry('selectorproviders'); - - // this will provide an arbitrary selector, and is designed to // be used with the makeAnyPP factory function. -kukit.sr.AnyPP = function() {}; +kukit.sr.AnyPP = function(selectorFunc) { + this.selectorFunc = selectorFunc; +}; + kukit.sr.AnyPP.prototype = { check: function(args) { // check does not need to be used here actually. @@ -36,22 +33,17 @@ ;;; } }, eval: function(args, node, defaultParameters) { - var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type); // We don't have orignode if we evaluate from here, consequently // the orignode parameter cannot be used from selectors. We pass // node just to be sure... - return f(args[0], node, defaultParameters, node); + return this.selectorFunc(args[0], node, defaultParameters, node); } }; -kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP); - -kukit.sr.makeAnyPP = function(selector_type) { - var pp = function () {}; - pp.prototype.eval = kukit.sr.AnyPP.prototype.eval; -;;; pp.prototype.check = kukit.sr.AnyPP.prototype.check; - pp.prototype.selector_type = selector_type; - return pp; +kukit.sr.makeAnySelectorProvider = function(selectorFunc) { + var providerClass = function() {}; + providerClass.prototype = new kukit.sr.AnyPP(selectorFunc); + return providerClass; }; // this can be used to pass a node programmatically @@ -73,7 +65,11 @@ return nodes; } }; -kukit.sr.pproviderSelRegistry.register('passnode', kukit.sr.PassnodePP); +var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); +var info = {providerClass: kukit.sr.PassnodePP}; +iface.getMethodDescriptor('passnode').register(info); +// the item now will contain providerClass only, +// as passnode is only allowed from the kss file, not as a command selector. /* @@ -87,40 +83,30 @@ * */ kukit.sr.SelectorTypeRegistry = function () { - this.mapping = {}; }; -kukit.sr.SelectorTypeRegistry.prototype.defaultSelectorType = 'css'; - -kukit.sr.SelectorTypeRegistry.prototype.register = function(name, func) { +kukit.sr.SelectorTypeRegistry.prototype.register = function(name, selectorFunc) { ;;; // Check func parameter: diagnostics only, as this will cause ;;; // an error later anyway. -;;; if (typeof(func) == 'undefined') { +;;; if (typeof(selectorFunc) == 'undefined') { ;;; kukit.E = 'Func is mandatory in SelectorTypeRegistry.register.'; ;;; throw new Error(kukit.E); ;;; } -;;; if (this.mapping[name]) { -;;; // Do not allow redefinition -;;; kukit.logError('Error : redefinition attempt of selector ' + name); -;;; return; -;;; } - this.mapping[name] = func; // Also register the selector param provider - var pp = kukit.sr.makeAnyPP(name); - kukit.sr.pproviderSelRegistry.register(name, pp); + var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); + var providerClass = kukit.sr.makeAnySelectorProvider(selectorFunc); + iface.getMethodDescriptor(name).register({ + providerClass: providerClass, + selectorFunc: selectorFunc}); + // the item now will contain providerClass and selectorFunc as well }; kukit.sr.SelectorTypeRegistry.prototype.get = function(name) { - if (! name) { - // if name is null or undefined or '', - // we use the default type. - name = this.defaultSelectorType; - } - var result = this.mapping[name]; -;;; if (typeof(result) == 'undefined') { + var info = kukit.interfaces.global.selectors[name]; +;;; if (! info || ! info.selectorFunc) { ;;; throw new Error('Unknown selector type "' + name + '"'); ;;; } - return result; + return info.selectorFunc; }; kukit.selectorTypesGlobalRegistry = new kukit.sr.SelectorTypeRegistry(); @@ -140,6 +126,15 @@ return nodes; }); +// Since css is the default selector, copy the provider class +// to the identity function. That is, if the selector is +// not css() htmlid() etc. but a string, +// we use the default selector, css. +var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); +var css_config = iface.getMethodDescriptor('css').config; +iface.getMethodDescriptor('').register(css_config); +// the item now will contain providerClass and selectorFunc: both are needed. + kukit.selectorTypesGlobalRegistry.register('samenode', function(expr, node) { nodes = [node]; return nodes; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Fri Dec 28 12:42:37 2007 @@ -457,13 +457,13 @@ iterName: 'Each', binderClass: MSub, bindMethodName: 'bind'}); - // initialize + // finalize iface.finalize({}); // Check that our classes are set as expected. - this.assert(this.interfaces.dummybinditeration.click.binderClass, M); - this.assert(this.interfaces.dummybinditeration.timeout.binderClass, M); - this.assert(this.interfaces.dummybinditeration.keydown.binderClass, MSub); - this.assert(this.interfaces.dummybinditeration.keypress.binderClass, MSub); + this.assertEquals(this.interfaces.dummybinditeration.click.binderClass, M); + this.assertEquals(this.interfaces.dummybinditeration.timeout.binderClass, M); + this.assertEquals(this.interfaces.dummybinditeration.keydown.binderClass, MSub); + this.assertEquals(this.interfaces.dummybinditeration.keypress.binderClass, MSub); // Check that both classes have a class name. this.assert(M.prototype.__className__); this.assert(MSub.prototype.__className__); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 12:42:37 2007 @@ -54,10 +54,13 @@ kukit.pprovidersGlobalRegistry.register('formVar', kukit.pr.FormVarPP); kukit.pprovidersGlobalRegistry.register('nodeAttr', kukit.pr.NodeAttrPP); // + // Create the identity value provider for kssSelector, this is needed + // at least to evaluate strings. + var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); + var info = {providerClass: kukit.pr.IdentityPP}; + iface.getMethodDescriptor('').register(info); //Create some selectors - //XXX this is temporary untul the selectors registry is finished - kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP); - kukit.sr.pproviderSelRegistry.register('htmlid', kukit.sr.AnyPP); + kukit.selectorTypesGlobalRegistry.register('htmlid', function(expr, node) {}); // // finalize the interfaces we just set up kukit.interfaces.cleanRoomFinalize(this); From reebalazs at codespeak.net Fri Dec 28 12:53:13 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 12:53:13 +0100 (CET) Subject: [KSS-checkins] r50158 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . tests Message-ID: <20071228115313.501921684CE@codespeak.net> Author: reebalazs Date: Fri Dec 28 12:53:12 2007 New Revision: 50158 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Log: Fix ecma tests in production mode: errors tests are only added to the case in development mode. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js Fri Dec 28 12:53:12 2007 @@ -147,5 +147,9 @@ kukit.ErrorsTestCase.prototype = new kukit.UtilsTestCaseBase; if (typeof(testcase_registry) != 'undefined') { - testcase_registry.registerTestCase(kukit.ErrorsTestCase, 'kukit.ErrorsTestCase'); + // Only add these tests for development mode + // (For the console, they are added elsewhere permanently.) + if (kukit.isDevelMode) { + testcase_registry.registerTestCase(kukit.ErrorsTestCase, 'kukit.ErrorsTestCase'); + } } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Fri Dec 28 12:53:12 2007 @@ -61,9 +61,9 @@ } this.assertNotEquals(exc, null, 'Should have thrown a ParsingError exception.'); // - var info = exc.info; // Assert the text of the error. if (typeof(errtxt) != 'undefined') { + var info = exc.info; // We are only interested for the ultimate error message // thas is, here we ignore the annotations we might have put on the message while (info.previous_info) { From kukit-checkins at codespeak.net Fri Dec 28 19:01:27 2007 From: kukit-checkins at codespeak.net (Doctor Brandon Bauer) Date: Fri, 28 Dec 2007 19:01:27 +0100 (CET) Subject: [KSS-checkins] December 74% OFF Message-ID: <20071228120130.2858.qmail@host-77-41-97-145.qwerty.ru> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20071228/5a66e963/attachment-0001.htm From reebalazs at codespeak.net Fri Dec 28 21:33:53 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 21:33:53 +0100 (CET) Subject: [KSS-checkins] r50165 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228203353.1ADC6168500@codespeak.net> Author: reebalazs Date: Fri Dec 28 21:33:52 2007 New Revision: 50165 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Log: Simplify interfaces conceptually. Adjusts tests and kss to run with the redesign. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js Fri Dec 28 21:33:52 2007 @@ -35,8 +35,8 @@ ;;; kukit.E += ' [ActionRegistry.register].'; ;;; throw new Error(kukit.E); ;;;} - var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); - actions.getMethodDescriptor(name).register({actionFunc: func}); + var actions = kukit.interfaces.global.schema.actions; + actions.getAttribute(name).register({actionFunc: func}); }; ActionRegistry.prototype.get = function(name) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Fri Dec 28 21:33:52 2007 @@ -45,37 +45,37 @@ */ _CommandRegistry.prototype.registerFromAction = function(srcname, factory, name) { - var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); + var actions = kukit.interfaces.global.schema.actions; // // register a given action as a command, using the given vactor - var descriptor = actions.getMethodDescriptor(srcname); - if (! descriptor.config) { + var attrib = actions.getAttribute(srcname); + if (! attrib.config) { ;;; 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(descriptor.config.actionFunc); + var commandClass = factory(attrib.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.getMethodDescriptor(name).register(descriptor.config); + actions.getAttribute(name).register(attrib.config); // only declare the command class if it's missing - if (typeof(descriptor.config.commandClass) == 'undefined') { - this._register(name, commandClass, descriptor); + if (typeof(attrib.config.commandClass) == 'undefined') { + this._register(name, commandClass, attrib); } } else { // This is the normal case - just register it - this._register(srcname, commandClass, descriptor); + this._register(srcname, commandClass, attrib); } }; _CommandRegistry.prototype.register = function(name, commandClass) { - var actions = kukit.interfaces.global.get('actions', kukit.interfaces.PluginMethodDescriptor); - var descriptor = actions.getMethodDescriptor(name); - this._register(name, commandClass, descriptor); + var actions = kukit.interfaces.global.schema.actions; + var attrib = actions.getAttribute(name); + this._register(name, commandClass, attrib); }; _CommandRegistry.prototype._register = function(name, commandClass, descriptor) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Fri Dec 28 21:33:52 2007 @@ -74,18 +74,18 @@ } namespacedEventNames.push(eventName); // register the event informataion - var events = kukit.interfaces.global.get('events', kukit.interfaces.PluginMethodDescriptor); - events.getMethodDescriptor(eventName).register({ + var events = kukit.interfaces.global.schema.events; + events.getAttribute(eventName).register({ eventName: eventName, defaultActionMethodName: defaultActionMethodName, - parmtypes: null // missing from this api. + parmTypes: null // missing from this api. }); } // Register the bind iteration // This will specify the set of events that will be bound together, // with the specified iterator - var binditerations = kukit.interfaces.global.get('binditerations', kukit.interfaces.BindIterationDescriptor); - binditerations.getMethodDescriptor('').register({ + var binditerations = kukit.interfaces.global.schema.binditerations; + binditerations.getAttribute('').register({ eventNames: namespacedEventNames, iterName: iterName, binderClass: binderClass, Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 21:33:52 2007 @@ -4,110 +4,163 @@ /* * Kukit interfaces * - * Warning: this is not comparable with Zope interfaces. It has much smaller - * scope and aims at a different use case. + * Warning: this is not comparable with Zope interfaces. It has much + * smaller scope and aims at a different use case. * - * We want a way to initialize a "set of attributes". These can be - * the registered vents, actions, etc., or methods of a service interface. - * The initialization of these attributes depends only on what javascript - * code is present and how it is defining these interfaces. + * We want a way to initialize a "set of attributes". An attribute can + * be the an event, action, etc. registry, or method of a service + * interface. The initialization of these attributes depends only on + * what javascript code is present and how it is defining these + * interfaces. * * The atributes or methods have method descriptors that can get their - * methods called and have a state that represents offers and demands on - * that given attribute or method. + * methods called and have a state that represents offers and demands + * on that given attribute or method. * - * In case of an action plugin, this is just storing registry info keyed by - * the action name. However in case of a service interface, different components - * may provide the requested item, and the final value of the method is decided - * at finalization and all this logic is handled by the method descriptor. - * In case of service interfaces, this allows that "define service" - * and "provide service" sections can be in different javascript files (plugins), - * and the final outcome is independent of the order of their execution. + * In case of an action plugin, this is just storing registry info + * keyed by the action name. However in case of a service interface, + * different components may provide the requested item, and the final + * value of the method is decided at finalization and all this logic + * is handled by the method descriptor. In case of service + * interfaces, this allows that "define service" and "provide service" + * sections can be in different javascript files (plugins), and the + * final outcome is independent of the order of their execution. + * + * The order in which they are loaded is irrelevant, provided they + * load after interfaces.js. + * + * Managing the schema + * ------------------- + * + * When various javascript code is loaded, it can set up the + * schema for the interfaces it handles. For example, during the + * loading of javascript, plugin code set up its registry, other code + * sets up core services it provides or depends on. + * + * Before accessing the scnema of any named interfaces, its context + * need to be initialized. This may be happen several times, but at + * least once it has been done before the schema is looked up from + * code. (It is only needed for getSchema.) + * + * This is the only dependency what we have for the order of the code. + * Ewerywhere else, order is independent. This means that if all + * javascript file does the initialization for itself, (or otherwise + * can assume that it cas been called by preceding code like in the + * case of the plugins), then the order of these javascripts is + * arbitrary for interfaces to work. + * + * In the initialization the interface name and the attribute class + * (describing the attribute schema) needs to be supplied as + * parameters. + * + * interfaces.initializeContext('myinterface', MyAttributeClass); + * + * After this the schema of the interface can be looked up with: + * + * var iface = interfaces.schema.myinterface; + * + * 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 attrib = interfaces.schema.myinterface.getAttribute('mykey'); + * attrib.doWhateverAttributeClassImplements(blah); + * + * This concludes everything we can do, before finalization. + * Finalization freezes the setup of attributes on the interface and + * allows its direct use, without the schema. For the finalization, a + * singleton has to be provided. The interface is finalized on this + * singleton. + * + * iface.finalize(singleton); + * + * In most cases, the singleton can simply be a normal object. So + * the usual setup what we have a registry for plugins is: + * + * iface.finalize({}); + * + * However an interface could have attributes inherited with + * a prototype, and if we want to have this, we could finalize + * it on an object with a different prototype. + * + * After being finalized, the singleton set up for this interface, + * will appear directly accessable from interfaces. * - * The order in which they are loaded is irrelevant, provided they load - * after interfaces.js. + * interfaces.myinterface == singleton * - * An interface needs to be finalized before being used, and all - * methods will be finalized this time as well. + * This will be equal to the singleton we used for finalizing it. + * The singleton contains our attributes directly. (not the schema + * but already the actual values returned be the attribute's + * finalize. + * + * interfaces.myinterface.mykey == value * * After being finalized, all named interfaces can be accessed from - * the interfaces object, e.g.: + * the interfaces object, e.g. in the following way: * * interfaces.events.click - is an event's registry * interfaces.actions.setAttr - is an action's registry * interfaces.core.cssQuery - is a core service method * interfaces.core.forEach - is a core service method * - * - * This is not an API. It _can_ be used for generic purpose in any - * component, though. - * - * Kukit sets up the following interfaces for itself. The finalization - * of these interfaces is done by kukit at the beginning of bootstrap. - * - * name class - * ---- ----- - * core core services kukit.interfaces.ServiceMethodDescriptor - * events kss event name registry kukit.interfaces.PluginMethodDescriptor - * binditerations kss event binding reg. kukit.interfaces.BindIterationDescriptor - * actions kss action registry kukit.interfaces.PluginMethodDescriptor - * selectors kss selector registry kukit.interfaces.PluginMethodDescriptor - * valueproviders value provider registry kukit.interfaces.PluginMethodDescriptor - * - * They are initialized into kukit.interfaces.global. + * Kukit sets up the following interfaces for its own use. The + * finalization of these interfaces is done by kukit at the beginning + * of bootstrap. + * + * name purpose attribute class + * ---- ------- --------------- + * core core services kukit.interfaces.ServiceMethod + * events kss event name registry kukit.interfaces.PluginResource + * binditerations kss event binding reg. kukit.interfaces.BindIterationResource + * actions kss action registry kukit.interfaces.PluginResource + * selectors kss selector registry kukit.interfaces.PluginResource + * valueproviders value provider registry kukit.interfaces.PluginResource + * formproviders providers for forms kukit.interfaces.PluginResource + * + * They are initialized into kukit.interfaces.global during the kukit + * bootstrap. This means that if the finalization is done from a load + * event, it does not raise any additional contstraint on the order of + * javascript files. * * For more information, see ../tests/test_interfaces.js . * */ -var InterfaceDescriptor = function(interfaces, name, MethodDescriptor) { + +var Interface = function(interfaces, interfaceName, AttributeClass) { // A parameters are the name of the interface, and // the method descriptor class it uses. // this.interfaces = interfaces; - this.name = name; + this.interfaceName = interfaceName; this.finalized = false; - this.registry = {}; - this.MethodDescriptor = MethodDescriptor; + this._registry = {}; + this.AttributeClass = AttributeClass; - this.getMethodDescriptor = function(methodName) { - // assert prohibited names - if (methodName == 'get' || methodName == 'registry') { -;;; kukit.E = 'Method name "' + methodName + '" is prohibited, in interface ['; -;;; kukit.E += this.name + ']'; - throw new Error(kukit.E); - } - // create the descriptor on demand - var methodDescriptor; - methodDescriptor = this.registry[methodName]; - if (typeof(methodDescriptor) == 'undefined') { + this.getAttribute = function(attributeName) { + // create the attribute on demand + var attrib = this._registry[attributeName]; + if (typeof(attrib) == 'undefined') { // Use the registry in the instance, to look up the MethodDescriptor class // for this method name - + // // instantiate the descriptor - methodDescriptor = this.registry[methodName] = new this.MethodDescriptor(this, methodName); + attrib = this._registry[attributeName] = new this.AttributeClass(this, attributeName); } - return methodDescriptor; + return attrib; }; - /* Apply functions on method descriptors of the interface */ + /* Apply functions on attributes of the interface */ - var _applyFunc = function(f, methodName, methodDescriptor, argArray, nextArg) { - var newArray = []; - newArray.push(methodName); - newArray.push(methodDescriptor); - for ( ;nextArg < argArray.length; nextArg++) { - newArray.push(argArray[nextArg]); - } - f.apply(null, newArray); - }; - - this.forEachMethod = function(f) { - // Execute f for the designated method. + this.forEachAttribute = function(f, a1, a2, a3, a4, a5) { + // Execute f for each attribute. + // f will receive attributeName, attribute, and the rest + // of the parameters passed to forEach. // methodName and MethodDescriptor will be passed to f as parameters. // Extra arguments will be passed in addition. - for (var methodName in this.registry) { - var methodDescriptor = this.registry[methodName]; - _applyFunc(f, methodName, methodDescriptor, arguments, 1); + for (var attributeName in this._registry) { + var attribute = this._registry[attributeName]; + // Provide the necessary parameters and call f + f(attributeName, attribute, a1, a2, a3, a4, a5); } }; @@ -120,60 +173,77 @@ // Check if we are finalized. if (this.finalized) { ;;; kukit.E = 'Attempt to finalize already finalized plugin interface ['; -;;; kukit.E += this.name + ']'; +;;; kukit.E += this.interfaceName + ']'; throw new Error(kukit.E); } -;;; kukit.E = 'Finalizing interface [' + this.name + ']'; +;;; kukit.E = 'Finalizing interface [' + this.interfaceName + ']'; ;;; kukit.logDebug(kukit.E); // Finalize all methods. - this.forEachMethod(function(methodName, methodDescriptor) { + this.forEachAttribute(function(attributeName, attribute) { // finalize the attributes and store them on the singleton // // Get the finalized value for this attribute - var value = methodDescriptor.finalize(loader); + var value = attribute.finalize(loader); if (typeof(value) != 'undefined') { // Set the attribute on the singleton - singleton[methodName] = value; + singleton[attributeName] = value; }; }); // Store the singleton itself on interfaces - this.interfaces[this.name] = singleton; + this.interfaces[this.interfaceName] = singleton; // Set finalized state. // We are finalized if the loader has no items to load. // If there is no loader, we are finalized always. this.finalized = ! loader || loader.empty(); ;;; if (! this.finalized) { -;;; kukit.E = 'Postpone finalization of interface [' + this.name + '],'; +;;; kukit.E = 'Postpone finalization of interface [' + this.interfaceName + '],'; ;;; kukit.E = ' and request sources [', loader.getSources() + ']'; ;;; kukit.logDebug(kukit.E); ;;; } }; -}; /* end InterfaceDescriptor */ +}; /* end Interface */ this.NamedInterfaces = function() { - - this.registry = {}; - this.get = function(name, MethodDescriptor) { + this.schema = {}; + + this.initializeContext = function(interfaceName, AttributeClass) { + // This sets up the interface given by name with the + // specified Attribute class, or checks it. + // This method needs to be called preceding the calls + // to getSchema on the given interface. + // It can be called more times with the same method + // descriptor. + // ;;; // Check for missing parameter; this will cause an error later anyway. -;;; if (! MethodDescriptor) { -;;; kukit.E = 'NamedInterfaces.get is called for interface ['; -;;; kukit.E += name + '] without a MethodDescriptor parameter.'; +;;; if (! AttributeClass) { +;;; kukit.E = 'NamedInterfaces.initializeContext() is called for interface ['; +;;; kukit.E += interfaceName + '] without an AttributeClass parameter.'; ;;; throw new Error(kukit.E); ;;; } - // create the descriptor on demand - var interfaceDescriptor; - interfaceDescriptor = this.registry[name]; - if (typeof(interfaceDescriptor) == 'undefined') { - interfaceDescriptor = this.registry[name] = new InterfaceDescriptor(this, name, MethodDescriptor); + // Check prohibited names + if (interfaceName == 'schema' || interfaceName == 'initializeContext') { +;;; kukit.E = 'NamedInterfaces.initializeContext() cannot be called '; +;;; kukit.E += 'with a reserved name ['; +;;; kukit.E += interfaceName + '].'; + throw new Error(kukit.E); + } + // see if we already have an attribute + var iface = this.schema[interfaceName]; + // create the interface on demand + if (typeof(iface) == 'undefined') { + // create the interface and store it on myself + this.schema[interfaceName] = new Interface(this, interfaceName, AttributeClass); } else { - if (interfaceDescriptor.MethodDescriptor != MethodDescriptor) { -;;; kukit.E = 'Interface "' + name + '" already has a different method descriptor specified earlier.'; + // check that the same AtributeClass was provided. If not, + // it's a conflict. + if (iface.AttributeClass != AttributeClass) { +;;; kukit.E = 'NamedInterfaces.initializeContext() is called for interface ['; +;;; kukit.E += interfaceName + '] with a different AttributeClass than earlier.'; throw new Error(kukit.E); } } - return interfaceDescriptor; }; }; /* end NamedInterfaces */ @@ -182,7 +252,7 @@ * KSS service layer registry */ -this.ServiceMethodDescriptor = function(iface, methodName) { +this.ServiceMethod = function(iface, methodName) { this.iface = iface; this.methodName = methodName; @@ -193,7 +263,7 @@ if (this.preferredProviders) { ;;; kukit.E = 'Attempt to double define method ['; ;;; kukit.E += this.methodName + '] on interface ['; -;;; kukit.E += this.iface.name + ']'; +;;; kukit.E += this.iface.interfaceName + ']'; throw new Error(kukit.E); }; this.preferredProviders = preferredProviders; @@ -205,13 +275,13 @@ if (this.iface.finalized) { ;;; kukit.E = 'Attempt to provide implementation to method ['; ;;; kukit.E += this.methodName + '] on already finalized interface ['; -;;; kukit.E += this.iface.name + ']'; +;;; kukit.E += this.iface.interfaceName + ']'; throw new Error(kukit.E); } else if (typeof(this.registry[providerName]) != 'undefined') { ;;; kukit.E = 'Double registration by [' + providerName + ']['; ;;; kukit.E += providerVersion; ;;; kukit.E += '] of method [' + this.methodName; -;;; kukit.E += '] in interface [' + this.iface.name + ']'; +;;; kukit.E += '] in interface [' + this.iface.interfaceName + ']'; throw new Error(kukit.E); } this.registry[providerName] = { @@ -226,7 +296,7 @@ if (! this.preferredProviders) { ;;; kukit.E = 'Undefined method ['; ;;; kukit.E += this.methodName + '] on interface ['; -;;; kukit.E += this.iface.name + '], '; +;;; kukit.E += this.iface.interfaceName + '], '; ;;; kukit.E += 'but the following were provided:'; ;;; kukit.E += this.registry + ']'; throw new Error(kukit.E); @@ -257,7 +327,7 @@ // We raise an error. ;;; kukit.E = 'Could not finalize method ['; ;;; kukit.E += this.methodName + '] on interface ['; -;;; kukit.E += this.iface.name + '], because no provider found '; +;;; kukit.E += this.iface.interfaceName + '], because no provider found '; ;;; kukit.E += 'of the following preferences: ['; ;;; kukit.E += this.preferredProviders + ']'; throw new Error(kukit.E); @@ -277,17 +347,17 @@ } }; -}; /* end ServiceMethodDescriptor */ +}; /* end ServiceMethod */ /* * KSS plugin registry */ -this.PluginMethodDescriptor = function(iface, methodName) { +this.PluginResource = function(iface, attributeName) { this.iface = iface; - this.methodName = methodName; + this.attributeName = attributeName; // Set the config to undefined, this means that methods // that were fetched but not registered during the configuration, // will not be finalized. @@ -295,8 +365,8 @@ this.register = function(config) { if (typeof(this.config) != 'undefined') { -;;; kukit.E = 'Double registration of method [' + this.methodName; -;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; +;;; kukit.E = 'Double registration of plugin [' + this.attributeName; +;;; kukit.E += '] in plugin interface [' + this.iface.interfaceName + ']'; throw new Error(kukit.E); } this.config = config; @@ -311,7 +381,7 @@ return this.config; }; -}; /* end PluginMethodDescriptor */ +}; /* end PluginResource */ /* * BindIterationDescriptor @@ -328,26 +398,27 @@ * may make sense, it can be put back in form of asserts on the * event names. */ -this.BindIterationDescriptor = function(iface, methodName) { +this.BindIterationResource = function(iface, attributeName) { this.iface = iface; - this.methodName = methodName; + this.attributeName = attributeName; this.config = null; this.register = function(config) { - // This is called on any method descriptors. + // 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.iface.getMethodDescriptor(name)._register(config); + this.iface.getAttribute(name)._register(config); } }; this._register = function(config) { if (this.config != null) { -;;; kukit.E = 'Double registration of method [' + this.methodName; -;;; kukit.E += '] in plugin interface [' + this.iface.name + ']'; +;;; kukit.E = 'Double registration of attribute [' + this.attributeName; +;;; kukit.E += '] in plugin interface [' + this.iface.interfaceName + ']'; throw new Error(kukit.E); } // Do some diagnostics // check the iterator. @@ -370,7 +441,7 @@ return this.config; }; -}; /* end BindIterationDescriptor */ +}; /* end BindIterationResource */ @@ -382,7 +453,6 @@ // create singleton for interfaces this.global = new this.NamedInterfaces(); }; -this._createGlobalInterfaces(); // The following methods can acquire a given interface @@ -399,20 +469,55 @@ this._saved_global = this.global; // now create interfaces this._createGlobalInterfaces(); + // and initialize them + this.initializeGlobalInterfaces(); }; + this.cleanRoomFinalize = function(suite) { // Need to finalize these interfaces - this.global.get('events', this.PluginMethodDescriptor).finalize({}); - this.global.get('binditerations', this.BindIterationDescriptor).finalize({}); - // this is not strictly necessary, as we don't get as far as execution - this.global.get('actions', this.PluginMethodDescriptor).finalize({}); - this.global.get('formproviders', this.PluginMethodDescriptor).finalize({}); - this.global.get('valueproviders', this.PluginMethodDescriptor).finalize({}); - this.global.get('selectors', this.PluginMethodDescriptor).finalize({}); + this.finalizeGlobalInterfaces(); }; this.cleanRoomTearDown = function(suite) { + // Revert the saved state this.global = this.saved_global; }; +/* These methods handle the specific interfaces + * used by kukit itself. They are all stored on + * interfaces.global. + */ + +// Initialize global interfaces +this.initializeGlobalInterfaces = function() { + var i = this.global; + i.initializeContext('core', this.ServiceMethod); + i.initializeContext('events', this.PluginResource); + i.initializeContext('binditerations', this.BindIterationResource); + i.initializeContext('actions', this.PluginResource); + i.initializeContext('valueproviders', this.PluginResource); + i.initializeContext('formproviders', this.PluginResource); + i.initializeContext('selectors', this.PluginResource); +}; + +// Finalize global interfaces +this.finalizeGlobalInterfaces = function() { + var schema = this.global.schema; + schema.core.finalize({}); + schema.events.finalize({}); + schema.binditerations.finalize({}); + schema.actions.finalize({}); + schema.valueproviders.finalize({}); + schema.formproviders.finalize({}); + schema.selectors.finalize({}); +}; + +// Now, create the global interfaces +this._createGlobalInterfaces(); +// At this point we initialize the interfaces used by kukit, that means +// any code can use them from top level, without initialization. +this.initializeGlobalInterfaces(); +// The finalization of these interfaces will be done from bootstrap. + + }(); /* END CLOSURE kukit.interfaces */ Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Fri Dec 28 21:33:52 2007 @@ -240,15 +240,8 @@ ;;; kukit.log('[initializeRules] is called twice.'); return; } - // We finalize the core interface. - var interfaces = kukit.interfaces.global; - interfaces.get('core', kukit.interfaces.ServiceMethodDescriptor).finalize({}); - interfaces.get('events', kukit.interfaces.PluginMethodDescriptor).finalize({}); - interfaces.get('binditerations', kukit.interfaces.BindIterationDescriptor).finalize({}); - interfaces.get('actions', kukit.interfaces.PluginMethodDescriptor).finalize({}); - interfaces.get('valueproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); - interfaces.get('formproviders', kukit.interfaces.PluginMethodDescriptor).finalize({}); - interfaces.get('selectors', kukit.interfaces.PluginMethodDescriptor).finalize({}); + // We finalize the core interfaces. + kukit.interfaces.finalizeGlobalInterfaces(); ;;; kukit.log('All interfaces finalized.'); ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js Fri Dec 28 21:33:52 2007 @@ -36,10 +36,8 @@ throw new Error(kukit.E); } // Always use the global interfaces to get the descriptor. - var iface = kukit.interfaces.global.get(this.name, - kukit.interfaces.PluginMethodDescriptor); - var descriptor = iface.getMethodDescriptor(name); - descriptor.register({providerClass: func}); + var iface = kukit.interfaces.global.schema[this.name]; + iface.getAttribute(name).register({providerClass: func}); }; kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry('valueproviders'); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js Fri Dec 28 21:33:52 2007 @@ -65,9 +65,9 @@ return nodes; } }; -var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); -var info = {providerClass: kukit.sr.PassnodePP}; -iface.getMethodDescriptor('passnode').register(info); +var iface = kukit.interfaces.global.schema.selectors; +iface.getAttribute('passnode').register({ + providerClass: kukit.sr.PassnodePP}); // the item now will contain providerClass only, // as passnode is only allowed from the kss file, not as a command selector. @@ -93,9 +93,9 @@ ;;; throw new Error(kukit.E); ;;; } // Also register the selector param provider - var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); + var iface = kukit.interfaces.global.schema.selectors; var providerClass = kukit.sr.makeAnySelectorProvider(selectorFunc); - iface.getMethodDescriptor(name).register({ + iface.getAttribute(name).register({ providerClass: providerClass, selectorFunc: selectorFunc}); // the item now will contain providerClass and selectorFunc as well @@ -130,9 +130,11 @@ // to the identity function. That is, if the selector is // not css() htmlid() etc. but a string, // we use the default selector, css. -var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); -var css_config = iface.getMethodDescriptor('css').config; -iface.getMethodDescriptor('').register(css_config); +// +//var iface = kukit.interfaces.global.schema.selectors; +var css_config = iface.getAttribute('css').config +iface.getAttribute('').register(css_config); + // the item now will contain providerClass and selectorFunc: both are needed. kukit.selectorTypesGlobalRegistry.register('samenode', function(expr, node) { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Fri Dec 28 21:33:52 2007 @@ -3,9 +3,9 @@ new function() { // BEGIN CLOSURE service - var core = kukit.interfaces.global.get('core', kukit.interfaces.ServiceMethodDescriptor); + var core = kukit.interfaces.global.schema.core; - core.getMethodDescriptor('cssQuery').define(['base2', 'cssQuery'], + core.getAttribute('cssQuery').define(['base2', 'cssQuery'], // a parameter checker common for each implementation function(selector, inNodes) { // to eliminate possible errors @@ -17,7 +17,7 @@ // providers are also here now - core.getMethodDescriptor('cssQuery').provide('cssQuery', '1.1', + core.getAttribute('cssQuery').provide('cssQuery', '1.1', function() { // Detect if cssQuery is present // @@ -38,7 +38,7 @@ }); - core.getMethodDescriptor('cssQuery').provide('base2', '1.1', + core.getAttribute('cssQuery').provide('base2', '1.1', function() { // Detect if base2 is present // Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Fri Dec 28 21:33:52 2007 @@ -38,9 +38,9 @@ var called = []; - var MethodDescriptor = function(iface, methodName) { + var TestAttribute = function(iface, attributeName) { this.iface = iface; - this.methodName = methodName; + this.attributeName = attributeName; this.doThis = function() { called.push("doThis"); } @@ -48,7 +48,7 @@ called.push("doThat"); } this.finalize = function(loader) { - var signature = "FUNC " + this.methodName; + var signature = "FUNC " + this.attributeName; called.push(signature); return signature; } @@ -58,41 +58,60 @@ // We can create a simple method descriptor for an interface we want. // The method descriptor is managing the method's registration state called = []; - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummytest', MethodDescriptor); + // Let's create an interface that uses TestAttribute. + // We need to initialize it + this.interfaces.initializeContext('dummytest', TestAttribute); + // Now we can access the schema. + var iface = this.interfaces.schema.dummytest; + this.assert(typeof(iface), 'object'); // Let's get two methods - iface.getMethodDescriptor('fooMethod').doThis() - iface.getMethodDescriptor('barMethod').doThat() + iface.getAttribute('fooMethod').doThis() + iface.getAttribute('barMethod').doThat() // Check this.assertListEquals(called, ['doThis', 'doThat']); called = []; // Ok. Now get the descriptors again... - iface.getMethodDescriptor('fooMethod').doThis() - iface.getMethodDescriptor('barMethod').doThat() + iface.getAttribute('fooMethod').doThis() + iface.getAttribute('barMethod').doThat() // Check this.assertListEquals(called, ['doThis', 'doThat']); called = []; // // Now let's iterate on all instantiated methods: - iface.forEachMethod(function(methodName, methodDescriptor) { - methodDescriptor.doThis() + iface.forEachAttribute(function(attributeName, attribute) { + attribute.doThis(); }); // Check this.assertListEquals(called, ['doThis', 'doThis']); called = []; }; + this.testReservedInterfaceNames = function() { + // Reversed interface names are prohibited. + // (thex would conflict with the interface class) + var self = this; + this.assertThrows(function() { + this.interfaces.initializeContext('initializeContext', TestAttribute); + }, + Error); + this.assertThrows(function() { + this.interfaces.initializeContext('schema', TestAttribute); + }, + Error); + }; + this.testFinalizeInterfaces = function() { // We have a singleton, called s. var s = {}; - // We can create a simple method descriptor for an interface we want. - // The method descriptor is managing the method's registration state + // We eill create a simple attribute for a selected interface . + // The attribute is managing the attribute's registration state called = []; - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummytest', MethodDescriptor); + // Let's initialize a dimmytest interface. + this.interfaces.initializeContext('dummytest', TestAttribute); + var iface = this.interfaces.schema.dummytest; // Let's get two methods - iface.getMethodDescriptor('fooMethod').doThis() - iface.getMethodDescriptor('barMethod').doThat() + iface.getAttribute('fooMethod').doThis() + iface.getAttribute('barMethod').doThat() // Check this.assertListEquals(called, ['doThis', 'doThat']); called = []; @@ -108,31 +127,29 @@ // ... so if the descriptor sets methodFunc on the }; - this.testTwoInterfaces = function() { + this.testInitializationIsRepeatable = function() { // Let's have a second method descriptor class - var MethodDescriptor2 = function(iface, methodName) { + var TestAttribute2 = function(iface, attributeName) { this.iface = iface; - this.methodName = methodName; + this.attributeName = attributeName; this.finalize = function(loader) { - var signature = "IFACE2 " + this.methodName; + var signature = "IFACE2 " + this.attributeName; return signature; } }; - // We have a class, called C. - var C = function() {}; - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummytest', MethodDescriptor); + // Let's initialize a dimmytest interface. + this.interfaces.initializeContext('dummytest', TestAttribute); // We can get the same interface again... - this.interfaces.get('dummytest', MethodDescriptor); + this.interfaces.initializeContext('dummytest', TestAttribute); // however not with a different descriptor class! var self = this; this.assertThrows(function() { - self.interfaces.get('dummytest', MethodDescriptor2); + this.interfaces.initializeContext('dummytest', TestAttribute2); }, Error); // // On the other hand setting up a second interface is no problem. - var iface2 = this.interfaces.get('dummytest2', MethodDescriptor2); + this.interfaces.initializeContext('dummytest2', TestAttribute2); }; }; /* end InterfacesTestCase */ @@ -144,67 +161,72 @@ /* * Service interfaces */ + this.setUp = function() { + // work with our own object, not interfering + // kukit.interfaces + this.interfaces = new kukit.interfaces.NamedInterfaces(); + // Let's initialize an events and binditeration interface. + this.interfaces.initializeContext('dummyservice', kukit.interfaces.ServiceMethod); + }; this.testServiceInterfaces = function() { // We have a singleton, called s. var s = {}; - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Define four methods, thie defines their necessity and preferred providers - iface.getMethodDescriptor('first').define(['corelib', 'extralib']); - iface.getMethodDescriptor('second').define(['extralib', 'corelib']); - iface.getMethodDescriptor('third').define(['corelib']); - iface.getMethodDescriptor('fourth').define(['extralib']); + iface.getAttribute('first').define(['corelib', 'extralib']); + iface.getAttribute('second').define(['extralib', 'corelib']); + iface.getAttribute('third').define(['corelib']); + iface.getAttribute('fourth').define(['extralib']); // // somewhere else, provider "core" provides the methods: - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); - iface.getMethodDescriptor('second').provide('corelib', '1.1', + iface.getAttribute('second').provide('corelib', '1.1', function() {return function() {return 'second/core';}}); - iface.getMethodDescriptor('third').provide('corelib', '1.1', + iface.getAttribute('third').provide('corelib', '1.1', function() {return function() {return 'third/core';}}); // // somewhere else, provider "extras" provides the methods: - iface.getMethodDescriptor('first').provide('extralib', '12.4', + iface.getAttribute('first').provide('extralib', '12.4', function() {return function() {return 'first/extra';}}); - iface.getMethodDescriptor('second').provide('extralib', '12.4', + iface.getAttribute('second').provide('extralib', '12.4', function() {return function() {return 'second/extra';}}); - iface.getMethodDescriptor('fourth').provide('extralib', '12.4', + iface.getAttribute('fourth').provide('extralib', '12.4', function() {return function() {return 'fourth/extra';}}); // // Now finalize it. iface.finalize(s); // We can call the methods on it, - this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); - this.assertEquals(this.interfaces.dummytest.second(), 'second/extra'); - this.assertEquals(this.interfaces.dummytest.third(), 'third/core'); - this.assertEquals(this.interfaces.dummytest.fourth(), 'fourth/extra'); + this.assertEquals(this.interfaces.dummyservice.first(), 'first/core'); + this.assertEquals(this.interfaces.dummyservice.second(), 'second/extra'); + this.assertEquals(this.interfaces.dummyservice.third(), 'third/core'); + this.assertEquals(this.interfaces.dummyservice.fourth(), 'fourth/extra'); }; this.testChecker = function() { // Test with a checker function. // We have a singleton, called s. var s = {}; - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // and a counter for the checker var checker_counter = 0; // Define three methods - iface.getMethodDescriptor('first').define(['corelib', 'extralib'], + iface.getAttribute('first').define(['corelib', 'extralib'], function() {checker_counter++;}); // // somewhere else, core provides the methods: - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // // somewhere else, extras provides the methods: - iface.getMethodDescriptor('first').provide('extralib', '12.4', + iface.getAttribute('first').provide('extralib', '12.4', function() {return function() {return 'first/extra';}}); // // Now finalize it. iface.finalize(s); // call it - this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); + this.assertEquals(this.interfaces.dummyservice.first(), 'first/core'); // Check that the checker has been called. this.assertEquals(checker_counter, 1); }; @@ -214,27 +236,27 @@ // a plugin first provides a method that another plugin later defines. // We have a singleton, called s. var s = {}; - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // Define the method later - iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + iface.getAttribute('first').define(['corelib', 'extralib']); // Now finalize it. iface.finalize(s); // We can call the methods on it, - this.assertEquals(this.interfaces.dummytest.first(), 'first/core'); + this.assertEquals(this.interfaces.dummyservice.first(), 'first/core'); }; this.testFinalizeTwice = function() { // An interface can only be finalized once. var s = {}; - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // Define the method later - iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + iface.getAttribute('first').define(['corelib', 'extralib']); // Now finalize it. iface.finalize(s); // Finalize it again. @@ -247,9 +269,9 @@ this.testNotDefined = function() { // A method is provided but not defined. var s = {}; - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // Now finalize it. this.assertThrows(function() { @@ -260,13 +282,14 @@ this.testDoubleProvided = function() { // A method cannot be provided twice by the same provider. - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + // Let's initialize a dimmytest interface. + var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}); // Now provide it for the second time. this.assertThrows(function() { - iface.getMethodDescriptor('first').provide('corelib', '1.1', + iface.getAttribute('first').provide('corelib', '1.1', function() {return function() {return 'first/core';}}) }, Error); @@ -274,12 +297,12 @@ this.testDoubleDefined = function() { // A method can only be defined once. - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Define the method first - iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + iface.getAttribute('first').define(['corelib', 'extralib']); // define it again. this.assertThrows(function() { - iface.getMethodDescriptor('first').defineMethod(['corelib', 'extralib']) + iface.getAttribute('first').defineMethod(['corelib', 'extralib']) }, Error); }; @@ -287,11 +310,11 @@ this.testNotProvided = function() { // No preferred provider can be found for a method. var s = {}; - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Define the method first - iface.getMethodDescriptor('first').define(['corelib', 'extralib']); + iface.getAttribute('first').define(['corelib', 'extralib']); // Someone provides the method, but it's not good. - iface.getMethodDescriptor('first').provide('craplib', '1.1', + iface.getAttribute('first').provide('craplib', '1.1', function() {return function() {return 'first/crap';}}); // Now finalize it. this.assertThrows(function() { @@ -318,26 +341,26 @@ }(); // Now, for the interface part var s = {}; - var iface = this.interfaces.get('dummytest', kukit.interfaces.ServiceMethodDescriptor); + var iface = this.interfaces.schema.dummyservice; // Define the method with loader and fallback script - iface.getMethodDescriptor('first').define(['corelib', 'extralib'], null, '++resource++one'); - iface.getMethodDescriptor('second').define(['corelib', 'extralib'], null, '++resource++two'); - iface.getMethodDescriptor('third').define(['corelib', 'extralib'], null, '++resource++thr'); + iface.getAttribute('first').define(['corelib', 'extralib'], null, '++resource++one'); + iface.getAttribute('second').define(['corelib', 'extralib'], null, '++resource++two'); + iface.getAttribute('third').define(['corelib', 'extralib'], null, '++resource++thr'); // Someone provides the method, but it's not good. - iface.getMethodDescriptor('first').provide('craplib', '1.1', + iface.getAttribute('first').provide('craplib', '1.1', function() {return function() {return 'first/crap';}}); // Third will be satisfied. - iface.getMethodDescriptor('third').provide('extralib', '1.1', + iface.getAttribute('third').provide('extralib', '1.1', function() {return function() {return 'third/extra';}}); // Now finalize it. It goes without error. iface.finalize(s, loader); // We see the contents of the loader. Third is not in there. this.assertListEquals(loader.loaded, ['++resource++one', '++resource++two'], 'Loaded contents differs.'); // Third is actually working. - this.assertEquals(this.interfaces.dummytest.third(), 'third/extra'); + this.assertEquals(this.interfaces.dummyservice.third(), 'third/extra'); // First and second are undefined. - this.assertEquals(typeof(this.interfaces.dummytest.first), 'undefined'); - this.assertEquals(typeof(this.interfaces.dummytest.second), 'undefined'); + this.assertEquals(typeof(this.interfaces.dummyservice.first), 'undefined'); + this.assertEquals(typeof(this.interfaces.dummyservice.second), 'undefined'); // Now the loader can go to load the needed files... // then it is supposed to re-finalize with and without a loader. Check if this is possible: iface.finalize(s, loader); @@ -359,27 +382,35 @@ * Plugin interfaces */ + this.setUp = function() { + // work with our own object, not interfering + // kukit.interfaces + this.interfaces = new kukit.interfaces.NamedInterfaces(); + // Let's initialize an events and binditeration interface. + this.interfaces.initializeContext('dummyevents', kukit.interfaces.PluginResource); + this.interfaces.initializeContext('dummybinditerations', kukit.interfaces.BindIterationResource); + }; + var M = function() { this.bind = function(oper) {}; }; this.testPluginInterfaces = function() { - // Let's create a TestDummy interface. - var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); - var binditerations = this.interfaces.get('dummybinditerations', kukit.interfaces.BindIterationDescriptor); + var events = this.interfaces.schema.dummyevents; + var binditerations = this.interfaces.schema.dummybinditerations; // somewhere else, core registers the methods: - events.getMethodDescriptor('click').register({ + events.getAttribute('click').register({ name: 'click', defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - events.getMethodDescriptor('keydown').register({ + events.getAttribute('keydown').register({ name: 'keydown', defaultActionMethodName: null, parmtypes: [ ['preventDefault', 'bool', true], ['allowBubbling', 'bool', false]]}); - binditerations.getMethodDescriptor('').register({ + binditerations.getAttribute('').register({ eventNames: ['click', 'keydown'], iterName: 'Each', binderClass: M, @@ -387,7 +418,7 @@ //*/ // // somewhere else, extras registers the methods: - events.getMethodDescriptor('timeout').register({ + events.getAttribute('timeout').register({ name: 'timeout', defaultActionMethodName: null, parmtypes: [ @@ -395,7 +426,7 @@ ['renew', 'bool', false]]}); // It needs a bind iterator even though it is a single // group. - binditerations.getMethodDescriptor('').register({ + binditerations.getAttribute('').register({ eventNames: ['timeout'], iterName: 'Each', binderClass: M, @@ -413,10 +444,10 @@ this.testPluginNoDoubleReg = function() { // No double registration for test plugins. - // Let's create a TestDummy interface. - var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); + var events = this.interfaces.schema.dummyevents; + var binditerations = this.interfaces.schema.dummybinditerations; // somewhere a plugin registers something: - events.getMethodDescriptor('click').register({ + events.getAttribute('click').register({ name: 'click', defaultActionMethodName: null, parmtypes: [ @@ -424,7 +455,7 @@ ['allowBubbling', 'bool', false]]}); // But another providing attempt is punished by an Error. this.assertThrows(function() { - events.getMethodDescriptor('click').register({ + events.getAttribute('click').register({ name: 'click', defaultActionMethodName: null, parmtypes: [ @@ -436,10 +467,11 @@ this.testBindIterationNoDoubleReg = function() { // No double registration for test plugins. - // Let's create a TestDummy interface. - var iface = this.interfaces.get('dummybinditeration', kukit.interfaces.BindIterationDescriptor); + var events = this.interfaces.schema.dummyevents; + var binditerations = this.interfaces.schema.dummybinditerations; // somewhere else, core registers the methods: - iface.getMethodDescriptor('').register({ + // XXX attribute '' is used to call interface level methods + binditerations.getAttribute('').register({ eventNames: ['click', 'timeout'], iterName: 'Each', binderClass: M, @@ -452,18 +484,18 @@ this.bind2 = function(oper) {}; }; MSub.prototype = new M(); - iface.getMethodDescriptor('').register({ + binditerations.getAttribute('').register({ eventNames: ['keydown', 'keypress'], iterName: 'Each', binderClass: MSub, bindMethodName: 'bind'}); // finalize - iface.finalize({}); + binditerations.finalize({}); // Check that our classes are set as expected. - this.assertEquals(this.interfaces.dummybinditeration.click.binderClass, M); - this.assertEquals(this.interfaces.dummybinditeration.timeout.binderClass, M); - this.assertEquals(this.interfaces.dummybinditeration.keydown.binderClass, MSub); - this.assertEquals(this.interfaces.dummybinditeration.keypress.binderClass, MSub); + this.assertEquals(this.interfaces.dummybinditerations.click.binderClass, M); + this.assertEquals(this.interfaces.dummybinditerations.timeout.binderClass, M); + this.assertEquals(this.interfaces.dummybinditerations.keydown.binderClass, MSub); + this.assertEquals(this.interfaces.dummybinditerations.keypress.binderClass, MSub); // Check that both classes have a class name. this.assert(M.prototype.__className__); this.assert(MSub.prototype.__className__); @@ -474,10 +506,10 @@ this.testOnlyRegisteredPluginsAreFinalized = function() { // We assure that if a method descriptor is get but it is not registered, // it will not be finalized on the configuration. - // Let's create a TestDummy interface. - var events = this.interfaces.get('dummyevents', kukit.interfaces.PluginMethodDescriptor); + var events = this.interfaces.schema.dummyevents; + var binditerations = this.interfaces.schema.dummybinditerations; // Just call up the method descriptor: this will create it with config=null. - events.getMethodDescriptor('click'); + events.getAttribute('click'); // finalize events.finalize({}); // Check that click is not defined at all. (in particular, it should not be null or {}.) Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js Fri Dec 28 21:33:52 2007 @@ -56,9 +56,9 @@ // // Create the identity value provider for kssSelector, this is needed // at least to evaluate strings. - var iface = kukit.interfaces.global.get('selectors', kukit.interfaces.PluginMethodDescriptor); - var info = {providerClass: kukit.pr.IdentityPP}; - iface.getMethodDescriptor('').register(info); + var iface = kukit.interfaces.global.schema.selectors; + iface.getAttribute('').register({ + providerClass: kukit.pr.IdentityPP}); //Create some selectors kukit.selectorTypesGlobalRegistry.register('htmlid', function(expr, node) {}); // From reebalazs at codespeak.net Fri Dec 28 21:33:57 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 21:33:57 +0100 (CET) Subject: [KSS-checkins] r50166 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit tests Message-ID: <20071228203357.0C36A168510@codespeak.net> Author: reebalazs Date: Fri Dec 28 21:33:57 2007 New Revision: 50166 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Switch also the service layer to config dicts, causes a better readable service.js and tests. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 21:33:57 2007 @@ -249,7 +249,7 @@ }; /* end NamedInterfaces */ /* - * KSS service layer registry + * KSS service layer resource */ this.ServiceMethod = function(iface, methodName) { @@ -257,43 +257,64 @@ this.iface = iface; this.methodName = methodName; this.registry = {}; - this.preferredProviders = null; + this.preferredSources = null; - this.define = function(preferredProviders, checker, fallbackProvider) { - if (this.preferredProviders) { -;;; kukit.E = 'Attempt to double define method ['; +;;; this._makeError = function(componentName, name) { +;;; kukit.E = 'In a call to ' + componentName + ', '; +;;; kukit.E += name + ' must be provided for method ['; +;;; kukit.E += this.methodName + '] on interface ['; +;;; kukit.E += this.iface.interfaceName + ']'; +;;; return new Error(kukit.E); +;;; }; + + this.require = function(config) { +;;; // Diagnose if parameters are all right. +;;; if (! config.preferredSources) { +;;; throw this._makeError('ServiceMethod.require', 'config.getter'); +;;; }; + if (this.preferredSources) { +;;; kukit.E = 'ServiceMethod.require is called twice on ['; ;;; kukit.E += this.methodName + '] on interface ['; ;;; kukit.E += this.iface.interfaceName + ']'; throw new Error(kukit.E); }; - this.preferredProviders = preferredProviders; - this.checker = checker; - this.fallbackProvider = fallbackProvider; + this.preferredSources = config.preferredSources; + this.checker = config.checker; + this.fallbackProvider = config.fallbackProvider; }; - this.provide = function(providerName, providerVersion, getter) { + this.provide = function(config) { +;;; // Diagnose if parameters are all right. +;;; var componentName = 'SericeDescriptor.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.iface.finalized) { ;;; kukit.E = 'Attempt to provide implementation to method ['; ;;; kukit.E += this.methodName + '] on already finalized interface ['; ;;; kukit.E += this.iface.interfaceName + ']'; throw new Error(kukit.E); - } else if (typeof(this.registry[providerName]) != 'undefined') { -;;; kukit.E = 'Double registration by [' + providerName + ']['; + } else if (typeof(this.registry[config.sourceName]) != 'undefined') { +;;; kukit.E = 'Double registration by [' + config.sourceName + ']['; ;;; kukit.E += providerVersion; ;;; kukit.E += '] of method [' + this.methodName; ;;; kukit.E += '] in interface [' + this.iface.interfaceName + ']'; throw new Error(kukit.E); } - this.registry[providerName] = { - methodName: this.methodName, - providerName: providerName, - providerVersion: providerVersion, - getter: getter}; + // Use the config to set the registry + config.methodName = this.methodName; + this.registry[config.sourceName] = config; }; this.finalize = function(loader) { var func; - if (! this.preferredProviders) { + if (! this.preferredSources) { ;;; kukit.E = 'Undefined method ['; ;;; kukit.E += this.methodName + '] on interface ['; ;;; kukit.E += this.iface.interfaceName + '], '; @@ -302,8 +323,8 @@ throw new Error(kukit.E); } // loop through all preferred providers - for (var i = 0; i < this.preferredProviders.length; i++) { - var item = this.registry[this.preferredProviders[i]]; + for (var i = 0; i < this.preferredSources.length; i++) { + var item = this.registry[this.preferredSources[i]]; // Did we have an item? if (typeof(item) == 'undefined') { continue; @@ -329,7 +350,7 @@ ;;; kukit.E += this.methodName + '] on interface ['; ;;; kukit.E += this.iface.interfaceName + '], because no provider found '; ;;; kukit.E += 'of the following preferences: ['; -;;; kukit.E += this.preferredProviders + ']'; +;;; kukit.E += this.preferredSources + ']'; throw new Error(kukit.E); } } else { Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Fri Dec 28 21:33:57 2007 @@ -1,64 +1,74 @@ - new function() { // BEGIN CLOSURE service - var core = kukit.interfaces.global.schema.core; +var core = kukit.interfaces.global.schema.core; - core.getAttribute('cssQuery').define(['base2', 'cssQuery'], - // a parameter checker common for each implementation - function(selector, inNodes) { - // to eliminate possible errors - if (typeof(inNodes) != 'undefined' && inNodes == null) { -;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; - throw new Error(kukit.E); - } - }); - - // providers are also here now - - core.getAttribute('cssQuery').provide('cssQuery', '1.1', - function() { - // Detect if cssQuery is present - // - if (typeof(cssQuery) == 'undefined') { - return; - } - // return the method plug -;;; kukit.log('Using original cssQuery.'); - return function(selector, inNodes) { - // global scope, always. - // This is very bad. However the binding makes sure that - // nodes once bound will never be bound again - // (also, noticed the following issue: cssQuery, when called - // on an element, does not check the element itself.) - var results = cssQuery(selector); - return results; - }; - }); - - - core.getAttribute('cssQuery').provide('base2', '1.1', - function() { - // Detect if base2 is present - // - if (typeof(base2) == 'undefined') { - return; - } - // return the method plug -;;; kukit.log('Using cssQuery from base2.'); - return function(selector, inNodes) { - // global scope, always. - // This is very bad. However the binding makes sure that - // nodes once bound will never be bound again - var results = base2.DOM.Document.matchAll(document, selector); - var nodes = []; - for(var i = 0; i < results.length; i++) { - nodes.push(results.item(i)); - } - return nodes; - }; - }); +// Requirements towards core services. It contains +// kukit's preferences to choose between vendors +// that implement a given functionality. + +core.getAttribute('cssQuery').require({ + preferredSources: ['base2', 'cssQuery'], + // a parameter checker common for each implementation + checker: function(selector, inNodes) { + // to eliminate possible errors + if (typeof(inNodes) != 'undefined' && inNodes == null) { +;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; + throw new Error(kukit.E); + } + }}); + +// Third party code provides services. We have a few things +// that we can detect ourselves. by inspecting if a given +// library is loaded. + +core.getAttribute('cssQuery').provide({ + sourceName:'cssQuery', + sourceVersion: '1.1', + getter: function() { + // Detect if cssQuery is present + // + if (typeof(cssQuery) == 'undefined') { + return; + } + // return the method plug +;;; kukit.log('Using original cssQuery.'); + return function(selector, inNodes) { + // global scope, always. + // This is very bad. However the binding makes sure that + // nodes once bound will never be bound again + // (also, noticed the following issue: cssQuery, when called + // on an element, does not check the element itself.) + var results = cssQuery(selector); + return results; + }; + }}); + + +core.getAttribute('cssQuery').provide({ + sourceName: 'base2', + sourceVersion: '1.1', + getter: function() { + // Detect if base2 is present + // + if (typeof(base2) == 'undefined') { + return; + } + // return the method plug +;;; kukit.log('Using cssQuery from base2.'); + return function(selector, inNodes) { + // global scope, always. + // This is very bad. However the binding makes sure that + // nodes once bound will never be bound again + var results = base2.DOM.Document.matchAll(document, selector); + var nodes = []; + for(var i = 0; i < results.length; i++) { + nodes.push(results.item(i)); + } + return nodes; + }; + }}); }() // END CLOSURE service Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Fri Dec 28 21:33:57 2007 @@ -173,27 +173,43 @@ // We have a singleton, called s. var s = {}; var iface = this.interfaces.schema.dummyservice; - // Define four methods, thie defines their necessity and preferred providers - iface.getAttribute('first').define(['corelib', 'extralib']); - iface.getAttribute('second').define(['extralib', 'corelib']); - iface.getAttribute('third').define(['corelib']); - iface.getAttribute('fourth').define(['extralib']); + // Requires four methods, thie defines their necessity and preferred providers + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']}); + iface.getAttribute('second').require({ + preferredSources: ['extralib', 'corelib']}); + iface.getAttribute('third').require({ + preferredSources: ['corelib']}); + iface.getAttribute('fourth').require({ + preferredSources: ['extralib']}); // - // somewhere else, provider "core" provides the methods: - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); - iface.getAttribute('second').provide('corelib', '1.1', - function() {return function() {return 'second/core';}}); - iface.getAttribute('third').provide('corelib', '1.1', - function() {return function() {return 'third/core';}}); + // somewhere else, source "corelib" provides the methods: + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); + iface.getAttribute('second').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'second/core';}}}); + iface.getAttribute('third').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'third/core';}}}); // - // somewhere else, provider "extras" provides the methods: - iface.getAttribute('first').provide('extralib', '12.4', - function() {return function() {return 'first/extra';}}); - iface.getAttribute('second').provide('extralib', '12.4', - function() {return function() {return 'second/extra';}}); - iface.getAttribute('fourth').provide('extralib', '12.4', - function() {return function() {return 'fourth/extra';}}); + // somewhere else, source "extras" provides the methods: + iface.getAttribute('first').provide({ + sourceName: 'extralib', + sourceVersion: '12.4', + getter: function() {return function() {return 'first/extra';}}}); + iface.getAttribute('second').provide({ + sourceName: 'extralib', + sourceVersion: '12.4', + getter: function() {return function() {return 'second/extra';}}}); + iface.getAttribute('fourth').provide({ + sourceName: 'extralib', + sourceVersion: '12.4', + getter: function() {return function() {return 'fourth/extra';}}}); // // Now finalize it. iface.finalize(s); @@ -212,16 +228,21 @@ // and a counter for the checker var checker_counter = 0; // Define three methods - iface.getAttribute('first').define(['corelib', 'extralib'], - function() {checker_counter++;}); + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib'], + checker: function() {checker_counter++;}}); // // somewhere else, core provides the methods: - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); // // somewhere else, extras provides the methods: - iface.getAttribute('first').provide('extralib', '12.4', - function() {return function() {return 'first/extra';}}); + iface.getAttribute('first').provide({ + sourceName: 'extralib', + sourceVersion: '12.4', + getter: function() {return function() {return 'first/extra';}}}); // // Now finalize it. iface.finalize(s); @@ -233,15 +254,18 @@ this.testReverseOrder = function() { // Method creation also works in reverse order: - // a plugin first provides a method that another plugin later defines. + // a plugin first provides a method that another plugin later requires. // We have a singleton, called s. var s = {}; var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); // Define the method later - iface.getAttribute('first').define(['corelib', 'extralib']); + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']}); // Now finalize it. iface.finalize(s); // We can call the methods on it, @@ -253,10 +277,13 @@ var s = {}; var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); // Define the method later - iface.getAttribute('first').define(['corelib', 'extralib']); + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']}); // Now finalize it. iface.finalize(s); // Finalize it again. @@ -267,12 +294,14 @@ }; this.testNotDefined = function() { - // A method is provided but not defined. + // A method is provided but not required. var s = {}; var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); // Now finalize it. this.assertThrows(function() { iface.finalize(s); @@ -281,41 +310,49 @@ }; this.testDoubleProvided = function() { - // A method cannot be provided twice by the same provider. + // A method cannot be provided twice by the same source. // Let's initialize a dimmytest interface. var iface = this.interfaces.schema.dummyservice; // Provide the method first - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}); + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); // Now provide it for the second time. this.assertThrows(function() { - iface.getAttribute('first').provide('corelib', '1.1', - function() {return function() {return 'first/core';}}) + iface.getAttribute('first').provide({ + sourceName: 'corelib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/core';}}}); }, Error); }; this.testDoubleDefined = function() { - // A method can only be defined once. + // A method can only be required once. var iface = this.interfaces.schema.dummyservice; // Define the method first - iface.getAttribute('first').define(['corelib', 'extralib']); - // define it again. + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']}); + // require it again. this.assertThrows(function() { - iface.getAttribute('first').defineMethod(['corelib', 'extralib']) - }, + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']})}, Error); }; this.testNotProvided = function() { - // No preferred provider can be found for a method. + // No preferred vendor can be found for a method. var s = {}; var iface = this.interfaces.schema.dummyservice; // Define the method first - iface.getAttribute('first').define(['corelib', 'extralib']); + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib']}); // Someone provides the method, but it's not good. - iface.getAttribute('first').provide('craplib', '1.1', - function() {return function() {return 'first/crap';}}); + iface.getAttribute('first').provide({ + sourceName: 'craplib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/crap';}}}); // Now finalize it. this.assertThrows(function() { iface.finalize(s); @@ -343,15 +380,25 @@ var s = {}; var iface = this.interfaces.schema.dummyservice; // Define the method with loader and fallback script - iface.getAttribute('first').define(['corelib', 'extralib'], null, '++resource++one'); - iface.getAttribute('second').define(['corelib', 'extralib'], null, '++resource++two'); - iface.getAttribute('third').define(['corelib', 'extralib'], null, '++resource++thr'); + iface.getAttribute('first').require({ + preferredSources: ['corelib', 'extralib'], + fallbackProvider: '++resource++one'}); + iface.getAttribute('seconf').require({ + preferredSources: ['corelib', 'extralib'], + fallbackProvider: '++resource++two'}); + iface.getAttribute('third').require({ + preferredSources: ['corelib', 'extralib'], + fallbackProvider: '++resource++three'}); // Someone provides the method, but it's not good. - iface.getAttribute('first').provide('craplib', '1.1', - function() {return function() {return 'first/crap';}}); + iface.getAttribute('first').provide({ + sourceName: 'craplib', + sourceVersion: '1.1', + getter: function() {return function() {return 'first/crap';}}}); // Third will be satisfied. - iface.getAttribute('third').provide('extralib', '1.1', - function() {return function() {return 'third/extra';}}); + iface.getAttribute('third').provide({ + sourceName: 'extralib', + sourceVersion: '12.4', + getter: function() {return function() {return 'third/extra';}}}); // Now finalize it. It goes without error. iface.finalize(s, loader); // We see the contents of the loader. Third is not in there. From reebalazs at codespeak.net Fri Dec 28 21:34:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 28 Dec 2007 21:34:01 +0100 (CET) Subject: [KSS-checkins] r50167 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . kukit Message-ID: <20071228203401.CDE71168512@codespeak.net> Author: reebalazs Date: Fri Dec 28 21:34:01 2007 New Revision: 50167 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Log: Make logging of the service method choices better. On Firefox, make the interface logged to allow introspection. Set versions of cssQuery and base2 that kukit uses. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Fri Dec 28 21:34:01 2007 @@ -354,6 +354,13 @@ throw new Error(kukit.E); } } else { + // We found the func that we can finalze now. +;;; kukit.E = 'Using method ['; +;;; kukit.E += this.methodName + '] from source ['; +;;; kukit.E += item.sourceName + '] version ['; +;;; kukit.E += item.sourceVersion + '].'; +;;; kukit.log(kukit.E); + // Return the func, optionally prefixed with a checker. if (this.checker) { // if there is a checker, merge them together var self = this; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Fri Dec 28 21:34:01 2007 @@ -243,6 +243,12 @@ // We finalize the core interfaces. kukit.interfaces.finalizeGlobalInterfaces(); ;;; kukit.log('All interfaces finalized.'); +;;; // If we have firebug, log the interfaces to +;;; // be introspected from the console. +;;; if (kukit.hasFirebug) { +;;; kukit.logDebug(kukit.interfaces.global); +;;; } + // ;;; kukit.log('Initializing kinetic stylesheets.'); // Succesful initialization. At the moment the engine is kept // as a global variable, but this needs refinement in the future. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Fri Dec 28 21:34:01 2007 @@ -5,7 +5,7 @@ var core = kukit.interfaces.global.schema.core; // Requirements towards core services. It contains -// kukit's preferences to choose between vendors +// kukit's preferences to choose between sources // that implement a given functionality. core.getAttribute('cssQuery').require({ @@ -25,7 +25,7 @@ core.getAttribute('cssQuery').provide({ sourceName:'cssQuery', - sourceVersion: '1.1', + sourceVersion: '2.0.2', getter: function() { // Detect if cssQuery is present // @@ -33,7 +33,6 @@ return; } // return the method plug -;;; kukit.log('Using original cssQuery.'); return function(selector, inNodes) { // global scope, always. // This is very bad. However the binding makes sure that @@ -48,7 +47,7 @@ core.getAttribute('cssQuery').provide({ sourceName: 'base2', - sourceVersion: '1.1', + sourceVersion: '0.??', getter: function() { // Detect if base2 is present // @@ -56,7 +55,6 @@ return; } // return the method plug -;;; kukit.log('Using cssQuery from base2.'); return function(selector, inNodes) { // global scope, always. // This is very bad. However the binding makes sure that From reebalazs at codespeak.net Sat Dec 29 11:54:29 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sat, 29 Dec 2007 11:54:29 +0100 (CET) Subject: [KSS-checkins] r50169 - kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo Message-ID: <20071229105429.AED24168465@codespeak.net> Author: reebalazs Date: Sat Dec 29 11:54:27 2007 New Revision: 50169 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js Log: Demonstrate the use of registry by implementing Godefroid's improvement to the more_selectors demo, from finish-closures Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js Sat Dec 29 11:54:27 2007 @@ -14,9 +14,17 @@ // overwrite countsomuch this.countsomuch = oper.parms.count; this.count = this.countsomuch; - // Just bind the event via the native event binder + // Just bind the event via the native click event binder oper.parms = {}; - kukit.pl.NativeEventBinder.prototype.__bind__(oper, 'click'); + // Bind the event by looking up the binder class from the registry + // + // This __bind__ method offers an additional parameter to overwrite + // the name of the native browser event to bind. + // (Oper would fetch "annoyclicker-click" from the kssSelector, + // and this is used for info messages, but "click" will be + // bound physically.) + var click = kukit.interfaces.global.binditerations.click; + click.binderClass.prototype.__bind__(oper, 'click'); }; kukit.more_selectors.AnnoyClickerEvent.prototype.__default_click__ = function(name, oper) { From reebalazs at codespeak.net Sat Dec 29 14:00:05 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sat, 29 Dec 2007 14:00:05 +0100 (CET) Subject: [KSS-checkins] r50170 - in kukit/buildout/kss.zope: . extraproducts Message-ID: <20071229130005.AB27E16851F@codespeak.net> Author: reebalazs Date: Sat Dec 29 14:00:04 2007 New Revision: 50170 Removed: kukit/buildout/kss.zope/extraproducts/ Modified: kukit/buildout/kss.zope/base.cfg kukit/buildout/kss.zope/buildout.cfg Log: Zelenium is now produced with infrae.subversion Modified: kukit/buildout/kss.zope/base.cfg ============================================================================== --- kukit/buildout/kss.zope/base.cfg (original) +++ kukit/buildout/kss.zope/base.cfg Sat Dec 29 14:00:04 2007 @@ -69,6 +69,11 @@ transition/kss.zope transition/kss.demo +[extraproducts] +recipe = infrae.subversion +urls = + svn://svn.zope.org/repos/main/Zelenium/trunk Zelenium + [zope2] recipe = plone.recipe.zope2install # url = http://www.zope.org/Products/Zope/2.10.4/Zope-2.10.4-final.tgz @@ -83,6 +88,7 @@ #http-address = 127.0.0.1:8080 products = ${buildout:directory}/products + ${buildout:directory}/parts/extraproducts eggs = ${buildout:eggs} @@ -90,6 +96,7 @@ kss.base kss.zope kss.demo + ipdb zcml = Products.CMFPlone Modified: kukit/buildout/kss.zope/buildout.cfg ============================================================================== --- kukit/buildout/kss.zope/buildout.cfg (original) +++ kukit/buildout/kss.zope/buildout.cfg Sat Dec 29 14:00:04 2007 @@ -8,6 +8,7 @@ zope2 instance zopepy + extraproducts # clouseau # docfindertab @@ -24,7 +25,7 @@ products = ${buildout:directory}/products - ${buildout:directory}/extraproducts + ${buildout:directory}/parts/extraproducts # ${clouseau:location} # ${docfindertab:location} From reebalazs at codespeak.net Sat Dec 29 18:35:56 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sat, 29 Dec 2007 18:35:56 +0100 (CET) Subject: [KSS-checkins] r50176 - kukit/buildout/kss.zope Message-ID: <20071229173556.DB22D168538@codespeak.net> Author: reebalazs Date: Sat Dec 29 18:35:56 2007 New Revision: 50176 Modified: kukit/buildout/kss.zope/base.cfg Log: Follow changes from ploneout trunk Modified: kukit/buildout/kss.zope/base.cfg ============================================================================== --- kukit/buildout/kss.zope/base.cfg (original) +++ kukit/buildout/kss.zope/base.cfg Sat Dec 29 18:35:56 2007 @@ -13,6 +13,7 @@ # with some packages clearly commented out, # and extra packages added to the end. develop = + src/Archetypes src/Products.ATReferenceBrowserWidget src/Products.CMFDynamicViewFTI src/Products.CMFFormController From jvloothuis at codespeak.net Sat Dec 29 23:07:19 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sat, 29 Dec 2007 23:07:19 +0100 (CET) Subject: [KSS-checkins] r50181 - kukit/kss.base/branches/protocol-data-types Message-ID: <20071229220719.C11CD168538@codespeak.net> Author: jvloothuis Date: Sat Dec 29 23:07:17 2007 New Revision: 50181 Added: kukit/kss.base/branches/protocol-data-types/ - copied from r50180, kukit/kss.base/trunk/ Log: Branch for introduction of protocol datatypes From jvloothuis at codespeak.net Sat Dec 29 23:14:20 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sat, 29 Dec 2007 23:14:20 +0100 (CET) Subject: [KSS-checkins] r50182 - kukit/kss.base/branches/protocol-data-types/kss/base Message-ID: <20071229221420.4E2C616852E@codespeak.net> Author: jvloothuis Date: Sat Dec 29 23:14:19 2007 New Revision: 50182 Modified: kukit/kss.base/branches/protocol-data-types/kss/base/__init__.py kukit/kss.base/branches/protocol-data-types/kss/base/commands.py kukit/kss.base/branches/protocol-data-types/kss/base/commands.txt kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.py kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.txt Log: Added parameter types. These are used when serializing data to the client. We currently have cdata, xml and html support. Changed string representation of KSS commands so that global commands do not show a None selector. Removed automatic conversion to css selector in the add method of commands. The client will decides the selector type if the server has not given any. Modified: kukit/kss.base/branches/protocol-data-types/kss/base/__init__.py ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/__init__.py (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/__init__.py Sat Dec 29 23:14:19 2007 @@ -1,3 +1,4 @@ from kss.base.commands import KSSCommands from kss.base.selectors import selectors from kss.base.plugin import load_plugins +from kss.base.commands import xmldata, htmldata, cdatadata Modified: kukit/kss.base/branches/protocol-data-types/kss/base/commands.py ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/commands.py (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/commands.py Sat Dec 29 23:14:19 2007 @@ -1,7 +1,6 @@ -from xml.sax.saxutils import quoteattr +from xml.sax.saxutils import quoteattr, escape from kss.base.registry import command_set_registry from kss.base.selectors import Selector -from kss.base.selectors import css kss_response_header = ''' @@ -14,7 +13,23 @@ kss_command_end = '' -kss_param = '' +kss_param = '%(value)s' + +class cdatadata(object): + def __init__(self, value): + self.value = value + + def __str__(self): + return '' % self.value.replace(']]>', ']]>') + + def __repr__(self): + return "%s('%s')" % (self.__class__.__name__, self.value) + +class htmldata(cdatadata): + pass + +class xmldata(cdatadata): + pass class KSSCommands(object): '''Command renderer for creating KSS responses''' @@ -24,9 +39,6 @@ def add(self, action, selector, **kwargs): self._strip_none_parameters(kwargs) - if selector is not None and not isinstance(selector, Selector): - selector = css(selector) - self.commands.append((action, selector, kwargs)) def _strip_none_parameters(self, parameters): @@ -37,11 +49,24 @@ def render(self): output = [kss_response_header] for action, selector, options in self.commands: + try: + selector_type = selector.type + selector = selector.value + except AttributeError: + # It is probably a string or unicode object so we can + # let the client decide the default selector + selector_type = '' + output.append(kss_command_start % dict( - selector=quoteattr(selector.value), - selector_type=quoteattr(selector.type), - action=quoteattr(action))) + selector=quoteattr(selector), + selector_type=quoteattr(selector_type), + action=quoteattr(action))) + for name, value in options.items(): + if isinstance(value, basestring): + value = escape(value) + else: + value = str(value) output.append(kss_param % dict( name=quoteattr(name), value=value)) output.append(kss_command_end) @@ -52,18 +77,21 @@ self.commands = [] def __str__(self): - def format_options(options): - if not options: - return '' - return ', ' + ', '.join( - ["%s='%s'" % item for item in options.items()]) - lines = [] for action, selector, options in self.commands: - lines.append("%(action)s(%(selector)s%(options)s)" % { - 'action': action, - 'selector': selector, - 'options': format_options(options)}) + line = '%s(' % action + if isinstance(selector, Selector): + line += '%s' % selector + elif isinstance(selector, basestring): + line += "'%s'" % selector + + if options: + if selector is not None: + line += ', ' + line += ', '.join( + ["%s=%s" % (key, repr(value)) for + key, value in options.items()]) + lines.append(line + ')') return '\n'.join(lines) def __getattr__(self, name): Modified: kukit/kss.base/branches/protocol-data-types/kss/base/commands.txt ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/commands.txt (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/commands.txt Sat Dec 29 23:14:19 2007 @@ -40,9 +40,10 @@ '...some value...some arg...' + + Response format =============== - The response is an XML document. >>> from xml.dom import minidom @@ -55,7 +56,32 @@ [, ] Each parameter is represented by a child node in a command. Their name -is stored in the attribute and their value is put within CDATA blocks. +is stored in the attribute and their value is put within text nodes or +CDATA blocks. Which type of node is used depends on the type of +the keyword argument given to the command. + +Depending on the type the serialisation to XML changes. Strings and +unicode objects will be send as text nodes. You can also mark data as +HTML, XML or CDATA blocks. This is used so that these can have special +escaping rules. + + >>> from kss.base import xmldata, htmldata, cdatadata + +Now if we make a command with these types the output will be different. + + >>> commands = KSSCommands() + >>> commands.add('htmlAction', css('#someid'), html=htmldata('some value')) + >>> commands.add('cdataAction', css('#otherid'), arg=cdatadata('some arg')) + >>> commands.add('xmlAction', css('#otherid'), arg=xmldata('some arg')) + >>> commands.add('normalAction', css('#otherid'), arg='normal arg') + >>> doc = minidom.parseString(commands.render()) + >>> for command in doc.getElementsByTagName('command'): + ... params = command.getElementsByTagName('param') + ... print params[0].childNodes[0].nodeType == doc.CDATA_SECTION_NODE + True + True + True + False >>> replace_command = doc.getElementsByTagName('command')[0] @@ -125,12 +151,12 @@ You can also use strings instead of a selector instance as a value for selector. In this case the string will automatically be converted to a -CSS selector. +selector on the client. By default this is the CSS selector. >>> commands.clear() >>> commands.add('replaceHTML', '#someid', html='some value') >>> print commands - replaceHTML(css('#someid'), html='some value') + replaceHTML('#someid', html='some value') Command sets @@ -182,6 +208,6 @@ >>> commands.core.replaceInnerHTML(css('div'), 'example') >>> print commands - replaceInnerHTML(css('div'), html='example') + replaceInnerHTML(css('div'), html=htmldata('example')) >>> command_set_registry.unregister('core') \ No newline at end of file Modified: kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.py ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.py (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.py Sat Dec 29 23:14:19 2007 @@ -1,4 +1,5 @@ from kss.base.commands import KSSCommandSet +from kss.base import htmldata class KSSCoreCommands(KSSCommandSet): @@ -27,7 +28,7 @@ extra_args = {} if not withKssSetup: extra_args['withKssSetup'] = 'False' - self.commands.add('replaceInnerHTML', selector, html=value, + self.commands.add('replaceInnerHTML', selector, html=htmldata(value), **extra_args) def replaceHTML(self, selector, value, withKssSetup=True): Modified: kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.txt ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.txt (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/corecommands.txt Sat Dec 29 23:14:19 2007 @@ -95,15 +95,15 @@ >>> commands.clear() >>> core.replaceInnerHTML(css('div'), 'some html') >>> print commands - replaceInnerHTML(css('div'), html='some html') + replaceInnerHTML(css('div'), html=htmldata('some html')) You can also avoid KSS event setup. Use this only if you really need the speedup because KSS will not be applied to these new nodes. >>> core.replaceInnerHTML(css('div'), 'some html', withKssSetup=False) >>> print commands - replaceInnerHTML(css('div'), html='some html') - replaceInnerHTML(css('div'), html='some html', withKssSetup='False') + replaceInnerHTML(css('div'), html=htmldata('some html')) + replaceInnerHTML(css('div'), html=htmldata('some html'), withKssSetup='False') Replace HTML @@ -261,7 +261,7 @@ >>> commands.clear() >>> core.setStateVar('varname', 'value') >>> print commands - setStateVar(None, varname='varname', value='value') + setStateVar(varname='varname', value='value') Trigger event ------------- @@ -269,4 +269,4 @@ >>> commands.clear() >>> core.triggerEvent('eventname') >>> print commands - triggerEvent(None, name='eventname') + triggerEvent(name='eventname') From reebalazs at codespeak.net Sun Dec 30 11:03:29 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 11:03:29 +0100 (CET) Subject: [KSS-checkins] r50184 - in kukit/kss.zope/trunk/kss: core zope zope/tests Message-ID: <20071230100329.EE9221684FF@codespeak.net> Author: reebalazs Date: Sun Dec 30 11:03:28 2007 New Revision: 50184 Added: kukit/kss.zope/trunk/kss/zope/tests/base.py kukit/kss.zope/trunk/kss/zope/tests/interfaces.py kukit/kss.zope/trunk/kss/zope/tests/test_actionwrapper.py Removed: kukit/kss.zope/trunk/kss/core/actionwrapper.py kukit/kss.zope/trunk/kss/core/permission.zcml Modified: kukit/kss.zope/trunk/kss/core/__init__.py kukit/kss.zope/trunk/kss/core/configure.zcml kukit/kss.zope/trunk/kss/zope/__init__.py kukit/kss.zope/trunk/kss/zope/actionwrapper.py kukit/kss.zope/trunk/kss/zope/commands.py kukit/kss.zope/trunk/kss/zope/meta.zcml kukit/kss.zope/trunk/kss/zope/view.py Log: port actionwrapper and attempt to fix tests, work in progress Modified: kukit/kss.zope/trunk/kss/core/__init__.py ============================================================================== --- kukit/kss.zope/trunk/kss/core/__init__.py (original) +++ kukit/kss.zope/trunk/kss/core/__init__.py Sun Dec 30 11:03:28 2007 @@ -30,14 +30,14 @@ from kss.core.kssview import KSSView from kss.zope.commandset import ZopeCommandSet as CommandSet +from kss.zope.actionwrapper import KSSExplicitError, kssaction -from kss.core.actionwrapper import KSSExplicitError, kssaction from kss.core.unicode_quirks import force_unicode, KSSUnicodeError from kss.core.interfaces import ICommandSet # BBB from kss.core.kssview import AzaxBaseView -from kss.core.actionwrapper import KssExplicitError +from kss.zope.actionwrapper import KssExplicitError import sys, kssview sys.modules['kss.core.azaxview'] = kssview Deleted: /kukit/kss.zope/trunk/kss/core/actionwrapper.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/actionwrapper.py Sun Dec 30 11:03:28 2007 +++ (empty file) @@ -1,256 +0,0 @@ -# Copyright (c) 2005-2007 -# Authors: KSS Project Contributors (see docs/CREDITS.txt) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -from textwrap import dedent -from inspect import formatargspec, getargspec, getargvalues, \ - formatargvalues, currentframe -from zope.interface import implements - -class KSSExplicitError(Exception): - 'Explicit error to be raised' - -class kssaction(object): - '''Descriptor to bundle kss server actions. - - - render() will be called automatically if there is no - return value - - - if KSSExplicitError is raised, a normal response is returned, - containing a single command:error KSS command. - - Let's say we have a class here - that is supposed to be a kss view. - - >>> from kss.core import kssaction, KSSExplicitError, KSSView - - >>> class MyView(KSSView): - ... def ok(self, a, b, c=0): - ... return 'OK %s %s %s' % (a, b, c) - ... def notok(self, a, b, c=0): - ... pass - ... def error(self, a, b, c=0): - ... raise KSSExplicitError, 'The error' - ... def exception(self, a, b, c=0): - ... raise Exception, 'Unknown exception' - - Now we try qualifying with kssaction. We overwrite render too, - just to enable sensible testing of the output: - - >>> class MyView(KSSView): - ... def render(self): - ... return 'Rendered' - ... @kssaction - ... def ok(self, a, b, c=3): - ... return 'OK %s %s %s' % (a, b, c) - ... @kssaction - ... def notok(self, a, b, c=3): - ... pass - ... @kssaction - ... def error(self, a, b, c=3): - ... raise KSSExplicitError, 'The error' - ... @kssaction - ... def exception(self, a, b, c=3): - ... raise Exception, 'Unknown exception' - - Instantiate a view. - - >>> view = MyView(None, None) - - Now, of course ok renders well. - - >>> view.ok(1, b=2) - 'OK 1 2 3' - - Not ok will have implicit rendering. - - >>> view.notok(1, b=2) - 'Rendered' - - The third type will return an error action. But it will render - instead of an error. - - >>> view.error(1, b=2) - 'Rendered' - - The fourth type will be a real error. - - >>> view.exception(1, b=2) - Traceback (most recent call last): - ... - Exception: Unknown exception - - Now for the sake of it, let's test the rendered kukit response. - So, we don't overwrite render like as we did in the previous - tests. - - >>> from zope.publisher.browser import TestRequest - - >>> class MyView(KSSView): - ... @kssaction - ... def error(self, a, b, c=3): - ... raise KSSExplicitError, 'The error' - ... @kssaction - ... def with_docstring(self, a, b, c=3): - ... "Docstring" - ... raise KSSExplicitError, 'The error' - - >>> request = TestRequest() - >>> view = MyView(None, request) - - Set debug-mode command rendering so we can see the results in a - more structured form. - - >>> from zope import interface as iapi - >>> from kss.core.tests.base import IDebugRequest - >>> iapi.directlyProvides(request, iapi.directlyProvidedBy(request) + IDebugRequest) - - See the results: - - >>> view.error(1, b=2) - [{'selectorType': None, 'params': {'message': u'The error'}, 'name': 'error', 'selector': None}] - - Usage of the method wrapped in browser view - ------------------------------------------- - - Finally, let's check if the method appears if defined on a browser view. - Since there could be a thousand reasons why Five's magic could fail, - it's good to check this. (XXX Note that this must be adjusted to run on Zope3.) - - >>> try: - ... import Products.Five - ... except ImportError: - ... # probably zope 3, not supported - ... raise 'Zope3 not supported in this test' - ... else: - ... from Products.Five.zcml import load_string, load_config - - >>> import kss.core.tests - >>> kss.core.tests.MyView = MyView - - We check for two basic types of declaration. The first one declares - a view with different attributes. The second one declares a dedicated - view with the method as the view default method. This is how we use - it in several places. - - >>> load_string(""" - ... - ... - ... - ... - ... - ... - ... """) - - Let's check it now: - - >>> self.folder.restrictedTraverse('/@@my_view/error') - >> v = self.folder.restrictedTraverse('/my_view2') - >>> isinstance(v, MyView) - True - >>> hasattr(v, 'error') - True - >>> v(1, b=2) - [{'selectorType': None, 'params': {'message': u'The error'}, 'name': 'error', 'selector': None}] - - In addition, to be publishable, the docstring must exist. Let's - see if the wrapper actually does this. If the method had a docstring, - it will be reused, but a docstring is provided in any case. - - >>> v = self.folder.restrictedTraverse('/@@my_view') - >>> bool(v.error.__doc__) - True - - >>> v.with_docstring.__doc__ - 'Docstring' - - ''' - def __init__(self, f): - self.f = f - # Now this is a solution I don't like, but we need the same - # function signature, otherwise the ZPublisher won't marshall - # the parameters. *arg, **kw would not suffice since no parameters - # would be marshalled at all. - argspec = getargspec(f) - orig_args = formatargspec(*argspec)[1:-1] - if argspec[3] is None: - fixed_args_num = len(argspec[0]) - else: - fixed_args_num = len(argspec[0]) - len(argspec[3]) - values_list = [v for v in argspec[0][:fixed_args_num]] - values_list.extend(['%s=%s' % (v, v) for v in argspec[0][fixed_args_num:]]) - values_args = ', '.join(values_list) - # provide a docstring in any case. - if self.f.__doc__ is not None: - docstring = repr(f.__doc__) - else: - docstring = '"XXX"' - # orig_args: "a, b, c=2" - # values_args: "a, b, c=c" - code = dedent('''\n - def wrapper(%s): - %s - return descr.apply(%s) - ''' % (orig_args, docstring, values_args)) - self.wrapper_code = compile(code, '', 'exec') - - def __get__(self, obj, cls=None): - d = {'descr': self, 'self': obj} - exec(self.wrapper_code, d) - wrapper = d['wrapper'].__get__(obj, cls) - return wrapper - - def apply(self, obj, *arg, **kw): - try: - result = self.f(obj, *arg, **kw) - except KSSExplicitError, exc: - # Clear all the commands, and emit an error command - obj._initcommands() - obj.commands.addCommand('error', message=str(exc)) - result = None - if result is None: - # render not returned - so we do it. - result = obj.render() - return result - -# backward compatibility -class KssExplicitError(KSSExplicitError): - def __init__(self, *args, **kw): - message = "'KssExplicitError' is deprecated," \ - "use 'KSSExplicitError'- KSS uppercase instead." - warnings.warn(message, DeprecationWarning, 2) - KSSExplicitError.__init__(self, *args, **kw) - Modified: kukit/kss.zope/trunk/kss/core/configure.zcml ============================================================================== --- kukit/kss.zope/trunk/kss/core/configure.zcml (original) +++ kukit/kss.zope/trunk/kss/core/configure.zcml Sun Dec 30 11:03:28 2007 @@ -3,8 +3,6 @@ xmlns:zcml="http://namespaces.zope.org/zcml" xmlns:five="http://namespaces.zope.org/five"> - - Deleted: /kukit/kss.zope/trunk/kss/core/permission.zcml ============================================================================== --- /kukit/kss.zope/trunk/kss/core/permission.zcml Sun Dec 30 11:03:28 2007 +++ (empty file) @@ -1,10 +0,0 @@ - - - - \ No newline at end of file Modified: kukit/kss.zope/trunk/kss/zope/__init__.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/__init__.py (original) +++ kukit/kss.zope/trunk/kss/zope/__init__.py Sun Dec 30 11:03:28 2007 @@ -1 +1,3 @@ +# from kss.zope.view import KSSView +from kss.zope.actionwrapper import KSSExplicitError, kssaction Modified: kukit/kss.zope/trunk/kss/zope/actionwrapper.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/actionwrapper.py (original) +++ kukit/kss.zope/trunk/kss/zope/actionwrapper.py Sun Dec 30 11:03:28 2007 @@ -16,9 +16,8 @@ # 02111-1307, USA. from textwrap import dedent -from inspect import formatargspec, getargspec, getargvalues, \ - formatargvalues, currentframe -from zope.interface import implements +from inspect import formatargspec, getargspec +import warnings class KSSExplicitError(Exception): 'Explicit error to be raised' @@ -34,7 +33,7 @@ Let's say we have a class here - that is supposed to be a kss view. - >>> from kss.core import kssaction, KSSExplicitError, KSSView + >>> from kss.zope import kssaction, KSSExplicitError, KSSView >>> class MyView(KSSView): ... def ok(self, a, b, c=0): @@ -114,13 +113,15 @@ more structured form. >>> from zope import interface as iapi - >>> from kss.core.tests.base import IDebugRequest + >>> from kss.zope.tests.interfaces import IDebugRequest >>> iapi.directlyProvides(request, iapi.directlyProvidedBy(request) + IDebugRequest) See the results: - >>> view.error(1, b=2) - [{'selectorType': None, 'params': {'message': u'The error'}, 'name': 'error', 'selector': None}] + >>> view.error(1, b=2).commands + [('error', None, {'message': 'The error'})] + + ## [{'selectorType': None, 'params': {'message': u'The error'}, 'name': 'error', 'selector': None}] Usage of the method wrapped in browser view ------------------------------------------- @@ -137,8 +138,8 @@ ... else: ... from Products.Five.zcml import load_string, load_config - >>> import kss.core.tests - >>> kss.core.tests.MyView = MyView + >>> import kss.zope.tests + >>> kss.zope.tests.MyView = MyView We check for two basic types of declaration. The first one declares a view with different attributes. The second one declares a dedicated @@ -154,7 +155,7 @@ ... ... >> self.folder.restrictedTraverse('/@@my_view/error') + ##>>> self.folder.restrictedTraverse('/@@my_view/error') + + + + + + Added: kukit/kss.zope/trunk/kss/zope/tests/base.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/tests/base.py Sun Dec 30 11:03:28 2007 @@ -0,0 +1,119 @@ +# -*- coding: latin-1 -*- +# Copyright (c) 2005-2007 +# Authors: KSS Project Contributors (see docs/CREDITS.txt) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +##from textwrap import dedent + +import warnings +from Testing.ZopeTestCase import ZopeTestCase, FunctionalTestCase + +from zope import interface +from interfaces import IDebugRequest +#from zope.app.testing import placelesssetup + +import kss.zope +from kss.zope import KSSView + +class KSSCoreLayer: + @classmethod + def setUp(cls): + try: + import Products.Five + except ImportError: + # probably zope 3 + pass + # XXX TODO fix this?? --- never run yet on Z3 + ##from zope.configuration.xmlconfig import XMLConfig + ##XMLConfig('tests/configure-unittest.zcml', kss.core)() + else: + ##from Products.Five.zcml import load_string, load_config + from Products.Five.zcml import load_config + load_config('meta.zcml', package=Products.Five) + + #try: + load_config('traversing.zcml', package=Products.Five) + #except IOError: + # Let's try the Zope 2.9 way (zope.app.traversing is + # moved in 2.10) + # load_string(dedent('''\ + # + # + # + # + # ''')) + # Load the permissions config, if it's there + #try: + # load_config('permissions.zcml', package=Products.Five) + #except IOError: + # Zope 2.10 / Five 1.3.6 does not have it + # pass + ##load_config('configure-unittest.zcml', package=kss.core.tests) + + @classmethod + def tearDown(cls): + pass # placelesssetup.tearDown() + + +class KSSLayer(KSSCoreLayer): + @classmethod + def setUp(cls): + try: + from Products.Five.zcml import load_config + except ImportError: + raise ImportError("KSSLayer requires Five to be installed.") + load_config('meta.zcml', package=kss.zope) + load_config('configure.zcml', package=kss.zope) + +# Test view +class TestView(KSSView): + def testMethod(self): + 'Yes.' + +class KSSViewTestCaseMixin: + + def loadCoreConfig(self, kss_core=True): + warnings.warn( + "KSS tests are now using layers. Please do not use " + "loadCoreConfig anymore.", + DeprecationWarning) + + def createView(self): + "Set up a fake view (with no content)" + self.view = self.folder.restrictedTraverse('testMethod') + return self.view + + def setDebugRequest(self): + 'commands will be rendered as test friendly data structures' + request = self.folder.REQUEST + interface.directlyProvides( + request, + interface.directlyProvidedBy(request) + IDebugRequest) + +class KSSViewTestCase(ZopeTestCase, KSSViewTestCaseMixin): + layer = KSSLayer + +class KSSViewFunctionalTestCase(FunctionalTestCase, KSSViewTestCase): + 'Functional test base' Added: kukit/kss.zope/trunk/kss/zope/tests/interfaces.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/tests/interfaces.py Sun Dec 30 11:03:28 2007 @@ -0,0 +1,10 @@ + +# Debug request +# This has a modified render. + +from zope.publisher.interfaces.browser import IBrowserRequest + +class IDebugRequest(IBrowserRequest): + 'The debug request' + + Added: kukit/kss.zope/trunk/kss/zope/tests/test_actionwrapper.py ============================================================================== --- (empty file) +++ kukit/kss.zope/trunk/kss/zope/tests/test_actionwrapper.py Sun Dec 30 11:03:28 2007 @@ -0,0 +1,31 @@ +# -*- coding: latin-1 -*- +# Copyright (c) 2005-2007 +# Authors: KSS Project Contributors (see docs/CREDITS.txt) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +from Testing.ZopeTestCase import FunctionalDocFileSuite +##from kss.zope.tests.base import KSSViewFunctionalTestCase +from kss.zope.tests.base import KSSViewTestCase +import unittest, doctest + +def test_suite(): + suites = [] + suites.append(FunctionalDocFileSuite('../actionwrapper.py', + optionflags=doctest.ELLIPSIS, +# test_class=KSSViewFunctionalTestCase, + test_class=KSSViewTestCase, + )) + return unittest.TestSuite(suites) Modified: kukit/kss.zope/trunk/kss/zope/view.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/view.py (original) +++ kukit/kss.zope/trunk/kss/zope/view.py Sun Dec 30 11:03:28 2007 @@ -43,6 +43,7 @@ from zope.component.interfaces import IObjectEvent from zope.app.component.interfaces import ISite from zope.app.publication.zopepublication import BeforeTraverseEvent +from kss.zope.tests.interfaces import IDebugRequest HAS_FIVE_LSM = True try: @@ -147,9 +148,15 @@ def render(self): """Views can use this to return their command set.""" - self.request.response.setHeader('Content-type', - 'text/xml;charset=utf-8') - return self.commands.render() + # Are we on a debug request? + if IDebugRequest.providedBy(self.request): + # Just return the commands + return self.commands + else: + # normal rendering of payload + self.request.response.setHeader('Content-type', + 'text/xml;charset=utf-8') + return self.commands.render() def cancelRedirect(self): if self.request.response.getStatus() in (302, 303): From reebalazs at codespeak.net Sun Dec 30 11:03:49 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 11:03:49 +0100 (CET) Subject: [KSS-checkins] r50185 - kukit/kss.base/trunk/kss/base Message-ID: <20071230100349.84FAA168502@codespeak.net> Author: reebalazs Date: Sun Dec 30 11:03:48 2007 New Revision: 50185 Modified: kukit/kss.base/trunk/kss/base/commands.py Log: Add support for global commands Modified: kukit/kss.base/trunk/kss/base/commands.py ============================================================================== --- kukit/kss.base/trunk/kss/base/commands.py (original) +++ kukit/kss.base/trunk/kss/base/commands.py Sun Dec 30 11:03:48 2007 @@ -11,6 +11,7 @@ kss_command_start = '' +kss_command_startglobal = '' kss_command_end = '' @@ -37,10 +38,16 @@ def render(self): output = [kss_response_header] for action, selector, options in self.commands: - output.append(kss_command_start % dict( - selector=quoteattr(selector.value), - selector_type=quoteattr(selector.type), - action=quoteattr(action))) + if selector is not None: + # selector command + output.append(kss_command_start % dict( + selector=quoteattr(selector.value), + selector_type=quoteattr(selector.type), + action=quoteattr(action))) + else: + # global command + output.append(kss_command_startglobal % dict( + action=quoteattr(action))) for name, value in options.items(): output.append(kss_param % dict( name=quoteattr(name), value=value)) From jvloothuis at codespeak.net Sun Dec 30 11:54:03 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 30 Dec 2007 11:54:03 +0100 (CET) Subject: [KSS-checkins] r50188 - kukit/kss.zope/trunk/kss/zope/tests Message-ID: <20071230105403.D17E81684CB@codespeak.net> Author: jvloothuis Date: Sun Dec 30 11:54:02 2007 New Revision: 50188 Modified: kukit/kss.zope/trunk/kss/zope/tests/base.py Log: Fixed the layer by subclassing the ZopeLite layer (which sets up the Zope 2 env) Modified: kukit/kss.zope/trunk/kss/zope/tests/base.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/tests/base.py (original) +++ kukit/kss.zope/trunk/kss/zope/tests/base.py Sun Dec 30 11:54:02 2007 @@ -20,6 +20,7 @@ import warnings from Testing.ZopeTestCase import ZopeTestCase, FunctionalTestCase +from Testing.ZopeTestCase.layer import ZopeLite from zope import interface from interfaces import IDebugRequest @@ -28,7 +29,7 @@ import kss.zope from kss.zope import KSSView -class KSSCoreLayer: +class KSSCoreLayer(ZopeLite): @classmethod def setUp(cls): try: @@ -36,41 +37,10 @@ except ImportError: # probably zope 3 pass - # XXX TODO fix this?? --- never run yet on Z3 - ##from zope.configuration.xmlconfig import XMLConfig - ##XMLConfig('tests/configure-unittest.zcml', kss.core)() else: - ##from Products.Five.zcml import load_string, load_config from Products.Five.zcml import load_config load_config('meta.zcml', package=Products.Five) - - #try: load_config('traversing.zcml', package=Products.Five) - #except IOError: - # Let's try the Zope 2.9 way (zope.app.traversing is - # moved in 2.10) - # load_string(dedent('''\ - # - # - # - # - # ''')) - # Load the permissions config, if it's there - #try: - # load_config('permissions.zcml', package=Products.Five) - #except IOError: - # Zope 2.10 / Five 1.3.6 does not have it - # pass - ##load_config('configure-unittest.zcml', package=kss.core.tests) @classmethod def tearDown(cls): From jvloothuis at codespeak.net Sun Dec 30 12:12:49 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 30 Dec 2007 12:12:49 +0100 (CET) Subject: [KSS-checkins] r50190 - kukit/kss.zope/trunk/kss/zope Message-ID: <20071230111249.B26CE168525@codespeak.net> Author: jvloothuis Date: Sun Dec 30 12:12:49 2007 New Revision: 50190 Modified: kukit/kss.zope/trunk/kss/zope/actionwrapper.py Log: Fixed the test by checking for the XML output instead of a list based output Modified: kukit/kss.zope/trunk/kss/zope/actionwrapper.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/actionwrapper.py (original) +++ kukit/kss.zope/trunk/kss/zope/actionwrapper.py Sun Dec 30 12:12:49 2007 @@ -185,7 +185,7 @@ >>> hasattr(v, 'error') True >>> v(1, b=2) - [{'selectorType': None, 'params': {'message': u'The error'}, 'name': 'error', 'selector': None}] + '\n\nThe error' In addition, to be publishable, the docstring must exist. Let's see if the wrapper actually does this. If the method had a docstring, From reebalazs at codespeak.net Sun Dec 30 13:17:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:17:01 +0100 (CET) Subject: [KSS-checkins] r50193 - kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo Message-ID: <20071230121701.B74C31684D3@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:17:00 2007 New Revision: 50193 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js Log: Simplify problematic part of the more selectors demo (accessing the registry from the binder, is a bad practice) Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/more_selectors.js Sun Dec 30 13:17:00 2007 @@ -16,15 +16,7 @@ this.count = this.countsomuch; // Just bind the event via the native click event binder oper.parms = {}; - // Bind the event by looking up the binder class from the registry - // - // This __bind__ method offers an additional parameter to overwrite - // the name of the native browser event to bind. - // (Oper would fetch "annoyclicker-click" from the kssSelector, - // and this is used for info messages, but "click" will be - // bound physically.) - var click = kukit.interfaces.global.binditerations.click; - click.binderClass.prototype.__bind__(oper, 'click'); + kukit.pl.registerBrowserEvent(oper, null, 'click'); }; kukit.more_selectors.AnnoyClickerEvent.prototype.__default_click__ = function(name, oper) { From reebalazs at codespeak.net Sun Dec 30 13:33:01 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:33:01 +0100 (CET) Subject: [KSS-checkins] r50194 - in kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo: . binderclasses binderclasses/selenium_tests selenium_tests Message-ID: <20071230123301.B91791684DD@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:32:58 2007 New Revision: 50194 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/README kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/__init__.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/configure.zcml kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.js kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/README.txt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/binderclasses.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/zopeconfig.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderclasses_temporary.html Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/configure.zcml kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Log: Add the binderclasses test to demonstrate the necessity of the following fixes Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/README ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/README Sun Dec 30 13:32:58 2007 @@ -0,0 +1,7 @@ + + +I put this demos under the subdirectory demo_for_binderids. +This is temporary, the demo will be merged under "demos" when +they are relocated from kss.demo to here. + +(ree) Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/__init__.py ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/__init__.py Sun Dec 30 13:32:58 2007 @@ -0,0 +1,4 @@ +"""\ +Module init +""" + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/configure.zcml ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/configure.zcml Sun Dec 30 13:32:58 2007 @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.js ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.js Sun Dec 30 13:32:58 2007 @@ -0,0 +1,63 @@ + +/* + * Event plugins for the binderclasses demo + * + * We test several things here: + * + * - Inheritence can be used to set up the event binder class. + * The __bind_click__ method is accessable from the subclass. + * + * - The event binder can have a constructor, and what is set up in the constructor + * will become a property of the instance, not of the class. + * + * - Event names defined on the same class, will be bound to the same + * class, not different ones. This means if the events bind to the same + * instance id, they share a common state. + */ + +(function () { // BEGIN CLOSURE + +var AlphaBinder = function() { + this.counter = [50]; + + this.customBind = function(name, func_to_bind, oper) { + // validate and set parameters + oper.evaluateParameters([], {}, 'testbinderclasses event binding'); + // Apply a filter before the execute actions hook. + // It always returns true, causing the actions to execute + // always. + // It sets up the counter on it, which can be used + // from action parameters as pass(counter). + var self = this; + var filter = function(oper) { + oper.defaultParameters = { + counter: '[' + self.counter[0] + ']'}; + self.counter[0]++; + return true; + } + // register this as a "click" browser event + kukit.pl.registerBrowserEvent(oper, filter, 'click'); + + }; + + this._prepareExecuteActions = function(oper) { + // Set up the execution of the actions. + // Make counter available from action parameters + // as pass(counter). + }; + +}; + +kukit.eventsGlobalRegistry.register('testbinderclass', 'alphaone', AlphaBinder, 'customBind', null); + + +var BetaBinder = function(name, func_to_bind, oper) { + this.counter = [100]; +}; +// inherited from AlphaBinder +BetaBinder.prototype = new AlphaBinder(); + +kukit.eventsGlobalRegistry.register('testbinderclass', 'betaone', BetaBinder, 'customBind', null); +kukit.eventsGlobalRegistry.register('testbinderclass', 'betatwo', BetaBinder, 'customBind', null); + +})(); // END CLOSURE Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.kss ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.kss Sun Dec 30 13:32:58 2007 @@ -0,0 +1,12 @@ + + + + +#alpha1:testbinderclass-alphaone, +#beta1:testbinderclass-betaone, +#beta2:testbinderclass-betatwo { + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: pass(counter); +} + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.pt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/kss_binder_classes.pt Sun Dec 30 13:32:58 2007 @@ -0,0 +1,44 @@ + + + + + +

    header

    + + +

    Binder classes handling

    + +

    The followings are checked in this demo:

    +
      +
    • inheritence must work with event binder classes.
    • +
    • If the constructors of the binder class set up variables on this.XX, these will + be properties of the _instance_, not that of the class.
    • +
    • If two events are bound on the same binder class, they are considered the same + class in the registry. That is, if the events are bound on the same instance + id (or the singleton), they will see a shared state.
    • +
    + +
    + + + + + + + +
    + +

    logger

    + +

    When you click button alpha1, logging of count should start + from 50. When you click beta1 or beta2, counting starts from 100. + Alpha and beta are independent, but beta1 and beta2 share the same + clicking state. +

    + + + + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/README.txt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/README.txt Sun Dec 30 13:32:58 2007 @@ -0,0 +1,4 @@ + +Save sour selenium tests into this directory, in html format. +All the tests ending with .html will be processed automatically. + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/binderclasses.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/selenium_tests/binderclasses.html Sun Dec 30 13:32:58 2007 @@ -0,0 +1,99 @@ + + + +binderclasses + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    binderclasses
    open/demo/kss_binder_classes.html
    clickalpha1
    waitForTextPresent[50]
    clickalpha1
    waitForTextPresent[50][51]
    clickbeta1
    waitForTextPresent[50][51][100]
    clickbeta2
    waitForTextPresent[50][51][100][101]
    clickbeta1
    waitForTextPresent[50][51][100][101][102]
    clickbeta1
    waitForTextPresent[50][51][100][101][102][103]
    clickbeta2
    verifyTextPresent[50][51][100][101][102][103][104]
    clickalpha1
    waitForTextPresent[50][51][100][101][102][103][104][52]
    + + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/zopeconfig.py ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderclasses/zopeconfig.py Sun Dec 30 13:32:58 2007 @@ -0,0 +1,35 @@ + +from kss.demo.interfaces import ( + IKSSDemoResource, + IKSSSeleniumTestResource, + ) +from kss.demo.resource import ( + KSSDemo, + KSSSeleniumTestDirectory, + ) +from zope.interface import implements + +# Create a mesh of provided interfaces +# This is needed, because an utility must have a single interface. +class IResource(IKSSDemoResource, IKSSSeleniumTestResource): + pass + +# XXX you do not need to change anything above here +# ------------------------------------------------- + +class KSSDemos(object): + implements(IResource) + + demos = ( + # List your demos here. + # (Second parameter can be a subcategory within the demo if needed.) + KSSDemo('', 'Core syntax', 'kss_binder_classes.html', 'Binder class usage'), + + ) + + # directories are relative from the location of this .py file + selenium_tests = ( + # if you only have one test directory, you + # need not change anything here. + KSSSeleniumTestDirectory('selenium_tests'), + ) Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/configure.zcml ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/configure.zcml (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/configure.zcml Sun Dec 30 13:32:58 2007 @@ -14,6 +14,7 @@ + @@ -128,6 +131,9 @@ HTML inserts + + Binder classes handling + From reebalazs at codespeak.net Sun Dec 30 13:46:56 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:46:56 +0100 (CET) Subject: [KSS-checkins] r50195 - in kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo: binderids binderids/selenium_tests selenium_tests Message-ID: <20071230124656.30F971684E6@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:46:55 2007 New Revision: 50195 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/selenium_tests/binderids.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.kss kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.pt kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Log: Add logging and selenium test to binder ids demo Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.kss ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.kss (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.kss Sun Dec 30 13:46:55 2007 @@ -4,17 +4,20 @@ */ .buttons:click(manual) { - action-client: alert; - alert-message: "manual"; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "manual"; } #button1:click(manual2) { - action-client: alert; - alert-message: "manual2"; + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: "manual2"; } .buttons.bindable_by_parm:click(kssAttr(binderid)) { - action-client: alert; - alert-message: kssAttr(binderid); + action-client: insertHTMLAsLastChild; + insertHTMLAsLastChild-kssSelector: #logger; + insertHTMLAsLastChild-html: kssAttr(binderid); } Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.pt ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.pt (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/binderids.pt Sun Dec 30 13:46:55 2007 @@ -12,8 +12,8 @@ Events bound to different binders will not merge. (Note that this is not the typical usage if event ids, only a simple check that it really works. - )If you click the buttons, you need to - receive alerts per each event bound. + )If you click the buttons, you must + receive logs per each event bound.


    @@ -28,6 +28,10 @@ value="button3">
    + +
    + +

    logger

    First we bind an event with id "manual" to each button. We also bind event with id "manual2" to the first button. Then Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/selenium_tests/binderids.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/selenium_tests/binderids.html Sun Dec 30 13:46:55 2007 @@ -0,0 +1,49 @@ + + + +binderids + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    binderids
    open/demo/binderids.html
    clickbutton1
    waitForTextPresentmanualmanual2
    clickbutton2
    waitForTextPresentmanualmanual2manualparm1
    clickbutton3
    waitForTextPresentmanualmanual2manualparm1manualparm2
    + + Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html Sun Dec 30 13:46:55 2007 @@ -0,0 +1,49 @@ + + + +binderids + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    binderids
    open/demo/binderids.html
    clickbutton1
    waitForTextPresentmanualmanual2
    clickbutton2
    waitForTextPresentmanualmanual2manualparm1
    clickbutton3
    waitForTextPresentmanualmanual2manualparm1manualparm2
    + + Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Sun Dec 30 13:46:55 2007 @@ -70,6 +70,9 @@ Binder classes handling + + Binder ids + @@ -134,6 +137,9 @@ Binder classes handling + + Binder ids + From reebalazs at codespeak.net Sun Dec 30 13:53:17 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:53:17 +0100 (CET) Subject: [KSS-checkins] r50196 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071230125317.10FCE1684E6@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:53:16 2007 New Revision: 50196 Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js Log: Trivial but important fix for registerBrowserEvent: the name parameter must be provided when we bind to different browser event than the kss event. Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Sun Dec 30 13:53:16 2007 @@ -131,7 +131,23 @@ ;;; kukit.log(msg); } }; + + // register the event listener kukit.ut.registerEventListener(oper.node, eventName, func); + + // + // XXX Safari hack + // necessary since Safari does not prevent the following + // (in case of allowbubbling we have to apply it to all clicks, as there + // might be a link inside that we cannot detect on the current node) + // + if (oper.parms.preventdefault && kukit.HAVE_SAFARI + && (oper.parms.allowbubbling || eventName == 'click' + && oper.node.tagName.toLowerCase() == 'a')) { + oper.node.onclick = function cancelClickSafari() { + return false; + }; + } }; /* @@ -182,23 +198,9 @@ throw new Error(kukit.E); } } - pl.registerBrowserEvent(oper); - // - // XXX Safari hack - // necessary since Safari does not prevent the following - // (in case of allowbubbling we have to apply it to all clicks, as there - // might be a link inside that we cannot detect on the current node) - // - // XXX not needed since we have the legacy name parameter: - // var name = oper.getEventName(); - if (oper.parms.preventdefault && kukit.HAVE_SAFARI - && (oper.parms.allowbubbling || name == 'click' - && oper.node.tagName.toLowerCase() == 'a')) { - var cancelClickSafari = function() { - return false; - }; - oper.node.onclick = cancelClickSafari; - } + // we give the name parameter to the registration, so we + // really bind to the event name we want. + pl.registerBrowserEvent(oper, null, name); }; this.__bind_key__ = From reebalazs at codespeak.net Sun Dec 30 13:56:18 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:56:18 +0100 (CET) Subject: [KSS-checkins] r50197 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo Message-ID: <20071230125618.B8947168448@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:56:17 2007 New Revision: 50197 Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js Log: Attempt to simplify the binding of the browser click event from the more_selectors demo. This solution is better and solves the problem with reusing core from the browser level. Also I had to realize that accessing the registry from the binder method is not needed after all. Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/more_selectors.js Sun Dec 30 13:56:17 2007 @@ -13,10 +13,9 @@ // overwrite countsomuch this.countsomuch = oper.parms.count; this.count = this.countsomuch; - // Just bind the event via the native event binder + // register this as a "click" browser event oper.parms = {}; - var clickBinder = kukit.eventsGlobalRegistry.getBinderClassByEventNamespace('', 'click'); - clickBinder.prototype.__bind__('click', func_to_bind, oper); + kukit.pl.registerBrowserEvent(oper, null, 'click'); }; this.__default_click__ = function(name, oper) { From reebalazs at codespeak.net Sun Dec 30 13:59:57 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 13:59:57 +0100 (CET) Subject: [KSS-checkins] r50198 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071230125957.0C119168448@codespeak.net> Author: reebalazs Date: Sun Dec 30 13:59:57 2007 New Revision: 50198 Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Log: Attempt to fix the handling of binder classes dquote> This is the correct implementation of one of the possible solutions. dquote> This satisfies the binderclass demo. Modified: kukit/kukit.js/branch/finish-closures/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/eventreg.js Sun Dec 30 13:59:57 2007 @@ -50,24 +50,40 @@ /* binder registration */ -this.registerBinder = function(className, klass) { +this.registerBinder = function(klass) { if (typeof(klass) == 'undefined') { ;;; kukit.E = 'klass argument is mandatory when registering an event'; ;;; kukit.E += ' binder (_EventRegistry.registerBinder).'; throw new Error(kukit.E); } - if (this.classes[className]) { - // Do not allow redefinition -;;; var msg = 'Error : event class [' + className + '] already registered.'; -;;; kukit.logError(msg); + // See if we are set up already? + // We make a mark not on the class prototype, + // but on the class itself. This will make + // sure inherited classes get a distinct class name. + if (klass.__decorated_for_kss__) { return; - } - klass.prototype = new _EventBinder(); + // We do _not_ overwrite the class's prototype, since + // that destroys any inheritance it has. Our purpose + // is to allow any javascript class to function, so + // we copy the class's attributes to the prototype. + var binder_prototype = new _EventBinder(); + for (var key in binder_prototype) { + klass.prototype[key] = binder_prototype[key]; + } + // Create a className, and register it too. + // + // The reason to create a __className__ is to provide a + // way to lookup the class by a string. This is needed + // because dict keys in javascript can only be strings. + className = '' + _eventClassCounter; + _eventClassCounter += 1; klass.prototype.__className__ = className; - var newKlass = function() {}; - newKlass.prototype = new klass(); - this.classes[className] = newKlass; + this.classes[className] = klass; + // mark decorated. We store the class there + // so we can decide if this class has been + // decorated or not. + klass.__decorated_for_kss__ = true; }; this.existsBinder = function(className) { @@ -93,15 +109,8 @@ ;;; kukit.E = 'Missing arguments when calling [_EventRegistry.register].'; throw new Error(kukit.E); } - // Find out the class name. (Not specified now.) - var className = klass.prototype.__className__; - if (typeof(className) == 'undefined') { - // Create a className, and register it too. - className = '' + _eventClassCounter; - _eventClassCounter += 1; - this.registerBinder(className, klass); - } - var binderKlass = this.getBinderClass(className); + // Register and decorate the binder's class. + this.registerBinder(klass); if (!eventName) { ;;; kukit.E = '[eventName] argument cannot be empty when registering'; ;;; kukit.E += ' an event with [_EventRegistry.register].'; @@ -118,19 +127,9 @@ ;;; kukit.E += ' an event with [_EventRegistry.register].'; throw new Error(kukit.E); } - // check bindMethodName and defaultActionMethodName - if (bindMethodName && ! binderKlass.prototype[bindMethodName]) { -;;; kukit.E = 'In _EventRegistry.register bind method [' + bindMethodName; -;;; kukit.E += '] is undefined for event [' + eventName; -;;; kukit.E += '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } - if (defaultActionMethodName && ! binderKlass.prototype[defaultActionMethodName]) { -;;; kukit.E = 'In _EventRegistry.register default action method ['; -;;; kukit.E += defaultActionMethodName + '] is undefined for event ['; -;;; kukit.E += eventName + '] namespace [' + namespace + '].'; - throw new Error(kukit.E); - } + // XXX We do not check bindMethodName and defaltActionMethodName + // here, because at this point they may be hidden by closure. + // // check the iterator. if (! er.getBindIterator(iterName)) { ;;; kukit.E = 'In _EventRegistry.register unknown bind iterator ['; From reebalazs at codespeak.net Sun Dec 30 14:01:15 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 14:01:15 +0100 (CET) Subject: [KSS-checkins] r50199 - kukit/kukit.js/branch/finish-closures/kukit Message-ID: <20071230130115.B67DE168448@codespeak.net> Author: reebalazs Date: Sun Dec 30 14:01:14 2007 New Revision: 50199 Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Log: Attempt to improve the new token table by use of 'this'. Modified: kukit/kukit.js/branch/finish-closures/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/kssparser.js Sun Dec 30 14:01:14 2007 @@ -45,41 +45,41 @@ /* Helpers */ -var _emitAndReturn = function(parser) { - return parser.emitAndReturn(); +var _emitAndReturn = function() { + return this.emitAndReturn(); }; var _mkEmitAndReturnToken = function(klass) { - return function(parser) { - var token = new klass(parser.cursor); - return parser.emitAndReturn(token); + return function() { + var token = new klass(this.cursor); + return this.emitAndReturn(token); }; }; var _mkReturnToken = function(klass) { - return function(parser) { - return new klass(parser.cursor); + return function() { + return new klass(this.cursor); }; }; -var _returnComment = function(parser) { - return new kssp.Comment(parser.cursor, kssp.openComment) +var _returnComment = function() { + return new kssp.Comment(this.cursor, kssp.openComment) }; -var _returnString = function(parser) { - return new kssp.String(parser.cursor, kssp.quote) +var _returnString = function() { + return new kssp.String(this.cursor, kssp.quote) }; -var _returnString2 = function(parser) { - return new kssp.String2(parser.cursor, kssp.dquote) +var _returnString2 = function() { + return new kssp.String2(this.cursor, kssp.dquote) }; -var _returnMethodArgs = function(parser) { - return new kssp.MethodArgs(parser.cursor, kssp.openParent) +var _returnMethodArgs = function() { + return new kssp.MethodArgs(this.cursor, kssp.openParent) }; -var _returnBackslashed = function(parser) { - return new kssp.Backslashed(parser.cursor, kssp.backslash) +var _returnBackslashed = function() { + return new kssp.Backslashed(this.cursor, kssp.backslash) }; /* @@ -116,8 +116,8 @@ }; kssp.Document = kukit.tk.mkParser('document', { "\/\*": _returnComment, - "{": function(parser) { - return new kssp.Block(parser.cursor, kssp.openBrace) + "{": function() { + return new kssp.Block(this.cursor, kssp.openBrace) } }, _Document @@ -420,9 +420,9 @@ }; kssp.Block = kukit.tk.mkParser('block', { ";": _mkReturnToken(kssp.semicolon), - ":": function(parser) { - return [new kssp.colon(parser.cursor), - new kssp.PropValue(parser.cursor)] + ":": function() { + return [new kssp.colon(this.cursor), + new kssp.PropValue(this.cursor)] }, "}": _mkEmitAndReturnToken(kssp.closeBrace) }, @@ -612,9 +612,9 @@ "\r": _emitAndReturn, "\/\*": _emitAndReturn, ":": _emitAndReturn, - "(": function(parser) { - return [new kssp.openParent(parser.cursor), - new kssp.PropValue(parser.cursor)] + "(": function() { + return [new kssp.openParent(this.cursor), + new kssp.PropValue(this.cursor)] }, ")": _mkEmitAndReturnToken(kssp.closeParent) }, @@ -809,11 +809,11 @@ }; kssp.KssSelectors = kukit.tk.mkParser('kssselectors', { - "'": function(parser) { - return new kssp.StringInSelector(parser.cursor, kssp.quote) + "'": function() { + return new kssp.StringInSelector(this.cursor, kssp.quote) }, - '"': function(parser) { - return new kssp.String2InSelector(parser.cursor, kssp.dquote) + '"': function() { + return new kssp.String2InSelector(this.cursor, kssp.dquote) }, ",": _mkReturnToken(kssp.comma), "{": _emitAndReturn, @@ -949,9 +949,9 @@ }; kssp.KssSelector = kukit.tk.mkParser('kssselector', { - ":": function(parser) { - return [new kssp.colon(parser.cursor), - new kssp.EventValue(parser.cursor)] + ":": function() { + return [new kssp.colon(this.cursor), + new kssp.EventValue(this.cursor)] }, "{": _emitAndReturn, "\/\*": _returnComment Modified: kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/tokenizer.js Sun Dec 30 14:01:14 2007 @@ -82,7 +82,7 @@ if (best_symbol) { // found a symbol, handle that // make the token and push it - var tokens = table[best_symbol](this); + var tokens = table[best_symbol].call(this); if (typeof(tokens) != 'undefined') { if (typeof(tokens.length) == 'undefined') { tokens = [tokens]; From reebalazs at codespeak.net Sun Dec 30 14:01:57 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 14:01:57 +0100 (CET) Subject: [KSS-checkins] r50200 - kukit/kukit.js/branch/finish-closures/tests Message-ID: <20071230130157.B24BC16844A@codespeak.net> Author: reebalazs Date: Sun Dec 30 14:01:56 2007 New Revision: 50200 Modified: kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js Log: Change the tokenizer to match the the new token table (this was missing) Modified: kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js (original) +++ kukit/kukit.js/branch/finish-closures/tests/test_tokenizer.js Sun Dec 30 14:01:56 2007 @@ -155,8 +155,8 @@ kukit.tk.openBracket = kukit.tk.mkToken('openBracket', '['); var pf = kukit.tk.mkParser('block', { - '[': 'this.emitAndReturn(new kukit.tk.openBracket(this.cursor))', - '{': 'new kukit.tk.openBrace(this.cursor)' + '[': function() {return this.emitAndReturn(new kukit.tk.openBracket(this.cursor));}, + '{': function() {return new kukit.tk.openBrace(this.cursor);} }, this.Dummy ); @@ -194,15 +194,15 @@ kukit.tk.wrappedBracket = kukit.tk.mkToken('wrappedBracket', '['); kukit.tk.global = kukit.tk.mkParser('global', { - '[': 'new kukit.tk.openBracket(this.cursor)', - '{': 'new kukit.tk.inside(this.cursor, kukit.tk.openBrace)' + '[': function() {return new kukit.tk.openBracket(this.cursor);}, + '{': function() {return new kukit.tk.inside(this.cursor, kukit.tk.openBrace);} }, this.Dummy ); kukit.tk.inside = kukit.tk.mkParser('inside', { - '[': 'new kukit.tk.wrappedBracket(this.cursor)', - '}': 'this.emitAndReturn(new kukit.tk.closeBrace(this.cursor))' + '[': function() {return new kukit.tk.wrappedBracket(this.cursor);}, + '}': function() {return this.emitAndReturn(new kukit.tk.closeBrace(this.cursor));} }, this.Dummy ); @@ -265,7 +265,7 @@ kukit.tk.backslash = kukit.tk.mkToken('backslash', "\\"); kukit.tk.global = kukit.tk.mkParser('global', { - "'": 'new kukit.tk.string(this.cursor, kukit.tk.quote)' + "'": function() {return new kukit.tk.string(this.cursor, kukit.tk.quote);} }, this.Dummy ); @@ -279,8 +279,8 @@ }; }; kukit.tk.string = kukit.tk.mkParser('string', { - "'": 'this.emitAndReturn(new kukit.tk.quote(this.cursor))', - "\\": 'new kukit.tk.backslashed(this.cursor, kukit.tk.backslash)' + "'": function() {return this.emitAndReturn(new kukit.tk.quote(this.cursor));}, + "\\": function() {return new kukit.tk.backslashed(this.cursor, kukit.tk.backslash);} }, _String ); @@ -350,8 +350,8 @@ kukit.tk.closeBracket = kukit.tk.mkToken('closeBracket', ']'); kukit.tk.global = kukit.tk.mkParser('global', { - '[': 'new kukit.tk.openBracket(this.cursor)', - '{': 'new kukit.tk.inside(this.cursor, kukit.tk.openBrace)' + '[': function() {return new kukit.tk.openBracket(this.cursor);}, + '{': function() {return new kukit.tk.inside(this.cursor, kukit.tk.openBrace)} }, this.Dummy ); @@ -375,19 +375,19 @@ }; }; kukit.tk.inside = kukit.tk.mkParser('inside', { - '}': 'this.emitAndReturn(new kukit.tk.closeBrace(this.cursor))' + '}': function() {return this.emitAndReturn(new kukit.tk.closeBrace(this.cursor));} }, _Inside ); kukit.tk.embedded = kukit.tk.mkParser('embedded', { - '[': 'new kukit.tk.embeddedInside(this.cursor, kukit.tk.openBracket)' + '[': function() {return new kukit.tk.embeddedInside(this.cursor, kukit.tk.openBracket);} }, this.Dummy ); kukit.tk.embeddedInside = kukit.tk.mkParser('embeddedInside', { - ']': 'this.emitAndReturn(new kukit.tk.closeBracket(this.cursor))' + ']': function() {return this.emitAndReturn(new kukit.tk.closeBracket(this.cursor));} }, this.Dummy ); @@ -430,16 +430,16 @@ kukit.tk.wrappedBracket = kukit.tk.mkToken('wrappedBracket', '['); kukit.tk.global = kukit.tk.mkParser('global', { - '[': 'new kukit.tk.openBracket(this.cursor)', - '{': '[new kukit.tk.openBrace(this.cursor), new kukit.tk.inside(this.cursor)]', - '}': 'new kukit.tk.closeBrace(this.cursor)' + '[': function() {return new kukit.tk.openBracket(this.cursor);}, + '{': function() {return [new kukit.tk.openBrace(this.cursor), new kukit.tk.inside(this.cursor)];}, + '}': function() {return new kukit.tk.closeBrace(this.cursor);} }, this.Dummy ); kukit.tk.inside = kukit.tk.mkParser('inside', { - '[': 'new kukit.tk.wrappedBracket(this.cursor)', - '}': 'this.emitAndReturn()' + '[': function() {return new kukit.tk.wrappedBracket(this.cursor);}, + '}': function() {return this.emitAndReturn();} }, this.Dummy ); From reebalazs at codespeak.net Sun Dec 30 14:49:36 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 14:49:36 +0100 (CET) Subject: [KSS-checkins] r50201 - in kukit/kukit.js/branch/finish-closures: kukit tests Message-ID: <20071230134936.32719168454@codespeak.net> Author: reebalazs Date: Sun Dec 30 14:49:34 2007 New Revision: 50201 Modified: kukit/kukit.js/branch/finish-closures/kukit/errors.js kukit/kukit.js/branch/finish-closures/kukit/utils.js kukit/kukit.js/branch/finish-closures/tests/runner.html kukit/kukit.js/branch/finish-closures/tests/runtests.sh Log: Merge in changes from trunk -r48593:50168 the essential fix that was missing was a fix on the logging improvements, that disabled ecma tests run from console Iow: this fixes exmatests run via runtests.sh Modified: kukit/kukit.js/branch/finish-closures/kukit/errors.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/errors.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/errors.js Sun Dec 30 14:49:34 2007 @@ -55,9 +55,10 @@ */ /* -* class _ErrorAnnotation +* class ErrorAnnotation */ -var _ErrorAnnotation = function() { + +var ErrorAnnotation = function() { this.constructError = function(e, name, message, kw) { ;;; if (typeof(kw) == "undefined") { @@ -104,7 +105,7 @@ }; var setErrorInfo = function(e, name, message, kw) { - return new _ErrorAnnotation().constructError(e, name, message, kw); + return new ErrorAnnotation().constructError(e, name, message, kw); }; /* Protects a function */ Modified: kukit/kukit.js/branch/finish-closures/kukit/utils.js ============================================================================== --- kukit/kukit.js/branch/finish-closures/kukit/utils.js (original) +++ kukit/kukit.js/branch/finish-closures/kukit/utils.js Sun Dec 30 14:49:34 2007 @@ -96,7 +96,17 @@ ;;; // set default level ;;; this.loglevel = 0; ;;; // read the cookie -;;; var cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; /// (ignore if we run from test) +;;; var cookie; +;;; try { +;;; // in test, document would throw ReferenceError +;;; var _dummy = document; +;;; } catch(e) { +;;; var _dummy; +;;; } +;;; if (_dummy && typeof(document.cookie) != 'undefined') { +;;; cookie = kukit.readCookie(kukit._COOKIE_LOGLEVEL); +;;; } ;;; if (cookie) { ;;; // decode it to a numeric level ;;; cookie = cookie.toLowerCase(); Modified: kukit/kukit.js/branch/finish-closures/tests/runner.html ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/runner.html (original) +++ kukit/kukit.js/branch/finish-closures/tests/runner.html Sun Dec 30 14:49:34 2007 @@ -39,18 +39,18 @@ - - Modified: kukit/kukit.js/branch/finish-closures/tests/runtests.sh ============================================================================== --- kukit/kukit.js/branch/finish-closures/tests/runtests.sh (original) +++ kukit/kukit.js/branch/finish-closures/tests/runtests.sh Sun Dec 30 14:49:34 2007 @@ -3,10 +3,10 @@ -f unittestUtilities.js \ -f browserstub.js \ -f ../3rd_party/base2-dom-fp.js \ + -f ../kukit/kukit.js \ -f ../kukit/utils.js \ -f ../kukit/errors.js \ -f ../kukit/oper.js \ - -f ../kukit/kukit.js \ -f ../kukit/tokenizer.js \ -f ../kukit/providerreg.js \ -f ../kukit/resourcedata.js \ From reebalazs at codespeak.net Sun Dec 30 15:21:00 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 15:21:00 +0100 (CET) Subject: [KSS-checkins] r50202 - kukit/kss.core/branch/finish-closures/kss/core/tests Message-ID: <20071230142100.9746B16843C@codespeak.net> Author: reebalazs Date: Sun Dec 30 15:20:59 2007 New Revision: 50202 Modified: kukit/kss.core/branch/finish-closures/kss/core/tests/test_kssview_core.py Log: Fix failing test dues to version change - now all tests of kss.core run. Modified: kukit/kss.core/branch/finish-closures/kss/core/tests/test_kssview_core.py ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/tests/test_kssview_core.py (original) +++ kukit/kss.core/branch/finish-closures/kss/core/tests/test_kssview_core.py Sun Dec 30 15:20:59 2007 @@ -100,7 +100,7 @@ def _wrapped_commands(self, inline): header = textwrap.dedent(u'''\ - + ''') footer = textwrap.dedent('''\ From reebalazs at codespeak.net Sun Dec 30 15:41:03 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 15:41:03 +0100 (CET) Subject: [KSS-checkins] r50203 - in kukit/kss.demo/branch/finish-closures: docs kss/demo kss/demo/browser kss/demo/docs kss/demo/selenium_utils Message-ID: <20071230144103.91D73168442@codespeak.net> Author: reebalazs Date: Sun Dec 30 15:41:02 2007 New Revision: 50203 Added: kukit/kss.demo/branch/finish-closures/docs/ - copied from r50168, kukit/kss.demo/trunk/docs/ kukit/kss.demo/branch/finish-closures/kss/demo/browser/kss_demo_suite.pt - copied unchanged from r50168, kukit/kss.demo/trunk/kss/demo/browser/kss_demo_suite.pt kukit/kss.demo/branch/finish-closures/kss/demo/browser/setDevMode.html - copied unchanged from r50168, kukit/kss.demo/trunk/kss/demo/browser/setDevMode.html kukit/kss.demo/branch/finish-closures/kss/demo/browser/setProdMode.html - copied unchanged from r50168, kukit/kss.demo/trunk/kss/demo/browser/setProdMode.html kukit/kss.demo/branch/finish-closures/kss/demo/selenium_utils/builder.py - copied unchanged from r50168, kukit/kss.demo/trunk/kss/demo/selenium_utils/builder.py Removed: kukit/kss.demo/branch/finish-closures/kss/demo/docs/ Modified: kukit/kss.demo/branch/finish-closures/docs/HISTORY.txt kukit/kss.demo/branch/finish-closures/docs/INSTALL.txt kukit/kss.demo/branch/finish-closures/docs/LICENSE.GPL kukit/kss.demo/branch/finish-closures/docs/LICENSE.txt kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml kukit/kss.demo/branch/finish-closures/kss/demo/browser/kss_demo_index.pt kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py kukit/kss.demo/branch/finish-closures/kss/demo/interfaces.py kukit/kss.demo/branch/finish-closures/kss/demo/meta.zcml kukit/kss.demo/branch/finish-closures/kss/demo/registry.py Log: Merge changes from trunk -r49476:50168 This includes: - usage of the registry for demos and selenium directories - allowing to go to selenium directly from the demo page Modified: kukit/kss.demo/branch/finish-closures/docs/HISTORY.txt ============================================================================== Modified: kukit/kss.demo/branch/finish-closures/docs/INSTALL.txt ============================================================================== Modified: kukit/kss.demo/branch/finish-closures/docs/LICENSE.GPL ============================================================================== Modified: kukit/kss.demo/branch/finish-closures/docs/LICENSE.txt ============================================================================== Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/configure.zcml Sun Dec 30 15:41:02 2007 @@ -55,10 +55,24 @@ + + @@ -76,5 +90,29 @@ permission="demo.Manager" /> + + + + + + + + + Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/kss_demo_index.pt ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/kss_demo_index.pt (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/kss_demo_index.pt Sun Dec 30 15:41:02 2007 @@ -8,10 +8,20 @@

    KSS demos

    Kss mode

    -

    Unit tests

    +

    Tests

    +

    + Zelenium object link must be an absolute path from the domain root, + or a relative path from the demo SimpleContent's parent. +

    Core plugin

    Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py Sun Dec 30 15:41:02 2007 @@ -4,6 +4,8 @@ from zope.publisher.interfaces import NotFound from zope.component import getUtility from zope.interface import implements +from kss.demo.selenium_utils.builder import cookSeleniumTests +import os.path try: from Products.Five import BrowserView BrowserView # make pyflakes happy @@ -54,6 +56,57 @@ group.append(demo) return demo_groups + @staticmethod + def _filename_to_title(filename): + """Automatic conversion of filename to readable title""" + if filename.lower().endswith('.html'): + filename = filename[:-5] + elif filename.lower().endswith('.htm'): + filename = filename[:-4] + words = os.path.basename(filename).split('_') + result = ' '.join([word.capitalize() for word in words]) + return result + + @staticmethod + def _filename_to_href(filename): + """Automatic conversion of filename to publication href""" + return "@@resource?filename=%s" % (filename, ) + + def getSeleniumTests(self): + """Get selenium tests annotated with title and href.""" + return [dict( + href = self._filename_to_href(filename), + title=self._filename_to_title(filename), + ) + for filename in self.selenium_test_filenames] + + @property + def selenium_test_filenames(self): + """A cached representation of all filenames.""" + try: + return self._cooked_selenium_test_filenames + except AttributeError: + registry = getUtility(IKSSDemoRegistry) + self._cooked_selenium_test_filenames = filenames = \ + registry.selenium_tests + return filenames + + def getSeleniumTestResource(self, filename): + """Return the html resource, whose absolute filename is given,""" + # First of all, let's check if this is one of our file. + # (Refuse otherwise - we don't want access to all files on the server.) + if filename not in self.selenium_test_filenames: + raise Exception, "Nonexistent resource" + # Return the file's content. + self.request.response.setHeader('Content-type', 'text/html;charset=utf-8') + return file(filename).read() + + def getZuiteHomePage(self, path): + """Redirects to the Zuite home page, Zuite object is found from path.""" + zuite = self.context.aq_inner.aq_parent.restrictedTraverse(path) + html = "%s/core/TestRunner.html?test=%s/suite.html" % (zuite.absolute_url(), self.context.absolute_url()) + return self.request.response.redirect(html) + class KSSDemoRegistryAdminView(BrowserView): """Things that only admin should do""" implements(IBrowserPublisher) @@ -90,5 +143,8 @@ of kss.demo.selenium_utils . """ registry = getUtility(IKSSDemoRegistry) - registry.cookSeleniumTests() - return "Selenium tests cooked OK. (%i)" % (len(registry.selenium_tests), ) + filenames = registry.selenium_tests + # Cook them. This will create seltest_all.py. + cookSeleniumTests(filenames) + # We are done. + return "Selenium tests cooked OK. (%i)" % (len(filenames), ) Modified: kukit/kss.demo/branch/finish-closures/kss/demo/interfaces.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/interfaces.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/interfaces.py Sun Dec 30 15:41:02 2007 @@ -126,13 +126,6 @@ def unregisterSeleniumTestFile(test_filename): """Unregister the given test directory.""" - def cookSeleniumTests(): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ # -- # Event that gets redispatched, for allowing Modified: kukit/kss.demo/branch/finish-closures/kss/demo/meta.zcml ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/meta.zcml (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/meta.zcml Sun Dec 30 15:41:02 2007 @@ -1,6 +1,11 @@ + + + Modified: kukit/kss.demo/branch/finish-closures/kss/demo/registry.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/registry.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/registry.py Sun Dec 30 15:41:02 2007 @@ -16,25 +16,12 @@ IRegistered, IUnregistered, ) -import sys, os, re, textwrap -from elementtree import HTMLTreeBuilder -from string import Template -import kss.demo.selenium_utils -# shut the mouth of pyflakes -kss.demo.selenium_utils +from kss.demo.selenium_utils.builder import getSeleniumTestsFromSuite # -- # Registry implementation for use with Zope # -- -def getRootDirOfModule(module_name): - return os.path.dirname(sys.modules[module_name].__file__) - -def getRootDirOfClass(cls): - return getRootDirOfModule(cls.__module__) - -def getRootDirOfInstance(obj): - return getRootDirOfClass(obj.__class__) # Create a mesh of provided interfaces # This is needed, because an utility must have a single interface. @@ -76,6 +63,8 @@ for name, plugin in site.getUtilitiesFor(IKSSDemoResource): for demo in plugin.demos: self.registerDemo(demo) + for test_filename in self._getSeleniumTestsFromPlugin(plugin): + self.registerSeleniumTestFile(test_filename) @adapter(IKSSDemoResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) def registerDemosFromPlugin(self, plugin, registration=None, event=None, new_event=None): @@ -142,13 +131,9 @@ @staticmethod def _getSeleniumTestsFromPlugin(plugin): test_filenames = [] - root_dir = getRootDirOfInstance(plugin) - for selenium_test_directory in plugin.selenium_tests: - tests_root_dir = os.path.join(root_dir, selenium_test_directory.test_directory) - for test_filename in os.listdir(tests_root_dir): - if test_filename.lower().endswith('.html') or \ - test_filename.endswith('.htm'): - test_filenames.append(os.path.join(tests_root_dir, test_filename)) + for selenium_test_suite in plugin.selenium_tests: + filenames = getSeleniumTestsFromSuite(plugin, selenium_test_suite) + test_filenames.extend(filenames) return test_filenames @adapter(IKSSSeleniumTestResource, IUtilityRegistration, IRegistered, IKSSDemoRegistrationEvent) @@ -178,77 +163,3 @@ del self.selenium_tests[test_filename] except KeyError: raise Exception, 'The selenium test for %s is yet unregistered. Cannot remove.' % (test_filename, ) - - template = Template(textwrap.dedent('''\ - from seleniumtestcase import SeleniumTestCase - import unittest, time - - class seltest_$testname(SeleniumTestCase): - - $tests - - def test_suite(): - return unittest.makeSuite(seltest_$testname) - - if __name__ == "__main__": - unittest.main() - ''')) - - variable_regexp = re.compile('\$\{(?P\w*)\}') - @classmethod - def formatcommand(cls, command, *args): - if not command: - return '' # Change this to raise an exception? - - arguments = [] - for arg in args: - if not arg: - continue - matched = cls.variable_regexp.match(arg) - if matched is None: - arguments.append('"%s"'%arg) - else: - arguments.append("self.getVar('%s')"%matched.group('varname')) - return 'self.%s(%s)' % (command, ', '.join(arguments)) - - def cookSeleniumTests(self): - """Cook selenium tests - - The *.html tests from each plugin are produced - into the file seltest_all.pty in the directory - of kss.demo.selenium_utils . - """ - # Try to open the file for writing. - output_dir = getRootDirOfModule('kss.demo.selenium_utils') - output_filename = os.path.join(output_dir, 'seltest_all.py') - try: - f = open(output_filename, 'wb') - except IOError, exc: - raise IOError, ('Cannot open file "%s" for writing. ' - 'Make sure zope process has write access in directory. ' - '["%s"]') \ - % (output_filename, exc) - - htmlparser = HTMLTreeBuilder.TreeBuilder() - tests = [] - for filename in self.selenium_tests: - tree = HTMLTreeBuilder.parse(filename) - root = tree.getroot() - - try: - testname = root.find('.//title').text - except AttributeError: - continue - commands = [] - for row in root.findall('.//tbody/tr'): - commands.append(self.formatcommand(*[td.text for td in row.findall('td')])) - - testfilename = 'seltest_%s.py' % testname - testbody=' def test_%s(self):\n'%testname+' '*8+'\n '.join(commands)+'\n' - tests.append(testbody) - - f.write(self.template.substitute(dict( - testname=testname, - tests='\n'.join(tests), - ))) - f.close() From reebalazs at codespeak.net Sun Dec 30 15:44:59 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 15:44:59 +0100 (CET) Subject: [KSS-checkins] r50204 - in kukit/kss.core/branch/finish-closures/kss/core: . docs plugins/core/demo plugins/core/demo/binderids plugins/core/demo/selenium_tests Message-ID: <20071230144459.22421168449@codespeak.net> Author: reebalazs Date: Sun Dec 30 15:44:59 2007 New Revision: 50204 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/config.py - copied unchanged from r50168, kukit/kss.core/trunk/kss/core/plugins/core/demo/binderids/config.py kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/config.py - copied unchanged from r50168, kukit/kss.core/trunk/kss/core/plugins/core/demo/config.py Removed: kukit/kss.core/branch/finish-closures/kss/core/docs/ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Modified: kukit/kss.core/branch/finish-closures/kss/core/configure.zcml kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/binderids/configure.zcml kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/configure.zcml kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/form_submit.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/inline_edit.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/selectors.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_selects.html Log: Merge up changes from trunk -r48594-50168 This includes the followings: - switch to the demo registry - enable tests to be used from kss.zope transition - fix a bunch of tests failing mostly for '/n' difference, this version confirmedly works with zelenium trunk. Modified: kukit/kss.core/branch/finish-closures/kss/core/configure.zcml ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/configure.zcml (original) +++ kukit/kss.core/branch/finish-closures/kss/core/configure.zcml Sun Dec 30 15:44:59 2007 @@ -53,15 +53,6 @@ name="base2-dom-fp.js" /> - - - @@ -9,12 +10,14 @@ --> - + + + @@ -21,12 +22,14 @@ --> - + + + - assertTextPresent + verifyTextPresent 100 - assertTextPresent + verifyTextPresent Foobar - assertTextPresent + verifyTextPresent USA - assertTextPresent + verifyTextPresent John Foo - assertTextPresent + verifyTextPresent Bar street, 12 @@ -109,32 +109,37 @@ - assertTextPresent + waitForTextPresent + dring + + + + verifyTextPresent Async saved: - assertTextPresent + verifyTextPresent dring - assertTextPresent + verifyTextPresent Southway - assertTextPresent + verifyTextPresent Norway - assertTextPresent + verifyTextPresent Brigitte Bardou - assertTextPresent + verifyTextPresent Cool street Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/inline_edit.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/inline_edit.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/inline_edit.html Sun Dec 30 15:44:59 2007 @@ -30,13 +30,8 @@ waitForValue - value - click me! - - - assertValue - value - click me! + save + save type Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/selectors.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/selectors.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/selectors.html Sun Dec 30 15:44:59 2007 @@ -25,8 +25,8 @@ assertText - target - Target Click me! + parentnodeok + Click me! click Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/suite.html Sun Dec 30 15:44:59 2007 +++ (empty file) @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Test Suite
    -

    - Development mode -

    -
    Ecmaunit tests
    Basic commands
    Two selects
    Two selects revisited
    Forms
    Actions
    Auto update
    Focus
    Prevent default on click
    Prevent default
    Inline edit
    Bubbling
    Selector parameters
    Selectors
    More Selectors
    Form submit
    Error handling
    HTML inserts
    Binder classes handling
    Binder ids
    -

    - Production mode -

    -
    Ecmaunit tests
    Basic commands
    Two selects
    Two selects revisited
    Forms
    Actions
    Auto update
    Focus
    Prevent default on click
    Prevent default
    Inline edit
    Bubbling
    Selector parameters
    Selectors
    More Selectors
    Form submit
    Error handling
    HTML inserts
    Binder classes handling
    Binder ids
    - - Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_select_revisited.html Sun Dec 30 15:44:59 2007 @@ -16,7 +16,7 @@ assertText first-master - animals machines + animals machines assertText @@ -56,7 +56,7 @@ assertText second-master - animals machines + animals machines assertText @@ -96,7 +96,7 @@ assertText third-master - animals machines + animals machines assertText Modified: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_selects.html ============================================================================== --- kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_selects.html (original) +++ kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/two_selects.html Sun Dec 30 15:44:59 2007 @@ -16,7 +16,7 @@ assertText first - animals machines + animals machines assertText From reebalazs at codespeak.net Sun Dec 30 15:46:31 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 15:46:31 +0100 (CET) Subject: [KSS-checkins] r50205 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071230144631.D6DFE168449@codespeak.net> Author: reebalazs Date: Sun Dec 30 15:46:31 2007 New Revision: 50205 Removed: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderclasses_temporary.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html Log: Removed unneeded tests, they are in their own dir now Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderclasses_temporary.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderclasses_temporary.html Sun Dec 30 15:46:31 2007 +++ (empty file) @@ -1,99 +0,0 @@ - - - -binderclasses - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    binderclasses
    open/demo/kss_binder_classes.html
    clickalpha1
    waitForTextPresent[50]
    clickalpha1
    waitForTextPresent[50][51]
    clickbeta1
    waitForTextPresent[50][51][100]
    clickbeta2
    waitForTextPresent[50][51][100][101]
    clickbeta1
    waitForTextPresent[50][51][100][101][102]
    clickbeta1
    waitForTextPresent[50][51][100][101][102][103]
    clickbeta2
    verifyTextPresent[50][51][100][101][102][103][104]
    clickalpha1
    waitForTextPresent[50][51][100][101][102][103][104][52]
    - - Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/binderids_temporary.html Sun Dec 30 15:46:31 2007 +++ (empty file) @@ -1,49 +0,0 @@ - - - -binderids - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    binderids
    open/demo/binderids.html
    clickbutton1
    waitForTextPresentmanualmanual2
    clickbutton2
    waitForTextPresentmanualmanual2manualparm1
    clickbutton3
    waitForTextPresentmanualmanual2manualparm1manualparm2
    - - From reebalazs at codespeak.net Sun Dec 30 17:35:49 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 17:35:49 +0100 (CET) Subject: [KSS-checkins] r50206 - kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests Message-ID: <20071230163549.A353A1684C0@codespeak.net> Author: reebalazs Date: Sun Dec 30 17:35:47 2007 New Revision: 50206 Added: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/0_ecmaunit_tests.html - copied unchanged from r50168, kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html Removed: kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Log: These are also not needed (deleted on trunk) Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/ecmaunit_tests.html Sun Dec 30 17:35:47 2007 +++ (empty file) @@ -1,59 +0,0 @@ - - - -ecma_tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ecma_tests
    open/demo/@@kukittestsuite/runner.html
    assertTextPresentRun Testcases
    clickcss=a[href="javascript:runTestCases();"]
    assertText//div[@id='kukit.UtilsTestCase']/divOK!
    assertText//div[@id='kukit.RequestManagerTestCase']/divOK!
    assertText//div[@id='kukit.TokenizerTestCase']/divOK!
    assertText//div[@id='kukit.KssParserTestCase']/divOK!
    assertText//div[@id='kukit.KssParserSelectorTestCase']/divOK!
    assertText//div[@id='kukit.KssParserSelectorsTestCase']/divOK!
    - - Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setDevMode.html Sun Dec 30 17:35:47 2007 +++ (empty file) @@ -1,33 +0,0 @@ - - - -basic_commands - - - - - - - - - - - - - - - - - - - - - - - - - - -
    basic_commands
    opendemo/@@kss_devel_mode/ui
    assertTextPresentKSS mode setup
    clickAndWaitbutton_devel
    assertTextPresentdevelopment
    - - Deleted: /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html ============================================================================== --- /kukit/kss.core/branch/finish-closures/kss/core/plugins/core/demo/selenium_tests/setProdMode.html Sun Dec 30 17:35:47 2007 +++ (empty file) @@ -1,33 +0,0 @@ - - - -basic_commands - - - - - - - - - - - - - - - - - - - - - - - - - - -
    basic_commands
    open/demo/@@kss_devel_mode/ui
    assertTextPresentKSS mode setup
    clickAndWaitbutton_prod
    assertTextPresentproduction
    - - From reebalazs at codespeak.net Sun Dec 30 17:43:19 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 30 Dec 2007 17:43:19 +0100 (CET) Subject: [KSS-checkins] r50207 - in kukit/kss.demo/branch/finish-closures/kss/demo: . browser selenium_utils Message-ID: <20071230164319.C28911684CA@codespeak.net> Author: reebalazs Date: Sun Dec 30 17:43:19 2007 New Revision: 50207 Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py kukit/kss.demo/branch/finish-closures/kss/demo/registry.py kukit/kss.demo/branch/finish-closures/kss/demo/selenium_utils/builder.py Log: Make alphabetical ordering of selenium tests in their plugin, this will assure that 0_ecmatest.html will come first. Modified: kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/browser/registry.py Sun Dec 30 17:43:19 2007 @@ -64,6 +64,12 @@ elif filename.lower().endswith('.htm'): filename = filename[:-4] words = os.path.basename(filename).split('_') + # if the first word is a number: it is ignored in the title + # This can be used to somelimited ordering, since filenames + # are listed in alphabetical order, ie. 00_xxx.html will come first. + if not words[0] or '0' <= words[0][0] <= '9': + words = words[1:] + # Compile the result. result = ' '.join([word.capitalize() for word in words]) return result Modified: kukit/kss.demo/branch/finish-closures/kss/demo/registry.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/registry.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/registry.py Sun Dec 30 17:43:19 2007 @@ -140,7 +140,10 @@ def registerSeleniumTestsFromPlugin(self, plugin, registration=None, event=None, new_event=None): """Add a demo collection to the registry. """ - for test_filename in self._getSeleniumTestsFromPlugin(plugin): + test_filenames = self._getSeleniumTestsFromPlugin(plugin) + # Sort filenames alphabetically + test_filenames.sort() + for test_filename in test_filenames: self.registerSeleniumTestFile(test_filename) @adapter(IKSSSeleniumTestResource, IUtilityRegistration, IUnregistered, IKSSDemoRegistrationEvent) @@ -153,6 +156,7 @@ def registerSeleniumTestFile(self, test_filename): """Register a selenium test by absolute filename """ + print "-----", test_filename if test_filename in self.selenium_tests: raise Exception, 'The selenium test for %s has already been registered. Cannot add.' % (test_filename, ) self.selenium_tests.append(test_filename) Modified: kukit/kss.demo/branch/finish-closures/kss/demo/selenium_utils/builder.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/selenium_utils/builder.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/selenium_utils/builder.py Sun Dec 30 17:43:19 2007 @@ -31,7 +31,11 @@ for test_filename in os.listdir(tests_root_dir): if test_filename.lower().endswith('.html') or \ test_filename.endswith('.htm'): - test_filenames.append(os.path.join(tests_root_dir, test_filename)) + test_filenames.append((test_filename, os.path.join(tests_root_dir, test_filename))) + # sort the testfilenames + test_filenames.sort() + # return only the absolute filenames + test_filenames = [filename[1] for filename in test_filenames] return test_filenames template = Template(textwrap.dedent('''\ From gotcha at codespeak.net Sun Dec 30 17:46:21 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 30 Dec 2007 17:46:21 +0100 (CET) Subject: [KSS-checkins] r50208 - kukit/kss.buildout/branch/with-Zelenium-dev Message-ID: <20071230164621.815581684CA@codespeak.net> Author: gotcha Date: Sun Dec 30 17:46:21 2007 New Revision: 50208 Modified: kukit/kss.buildout/branch/with-Zelenium-dev/buildout.cfg Log: add Zelenium Modified: kukit/kss.buildout/branch/with-Zelenium-dev/buildout.cfg ============================================================================== --- kukit/kss.buildout/branch/with-Zelenium-dev/buildout.cfg (original) +++ kukit/kss.buildout/branch/with-Zelenium-dev/buildout.cfg Sun Dec 30 17:46:21 2007 @@ -3,6 +3,7 @@ javaversion seleniumrc zope2 + extraproducts instance ksspy @@ -26,7 +27,13 @@ [zope2] recipe = plone.recipe.zope2install -url = http://www.zope.org/Products/Zope/2.10.4/Zope-2.10.4-final.tgz +url = http://www.zope.org/Products/Zope/2.10.5/Zope-2.10.5-final.tgz + +[extraproducts] +recipe = infrae.subversion +urls = + svn://svn.zope.org/repos/main/Zelenium/trunk Zelenium + [instance] recipe = plone.recipe.zope2instance @@ -35,6 +42,7 @@ debug-mode = on products = ${buildout:directory}/products + ${buildout:directory}/parts/extraproducts eggs = ${buildout:eggs} kss.core From jvloothuis at codespeak.net Sun Dec 30 18:25:17 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 30 Dec 2007 18:25:17 +0100 (CET) Subject: [KSS-checkins] r50210 - in kukit/kss.zope/trunk/kss: core core/tests zope zope/tests Message-ID: <20071230172517.931BB1684C0@codespeak.net> Author: jvloothuis Date: Sun Dec 30 18:25:17 2007 New Revision: 50210 Added: kukit/kss.zope/trunk/kss/zope/siteview.txt - copied unchanged from r49568, kukit/kss.zope/trunk/kss/core/siteview.txt kukit/kss.zope/trunk/kss/zope/tests/help_ttwapi.py - copied unchanged from r50185, kukit/kss.zope/trunk/kss/core/tests/help_ttwapi.py kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py - copied, changed from r49568, kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py - copied, changed from r50185, kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py kukit/kss.zope/trunk/kss/zope/ttwapi.py - copied, changed from r50185, kukit/kss.zope/trunk/kss/core/ttwapi.py Removed: kukit/kss.zope/trunk/kss/core/siteview.txt kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py Modified: kukit/kss.zope/trunk/kss/core/ttwapi.py kukit/kss.zope/trunk/kss/zope/__init__.py kukit/kss.zope/trunk/kss/zope/commands.py kukit/kss.zope/trunk/kss/zope/view.txt Log: Added ttwapi to kss.zope Fixed the BBB stuff for commands Deleted: /kukit/kss.zope/trunk/kss/core/siteview.txt ============================================================================== --- /kukit/kss.zope/trunk/kss/core/siteview.txt Sun Dec 30 18:25:17 2007 +++ (empty file) @@ -1,117 +0,0 @@ -========= -Site view -========= - -All KSS views are not only a browser view but provide a site manager -as well. The site manager is hooked into the component framework on -traversal time. This allows the KSS views to dispatch incomming -object events to (object, view, event) so that KSS-view-specific event -handlers can add to the view's commands. - -This behaviour is needed for making event driven changes to a page. -For instance when you change a title in a document you also want the -menu reloaded. By using events for this we can achieve a degree of -decoupling. - -The main class which implements views with a site manager is ``SiteView``: - - >>> from kss.core.kssview import SiteView - - >>> from zope import component - >>> old_sitemanager = component.getSiteManager() - - >>> from zope.publisher.browser import TestRequest - >>> class TestObject: - ... pass - >>> obj = TestObject() - >>> request = TestRequest() - >>> view = SiteView(obj, request) - -Let's register a handler for an object modified event event and -SiteView views: - - >>> from zope.lifecycleevent import ObjectModifiedEvent - >>> event = ObjectModifiedEvent(obj) - - >>> @component.adapter(TestObject, SiteView, ObjectModifiedEvent) - ... def catchTestObjectEvent(event_obj, event_view, event_event): - ... print "Special event handler was invoked, dispatch is working." - ... print "Object is the original one:", event_obj is obj - ... print "View is the original one:", event_view is view - ... print "Event is the original one:", event_event is event - ... - >>> component.provideHandler(catchTestObjectEvent) - -Without the SiteView view being activated as a site, it won't dispatch -to the handler: - - >>> from zope.event import notify - >>> notify(ObjectModifiedEvent(obj)) - -Now we make the view the current site. We'll see that its site -manager has become the current component registry: - - >>> from zope.app.component.hooks import setSite - >>> setSite(view) - - >>> old_sitemanager is component.getSiteManager() - False - >>> view.getSiteManager() is component.getSiteManager() - True - -The view also immediately registers its special event handler. Like -mentioned earlier this will dispatch to (obj, view, event) handlers, -including the one we defined above. So let's send that object -modified event again. We expect our site view event handler will be -invoked with the original object, view and event: - - >>> notify(ObjectModifiedEvent(obj)) - Special event handler was invoked, dispatch is working. - Object is the original one: True - View is the original one: True - Event is the original one: False - -Below a site ------------- - -Let's say SiteView is operating below a persistent site, e.g. the root -folder or a CMF site: - - >>> from zope.app.folder import Folder - >>> from zope.app.component.interfaces import ISite - >>> from zope.interface import alsoProvides - >>> from zope.component.globalregistry import base - >>> from zope.component.persistentregistry import PersistentComponents - - >>> site = Folder() - >>> components = PersistentComponents() - >>> components.__bases__ = (base,) - >>> site.setSiteManager(components) - >>> alsoProvides(site, ISite) - - >>> setSite(site) - -Let's also register a site view event subscriber *globally* and one -*locally* - - >>> @component.adapter(ISite, SiteView, ObjectModifiedEvent) - ... def catchSiteEventGlobally(event_obj, event_view, event_event): - ... print "Global event handler was invoked, dispatch is working." - ... - >>> component.provideHandler(catchSiteEventGlobally) - - >>> @component.adapter(ISite, SiteView, ObjectModifiedEvent) - ... def catchSiteEventLocally(event_obj, event_view, event_event): - ... print "Local event handler was invoked, dispatch is working." - ... - >>> components.registerHandler(catchSiteEventLocally) - -Let's now verify the SiteView still works and dispatches component -lookup accordingly. - - >>> view = SiteView(site, request) - >>> setSite(view) - - >>> notify(ObjectModifiedEvent(site)) - Global event handler was invoked, dispatch is working. - Local event handler was invoked, dispatch is working. Deleted: /kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py ============================================================================== --- /kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py Sun Dec 30 18:25:17 2007 +++ (empty file) @@ -1,164 +0,0 @@ -# -*- coding: latin-1 -*- -# Copyright (c) 2005-2007 -# Authors: KSS Project Contributors (see docs/CREDITS.txt) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -import unittest -import textwrap -from kss.core import KSSUnicodeError -from kss.core.tests.base import KSSViewTestCase -from Testing.ZopeTestCase import FunctionalDocFileSuite - -class TestKSSViewCoreCommandSet(KSSViewTestCase): - - def test_empty(self): - view = self.createView() - commands = view.getCommands() - self.assertEqual(len(commands), 0) - - def test_addCommand(self): - view = self.createView() - commands = view.getCommands() - command = commands.addCommand('replaceInnerHTML', 'selector') - self.assertEqual(len(commands), 1) - self.assertEqual(command.getName(), 'replaceInnerHTML') - self.assertEqual(command.getSelector(), 'selector') - params = command.getParams() - self.assertEqual(len(params), 0) - - # XXX since lxml is gone, the next cases are no problem anymore - # Nevertheless, we test all these cases - - def _checkSetHtmlResult(self, content, content2=None): - view = self.createView() - view.getCommandSet('core').replaceInnerHTML('div.class', content) - commands = view.getCommands() - self.assertEqual(len(commands), 1) - command = commands[0] - self.assertEqual(command.getName(), 'replaceInnerHTML') - self.assertEqual(command.getSelector(), 'div.class') - params = command.getParams() - self.assertEqual(len(params), 2) - self.assertEqual(params[0].getName(), 'html') - self.assertEqual(params[1].getName(), 'withKssSetup') - if content2 == None: - content2 = content - content2 = content2.encode('ascii', 'xmlcharrefreplace') - # wrap content into CDATA - content2 = '' % (content2, ) - # and finally check it - self.assertEqual(params[0].getContent().encode('ascii', 'xmlcharrefreplace'), content2) - - def test_replaceInnerHTMLTextPlusEntity(self): - 'See if non breaking space entity works' - ##self._checkSetHtmlResult(' ') - # XXX we remove html named entities now - self._checkSetHtmlResult(' ', ' ') - - def test_replaceInnerHTMLTextPlusEntityOthers(self): - 'See if the other HTML entities work as well' - # XXX we remove html named entities now - self._checkSetHtmlResult('

    »Hello world!«

    ', - '

    »Hello world!«

    ') - - def test_replaceInnerHTMLTextOnly(self): - self._checkSetHtmlResult('new content') - - def test_replaceInnerHTMLTagOnly(self): - self._checkSetHtmlResult('

    new_content

    ') - - def test_replaceInnerHTMLTagPlusText(self): - self._checkSetHtmlResult('

    new_content

    after') - - def test_replaceInnerHTMLTextTagPlusText(self): - self._checkSetHtmlResult('before

    new_content

    after') - - def test_setHtmlAcceptsUnicode(self): - 'Test that it accepts unicode' - self._checkSetHtmlResult(u'abc?') - - def test_setHtmlChecksForNonUnicode(self): - 'Test that it does not accept non unicode (unless pure ascii)' - self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc?') - -class FTestKSSViewCoreCommandSet(KSSViewTestCase): - 'Functional tests' - - def _wrapped_commands(self, inline): - header = textwrap.dedent(u'''\ - - - - ''') - footer = textwrap.dedent('''\ - - - ''') - return header + inline + footer - - def assertXMLEquals(self, a, b): - self.assertEqual(a, b) - - def assertCommandsEqual(self, a, b): - self.assertXMLEquals(a, self._wrapped_commands(b)) - - def test_empty(self): - view = self.createView() - result = view.render() - self.assertEquals(view.request.response.getHeader('content-type'), 'text/xml;charset=utf-8') - self.assertCommandsEqual(result, '') - - def test_replaceInnerHTML(self): - view = self.createView() - view.getCommandSet('core').replaceInnerHTML('div.class', 'new content') - result = view.render() - awaited = u'''\ - - - True - -''' - self.assertCommandsEqual(result, awaited) - - def test_setCommandSet(self): - view = self.createView() - cs = view.getCommandSet('core') - cs.replaceInnerHTML('div.class', 'new content') - result = view.render() - awaited = u'''\ - - - True - -''' - self.assertCommandsEqual(result, awaited) - -def afterSetUp(self): - KSSViewTestCase.afterSetUp(self) - self.setDebugRequest() - - -def test_suite(): - suites = [] - suites.append(unittest.makeSuite(TestKSSViewCoreCommandSet)) - suites.append(unittest.makeSuite(FTestKSSViewCoreCommandSet)) - suites.append(FunctionalDocFileSuite('../actionwrapper.py', - test_class=KSSViewTestCase, - setUp=afterSetUp, - tearDown=KSSViewTestCase.beforeTearDown.im_func)) - return unittest.TestSuite(suites) Modified: kukit/kss.zope/trunk/kss/core/ttwapi.py ============================================================================== --- kukit/kss.zope/trunk/kss/core/ttwapi.py (original) +++ kukit/kss.zope/trunk/kss/core/ttwapi.py Sun Dec 30 18:25:17 2007 @@ -1,36 +1,9 @@ -from zope.app.component.hooks import getSite, setSite -from zope import event -from zope.app.publication.zopepublication import BeforeTraverseEvent - from kss.core import KSSView from kss.core.interfaces import IKSSView from kss.core.unicode_quirks import force_unicode -def startKSSCommands(context, request): - view = KSSView(context, request) - # Alec suggested we should fire the BeforeTraverseEvent, but after - # debugging for a while I stopped caring about the event and think - # that setSite() is the only thing we're interested in. - setSite(view) - return view - -def getKSSCommandSet(name): - view = retrieveView() - cs = view.getCommandSet(name) - return cs - -def renderKSSCommands(): - view = retrieveView() - return view.render() - -def retrieveView(): - #because the view registers itself as a site, - #we can retrieve it... - site = getSite() - if not IKSSView.providedBy(site): - raise LookupError( - "You haven't initialized the KSS response yet, " - "do so by calling startKSSCommands(context, request).") - return site - +from kss.zope.ttwapi import startKSSCommands +from kss.zope.ttwapi import getKSSCommandSet +from kss.zope.ttwapi import renderKSSCommands +from kss.zope.ttwapi import retrieveView Modified: kukit/kss.zope/trunk/kss/zope/__init__.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/__init__.py (original) +++ kukit/kss.zope/trunk/kss/zope/__init__.py Sun Dec 30 18:25:17 2007 @@ -1,3 +1,10 @@ # from kss.zope.view import KSSView from kss.zope.actionwrapper import KSSExplicitError, kssaction + +try: + from AccessControl import allow_module +except ImportError: + pass # Not on Zope 2 +else: + allow_module('kss.zope.ttwapi') Modified: kukit/kss.zope/trunk/kss/zope/commands.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/commands.py (original) +++ kukit/kss.zope/trunk/kss/zope/commands.py Sun Dec 30 18:25:17 2007 @@ -3,7 +3,6 @@ from interfaces import IKSSPluginRegistry, IZopeCommandSet from bbb.commandset import CompatCommandSet # BBB -from kss.base.selectors import Selector, css #from bbb.deprecated import deprecated #when = 'after 2008-08-01' @@ -29,17 +28,55 @@ ## Don't BBB yet. Uncommenting the next line will activate BBB. ##@deprecated('use view.commands.add(action, selector **kw)', when) - def addCommand(self, command_name, selector=None, **kw): - self._strip_none_parameters(kw) - - if selector is not None and not isinstance(selector, Selector): - selector = css(selector) - - self.commands.append(CompatCommand((command_name, selector, kw))) + def addCommand(self, command_name, selector=None): + cmd = CompatCommand(command_name, selector) + self.commands.append(cmd) + return cmd + + def __len__(self): + # BBB: Used from some tests + return len(self.commands) + + def __getitem__(self, index): + # BBB: Used from some tests + action, selector, options = self.commands[index] + cmd = CompatCommand(action, selector) + for key, value in options.items(): + cmd.addParam(key, value) + return cmd # Nasty BBB for covering this old usage: # command = self.addCommand('command_name', 'selector') # command.addParam('key', 'value') -class CompatCommand(tuple): +class CompatCommand(object): + def __init__(self, action, selector): + self.action = action + self.selector = selector + self.options = [] + + def __iter__(self): + return (self.action, self.selector, dict(self.options)).__iter__() + def addParam(self, key, value): - self[2][key] = value + self.options.append(Param(key, value)) + + def getName(self): + return self.action + + def getSelector(self): + return self.selector + + def getParams(self): + return self.options + + +class Param(object): + def __init__(self, name, value): + self.name = name + self.value = value + + def getName(self): + return self.name + + def getContent(self): + return self.value Copied: kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py (from r49568, kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py) ============================================================================== --- kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py (original) +++ kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py Sun Dec 30 18:25:17 2007 @@ -18,11 +18,29 @@ import unittest import textwrap +from zope.testing import cleanup +from zope.app.component.hooks import setHooks +from zope import component +from zope.publisher.browser import TestRequest +from zope.publisher.http import HTTPResponse + +from kss.zope.interfaces import IKSSPluginRegistry +from kss.zope.registry import GlobalPluginRegistry +from kss.zope.view import KSSView from kss.core import KSSUnicodeError -from kss.core.tests.base import KSSViewTestCase -from Testing.ZopeTestCase import FunctionalDocFileSuite -class TestKSSViewCoreCommandSet(KSSViewTestCase): +class KSSTestCase(unittest.TestCase): + def setUp(self): + cleanup.CleanUp().setUp() + setHooks() + component.provideUtility(GlobalPluginRegistry(), IKSSPluginRegistry) + + + def createView(self): + request = TestRequest(response=HTTPResponse()) + return KSSView(None, request) + +class TestKSSViewCoreCommandSet(KSSTestCase): def test_empty(self): view = self.createView() @@ -51,16 +69,8 @@ self.assertEqual(command.getName(), 'replaceInnerHTML') self.assertEqual(command.getSelector(), 'div.class') params = command.getParams() - self.assertEqual(len(params), 2) + self.assertEqual(len(params), 1) self.assertEqual(params[0].getName(), 'html') - self.assertEqual(params[1].getName(), 'withKssSetup') - if content2 == None: - content2 = content - content2 = content2.encode('ascii', 'xmlcharrefreplace') - # wrap content into CDATA - content2 = '' % (content2, ) - # and finally check it - self.assertEqual(params[0].getContent().encode('ascii', 'xmlcharrefreplace'), content2) def test_replaceInnerHTMLTextPlusEntity(self): 'See if non breaking space entity works' @@ -89,24 +99,23 @@ def test_setHtmlAcceptsUnicode(self): 'Test that it accepts unicode' self._checkSetHtmlResult(u'abc?') - - def test_setHtmlChecksForNonUnicode(self): - 'Test that it does not accept non unicode (unless pure ascii)' - self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc?') -class FTestKSSViewCoreCommandSet(KSSViewTestCase): +# FIXME! Figure our what to do with this since there is nothing like +# this in kss.base +# def test_setHtmlChecksForNonUnicode(self): +# 'Test that it does not accept non unicode (unless pure ascii)' +# self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc?') + + +class FTestKSSViewCoreCommandSet(KSSTestCase): 'Functional tests' def _wrapped_commands(self, inline): header = textwrap.dedent(u'''\ - - - ''') - footer = textwrap.dedent('''\ - - + ''') + footer = '' return header + inline + footer def assertXMLEquals(self, a, b): @@ -125,13 +134,7 @@ view = self.createView() view.getCommandSet('core').replaceInnerHTML('div.class', 'new content') result = view.render() - awaited = u'''\ - - - True - -''' + awaited = u'''''' self.assertCommandsEqual(result, awaited) def test_setCommandSet(self): @@ -139,13 +142,7 @@ cs = view.getCommandSet('core') cs.replaceInnerHTML('div.class', 'new content') result = view.render() - awaited = u'''\ - - - True - -''' + awaited = u'''''' self.assertCommandsEqual(result, awaited) def afterSetUp(self): @@ -157,8 +154,4 @@ suites = [] suites.append(unittest.makeSuite(TestKSSViewCoreCommandSet)) suites.append(unittest.makeSuite(FTestKSSViewCoreCommandSet)) - suites.append(FunctionalDocFileSuite('../actionwrapper.py', - test_class=KSSViewTestCase, - setUp=afterSetUp, - tearDown=KSSViewTestCase.beforeTearDown.im_func)) return unittest.TestSuite(suites) Copied: kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py (from r50185, kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py) ============================================================================== --- kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py (original) +++ kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py Sun Dec 30 18:25:17 2007 @@ -4,7 +4,7 @@ ZopeTestCase.installProduct('PythonScripts') from AccessControl import allow_module -allow_module('kss.core.tests.help_ttwapi') +allow_module('kss.zope.tests.help_ttwapi') import Products.Five.component from Products.Five import zcml @@ -13,8 +13,8 @@ from zope.lifecycleevent import ObjectModifiedEvent from zope.app.component.hooks import setHooks -from kss.core import KSSView -from kss.core.tests.base import KSSViewTestCase +from kss.zope import KSSView +from kss.zope.tests.base import KSSViewTestCase class TTWTestCase(KSSViewTestCase): @@ -25,7 +25,7 @@ + package="kss.zope.tests.test_ttwapi"> ''' zcml.load_string(configure_zcml) @@ -39,45 +39,26 @@ def test_scriptWithCore(self): pythonScriptCode = ''' -from kss.core.ttwapi import startKSSCommands -from kss.core.ttwapi import getKSSCommandSet -from kss.core.ttwapi import renderKSSCommands +from kss.zope.ttwapi import startKSSCommands +from kss.zope.ttwapi import getKSSCommandSet +from kss.zope.ttwapi import renderKSSCommands startKSSCommands(context, context.REQUEST) core = getKSSCommandSet('core') core.replaceInnerHTML('#test', '

    Done

    ') return renderKSSCommands() ''' self.app.kss_test.ZPythonScript_edit('', pythonScriptCode) - result = self.app.kss_test() - self.assertEquals(len(result), 1) - command = result[0] - self.assertEquals(command['selector'], '#test') - self.assertEquals(command['name'], 'replaceInnerHTML') - - def test_scriptWithEffect(self): - pythonScriptCode = ''' -from kss.core.ttwapi import startKSSCommands -from kss.core.ttwapi import getKSSCommandSet -from kss.core.ttwapi import renderKSSCommands -startKSSCommands(context, context.REQUEST) -commandSet = getKSSCommandSet('effects') -commandSet.effect('#test', 'fade') -return renderKSSCommands() -''' - self.app.kss_test.ZPythonScript_edit('', pythonScriptCode) - result = self.app.kss_test() - self.assertEquals(len(result), 1) - command = result[0] - self.assertEquals(command['selector'], '#test') - self.assertEquals(command['name'], 'effect') - self.assertEquals(command['params']['type'], 'fade') + result = self.app.kss_test() + self.assertEquals( + str(result), + "replaceInnerHTML('#test', html=htmldata('

    Done

    '))") def test_scriptWithEvents(self): pythonScriptCode = ''' -from kss.core.ttwapi import startKSSCommands -from kss.core.ttwapi import getKSSCommandSet -from kss.core.ttwapi import renderKSSCommands -from kss.core.tests.help_ttwapi import objectModified +from kss.zope.ttwapi import startKSSCommands +from kss.zope.ttwapi import getKSSCommandSet +from kss.zope.ttwapi import renderKSSCommands +from kss.zope.tests.help_ttwapi import objectModified startKSSCommands(context, context.REQUEST) core = getKSSCommandSet('core') core.replaceInnerHTML('#test', '

    Done

    ') @@ -86,13 +67,10 @@ ''' self.app.kss_test.ZPythonScript_edit('', pythonScriptCode) result = self.app.kss_test() - self.assertEquals(len(result), 2) - command = result[0] - self.assertEquals(command['selector'], '#test') - self.assertEquals(command['name'], 'replaceInnerHTML') - command = result[1] - self.assertEquals(command['selector'], '#event') - self.assertEquals(command['name'], 'replaceInnerHTML') + self.assertEquals( + str(result).split('\n'), + ["replaceInnerHTML('#test', html=htmldata('

    Done

    '))", + "replaceInnerHTML('#event', html=htmldata('Event subscriber was here.'))"]) @component.adapter(None, KSSView, ObjectModifiedEvent) def objectModifiedThruKSSView(obj, view, event): Copied: kukit/kss.zope/trunk/kss/zope/ttwapi.py (from r50185, kukit/kss.zope/trunk/kss/core/ttwapi.py) ============================================================================== --- kukit/kss.zope/trunk/kss/core/ttwapi.py (original) +++ kukit/kss.zope/trunk/kss/zope/ttwapi.py Sun Dec 30 18:25:17 2007 @@ -1,10 +1,8 @@ from zope.app.component.hooks import getSite, setSite -from zope import event -from zope.app.publication.zopepublication import BeforeTraverseEvent +from AccessControl import allow_class -from kss.core import KSSView -from kss.core.interfaces import IKSSView -from kss.core.unicode_quirks import force_unicode +from kss.zope import KSSView +from kss.zope.interfaces import IKSSView def startKSSCommands(context, request): view = KSSView(context, request) @@ -17,6 +15,7 @@ def getKSSCommandSet(name): view = retrieveView() cs = view.getCommandSet(name) + allow_class(cs.__class__) return cs def renderKSSCommands(): Modified: kukit/kss.zope/trunk/kss/zope/view.txt ============================================================================== --- kukit/kss.zope/trunk/kss/zope/view.txt (original) +++ kukit/kss.zope/trunk/kss/zope/view.txt Sun Dec 30 18:25:17 2007 @@ -66,5 +66,8 @@ >>> xml_output = view.setTitle(u"some title") >>> print view.commands - replaceInnerHTML(css('div.class'), html='some title') + replaceInnerHTML('div.class', html=htmldata('some title')) + + + From jvloothuis at codespeak.net Sun Dec 30 18:41:14 2007 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 30 Dec 2007 18:41:14 +0100 (CET) Subject: [KSS-checkins] r50213 - kukit/kss.zope/trunk/kss/zope/tests Message-ID: <20071230174114.473B1168471@codespeak.net> Author: jvloothuis Date: Sun Dec 30 18:41:13 2007 New Revision: 50213 Modified: kukit/kss.zope/trunk/kss/zope/tests/base.py Log: Made the import of ZopeLite and its insertion into the test layer conditional so that it can work without as well (on Zope 3) Modified: kukit/kss.zope/trunk/kss/zope/tests/base.py ============================================================================== --- kukit/kss.zope/trunk/kss/zope/tests/base.py (original) +++ kukit/kss.zope/trunk/kss/zope/tests/base.py Sun Dec 30 18:41:13 2007 @@ -20,7 +20,6 @@ import warnings from Testing.ZopeTestCase import ZopeTestCase, FunctionalTestCase -from Testing.ZopeTestCase.layer import ZopeLite from zope import interface from interfaces import IDebugRequest @@ -29,7 +28,7 @@ import kss.zope from kss.zope import KSSView -class KSSCoreLayer(ZopeLite): +class KSSCoreLayer: @classmethod def setUp(cls): try: @@ -87,3 +86,12 @@ class KSSViewFunctionalTestCase(FunctionalTestCase, KSSViewTestCase): 'Functional test base' + +try: + from Testing.ZopeTestCase.layer import ZopeLite +except ImportError: + # Not on Zope 2 + pass +else: + # Fix the layers + KSSCoreLayer.__bases__ = (ZopeLite, ) From gotcha at codespeak.net Sun Dec 30 18:42:03 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 30 Dec 2007 18:42:03 +0100 (CET) Subject: [KSS-checkins] r50214 - kukit/kss.demo/branch/finish-closures Message-ID: <20071230174203.AEF2C1684CA@codespeak.net> Author: gotcha Date: Sun Dec 30 18:42:03 2007 New Revision: 50214 Modified: kukit/kss.demo/branch/finish-closures/setup.py Log: setuptools dependency Modified: kukit/kss.demo/branch/finish-closures/setup.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/setup.py (original) +++ kukit/kss.demo/branch/finish-closures/setup.py Sun Dec 30 18:42:03 2007 @@ -26,6 +26,7 @@ zip_safe=False, install_requires=[ # -*- Extra requirements: -*- + 'setuptools', 'kss.core>=dev', ], entry_points=""" From gotcha at codespeak.net Sun Dec 30 18:51:47 2007 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 30 Dec 2007 18:51:47 +0100 (CET) Subject: [KSS-checkins] r50217 - kukit/kss.buildout/trunk Message-ID: <20071230175147.0BCFD168473@codespeak.net> Author: gotcha Date: Sun Dec 30 18:51:47 2007 New Revision: 50217 Modified: kukit/kss.buildout/trunk/buildout.cfg Log: add Zelenium Modified: kukit/kss.buildout/trunk/buildout.cfg ============================================================================== --- kukit/kss.buildout/trunk/buildout.cfg (original) +++ kukit/kss.buildout/trunk/buildout.cfg Sun Dec 30 18:51:47 2007 @@ -2,6 +2,7 @@ parts = zope2 instance + extraproducts ksspy develop = @@ -14,6 +15,11 @@ recipe = plone.recipe.zope2install url = http://www.zope.org/Products/Zope/2.10.4/Zope-2.10.4-final.tgz +[extraproducts] +recipe = infrae.subversion +urls = + svn://svn.zope.org/repos/main/Zelenium/trunk Zelenium + [instance] recipe = plone.recipe.zope2instance zope2-location = ${zope2:location} @@ -28,6 +34,8 @@ kss.core kss.demo-meta kss.demo +products = + ${buildout:directory}/parts/extraproducts [ksspy] recipe = zc.recipe.egg