Author: jvloothuis
Date: Sun Dec 30 18:25:17 2007
New Revision: 50210
Added:
kukit/kss.zope/trunk/kss/zope/siteview.txt
- copied unchanged from r49568, kukit/kss.zope/trunk/kss/core/siteview.txt
kukit/kss.zope/trunk/kss/zope/tests/help_ttwapi.py
- copied unchanged from r50185,
kukit/kss.zope/trunk/kss/core/tests/help_ttwapi.py
kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py
- copied, changed from r49568,
kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py
kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py
- copied, changed from r50185,
kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py
kukit/kss.zope/trunk/kss/zope/ttwapi.py
- copied, changed from r50185, kukit/kss.zope/trunk/kss/core/ttwapi.py
Removed:
kukit/kss.zope/trunk/kss/core/siteview.txt
kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py
Modified:
kukit/kss.zope/trunk/kss/core/ttwapi.py
kukit/kss.zope/trunk/kss/zope/__init__.py
kukit/kss.zope/trunk/kss/zope/commands.py
kukit/kss.zope/trunk/kss/zope/view.txt
Log:
Added ttwapi to kss.zope
Fixed the BBB stuff for commands
Deleted: /kukit/kss.zope/trunk/kss/core/siteview.txt
==============================================================================
--- /kukit/kss.zope/trunk/kss/core/siteview.txt Sun Dec 30 18:25:17 2007
+++ (empty file)
@@ -1,117 +0,0 @@
-=========
-Site view
-=========
-
-All KSS views are not only a browser view but provide a site manager
-as well. The site manager is hooked into the component framework on
-traversal time. This allows the KSS views to dispatch incomming
-object events to (object, view, event) so that KSS-view-specific event
-handlers can add to the view's commands.
-
-This behaviour is needed for making event driven changes to a page.
-For instance when you change a title in a document you also want the
-menu reloaded. By using events for this we can achieve a degree of
-decoupling.
-
-The main class which implements views with a site manager is ``SiteView``:
-
- >>> from kss.core.kssview import SiteView
-
- >>> from zope import component
- >>> old_sitemanager = component.getSiteManager()
-
- >>> from zope.publisher.browser import TestRequest
- >>> class TestObject:
- ... pass
- >>> obj = TestObject()
- >>> request = TestRequest()
- >>> view = SiteView(obj, request)
-
-Let's register a handler for an object modified event event and
-SiteView views:
-
- >>> from zope.lifecycleevent import ObjectModifiedEvent
- >>> event = ObjectModifiedEvent(obj)
-
- >>> @component.adapter(TestObject, SiteView, ObjectModifiedEvent)
- ... def catchTestObjectEvent(event_obj, event_view, event_event):
- ... print "Special event handler was invoked, dispatch is working."
- ... print "Object is the original one:", event_obj is obj
- ... print "View is the original one:", event_view is view
- ... print "Event is the original one:", event_event is event
- ...
- >>> component.provideHandler(catchTestObjectEvent)
-
-Without the SiteView view being activated as a site, it won't dispatch
-to the handler:
-
- >>> from zope.event import notify
- >>> notify(ObjectModifiedEvent(obj))
-
-Now we make the view the current site. We'll see that its site
-manager has become the current component registry:
-
- >>> from zope.app.component.hooks import setSite
- >>> setSite(view)
-
- >>> old_sitemanager is component.getSiteManager()
- False
- >>> view.getSiteManager() is component.getSiteManager()
- True
-
-The view also immediately registers its special event handler. Like
-mentioned earlier this will dispatch to (obj, view, event) handlers,
-including the one we defined above. So let's send that object
-modified event again. We expect our site view event handler will be
-invoked with the original object, view and event:
-
- >>> notify(ObjectModifiedEvent(obj))
- Special event handler was invoked, dispatch is working.
- Object is the original one: True
- View is the original one: True
- Event is the original one: False
-
-Below a site
-------------
-
-Let's say SiteView is operating below a persistent site, e.g. the root
-folder or a CMF site:
-
- >>> from zope.app.folder import Folder
- >>> from zope.app.component.interfaces import ISite
- >>> from zope.interface import alsoProvides
- >>> from zope.component.globalregistry import base
- >>> from zope.component.persistentregistry import PersistentComponents
-
- >>> site = Folder()
- >>> components = PersistentComponents()
- >>> components.__bases__ = (base,)
- >>> site.setSiteManager(components)
- >>> alsoProvides(site, ISite)
-
- >>> setSite(site)
-
-Let's also register a site view event subscriber *globally* and one
-*locally*
-
- >>> @component.adapter(ISite, SiteView, ObjectModifiedEvent)
- ... def catchSiteEventGlobally(event_obj, event_view, event_event):
- ... print "Global event handler was invoked, dispatch is working."
- ...
- >>> component.provideHandler(catchSiteEventGlobally)
-
- >>> @component.adapter(ISite, SiteView, ObjectModifiedEvent)
- ... def catchSiteEventLocally(event_obj, event_view, event_event):
- ... print "Local event handler was invoked, dispatch is working."
- ...
- >>> components.registerHandler(catchSiteEventLocally)
-
-Let's now verify the SiteView still works and dispatches component
-lookup accordingly.
-
- >>> view = SiteView(site, request)
- >>> setSite(view)
-
- >>> notify(ObjectModifiedEvent(site))
- Global event handler was invoked, dispatch is working.
- Local event handler was invoked, dispatch is working.
Deleted: /kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py
==============================================================================
--- /kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py Sun Dec 30
18:25:17 2007
+++ (empty file)
@@ -1,164 +0,0 @@
-# -*- coding: latin-1 -*-
-# Copyright (c) 2005-2007
-# Authors: KSS Project Contributors (see docs/CREDITS.txt)
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-import unittest
-import textwrap
-from kss.core import KSSUnicodeError
-from kss.core.tests.base import KSSViewTestCase
-from Testing.ZopeTestCase import FunctionalDocFileSuite
-
-class TestKSSViewCoreCommandSet(KSSViewTestCase):
-
- def test_empty(self):
- view = self.createView()
- commands = view.getCommands()
- self.assertEqual(len(commands), 0)
-
- def test_addCommand(self):
- view = self.createView()
- commands = view.getCommands()
- command = commands.addCommand('replaceInnerHTML', 'selector')
- self.assertEqual(len(commands), 1)
- self.assertEqual(command.getName(), 'replaceInnerHTML')
- self.assertEqual(command.getSelector(), 'selector')
- params = command.getParams()
- self.assertEqual(len(params), 0)
-
- # XXX since lxml is gone, the next cases are no problem anymore
- # Nevertheless, we test all these cases
-
- def _checkSetHtmlResult(self, content, content2=None):
- view = self.createView()
- view.getCommandSet('core').replaceInnerHTML('div.class', content)
- commands = view.getCommands()
- self.assertEqual(len(commands), 1)
- command = commands[0]
- self.assertEqual(command.getName(), 'replaceInnerHTML')
- self.assertEqual(command.getSelector(), 'div.class')
- params = command.getParams()
- self.assertEqual(len(params), 2)
- self.assertEqual(params[0].getName(), 'html')
- self.assertEqual(params[1].getName(), 'withKssSetup')
- if content2 == None:
- content2 = content
- content2 = content2.encode('ascii', 'xmlcharrefreplace')
- # wrap content into CDATA
- content2 = '<![CDATA[%s]]>' % (content2, )
- # and finally check it
- self.assertEqual(params[0].getContent().encode('ascii',
'xmlcharrefreplace'), content2)
-
- def test_replaceInnerHTMLTextPlusEntity(self):
- 'See if non breaking space entity works'
- ##self._checkSetHtmlResult(' ')
- # XXX we remove html named entities now
- self._checkSetHtmlResult(' ', ' ')
-
- def test_replaceInnerHTMLTextPlusEntityOthers(self):
- 'See if the other HTML entities work as well'
- # XXX we remove html named entities now
- self._checkSetHtmlResult('<p
xmlns="http://www.w3.org/1999/xhtml">»Hello world!«</p>',
- '<p xmlns="http://www.w3.org/1999/xhtml">»Hello
world!«</p>')
-
- def test_replaceInnerHTMLTextOnly(self):
- self._checkSetHtmlResult('new content')
-
- def test_replaceInnerHTMLTagOnly(self):
- self._checkSetHtmlResult('<p
xmlns="http://www.w3.org/1999/xhtml">new_content</p>')
-
- def test_replaceInnerHTMLTagPlusText(self):
- self._checkSetHtmlResult('<p
xmlns="http://www.w3.org/1999/xhtml">new_content</p>after')
-
- def test_replaceInnerHTMLTextTagPlusText(self):
- self._checkSetHtmlResult('before<p
xmlns="http://www.w3.org/1999/xhtml">new_content</p>after')
-
- def test_setHtmlAcceptsUnicode(self):
- 'Test that it accepts unicode'
- self._checkSetHtmlResult(u'abc�')
-
- def test_setHtmlChecksForNonUnicode(self):
- 'Test that it does not accept non unicode (unless pure ascii)'
- self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc�')
-
-class FTestKSSViewCoreCommandSet(KSSViewTestCase):
- 'Functional tests'
-
- def _wrapped_commands(self, inline):
- header = textwrap.dedent(u'''\
- <?xml version="1.0" ?>
- <kukit xmlns="http://www.kukit.org/commands/1.0">
- <commands>
- ''')
- footer = textwrap.dedent('''\
- </commands>
- </kukit>
- ''')
- return header + inline + footer
-
- def assertXMLEquals(self, a, b):
- self.assertEqual(a, b)
-
- def assertCommandsEqual(self, a, b):
- self.assertXMLEquals(a, self._wrapped_commands(b))
-
- def test_empty(self):
- view = self.createView()
- result = view.render()
- self.assertEquals(view.request.response.getHeader('content-type'),
'text/xml;charset=utf-8')
- self.assertCommandsEqual(result, '')
-
- def test_replaceInnerHTML(self):
- view = self.createView()
- view.getCommandSet('core').replaceInnerHTML('div.class', 'new content')
- result = view.render()
- awaited = u'''\
-<command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <param name="html"><![CDATA[new content]]></param>
- <param name="withKssSetup">True</param>
-</command>
-'''
- self.assertCommandsEqual(result, awaited)
-
- def test_setCommandSet(self):
- view = self.createView()
- cs = view.getCommandSet('core')
- cs.replaceInnerHTML('div.class', 'new content')
- result = view.render()
- awaited = u'''\
-<command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <param name="html"><![CDATA[new content]]></param>
- <param name="withKssSetup">True</param>
-</command>
-'''
- self.assertCommandsEqual(result, awaited)
-
-def afterSetUp(self):
- KSSViewTestCase.afterSetUp(self)
- self.setDebugRequest()
-
-
-def test_suite():
- suites = []
- suites.append(unittest.makeSuite(TestKSSViewCoreCommandSet))
- suites.append(unittest.makeSuite(FTestKSSViewCoreCommandSet))
- suites.append(FunctionalDocFileSuite('../actionwrapper.py',
- test_class=KSSViewTestCase,
- setUp=afterSetUp,
-
tearDown=KSSViewTestCase.beforeTearDown.im_func))
- return unittest.TestSuite(suites)
Modified: kukit/kss.zope/trunk/kss/core/ttwapi.py
==============================================================================
--- kukit/kss.zope/trunk/kss/core/ttwapi.py (original)
+++ kukit/kss.zope/trunk/kss/core/ttwapi.py Sun Dec 30 18:25:17 2007
@@ -1,36 +1,9 @@
-from zope.app.component.hooks import getSite, setSite
-from zope import event
-from zope.app.publication.zopepublication import BeforeTraverseEvent
-
from kss.core import KSSView
from kss.core.interfaces import IKSSView
from kss.core.unicode_quirks import force_unicode
-def startKSSCommands(context, request):
- view = KSSView(context, request)
- # Alec suggested we should fire the BeforeTraverseEvent, but after
- # debugging for a while I stopped caring about the event and think
- # that setSite() is the only thing we're interested in.
- setSite(view)
- return view
-
-def getKSSCommandSet(name):
- view = retrieveView()
- cs = view.getCommandSet(name)
- return cs
-
-def renderKSSCommands():
- view = retrieveView()
- return view.render()
-
-def retrieveView():
- #because the view registers itself as a site,
- #we can retrieve it...
- site = getSite()
- if not IKSSView.providedBy(site):
- raise LookupError(
- "You haven't initialized the KSS response yet, "
- "do so by calling startKSSCommands(context, request).")
- return site
-
+from kss.zope.ttwapi import startKSSCommands
+from kss.zope.ttwapi import getKSSCommandSet
+from kss.zope.ttwapi import renderKSSCommands
+from kss.zope.ttwapi import retrieveView
Modified: kukit/kss.zope/trunk/kss/zope/__init__.py
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/__init__.py (original)
+++ kukit/kss.zope/trunk/kss/zope/__init__.py Sun Dec 30 18:25:17 2007
@@ -1,3 +1,10 @@
#
from kss.zope.view import KSSView
from kss.zope.actionwrapper import KSSExplicitError, kssaction
+
+try:
+ from AccessControl import allow_module
+except ImportError:
+ pass # Not on Zope 2
+else:
+ allow_module('kss.zope.ttwapi')
Modified: kukit/kss.zope/trunk/kss/zope/commands.py
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/commands.py (original)
+++ kukit/kss.zope/trunk/kss/zope/commands.py Sun Dec 30 18:25:17 2007
@@ -3,7 +3,6 @@
from interfaces import IKSSPluginRegistry, IZopeCommandSet
from bbb.commandset import CompatCommandSet
# BBB
-from kss.base.selectors import Selector, css
#from bbb.deprecated import deprecated
#when = 'after 2008-08-01'
@@ -29,17 +28,55 @@
## Don't BBB yet. Uncommenting the next line will activate BBB.
[EMAIL PROTECTED]('use view.commands.add(action, selector **kw)', when)
- def addCommand(self, command_name, selector=None, **kw):
- self._strip_none_parameters(kw)
-
- if selector is not None and not isinstance(selector, Selector):
- selector = css(selector)
-
- self.commands.append(CompatCommand((command_name, selector, kw)))
+ def addCommand(self, command_name, selector=None):
+ cmd = CompatCommand(command_name, selector)
+ self.commands.append(cmd)
+ return cmd
+
+ def __len__(self):
+ # BBB: Used from some tests
+ return len(self.commands)
+
+ def __getitem__(self, index):
+ # BBB: Used from some tests
+ action, selector, options = self.commands[index]
+ cmd = CompatCommand(action, selector)
+ for key, value in options.items():
+ cmd.addParam(key, value)
+ return cmd
# Nasty BBB for covering this old usage:
# command = self.addCommand('command_name', 'selector')
# command.addParam('key', 'value')
-class CompatCommand(tuple):
+class CompatCommand(object):
+ def __init__(self, action, selector):
+ self.action = action
+ self.selector = selector
+ self.options = []
+
+ def __iter__(self):
+ return (self.action, self.selector, dict(self.options)).__iter__()
+
def addParam(self, key, value):
- self[2][key] = value
+ self.options.append(Param(key, value))
+
+ def getName(self):
+ return self.action
+
+ def getSelector(self):
+ return self.selector
+
+ def getParams(self):
+ return self.options
+
+
+class Param(object):
+ def __init__(self, name, value):
+ self.name = name
+ self.value = value
+
+ def getName(self):
+ return self.name
+
+ def getContent(self):
+ return self.value
Copied: kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py (from r49568,
kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py)
==============================================================================
--- kukit/kss.zope/trunk/kss/core/tests/test_kssview_core.py (original)
+++ kukit/kss.zope/trunk/kss/zope/tests/test_kssview_core.py Sun Dec 30
18:25:17 2007
@@ -18,11 +18,29 @@
import unittest
import textwrap
+from zope.testing import cleanup
+from zope.app.component.hooks import setHooks
+from zope import component
+from zope.publisher.browser import TestRequest
+from zope.publisher.http import HTTPResponse
+
+from kss.zope.interfaces import IKSSPluginRegistry
+from kss.zope.registry import GlobalPluginRegistry
+from kss.zope.view import KSSView
from kss.core import KSSUnicodeError
-from kss.core.tests.base import KSSViewTestCase
-from Testing.ZopeTestCase import FunctionalDocFileSuite
-class TestKSSViewCoreCommandSet(KSSViewTestCase):
+class KSSTestCase(unittest.TestCase):
+ def setUp(self):
+ cleanup.CleanUp().setUp()
+ setHooks()
+ component.provideUtility(GlobalPluginRegistry(), IKSSPluginRegistry)
+
+
+ def createView(self):
+ request = TestRequest(response=HTTPResponse())
+ return KSSView(None, request)
+
+class TestKSSViewCoreCommandSet(KSSTestCase):
def test_empty(self):
view = self.createView()
@@ -51,16 +69,8 @@
self.assertEqual(command.getName(), 'replaceInnerHTML')
self.assertEqual(command.getSelector(), 'div.class')
params = command.getParams()
- self.assertEqual(len(params), 2)
+ self.assertEqual(len(params), 1)
self.assertEqual(params[0].getName(), 'html')
- self.assertEqual(params[1].getName(), 'withKssSetup')
- if content2 == None:
- content2 = content
- content2 = content2.encode('ascii', 'xmlcharrefreplace')
- # wrap content into CDATA
- content2 = '<![CDATA[%s]]>' % (content2, )
- # and finally check it
- self.assertEqual(params[0].getContent().encode('ascii',
'xmlcharrefreplace'), content2)
def test_replaceInnerHTMLTextPlusEntity(self):
'See if non breaking space entity works'
@@ -89,24 +99,23 @@
def test_setHtmlAcceptsUnicode(self):
'Test that it accepts unicode'
self._checkSetHtmlResult(u'abc�')
-
- def test_setHtmlChecksForNonUnicode(self):
- 'Test that it does not accept non unicode (unless pure ascii)'
- self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc�')
-class FTestKSSViewCoreCommandSet(KSSViewTestCase):
+# FIXME! Figure our what to do with this since there is nothing like
+# this in kss.base
+# def test_setHtmlChecksForNonUnicode(self):
+# 'Test that it does not accept non unicode (unless pure ascii)'
+# self.assertRaises(KSSUnicodeError, self._checkSetHtmlResult, 'abc�')
+
+
+class FTestKSSViewCoreCommandSet(KSSTestCase):
'Functional tests'
def _wrapped_commands(self, inline):
header = textwrap.dedent(u'''\
<?xml version="1.0" ?>
- <kukit xmlns="http://www.kukit.org/commands/1.0">
- <commands>
- ''')
- footer = textwrap.dedent('''\
- </commands>
- </kukit>
+ <kukit xmlns="http://www.kukit.org/commands/1.0"><commands>
''')
+ footer = '</commands></kukit>'
return header + inline + footer
def assertXMLEquals(self, a, b):
@@ -125,13 +134,7 @@
view = self.createView()
view.getCommandSet('core').replaceInnerHTML('div.class', 'new content')
result = view.render()
- awaited = u'''\
-<command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <param name="html"><![CDATA[new content]]></param>
- <param name="withKssSetup">True</param>
-</command>
-'''
+ awaited = u'''<command selector="div.class" name="replaceInnerHTML"
selectorType=""><param name="html"><![CDATA[new content]]></param></command>'''
self.assertCommandsEqual(result, awaited)
def test_setCommandSet(self):
@@ -139,13 +142,7 @@
cs = view.getCommandSet('core')
cs.replaceInnerHTML('div.class', 'new content')
result = view.render()
- awaited = u'''\
-<command selector="div.class" name="replaceInnerHTML"
- selectorType="">
- <param name="html"><![CDATA[new content]]></param>
- <param name="withKssSetup">True</param>
-</command>
-'''
+ awaited = u'''<command selector="div.class" name="replaceInnerHTML"
selectorType=""><param name="html"><![CDATA[new content]]></param></command>'''
self.assertCommandsEqual(result, awaited)
def afterSetUp(self):
@@ -157,8 +154,4 @@
suites = []
suites.append(unittest.makeSuite(TestKSSViewCoreCommandSet))
suites.append(unittest.makeSuite(FTestKSSViewCoreCommandSet))
- suites.append(FunctionalDocFileSuite('../actionwrapper.py',
- test_class=KSSViewTestCase,
- setUp=afterSetUp,
-
tearDown=KSSViewTestCase.beforeTearDown.im_func))
return unittest.TestSuite(suites)
Copied: kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py (from r50185,
kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py)
==============================================================================
--- kukit/kss.zope/trunk/kss/core/tests/test_ttwapi.py (original)
+++ kukit/kss.zope/trunk/kss/zope/tests/test_ttwapi.py Sun Dec 30 18:25:17 2007
@@ -4,7 +4,7 @@
ZopeTestCase.installProduct('PythonScripts')
from AccessControl import allow_module
-allow_module('kss.core.tests.help_ttwapi')
+allow_module('kss.zope.tests.help_ttwapi')
import Products.Five.component
from Products.Five import zcml
@@ -13,8 +13,8 @@
from zope.lifecycleevent import ObjectModifiedEvent
from zope.app.component.hooks import setHooks
-from kss.core import KSSView
-from kss.core.tests.base import KSSViewTestCase
+from kss.zope import KSSView
+from kss.zope.tests.base import KSSViewTestCase
class TTWTestCase(KSSViewTestCase):
@@ -25,7 +25,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
- package="kss.core.tests.test_ttwapi">
+ package="kss.zope.tests.test_ttwapi">
<subscriber handler=".objectModifiedThruKSSView" />
</configure>'''
zcml.load_string(configure_zcml)
@@ -39,45 +39,26 @@
def test_scriptWithCore(self):
pythonScriptCode = '''
-from kss.core.ttwapi import startKSSCommands
-from kss.core.ttwapi import getKSSCommandSet
-from kss.core.ttwapi import renderKSSCommands
+from kss.zope.ttwapi import startKSSCommands
+from kss.zope.ttwapi import getKSSCommandSet
+from kss.zope.ttwapi import renderKSSCommands
startKSSCommands(context, context.REQUEST)
core = getKSSCommandSet('core')
core.replaceInnerHTML('#test', '<p>Done</p>')
return renderKSSCommands()
'''
self.app.kss_test.ZPythonScript_edit('', pythonScriptCode)
- result = self.app.kss_test()
- self.assertEquals(len(result), 1)
- command = result[0]
- self.assertEquals(command['selector'], '#test')
- self.assertEquals(command['name'], 'replaceInnerHTML')
-
- def test_scriptWithEffect(self):
- pythonScriptCode = '''
-from kss.core.ttwapi import startKSSCommands
-from kss.core.ttwapi import getKSSCommandSet
-from kss.core.ttwapi import renderKSSCommands
-startKSSCommands(context, context.REQUEST)
-commandSet = getKSSCommandSet('effects')
-commandSet.effect('#test', 'fade')
-return renderKSSCommands()
-'''
- self.app.kss_test.ZPythonScript_edit('', pythonScriptCode)
- result = self.app.kss_test()
- self.assertEquals(len(result), 1)
- command = result[0]
- self.assertEquals(command['selector'], '#test')
- self.assertEquals(command['name'], 'effect')
- self.assertEquals(command['params']['type'], 'fade')
+ result = self.app.kss_test()
+ self.assertEquals(
+ str(result),
+ "replaceInnerHTML('#test', html=htmldata('<p>Done</p>'))")
def test_scriptWithEvents(self):
pythonScriptCode = '''
-from kss.core.ttwapi import startKSSCommands
-from kss.core.ttwapi import getKSSCommandSet
-from kss.core.ttwapi import renderKSSCommands
-from kss.core.tests.help_ttwapi import objectModified
+from kss.zope.ttwapi import startKSSCommands
+from kss.zope.ttwapi import getKSSCommandSet
+from kss.zope.ttwapi import renderKSSCommands
+from kss.zope.tests.help_ttwapi import objectModified
startKSSCommands(context, context.REQUEST)
core = getKSSCommandSet('core')
core.replaceInnerHTML('#test', '<p>Done</p>')
@@ -86,13 +67,10 @@
'''
self.app.kss_test.ZPythonScript_edit('', pythonScriptCode)
result = self.app.kss_test()
- self.assertEquals(len(result), 2)
- command = result[0]
- self.assertEquals(command['selector'], '#test')
- self.assertEquals(command['name'], 'replaceInnerHTML')
- command = result[1]
- self.assertEquals(command['selector'], '#event')
- self.assertEquals(command['name'], 'replaceInnerHTML')
+ self.assertEquals(
+ str(result).split('\n'),
+ ["replaceInnerHTML('#test', html=htmldata('<p>Done</p>'))",
+ "replaceInnerHTML('#event', html=htmldata('Event subscriber was
here.'))"])
@component.adapter(None, KSSView, ObjectModifiedEvent)
def objectModifiedThruKSSView(obj, view, event):
Copied: kukit/kss.zope/trunk/kss/zope/ttwapi.py (from r50185,
kukit/kss.zope/trunk/kss/core/ttwapi.py)
==============================================================================
--- kukit/kss.zope/trunk/kss/core/ttwapi.py (original)
+++ kukit/kss.zope/trunk/kss/zope/ttwapi.py Sun Dec 30 18:25:17 2007
@@ -1,10 +1,8 @@
from zope.app.component.hooks import getSite, setSite
-from zope import event
-from zope.app.publication.zopepublication import BeforeTraverseEvent
+from AccessControl import allow_class
-from kss.core import KSSView
-from kss.core.interfaces import IKSSView
-from kss.core.unicode_quirks import force_unicode
+from kss.zope import KSSView
+from kss.zope.interfaces import IKSSView
def startKSSCommands(context, request):
view = KSSView(context, request)
@@ -17,6 +15,7 @@
def getKSSCommandSet(name):
view = retrieveView()
cs = view.getCommandSet(name)
+ allow_class(cs.__class__)
return cs
def renderKSSCommands():
Modified: kukit/kss.zope/trunk/kss/zope/view.txt
==============================================================================
--- kukit/kss.zope/trunk/kss/zope/view.txt (original)
+++ kukit/kss.zope/trunk/kss/zope/view.txt Sun Dec 30 18:25:17 2007
@@ -66,5 +66,8 @@
>>> xml_output = view.setTitle(u"some title")
>>> print view.commands
- replaceInnerHTML(css('div.class'), html='some title')
+ replaceInnerHTML('div.class', html=htmldata('some title'))
+
+
+
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins