Changeset bb3e2b0 in git
- Timestamp:
- Jun 14, 2005, 12:27:27 PM (18 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- bfcf687e51e5ee8dc6e9b10bbbf0d8eddf26d90a
- Parents:
- 9a95b3a11b46e9041db2db3dc586e8863e9fed9e
- Location:
- modules/openmathserver
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/openmathserver/context.py
r9a95b3 rbb3e2b0 64 64 def XMLEncodeBody(self,body): 65 65 return self.XMLEncoder.encode(body) 66 66 def XMLEncode(self, obj): 67 obj.XMLencode(self) 67 68 class SimpleXMLEncoder(object): 68 69 def encode(self, string): -
modules/openmathserver/objects.py
r9a95b3 rbb3e2b0 1 1 from omexceptions import * 2 2 from exceptions import * 3 from cd import * 4 3 #from cd import * 4 class XMLattribute(object): 5 def __init__(self, name, value): 6 self.name=name 7 self.value=value 8 def encode(self, context): 9 return "".join([self.name,"=\"",self.value,"\""]) 5 10 class OMobject(object): 11 """ at the moment only a base class""" 6 12 def __init__(self): 7 13 self.attributes={} … … 50 56 except AttributeError: 51 57 self.__body=body 58 def __getXMLattributes(self): 59 try: 60 return self.getXMLattributes() 61 except AttributeError: 62 try: 63 return self.__XMLattributes 64 except AttributeError: 65 #do return None, cause if modifiying a new list, changes will not be saved 66 return [] 67 def __delXMLattributes(self): 68 try: 69 self.delXMLattributes() 70 return 71 except AttributeError: 72 try: 73 del self.__XMLattributes 74 except AttributeError: 75 pass 76 def __setXMLattributes(self,XMLattributes): 77 try: 78 self.setBody(XMLattributes) 79 except AttributeError: 80 self.__XMLattributes=XMLattributes 52 81 children=property(__getChildren, __setChildren,__delChildren,\ 53 82 """ children in an OMtree""") 54 83 body=property(__getBody,__setBody,__delBody,\ 55 84 "xml body,FIXME: at the moment only char data") 85 XMLattributes=property(__getXMLattributes,__setXMLattributes,__delXMLattributes,\ 86 "xml attributes") 56 87 def XMLencode(self, context): 57 try: 58 attr=self.XMLAttributes() 88 89 attr=self.XMLattributes 90 if attr: 59 91 attrstr=" "+" ".join([a.encode(context) for a in attr]) 60 e xcept:92 else: 61 93 attrstr="" 62 94 opening="".join(["<", self.XMLtag, attrstr,">"]) 63 95 children=self.children 64 96 if children: 65 body="".join([c .XMLencode(context) for iin children])97 body="".join([context.XMLencode(c) for c in children]) 66 98 else: 67 99 body=self.body … … 84 116 def __str__(self): 85 117 return "OMV(" + self.name +")" 118 XMLtag="OMV" 119 def getXMLattributes(self): 120 return [XMLattribute("name", self.name)] 86 121 class OMapplication(OMobject): 87 122 def __init__(self, func, args):
Note: See TracChangeset
for help on using the changeset viewer.