Author: jvloothuis
Date: Thu Mar 13 20:17:59 2008
New Revision: 52455

Removed:
   kukit/kss.core/branch/kss.core-on-kss.zope/src/kss/core/commands.py
Log:

The compatability code for this has been implemented in kss.zope


Deleted: /kukit/kss.core/branch/kss.core-on-kss.zope/src/kss/core/commands.py
==============================================================================
--- /kukit/kss.core/branch/kss.core-on-kss.zope/src/kss/core/commands.py        
Thu Mar 13 20:17:59 2008
+++ (empty file)
@@ -1,157 +0,0 @@
-from kss.zope.commands import KSSZopeCommands as KSSCommands
-
-# Old cruft
-from zope.interface import implements
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from interfaces import IKSSCommands, IKSSCommand, IKSSParam, IKSSCommandView
-from unicode_quirks import force_unicode
-import zope.component
-from parsers import XmlParser, HtmlParser
-##from pluginregistry import checkRegisteredSelector
-from pluginregistry import checkRegisteredSelector
-
-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):
-        # we expect this is not registered as command, anyway
-        # so check it as an action.
-## XXX command checking temporarily disabled
-## XXX TODO needs to work from new registry.
-##        checkRegisteredCommand(command_name)
-        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 = '<![CDATA[%s]]>' % (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
-
-class CommandView(object):
-    '''View of a command.
-    
-    The render method does actual marshalling
-    of the commands to be sent to the client.
-    '''
-    implements(IKSSCommandView)
-
-    def __init__(self, context, request):
-        self.context = context
-        self.request = request
-        # XXX From Zope2.9 we need this.
-        # Note: We don't use proper views for Five. As our context object
-        # is not even a proper Zope content. There would be a way to:
-        #
-        # - use ZopeTwoPageTemplateFile
-        # - and, make the object to be proper zope content.
-        #
-        # This would be two much ado for nothing, so we just use barefoot
-        # rendering but as a consequence no path expression, only python:
-        # is available from the page template.
-        if not hasattr(self.request, 'debug'):
-            self.request.debug = None
-
-        # Force parameters content to be unicode
-        for command in context:
-            for param in command.getParams():
-                param.force_content_unicode()
-    
-    # XML output gets rendered via a page template
-    # XXX note: barefoot rendering, use python: only after zope2.9
-    # XXX we must have the content type set both here and below
-    _render = ViewPageTemplateFile('browser/kukitresponse.pt', 
content_type='text/xml;charset=utf-8')
-
-    def render(self):
-        result = self._render()
-        # Always output text/xml to make sure browsers but the data in the
-        # responseXML instead of responseText attribute of the
-        # XMLHttpRequestobject.
-        self.request.response.setHeader('Content-type', 
'text/xml;charset=utf-8')
-        return result
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to