[mapserver-dev] Cannot get class name with Python

geographika geographika at gmail.com
Thu Feb 18 12:24:53 EST 2010


Hi,

I'm using MapServer 5.4 and mapscript with Python. I can't seem to get 
my class names back from my mapfile. I can get raster values back, and 
the class expressions though, so other things are working.
My classes are defined for a layer as follows:

    CLASS
     NAME 'Test1'
       EXPRESSION '3'
       STYLE
         SYMBOL 0
          COLOR 75 153 105
        END
     END

My code is below:

import mapscript

def test():
     mymap = mapscript.mapObj('C:/ms4w/apps/folder/test.map')
     layer = mymap.getLayerByName(layer_name)

     my_class = layer.getClass(1)
     my_class.getExpressionString() # this works fine
     my_class.name # this freezes then returns nothing for several 
different definitions / layers
     print getattr(my_class, 'name') # same problem as above - nothing 
returned

Thanks for any help,

Seth


More information about the mapserver-dev mailing list