Author: jvloothuis
Date: Sun May 13 15:52:28 2007
New Revision: 43309

Added:
   kukit/kss.commands/trunk/kss/commands/corecommands.py
Modified:
   kukit/kss.commands/trunk/kss/commands/README.txt
   kukit/kss.commands/trunk/kss/commands/__init__.py
   kukit/kss.commands/trunk/kss/commands/commands.py
Log:
Added start of commandset system. This is based on the current implementation 
which can be found in kss.core. It should be possible to make a kss.zope which 
declares interfaces etc. to make an almost drop-in replacement for kss.core's 
current version.


Modified: kukit/kss.commands/trunk/kss/commands/README.txt
==============================================================================
--- kukit/kss.commands/trunk/kss/commands/README.txt    (original)
+++ kukit/kss.commands/trunk/kss/commands/README.txt    Sun May 13 15:52:28 2007
@@ -60,4 +60,41 @@
 Command sets
 ============
 
+A command set wraps the commands system so that you get a highlevel way to
+communicate with the browser. Command sets are responsible for escaping and
+validating data and can provider a nicer api for calling.
 
+We will now take a look at the base class for all commandsets.
+
+  >>> from kss.commands import KSSCommandSet
+  >>> commands = KSSCommands()
+  >>> commandset = KSSCommandSet(commands)
+
+All this does is wrap our commands in the command set. We can still access the
+commands directly by using the `commands` attribute.
+
+  >>> commandset.commands
+  <...KSSCommands object at ...>
+
+The thing that makes this interesting is the actual command sets. Take a look
+at the core commands for a better understanding of the usage pattern.
+
+Core commands
+-------------
+
+The core commands wrap all standard KSS actions that are always available.
+These do not contain any effects and focus mostly on DOM manipulation.
+
+First we will need to create our command set.
+
+  >>> from kss.commands import KSSCoreCommands
+  >>> commands = KSSCommands()
+  >>> core = KSSCoreCommands(commands)
+
+Now we will look at the individual methods provided by the core commands.
+
+  >>> core.replaceInnerHTML(CSS('div'), 'some <h1>html</h1>')
+  >>> commands.render()
+  '...replaceInnerHTML...some <h1>html</h1>...'
+
+  

Modified: kukit/kss.commands/trunk/kss/commands/__init__.py
==============================================================================
--- kukit/kss.commands/trunk/kss/commands/__init__.py   (original)
+++ kukit/kss.commands/trunk/kss/commands/__init__.py   Sun May 13 15:52:28 2007
@@ -5,5 +5,6 @@
     from pkgutil import extend_path
     __path__ = extend_path(__path__, __name__)
 
-from commands import KSSCommands
+from commands import KSSCommands, KSSCommandSet
 from selectors import Selector
+from corecommands import KSSCoreCommands

Modified: kukit/kss.commands/trunk/kss/commands/commands.py
==============================================================================
--- kukit/kss.commands/trunk/kss/commands/commands.py   (original)
+++ kukit/kss.commands/trunk/kss/commands/commands.py   Sun May 13 15:52:28 2007
@@ -44,3 +44,7 @@
             output.append(kss_command_end)
         output.append(kss_response_footer)
         return ''.join(output)
+
+class KSSCommandSet(object):
+    def __init__(self, commands):
+        self.commands = commands

Added: kukit/kss.commands/trunk/kss/commands/corecommands.py
==============================================================================
--- (empty file)
+++ kukit/kss.commands/trunk/kss/commands/corecommands.py       Sun May 13 
15:52:28 2007
@@ -0,0 +1,5 @@
+from commands import KSSCommandSet
+
+class KSSCoreCommands(KSSCommandSet):
+    def replaceInnerHTML(self, selector, value):
+        self.commands.add('replaceInnerHTML', selector, html=value)
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to