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 itse