Changeset 219

Show
Ignore:
Timestamp:
07/17/02 17:37:03 (6 years ago)
Author:
sholloway
Message:

Refactored XMLClassBuilder into Jabber framework
Fixed XMLClassBuilder structure

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/XMLClassBuilder.py

    r214 r219  
    124124#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    125125 
    126 class XMLClassBuilderMixin(XMLBuilder.XMLBuilder): 
     126class XMLClassBuilderMixin(XMLBuilder.XMLBuilderMixin): 
    127127    """Mixin that forms the python import indirectly from a dictionary lookup of the namespace,  
    128128    and then combines the result with the node name.""" 
     
    182182        return FactoryFactory(owner, parent, node, attributes, namespacemap) 
    183183 
     184#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     185 
     186class XMLClassBuilder(XMLClassBuilderMixin, XMLBuilder.XMLBuilder): 
     187    pass 
  • trunk/RBJabber/RBJabber/Client.py

    r192 r219  
    5252from Foundation.Jabber.JabberConnection import JabberConnection 
    5353from Foundation import SubjectObserver 
     54from Foundation.XMLClassBuilder import ElementFactory as EF 
    5455 
    5556#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    6263    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    6364 
    64     JabberNodeMap = { 
     65    ElementFactories = JabberConnection.ElementFactories.copy() 
     66    ElementFactories.update({ 
    6567        # 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)
    6870 
    6971        # 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        }) 
    7678 
    7779    stream = None 
  • trunk/RBJabber/RBJabber/JabberConnection.py

    r211 r219  
    4848#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4949 
    50 from Foundation.XMLBuilder import XMLBuilderMixin, XMLBuilderObjectBase 
     50from Foundation.XMLBuilder import XMLBuilderObjectBase 
     51from Foundation.XMLClassBuilder import XMLClassBuilderMixin 
    5152from Foundation import SmartSelect 
    5253from Foundation.WeakBind import BindCallable 
     
    6869#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    6970 
    70 class JabberConnection(XMLBuilderMixin, SmartSelect.SmartSelectClientBase): 
     71class JabberConnection(XMLClassBuilderMixin, SmartSelect.SmartSelectClientBase): 
    7172    """Very basic Jabber client, including: 
    7273        - Smart select socket handling,  
     
    8283    _parser = None 
    8384    ServerJID = None 
    84     JabberNodeMap = {None: XMLBuilderObjectBase} 
    8585 
    8686    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    9090    def __init__(self, *args, **kw): 
    9191        # Base code 
    92         XMLBuilderMixin.__init__(self) 
     92        XMLClassBuilderMixin.__init__(self) 
    9393 
    9494        if args or kw: 
     
    186186                    attributes[key] = JID.JID(attributes[key]) 
    187187        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 to  
    191         represent the node defined by (owner, parent, node, attributes, namespacemap).""" 
    192         return self.JabberNodeMap.get(node, self.JabberNodeMap[None]) 
    193188 
    194189    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBSkinning/RBSkinning/XMLSkinner.py

    r216 r219  
    3535#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3636 
    37 from Foundation.XMLClassBuilder import XMLClassBuilderMixin 
     37from Foundation.XMLClassBuilder import XMLClassBuilder 
    3838from Foundation.WeakBind import BindCallable 
    3939import SkinContext 
     
    4646#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4747 
    48 class XMLSkinner(XMLClassBuilderMixin): 
     48class XMLSkinner(XMLClassBuilder): 
    4949    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    5050    #~ Special  
     
    5353    def __init__(self, mapSupportedSkinNamespaces={}, rootPath=''): 
    5454        self.rootPath = rootPath 
    55         XMLClassBuilderMixin.__init__(self) 
     55        XMLClassBuilder.__init__(self) 
    5656        self.AddElementFactories(mapSupportedSkinNamespaces) 
    5757 
  • trunk/RBSkinning/RBSkinning/__init__.py

    r216 r219  
    3333"""TODO: Document""" 
    3434 
     35#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     36#~ Imports  
     37#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     38 
    3539from XMLSkinner import XMLSkinner as _XMLSkinner 
    3640from Foundation.XMLClassBuilder import ElementFactory as EF 
    3741 
    38 class _XMLRobustSkinner(_XMLSkinner): 
    39     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    40     #~ Constants / Variables / Etc.  
    41     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     42#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     43#~ Constants / Variables / Etc.  
     44#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    4245 
     46StandardElementFactories = { 
     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 
     73class _StandardXMLSkinner(_XMLSkinner): 
    4374    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) 
    5176 
    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#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    6678 
    6779def SkinFile(*args, **kw): 
    68     return _XMLRobustSkinner().SkinFile(*args, **kw) 
     80    return _StandardXMLSkinner().SkinFile(*args, **kw) 
    6981 
    7082def SkinXML(*args, **kw): 
    71     return _XMLRobustSkinner().SkinXML(*args, **kw) 
     83    return _StandardXMLSkinner().SkinXML(*args, **kw) 
    7284