Changeset 219
- Timestamp:
- 07/17/02 17:37:03 (6 years ago)
- Files:
-
- trunk/RBFoundation/RBFoundation/XMLClassBuilder.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/Client.py (modified) (2 diffs)
- trunk/RBJabber/RBJabber/JabberConnection.py (modified) (5 diffs)
- trunk/RBSkinning/RBSkinning/XMLSkinner.py (modified) (3 diffs)
- trunk/RBSkinning/RBSkinning/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBFoundation/RBFoundation/XMLClassBuilder.py
r214 r219 124 124 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 125 125 126 class XMLClassBuilderMixin(XMLBuilder.XMLBuilder ):126 class XMLClassBuilderMixin(XMLBuilder.XMLBuilderMixin): 127 127 """Mixin that forms the python import indirectly from a dictionary lookup of the namespace, 128 128 and then combines the result with the node name.""" … … 182 182 return FactoryFactory(owner, parent, node, attributes, namespacemap) 183 183 184 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 186 class XMLClassBuilder(XMLClassBuilderMixin, XMLBuilder.XMLBuilder): 187 pass trunk/RBJabber/RBJabber/Client.py
r192 r219 52 52 from Foundation.Jabber.JabberConnection import JabberConnection 53 53 from Foundation import SubjectObserver 54 from Foundation.XMLClassBuilder import ElementFactory as EF 54 55 55 56 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 62 63 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 63 64 64 JabberNodeMap = { 65 ElementFactories = JabberConnection.ElementFactories.copy() 66 ElementFactories.update({ 65 67 # http://etherx.jabber.org/streams nodes 66 ('http://etherx.jabber.org/streams', 'stream'): ClientNodes.JabberStream,67 ('http://etherx.jabber.org/streams', 'error'): ClientNodes.JabberStreamError,68 ('http://etherx.jabber.org/streams', 'stream'): EF.Static(ClientNodes.JabberStream), 69 ('http://etherx.jabber.org/streams', 'error'): EF.Static(ClientNodes.JabberStreamError), 68 70 69 71 # jabber:client nodes 70 ('jabber:client', 'presence'): ClientNodes.JabberClientPresence,71 ('jabber:client', 'message'): ClientNodes.JabberClientMessage,72 ('jabber:client', 'iq'): ClientNodes.JabberClientIQ,73 74 None: ClientNodes.JabberNode, # Default if no match with a defined (namespace, node)75 } 72 ('jabber:client', 'presence'): EF.Static(ClientNodes.JabberClientPresence), 73 ('jabber:client', 'message'): EF.Static(ClientNodes.JabberClientMessage), 74 ('jabber:client', 'iq'): EF.Static(ClientNodes.JabberClientIQ), 75 76 None: EF.Static(ClientNodes.JabberNode), # Default if no match with a defined (namespace, node) 77 }) 76 78 77 79 stream = None trunk/RBJabber/RBJabber/JabberConnection.py
r211 r219 48 48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 49 49 50 from Foundation.XMLBuilder import XMLBuilderMixin, XMLBuilderObjectBase 50 from Foundation.XMLBuilder import XMLBuilderObjectBase 51 from Foundation.XMLClassBuilder import XMLClassBuilderMixin 51 52 from Foundation import SmartSelect 52 53 from Foundation.WeakBind import BindCallable … … 68 69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 70 70 class JabberConnection(XML BuilderMixin, SmartSelect.SmartSelectClientBase):71 class JabberConnection(XMLClassBuilderMixin, SmartSelect.SmartSelectClientBase): 71 72 """Very basic Jabber client, including: 72 73 - Smart select socket handling, … … 82 83 _parser = None 83 84 ServerJID = None 84 JabberNodeMap = {None: XMLBuilderObjectBase}85 85 86 86 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 90 90 def __init__(self, *args, **kw): 91 91 # Base code 92 XML BuilderMixin.__init__(self)92 XMLClassBuilderMixin.__init__(self) 93 93 94 94 if args or kw: … … 186 186 attributes[key] = JID.JID(attributes[key]) 187 187 return self.__super._start_element(name, attributes) 188 189 def _GetElementFactory(self, owner, parent, node, attributes, namespacemap):190 """Again used by the XML parsing mechanism to find an Element class factory to191 represent the node defined by (owner, parent, node, attributes, namespacemap)."""192 return self.JabberNodeMap.get(node, self.JabberNodeMap[None])193 188 194 189 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBSkinning/RBSkinning/XMLSkinner.py
r216 r219 35 35 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36 36 37 from Foundation.XMLClassBuilder import XMLClassBuilder Mixin37 from Foundation.XMLClassBuilder import XMLClassBuilder 38 38 from Foundation.WeakBind import BindCallable 39 39 import SkinContext … … 46 46 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47 47 48 class XMLSkinner(XMLClassBuilder Mixin):48 class XMLSkinner(XMLClassBuilder): 49 49 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 50 50 #~ Special … … 53 53 def __init__(self, mapSupportedSkinNamespaces={}, rootPath=''): 54 54 self.rootPath = rootPath 55 XMLClassBuilder Mixin.__init__(self)55 XMLClassBuilder.__init__(self) 56 56 self.AddElementFactories(mapSupportedSkinNamespaces) 57 57 trunk/RBSkinning/RBSkinning/__init__.py
r216 r219 33 33 """TODO: Document""" 34 34 35 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36 #~ Imports 37 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38 35 39 from XMLSkinner import XMLSkinner as _XMLSkinner 36 40 from Foundation.XMLClassBuilder import ElementFactory as EF 37 41 38 class _XMLRobustSkinner(_XMLSkinner): 39 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40 #~ Constants / Variables / Etc. 41 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 42 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 43 #~ Constants / Variables / Etc. 44 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 42 45 46 StandardElementFactories = { 47 ## Long names 48 ('http://namespaces.runeblade.com/skin',): EF.NodeImport('Foundation.Skinning.skin'), 49 ('http://namespaces.runeblade.com/wxPythonSkin',): EF.NodeImport('Foundation.Skinning.wxPythonSkin'), 50 ('http://namespaces.runeblade.com/xmlPython',): EF.NodeImport('Foundation.Skinning.xmlPython'), 51 ('http://namespaces.runeblade.com/wxogl',): EF.NodeImport('Foundation.Skinning.wxOGLSkin'), 52 ('http://namespaces.runeblade.com/state',): EF.NodeImport('Foundation.Skinning.StateSkin'), 53 ('http://namespaces.runeblade.com/xmlObjectify',): EF.StaticImport('Foundation.XMLObjectify', 'ObjectifiedXML'), 54 55 ## Short names 56 ('skin',): EF.NodeImport('Foundation.Skinning.skin'), 57 ('wxPythonSkin',): EF.NodeImport('Foundation.Skinning.wxPythonSkin'), 58 ('xmlPython',): EF.NodeImport('Foundation.Skinning.xmlPython'), 59 ('wxogl',): EF.NodeImport('Foundation.Skinning.wxOGLSkin'), 60 ('state',): EF.NodeImport('Foundation.Skinning.StateSkin'), 61 62 ('xmlObjectify',): EF.StaticImport('Foundation.XMLObjectify', 'ObjectifiedXML'), 63 64 ## Not-Just-RuneBlade schemes 65 ('http://www.w3.org/1999/xhtml',): EF.StaticImport('Foundation.Skinning.xhtml.xhtml', 'xhtml'), 66 ('http://www.w3.org/1999/xhtml','substitute'): EF.StaticImport('Foundation.Skinning.xhtml.substitute', 'substitute'), 67 } 68 69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 70 #~ Definitions 71 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 72 73 class _StandardXMLSkinner(_XMLSkinner): 43 74 ElementFactories = _XMLSkinner.ElementFactories.copy() 44 ElementFactories.update({ 45 ## Long names 46 ('http://namespaces.runeblade.com/skin',): EF.NodeImport('Foundation.Skinning.skin'), 47 ('http://namespaces.runeblade.com/wxPythonSkin',): EF.NodeImport('Foundation.Skinning.wxPythonSkin'), 48 ('http://namespaces.runeblade.com/xmlPython',): EF.NodeImport('Foundation.Skinning.xmlPython'), 49 ('http://namespaces.runeblade.com/wxogl',): EF.NodeImport('Foundation.Skinning.wxOGLSkin'), 50 ('http://namespaces.runeblade.com/state',): EF.NodeImport('Foundation.Skinning.StateSkin'), 75 ElementFactories.update(StandardElementFactories) 51 76 52 ('http://namespaces.runeblade.com/xmlObjectify',): EF.StaticImport('Foundation.XMLObjectify', 'ObjectifiedXML'), 53 ('http://www.w3.org/1999/xhtml',): EF.StaticImport('Foundation.Skinning.xhtml.xhtml', 'xhtml'), 54 ('http://www.w3.org/1999/xhtml','substitute'): EF.StaticImport('Foundation.Skinning.xhtml.substitute', 'substitute'), 55 56 ## Short names 57 ('skin',): EF.NodeImport('Foundation.Skinning.skin'), 58 ('wxPythonSkin',): EF.NodeImport('Foundation.Skinning.wxPythonSkin'), 59 ('xmlPython',): EF.NodeImport('Foundation.Skinning.xmlPython'), 60 ('wxogl',): EF.NodeImport('Foundation.Skinning.wxOGLSkin'), 61 ('state',): EF.NodeImport('Foundation.Skinning.StateSkin'), 62 63 ('xmlObjectify',): EF.StaticImport('Foundation.XMLObjectify', 'ObjectifiedXML'), 64 }) 65 77 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 78 67 79 def SkinFile(*args, **kw): 68 return _ XMLRobustSkinner().SkinFile(*args, **kw)80 return _StandardXMLSkinner().SkinFile(*args, **kw) 69 81 70 82 def SkinXML(*args, **kw): 71 return _ XMLRobustSkinner().SkinXML(*args, **kw)83 return _StandardXMLSkinner().SkinXML(*args, **kw) 72 84
