Changeset bb3e2b0 in git for modules


Ignore:
Timestamp:
Jun 14, 2005, 12:27:27 PM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '7e41ef9499d2014a20b2ab8b603aa2c6cce053c8')
Children:
bfcf687e51e5ee8dc6e9b10bbbf0d8eddf26d90a
Parents:
9a95b3a11b46e9041db2db3dc586e8863e9fed9e
Message:
*bricken: having fantastic fun


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

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/context.py

    r9a95b3 rbb3e2b0  
    6464    def XMLEncodeBody(self,body):
    6565        return self.XMLEncoder.encode(body)
    66 
     66    def XMLEncode(self, obj):
     67        obj.XMLencode(self)
    6768class SimpleXMLEncoder(object):
    6869    def encode(self, string):
  • modules/openmathserver/objects.py

    r9a95b3 rbb3e2b0  
    11from omexceptions import *
    22from exceptions import *
    3 from cd import *
    4 
     3#from cd import *
     4class 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,"\""])
    510class OMobject(object):
     11    """ at the moment only a base class"""
    612    def __init__(self):
    713        self.attributes={}
     
    5056        except AttributeError:
    5157                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
    5281    children=property(__getChildren, __setChildren,__delChildren,\
    5382                      """ children in an OMtree""")
    5483    body=property(__getBody,__setBody,__delBody,\
    5584        "xml body,FIXME: at the moment only char data")
     85    XMLattributes=property(__getXMLattributes,__setXMLattributes,__delXMLattributes,\
     86        "xml attributes")
    5687    def XMLencode(self, context):
    57         try:
    58             attr=self.XMLAttributes()
     88       
     89        attr=self.XMLattributes
     90        if attr:
    5991            attrstr=" "+" ".join([a.encode(context) for a in attr])
    60         except:
     92        else:
    6193            attrstr=""
    6294        opening="".join(["<", self.XMLtag, attrstr,">"])
    6395        children=self.children
    6496        if children:
    65             body="".join([c.XMLencode(context) for i in children])
     97            body="".join([context.XMLencode(c) for c in children])
    6698        else:
    6799            body=self.body
     
    84116    def __str__(self):
    85117        return "OMV(" + self.name +")"
     118    XMLtag="OMV"
     119    def getXMLattributes(self):
     120        return [XMLattribute("name", self.name)]
    86121class OMapplication(OMobject):
    87122    def __init__(self, func, args):
Note: See TracChangeset for help on using the changeset viewer.