Changeset d113d3 in git
- Timestamp:
- Jun 17, 2005, 11:25:17 AM (18 years ago)
- Branches:
- (u'spielwiese', '8d54773d6c9e2f1d2593a28bc68b7eeab54ed529')
- Children:
- 559396511a24a530616d6e6f0515acad72817234
- Parents:
- bf5590544366352bc842f5dc754a381cef5c7e0b
- Location:
- modules/openmathserver
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/openmathserver/context.py
rbf5590 rd113d3 71 71 return self.XMLEncoder.encode(body) 72 72 def XMLEncodeObject(self, obj): 73 return obj.XMLencode(self) 73 #TODO: Make Attribution List attributes 74 #TODO: Make all objects __hash__ and __eq__ 75 if (len(obj.attributes)==0): 76 return obj.XMLencode(self) 77 else: 78 toencode=copy(obj) 79 toencode.attributes={} 80 #FIXME: look on order 81 attribution=OMAttribution(*([OMAttributePair(k,obj.attributes[k])\ 82 for k in obj.attributes])+[toencode]) 83 return attribution.XMLencode(self) 84 74 85 class SimpleXMLEncoder(object): 75 86 def encode(self, string): -
modules/openmathserver/objects.py
rbf5590 rd113d3 1 1 from omexceptions import * 2 2 from exceptions import * 3 from copy import copy 3 4 import base64 4 5 #TODO: OMOBJ, OME, OMATTR … … 245 246 "FIXME: maybe it should also be able to encode as reference" 246 247 return context.XMLEncodeObject(self.ref) 248 class OMAttributePair(OMObjectBase): 249 def __init__(self,key, value): 250 super(OMAttributePair,self).__init__() 251 self.key=key 252 self.value=value 253 def getChildren(self): 254 return [self.key, self.value] 255 XMLtag = "OMATP" 256 def evaluate(self, context): 257 return OMAttributePair(context.evaluate(self.key),\ 258 context.evaluate(self.value)) 259 class OMAttribution(OMObjectBase): 260 def __init__(self, *args): 261 super(OMAttribution,self).__init__() 262 self.attr=list(args[:-1]) 263 self.value=args[-1] 264 def getChildren(self): 265 #print type(self.attr) 266 #print type(self.value) 267 return self.attr+[self.value] 268 def evaluate(self, context): 269 value=copy(self.value) 270 value.attributes=copy(value.attributes) 271 for a in self.attr: 272 ae=context.evaluate(a) 273 value.attributes[ae.key]=ae.value 274 return value 275 XMLtag="OMATTR" 247 276 if __name__=='__main__': 248 277 from context import * -
modules/openmathserver/omxmlreader.py
rbf5590 rd113d3 98 98 else: 99 99 raise UnresolvedReference 100 if (node.nodeName=="OMATP"): 101 children=[self.buildFromNode(c) for c in node.childNodes] 102 assert(len(children)==2) 103 erg=OMAttributePair(children[0],children[1]) 104 if (node.nodeName=="OMATTR"): 105 children=[self.buildFromNode(c) for c in node.childNodes] 106 erg=OMAttribution(*children) 100 107 if None==erg: 101 108 raise NotImplementedError
Note: See TracChangeset
for help on using the changeset viewer.