Changeset 281
- Timestamp:
- 09/09/02 01:23:56 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBFoundation/RBFoundation/Aspects/Advice.py
r280 r281 19 19 ##~ 20 20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~23 #~ Imports24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~25 26 from Foundation import ContextApply27 21 28 22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBFoundation/RBFoundation/Aspects/Aspect.py
r257 r281 19 19 ##~ 20 20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 21 22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~23 #~ Imports24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~25 26 from Foundation import ContextApply27 21 28 22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBFoundation/RBFoundation/XMLObjectify.py
r280 r281 407 407 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 408 408 409 class ObjectifiedXML(BaseObjectifiedXML):409 class AttributedObjectifiedXML(object): 410 410 def __getattribute__(self, name): 411 411 """Allows for the node.attribute or node.subnode semantics""" 412 412 if '_' != name[0]: 413 413 _attributes = self._attributes 414 if name in self._attributes: return _attributes[name]414 if name in _attributes: return _attributes[name] 415 415 xmlName = name.replace('_', '-') 416 416 if '-' == xmlName[-1]: xmlName = xmlName[:-1] … … 455 455 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 456 457 class ObjectifiedXML(BaseObjectifiedXML, AttributedObjectifiedXML): 458 pass 459 460 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 461 457 462 class Objectifier(XMLBuilder.XMLBuilder): 458 463 """An implementation of XMLBuilder that creates ObjectifiedXML nodes from an XML stream. … … 501 506 print obj.inner[0]._toXML(nsOuter=None) 502 507 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 503 538 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 504 539
