Author: bree
Date: Wed Apr 19 22:26:59 2006
New Revision: 2905

Added:
   azax/branches/plugin/plugins/event_action.py
   azax/branches/plugin/plugins/event_type.py
Modified:
   azax/branches/plugin/demos/azaxdemo/browser/azax_demo.kukit
   azax/branches/plugin/demos/azaxdemo/browser/azax_three_autoupdate.kukit
   azax/branches/plugin/demos/azaxdemo/browser/cancel_submit.kukit
   azax/branches/plugin/plugins/__init__.py
   azax/branches/plugin/plugins/configure.py
   azax/branches/plugin/plugins/configure.zcml
   azax/branches/plugin/plugins/directives.py
   azax/branches/plugin/plugins/meta.zcml
   azax/branches/plugin/tests/test_azaxview.py
Log:
Extend registry with events/actions; fix tests

Modified: azax/branches/plugin/demos/azaxdemo/browser/azax_demo.kukit
==============================================================================
--- azax/branches/plugin/demos/azaxdemo/browser/azax_demo.kukit (original)
+++ azax/branches/plugin/demos/azaxdemo/browser/azax_demo.kukit Wed Apr 19 
22:26:59 2006
@@ -10,9 +10,15 @@
     <event name="click">moveToDivContent</event>
   </rule>
   <rule selector="button#clear">
-    <event name="click">clearDivContent</event>
+    <!--event name="click">clearDivContent</event-->
+       <event name="click">
+               <action type="remote">clearDivContent</action>
+       </event>
   </rule>
   <rule selector="button#change">
-    <event name="click">getDivContent</event>
+    <!--event name="click">getDivContent</event-->
+    <event type="generic" name="click">
+               <action type="remote">getDivContent</action>
+       </event>
   </rule>
 </rules>

Modified: 
azax/branches/plugin/demos/azaxdemo/browser/azax_three_autoupdate.kukit
==============================================================================
--- azax/branches/plugin/demos/azaxdemo/browser/azax_three_autoupdate.kukit     
(original)
+++ azax/branches/plugin/demos/azaxdemo/browser/azax_three_autoupdate.kukit     
Wed Apr 19 22:26:59 2006
@@ -1,9 +1,15 @@
 <?xml version="1.0"?>
 <rules>
   <rule selector="div#update-area">
-    <kukitevent name="timeout">getCurrentTime 2000</kukitevent>
+    <!--kukitevent name="timeout">getCurrentTime 2000</kukitevent-->
+    <event type="timeout" millis="2000">
+               <action type="remote">getCurrentTime</action>
+       </event>
   </rule>
   <rule selector="input#start-update">
-    <event name="click">getAutoupdateMarkup</event>
+    <!--event name="click">getAutoupdateMarkup</event-->
+    <event type="generic" name="click">
+               <action type="remote">getAutoupdateMarkup</action>
+       </event>
   </rule>
 </rules>

Modified: azax/branches/plugin/demos/azaxdemo/browser/cancel_submit.kukit
==============================================================================
--- azax/branches/plugin/demos/azaxdemo/browser/cancel_submit.kukit     
(original)
+++ azax/branches/plugin/demos/azaxdemo/browser/cancel_submit.kukit     Wed Apr 
19 22:26:59 2006
@@ -1,6 +1,9 @@
 <?xml version="1.0"?>
 <rules>
   <rule selector="input#submit">
-    <kukitevent name="cancelSubmitClick">save</kukitevent>
+    <!--kukitevent name="cancelSubmitClick">save</kukitevent-->
+    <event type="cancelSubmitClick">
+               <action type="remote">save</action>
+       </event>
   </rule>
 </rules>

Modified: azax/branches/plugin/plugins/__init__.py
==============================================================================
--- azax/branches/plugin/plugins/__init__.py    (original)
+++ azax/branches/plugin/plugins/__init__.py    Wed Apr 19 22:26:59 2006
@@ -5,3 +5,5 @@
 from registry import AzaxPluginError
 from plugin import registerPlugin
 from command import Command
+from event_type import EventType
+from event_action import EventAction

Modified: azax/branches/plugin/plugins/configure.py
==============================================================================
--- azax/branches/plugin/plugins/configure.py   (original)
+++ azax/branches/plugin/plugins/configure.py   Wed Apr 19 22:26:59 2006
@@ -1,6 +1,8 @@
 
 import os.path
 from command import Command
+from event_type import EventType
+from event_action import EventAction
 from plugin import registerPlugin
 
 #class AzaxConfigurationError(Exception):
@@ -18,3 +20,29 @@
         callable = registerPlugin,
         args = (Command, name, jsfile),
         )
+
+def registerEventType(_context, name, jsfile=None):
+    'Directive that registers an event type' 
+    
+    # check to see if the file exists
+    if jsfile is not None:
+        file(jsfile, 'rb').close()
+
+    _context.action(
+        discriminator = ('registerAzaxEventType', name, jsfile),
+        callable = registerPlugin,
+        args = (EventType, name, jsfile),
+        )
+ 
+def registerEventAction(_context, name, jsfile=None):
+    'Directive that registers an event action' 
+    
+    # check to see if the file exists
+    if jsfile is not None:
+        file(jsfile, 'rb').close()
+
+    _context.action(
+        discriminator = ('registerAzaxEventAction', name, jsfile),
+        callable = registerPlugin,
+        args = (EventAction, name, jsfile),
+        )

Modified: azax/branches/plugin/plugins/configure.zcml
==============================================================================
--- azax/branches/plugin/plugins/configure.zcml (original)
+++ azax/branches/plugin/plugins/configure.zcml Wed Apr 19 22:26:59 2006
@@ -14,6 +14,16 @@
           name="myCustomCommand"
           jsfile="browser/my_plugins.js"
           />
+          
+      <azax:registerEventType
+          name="myCustomEventType"
+          jsfile="browser/my_plugins.js"
+          />
+  
+      <azax:registerEventAction
+          name="myCustomEventAction"
+          jsfile="browser/my_plugins.js"
+          />
   
      -->
 
@@ -65,4 +75,22 @@
           name="executeCode"
           />
           
+     <!-- Event types and actions -->
+
+    <azax:registerEventType
+        name="generic"
+        />
+          
+    <azax:registerEventType
+        name="timeout"
+        />
+
+    <azax:registerEventType
+        name="cancelSubmitClick"
+        />
+        
+    <azax:registerEventAction
+        name="remote"
+        />
+
 </configure>

Modified: azax/branches/plugin/plugins/directives.py
==============================================================================
--- azax/branches/plugin/plugins/directives.py  (original)
+++ azax/branches/plugin/plugins/directives.py  Wed Apr 19 22:26:59 2006
@@ -16,3 +16,33 @@
          description=u"The path of the javascript file that defines the 
plugin",
          required=False,
          )
+    
+class IRegisterEventTypeDirective(Interface):
+    'Register an AZAX event type'
+    
+    name = TextLine(
+         title=u"Name",
+         description=u"The name of the event type plugin.",
+         required=True,
+         )
+    
+    jsfile = Path(
+         title=u"Javascript file",
+         description=u"The path of the javascript file that defines the 
plugin",
+         required=False,
+         )
+    
+class IRegisterEventActionDirective(Interface):
+    'Register an AZAX event action'
+    
+    name = TextLine(
+         title=u"Name",
+         description=u"The name of the event action plugin.",
+         required=True,
+         )
+    
+    jsfile = Path(
+         title=u"Javascript file",
+         description=u"The path of the javascript file that defines the 
plugin",
+         required=False,
+         )

Added: azax/branches/plugin/plugins/event_action.py
==============================================================================
--- (empty file)
+++ azax/branches/plugin/plugins/event_action.py        Wed Apr 19 22:26:59 2006
@@ -0,0 +1,13 @@
+
+from plugin import Plugin
+
+class EventAction(Plugin):
+    '''The event action plugin
+
+    '''
+
+    plugintype = 'event_action'
+
+    def __init__(self, name, jsfile):
+        Plugin.__init__(self, name, jsfile)
+

Added: azax/branches/plugin/plugins/event_type.py
==============================================================================
--- (empty file)
+++ azax/branches/plugin/plugins/event_type.py  Wed Apr 19 22:26:59 2006
@@ -0,0 +1,13 @@
+
+from plugin import Plugin
+
+class EventType(Plugin):
+    '''The event type plugin
+
+    '''
+
+    plugintype = 'event_type'
+
+    def __init__(self, name, jsfile):
+        Plugin.__init__(self, name, jsfile)
+

Modified: azax/branches/plugin/plugins/meta.zcml
==============================================================================
--- azax/branches/plugin/plugins/meta.zcml      (original)
+++ azax/branches/plugin/plugins/meta.zcml      Wed Apr 19 22:26:59 2006
@@ -5,11 +5,25 @@
    <include package=".concatresource" file="meta.zcml"/>
 
    <directives namespace="http://namespaces.zope.org/azax";>
+   
      <directive
        name="registerCommand"
        schema=".directives.IRegisterCommandDirective"
        handler=".configure.registerCommand"
        />
+       
+     <directive
+       name="registerEventType"
+       schema=".directives.IRegisterEventTypeDirective"
+       handler=".configure.registerEventType"
+       />
+   
+     <directive
+       name="registerEventAction"
+       schema=".directives.IRegisterEventActionDirective"
+       handler=".configure.registerEventAction"
+       />
+
    </directives>
-  
+
 </configure>

Modified: azax/branches/plugin/tests/test_azaxview.py
==============================================================================
--- azax/branches/plugin/tests/test_azaxview.py (original)
+++ azax/branches/plugin/tests/test_azaxview.py Wed Apr 19 22:26:59 2006
@@ -109,7 +109,7 @@
     # XXX since lxml is gone, the next cases are no problem anymore
     # Nevertheless, we test all these cases
     
-    def _checkSetHtmlResult(self, content):
+    def _checkSetHtmlResult(self, content, content2=None):
         view = self.view
         view.setHtmlAsChild('div.class', content)
         commands = view.getCommands()
@@ -120,15 +120,21 @@
         params = command.getParams()
         self.assertEqual(len(params), 1)
         self.assertEqual(params[0].getName(), 'html')
-        self.assertEqual(params[0].getContent(), content)
+        if content2 == None:
+            content2 = content
+        self.assertEqual(params[0].getContent(), content2)
 
     def test_setHtmlAsChildTextPlusEntity(self):
         'See if non breaking space entity works'
-        self._checkSetHtmlResult('&nbsp;')
+        ##self._checkSetHtmlResult('&nbsp;')
+        # XXX we remove html named entities now
+        self._checkSetHtmlResult('&nbsp;', '&#160;')
         
     def test_setHtmlAsChildTextPlusEntityOthers(self):
         'See if the other HTML entities work as well'
-        self._checkSetHtmlResult('<p 
xmlns="http://www.w3.org/1999/xhtml";>&raquo;Hello world!&laquo;</p>')
+        # XXX we remove html named entities now
+        self._checkSetHtmlResult('<p 
xmlns="http://www.w3.org/1999/xhtml";>&raquo;Hello world!&laquo;</p>',
+                   '<p xmlns="http://www.w3.org/1999/xhtml";>&#187;Hello 
world!&#171;</p>')
 
     def test_setHtmlAsChildTextOnly(self):
         self._checkSetHtmlResult('new content')
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to