Changeset 222 for web


Ignore:
Timestamp:
Sep 22, 2009, 8:41:54 AM (11 years ago)
Author:
pvkouteren
Message:

Bug- & security fixes

Location:
web
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • web/IbidasAtomicServicesTemp.py

    r213 r222  
    3939                setattr(object, field, getattr(containerobject[i], field)())
    4040            objects.append(object)
     41        return objects
     42   
     43    def _tablecontainerToSerializer(self, containerobject, table):
     44        objects = []
     45        fields = containerobject.fields.name().tolist()
     46        print "fields = " + str(fields)
     47        print "containerobject = " + str(containerobject)
     48        for i in range(len(containerobject)):
     49            print "length of containerobject is " + str(len(containerobject))
     50            #try:
     51            object = web.IbidasMessage.name_types['ibidas'+table]()
     52            print "object = " + str(object)
     53            print "created new serializer for " + table
     54            for field in fields:
     55                print str(containerobject[i])
     56                print "field: " + str(field) + " -> " + str(getattr(containerobject[i], field))
     57                setattr(object, field, getattr(containerobject[i], field))
     58                print "just set attribute " + str(field) + " for this object to " + str(getattr(containerobject[i], field))
     59            objects.append(object)
     60            #except e:
     61            #    print "caught exception??"
     62            #    pass # table doesn't exist in name_types (e.g. set_pg_group)
     63        print "returning objects. Objects = " + str(objects)
    4164        return objects
    4265
     
    106129        """ Return a list of all available datasets in Ibidas """
    107130        return self._tableToSerializer('set')
     131   
     132    @soapmethod(Integer,_returns=IbidasMessage)
     133    def getDataset(self, id):
     134        """ Return all data associated with a particular set """
     135        im = IbidasMessage()
     136        for tabledata in self.cd._getTables():
     137            print "table = " + tabledata['name']
     138            containerobject = getattr(self.cd, tabledata['name'])
     139            print "containerobject: " + str(containerobject)
     140            if tabledata['name'] == 'set':
     141                data = self._tablecontainerToSerializer(containerobject[_.set_id == id], tabledata['name'])
     142            elif tabledata['name'] == 'set_pg_group':
     143                data = []
     144            else:
     145                data = self._tablecontainerToSerializer(containerobject[_.source_id == id], tabledata['name'])
     146            for dt in data:
     147                print "adding " + str(dt) + " to message"
     148                im.add(dt)
     149        #print "Gathered message"
     150        print str(im)
     151        return im
  • web/IbidasMessage.py

    r212 r222  
    2020        'ibidaspropterm':IbidasPropTerm,
    2121        'ibidassetrelationlink':IbidasSetRelationLink,
    22         'ibidassetpggroup':IbidasSetPgGroup,
    2322        'ibidassetproptxt':IbidasSetPropTxt,
    2423        'ibidastermlinkpropdouble':IbidasTermLinkPropDouble,
     
    161160                ibidasitemfamilylink = Array(IbidasItemFamilyLink)
    162161                ibidasitemproptxt = Array(IbidasItemPropTxt)
    163                 ibidassetpggroup = Array(IbidasSetPgGroup)
    164162 
    165163        def __init__(self):
     
    172170                        if isinstance(object, t):
    173171                                return v
     172                return None
    174173 
    175174        def add(self, something):
    176175                var = self._typeToVar(something)
    177                 current = getattr(self, var)
    178                 current.append(var)
    179                 setattr(self, var, current)
    180 
     176                if var is not None:
     177                        current = getattr(self, var)
     178                        current.append(something)
     179                        setattr(self, var, current)
  • web/model/IbidasSerializers.py

    r212 r222  
    1313        def __init__(self, **values):
    1414                for key,value in values.items():
     15                        print "Setting " + str(key) + " to " + str(value)
    1516                        setattr(self, key, value)
    1617
  • web/model/setup_serializers.py

    r212 r222  
    1010        self.filepath = self.folder + "/" + self.filename
    1111        #self.filename = folder + "/IbidasSerializers.py"
     12        # dirty hack for now: we don't want the set_pg_group table translated to a serializer
     13        self.excludetables = ['set_pg_group']
    1214   
    1315    def generate(self, cursor, tables):
     
    8385        classname_types = {}
    8486        for cn in classnames:
    85             classtype = self._generateClassname(cn)
    86             classname = classtype.lower()
    87             classname_types[classname] = classtype
    88             #dictstring += "'" + classname + "':" + classtype + ",\n"
    89             dictstring.append("\t'" + classname + "':" + classtype)
     87            if not cn in self.excludetables:
     88                classtype = self._generateClassname(cn)
     89                classname = classtype.lower()
     90                classname_types[classname] = classtype
     91                #dictstring += "'" + classname + "':" + classtype + ",\n"
     92                dictstring.append("\t'" + classname + "':" + classtype)
    9093        #dictstring = dictstring[:dictstring.rfind(u",")]
    9194        #dictstring += "}"
     
    112115        lines.append("\t\t\tif isinstance(object, t):")
    113116        lines.append("\t\t\t\treturn v")
     117        lines.append("\t\treturn None")
    114118        lines.append(" ")
    115119        lines.append("\tdef add(self, something):")
    116120        lines.append("\t\tvar = self._typeToVar(something)")
    117         lines.append("\t\tcurrent = getattr(self, var)")
    118         lines.append("\t\tcurrent.append(var)")
    119         lines.append("\t\tsetattr(self, var, current)")
     121        lines.append("\t\tif var is not None:")
     122        lines.append("\t\t\tcurrent = getattr(self, var)")
     123        lines.append("\t\t\tcurrent.append(var)")
     124        lines.append("\t\t\tsetattr(self, var, current)")
    120125        self._writeLines(lines)
    121126       
Note: See TracChangeset for help on using the changeset viewer.