[KSS-checkins] r44334 - in kukit/azax/branch/1.1-ree-plugin-dad: . plugins/core

reebalazs at codespeak.net reebalazs at codespeak.net
Mon Jun 18 12:47:26 CEST 2007


Author: reebalazs
Date: Mon Jun 18 12:47:20 2007
New Revision: 44334

Modified:
   kukit/azax/branch/1.1-ree-plugin-dad/deprecated.py
   kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/commands.py
   kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/configure.zcml
   kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/interfaces.py
   kukit/azax/branch/1.1-ree-plugin-dad/selectors.py
Log:
Merge in -r44330:44331 changeset from kss.core trunk: class manipulation actions and necessary fixes

Modified: kukit/azax/branch/1.1-ree-plugin-dad/deprecated.py
==============================================================================
--- kukit/azax/branch/1.1-ree-plugin-dad/deprecated.py	(original)
+++ kukit/azax/branch/1.1-ree-plugin-dad/deprecated.py	Mon Jun 18 12:47:20 2007
@@ -19,6 +19,9 @@
 # 02111-1307, USA.
 #
 import warnings
+def deprecated_warning(message):
+    warnings.warn(message, DeprecationWarning, 2)
+
 def deprecated(method, message):
     def deprecated_method(self, *args, **kw):
         warnings.warn(message, DeprecationWarning, 2)

Modified: kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/commands.py
==============================================================================
--- kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/commands.py	(original)
+++ kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/commands.py	Mon Jun 18 12:47:20 2007
@@ -1,16 +1,18 @@
-from interfaces import IKSSCoreCommands
+#from interfaces import IKSSCoreCommands
 
 
 try:
-    from azax.selectors import Selector, CssSelector, HtmlIdSelector
+    from azax.selectors import Selector, CssSelector, HtmlIdSelector, SameNodeSelector
     from azax.azaxview import AzaxViewAdapter
-    from azax.deprecated import deprecated
+    from azax.deprecated import deprecated, deprecated_warning
     from azax.parsers import XmlParser, HtmlParser
+    _dummy =  Selector, CssSelector, HtmlIdSelector, SameNodeSelector, AzaxViewAdapter, deprecated, deprecated_warning, XmlParser, HtmlParser   # satisfy pyflakes
 except ImportError:
-    from Products.azax.selectors import Selector, CssSelector, HtmlIdSelector
+    from Products.azax.selectors import Selector, CssSelector, HtmlIdSelector, SameNodeSelector
     from Products.azax.azaxview import AzaxViewAdapter
-    from Products.azax.deprecated import deprecated
+    from Products.azax.deprecated import deprecated, deprecated_warning
     from Products.azax.parsers import XmlParser, HtmlParser
+    _dummy =  Selector, CssSelector, HtmlIdSelector, SameNodeSelector, AzaxViewAdapter, deprecated, deprecated_warning, XmlParser, HtmlParser   # satisfy pyflakes
 
 
 class KSSCoreCommands(AzaxViewAdapter):
@@ -26,6 +28,8 @@
     def getHtmlIdSelector(self, selector):
         return HtmlIdSelector(selector)
 
+    def getSameNodeSelector(self):
+        return SameNodeSelector()
 
     # XXX the list is not full: maybe complete them?
     
@@ -131,14 +135,47 @@
         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')
@@ -149,4 +186,24 @@
     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/azax/branch/1.1-ree-plugin-dad/plugins/core/configure.zcml
==============================================================================
--- kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/configure.zcml	(original)
+++ kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/configure.zcml	Mon Jun 18 12:47:20 2007
@@ -251,6 +251,29 @@
         />
 
     <azax:registerAction
+        name="toggleClass"
+        command_factory="selector"
+        params_mandatory="value"
+        />
+
+    <azax:registerAction
+        name="addClass"
+        command_factory="selector"
+        params_mandatory="value"
+        />
+
+    <azax:registerAction
+        name="removeClass"
+        command_factory="selector"
+        params_mandatory="value"
+        />
+
+    <azax:registerAction
+        name="focus"
+        command_factory="selector"
+        />
+
+    <azax:registerAction
         name="setStateVar"
         command_factory="global"
         params_mandatory="varname value"

Modified: kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/interfaces.py
==============================================================================
--- kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/interfaces.py	(original)
+++ kukit/azax/branch/1.1-ree-plugin-dad/plugins/core/interfaces.py	Mon Jun 18 12:47:20 2007
@@ -1,4 +1,96 @@
 from zope.interface import Interface
 
 class IKSSCoreCommands(Interface):
-    '''all core commands'''
+    """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/azax/branch/1.1-ree-plugin-dad/selectors.py
==============================================================================
--- kukit/azax/branch/1.1-ree-plugin-dad/selectors.py	(original)
+++ kukit/azax/branch/1.1-ree-plugin-dad/selectors.py	Mon Jun 18 12:47:20 2007
@@ -19,6 +19,7 @@
 
 CSS_SELECTOR = 'css'
 HTMLID_SELECTOR = 'htmlid' 
+SAMENODE_SELECTOR = 'samenode' 
 
 class SelectorBase(object):
     
@@ -31,6 +32,11 @@
 class HtmlIdSelector(SelectorBase):
     type = HTMLID_SELECTOR        
 
+class SameNodeSelector(SelectorBase):
+    type = SAMENODE_SELECTOR   
+    def __init__(self):
+        self.value = ''
+
 # A generic (pluggable) selector
 
 class Selector(SelectorBase):


More information about the Kukit-checkins mailing list