Changeset 9a95b3 in git


Ignore:
Timestamp:
Jun 14, 2005, 11:48:02 AM (18 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
bb3e2b01b8b571e1ce0e1df85bcb71fb0ccb8e9d
Parents:
50225ad7ef398575b5988f3bb049c8b508002f04
Message:
*bricken: having even more fun


git-svn-id: file:///usr/local/Singular/svn/trunk@8360 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
modules/openmathserver
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/context.py

    r50225a r9a95b3  
    44from omexceptions import *
    55from objects import *
     6from re import sub
    67class Context(object):
    78    #TODO: Referenzen durch scope richtig behandeln
     
    910        self.scope=Scope()
    1011        self.implementations={}
     12        self.XMLEncoder=SimpleXMLEncoder()
    1113    def addCDImplementation(self, implementation):
    1214        self.implementations[implementation.cd]=implementation
     
    6062    def apply(self,func,args):
    6163        return func(self,*args)
    62        
     64    def XMLEncodeBody(self,body):
     65        return self.XMLEncoder.encode(body)
     66
     67class SimpleXMLEncoder(object):
     68    def encode(self, string):
     69        return sub("<","&lt;",sub("&","&amp;",string))
     70       
    6371class Scope(object):
    6472    def __init__(self):
  • modules/openmathserver/objects.py

    r50225a r9a95b3  
    1111        except AttributeError:
    1212            try:
    13                 return self.children
     13                return self.__children
    1414            except AttributeError:
    1515                return []
     
    2020        except AttributeError:
    2121            try:
    22                 del self.children
     22                del self.__children
    2323            except AttributeError:
    2424                pass
     
    2727            self.setChildren(children)
    2828        except AttributeError:
    29                 self.children=children
     29                self.__children=children
    3030    def __getBody(self):
    3131        try:
     
    3333        except AttributeError:
    3434            try:
    35                 return self.body
     35                return self.__body
    3636            except AttributeError:
    3737                return None
     
    4242        except AttributeError:
    4343            try:
    44                 del self.body
     44                del self.__body
    4545            except AttributeError:
    4646                pass
     
    4949            self.setBody(body)
    5050        except AttributeError:
    51                 self.body=body
     51                self.__body=body
    5252    children=property(__getChildren, __setChildren,__delChildren,\
    5353                      """ children in an OMtree""")
     
    5757        try:
    5858            attr=self.XMLAttributes()
    59             attrstr=" ".join([a.encode(context) for a in attr])
     59            attrstr=" "+" ".join([a.encode(context) for a in attr])
    6060        except:
    6161            attrstr=""
    62         opening="".join(["<", self.xmltag, " ", attrstr,">"])
     62        opening="".join(["<", self.XMLtag, attrstr,">"])
    6363        children=self.children
    6464        if children:
     
    6868            if not body:
    6969                body=""
    70             body=context.xmlEncodeBody(body)
    71         closing="".join(["</"+self.xmltag+">"])
     70            assert body!=None
     71            body=context.XMLEncodeBody(body)
     72            assert body!=None
     73        closing="".join(["</"+self.XMLtag+">"])
    7274        return "".join([opening,body,closing])
    7375class OMvar(OMobject):
     
    136138    def setBody(self, value):
    137139        raise OperationNotPossibleError
     140    XMLtag="OMI"
    138141class OMfloat(SimpleValue):
    139142    def __init__(self,value):
     
    182185    i=OMint(22482489)
    183186    print i.body
    184     i.body="dshj"
     187    print i.XMLencode(context)
     188    #i.body="dshj"
    185189   
Note: See TracChangeset for help on using the changeset viewer.