Changeset 281

Show
Ignore:
Timestamp:
09/09/02 01:23:56 (6 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

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

    r280 r281  
    1919##~ 
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    21  
    22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    23 #~ Imports  
    24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    25  
    26 from Foundation import ContextApply 
    2721 
    2822#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBFoundation/RBFoundation/Aspects/Aspect.py

    r257 r281  
    1919##~ 
    2020##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    21  
    22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    23 #~ Imports  
    24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    25  
    26 from Foundation import ContextApply 
    2721 
    2822#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • trunk/RBFoundation/RBFoundation/XMLObjectify.py

    r280 r281  
    407407#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    408408     
    409 class ObjectifiedXML(BaseObjectifiedXML): 
     409class AttributedObjectifiedXML(object): 
    410410    def __getattribute__(self, name): 
    411411        """Allows for the node.attribute or node.subnode semantics""" 
    412412        if '_' != name[0]: 
    413413            _attributes = self._attributes 
    414             if name in self._attributes: return _attributes[name] 
     414            if name in _attributes: return _attributes[name] 
    415415            xmlName = name.replace('_', '-') 
    416416            if '-' == xmlName[-1]: xmlName = xmlName[:-1] 
     
    455455#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    456456 
     457class ObjectifiedXML(BaseObjectifiedXML, AttributedObjectifiedXML): 
     458    pass 
     459 
     460#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     461 
    457462class Objectifier(XMLBuilder.XMLBuilder):  
    458463    """An implementation of XMLBuilder that creates ObjectifiedXML nodes from an XML stream. 
     
    501506    print obj.inner[0]._toXML(nsOuter=None) 
    502507 
     508    print 
     509    print ' ~ ' * 20 
     510    print 
     511 
     512    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     513 
     514    builder = Objectifier() 
     515    builder.objectified_class = BaseObjectifiedXML 
     516 
     517    xmlfile = open('test_objectify.xml', 'r') 
     518    obj = builder.ObjectifyFile(xmlfile) 
     519 
     520    print repr(obj) 
     521    print ' ~ ' * 20 
     522    print (obj._toXML()) 
     523    print ' ~ ' * 20 
     524 
     525    from Foundation.AspectOriented.Aspect import Aspect 
     526    class MyAspect(Aspect, AttributedObjectifiedXML): pass 
     527    MyAspect.InsertAspect(obj) 
     528    print (obj.message[0]._toXML()) 
     529 
     530    print 
     531    print ' ~ ' * 20 
     532    print 
     533 
     534    obj = builder.Objectify('''<test xmlns='OuterNamespace'><inner data='1'>content is fun!</inner></test>''') 
     535    MyAspect.InsertAspect(obj) 
     536    print obj.inner[0]._toXML(nsOuter=None) 
     537 
    503538#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    504539