Changeset 01cd17f in git for modules/openmathserver/objects.py
- Timestamp:
- Jun 15, 2005, 1:52:50 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- aeb6d365075d1f830530abf950058c3afdc8f977
- Parents:
- 16678227fe277530e8904f607ce8e6128f93df2a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/openmathserver/objects.py
r1667822 r01cd17f 2 2 from exceptions import * 3 3 #from cd import * 4 class XML attribute(object):4 class XMLAttribute(object): 5 5 def __init__(self, name, value): 6 6 self.name=name … … 56 56 except AttributeError: 57 57 raise UnsupportedOperationError 58 def __getXML attributes(self):59 try: 60 return self.getXML attributes()61 except AttributeError: 62 try: 63 return self.__XML attributes58 def __getXMLAttributes(self): 59 try: 60 return self.getXMLAttributes() 61 except AttributeError: 62 try: 63 return self.__XMLAttributes 64 64 except AttributeError: 65 65 #do return None, cause if modifiying a new list, changes will not be saved 66 66 return [] 67 def __delXML attributes(self):68 try: 69 self.delXML attributes()67 def __delXMLAttributes(self): 68 try: 69 self.delXMLAttributes() 70 70 return 71 71 except AttributeError: 72 72 try: 73 del self.__XML attributes73 del self.__XMLAttributes 74 74 except AttributeError: 75 75 pass 76 def __setXML attributes(self,XMLattributes):77 try: 78 self.setBody(XML attributes)76 def __setXMLAttributes(self,XMLAttributes): 77 try: 78 self.setBody(XMLAttributes) 79 79 except AttributeError: 80 80 raise UnsupportedOperationError … … 83 83 body=property(__getBody,__setBody,__delBody,\ 84 84 "xml body,FIXME: at the moment only char data") 85 XML attributes=property(__getXMLattributes,__setXMLattributes,__delXMLattributes,\85 XMLAttributes=property(__getXMLAttributes,__setXMLAttributes,__delXMLAttributes,\ 86 86 "xml attributes") 87 87 def XMLencode(self, context): 88 88 89 attr=self.XML attributes89 attr=self.XMLAttributes 90 90 if attr: 91 91 attrstr=" "+" ".join([a.encode(context) for a in attr]) … … 117 117 return "OMV(" + self.name +")" 118 118 XMLtag="OMV" 119 def getXML attributes(self):120 return [XML attribute("name", self.name)]119 def getXMLAttributes(self): 120 return [XMLAttribute("name", self.name)] 121 121 122 class OM application(OMObjectBase):122 class OMApply(OMObjectBase): 123 123 def __init__(self, func, args): 124 super(OM application,self).__init__()124 super(OMApply,self).__init__() 125 125 self.func=func 126 126 self.args=args … … 132 132 return context.apply(efunc, eargs) 133 133 except EvaluationFailedError, NotImplementedError: 134 return OM application(efunc, eargs)134 return OMApply(efunc, eargs) 135 135 #return self 136 136 else: 137 return OM application(efunc, eargs)137 return OMApply(efunc, eargs) 138 138 XMLtag="OMA" 139 139 def getChildren(self): … … 159 159 return context.evaluateSymbol(self) 160 160 XMLtag="OMS" 161 def getXML attributes(self):162 return [XML attribute("name", self.name),\163 XML attribute("cdbase",self.cd.base),\164 XML attribute("cd",self.cd.name)]165 def setXML attributes(self):161 def getXMLAttributes(self): 162 return [XMLAttribute("name", self.name),\ 163 XMLAttribute("cdbase",self.cd.base),\ 164 XMLAttribute("cd",self.cd.name)] 165 def setXMLAttributes(self): 166 166 raise UnsupportedOperationError 167 167 class SimpleValue(OMObjectBase): … … 204 204 return "OMfloat("+repr(self.value)+")" 205 205 XMLtag="OMF" 206 def getXML attributes(self):207 return [XML attribute("dec",str(self.value))]206 def getXMLAttributes(self): 207 return [XMLAttribute("dec",str(self.value))] 208 208 class OMRef(OMObjectBase): 209 209 def __init__(self, ref): … … 233 233 firstArg=OMbinding(lambdasym,[OMVar("x"), OMVar("y")], OMVar("x")) 234 234 #print context.evaluate(firstArg) 235 application=OM application(firstArg, [x,y])236 print context.evaluate(application) 237 application=OM application(firstArg,[y,x])235 application=OMApply(firstArg, [x,y]) 236 print context.evaluate(application) 237 application=OMApply(firstArg,[y,x]) 238 238 print context.evaluate(application) 239 239 import arith1 240 240 context.addCDImplementation(arith1.implementation) 241 241 #print type(context.lookupImplementation(arith1.plussym)) 242 #application=OM application(arith1.plussym,[x])243 #application=OM application(arith1.plussym,[x,x])244 application=OM application(OMSymbol("plus",arith1.content),[x,x])242 #application=OMApply(arith1.plussym,[x]) 243 #application=OMApply(arith1.plussym,[x,x]) 244 application=OMApply(OMSymbol("plus",arith1.content),[x,x]) 245 245 246 246 print context.evaluate(application) 247 application=OM application(OMSymbol("plus",arith1.content),[x,x,x])247 application=OMApply(OMSymbol("plus",arith1.content),[x,x,x]) 248 248 249 249 print context.evaluate(application)
Note: See TracChangeset
for help on using the changeset viewer.