[Mapserver-dev] Issue with undefining string attributes using mapscript
Sean Gillies
sgillies at frii.com
Mon Mar 10 12:01:55 EST 2003
Hello,
I just entered this as a bug in Bugzilla.
I'm going to use Python syntax in the description. I'm convinced, but
can't
prove, that this is an issue for the other flavors of SWIGged mapscript.
Say we have a mapfile that contains a layer (index = 0) and that no
group
is defined for the layer.
We then create a mapscript mapObj using this mapfile. When we try to
access the 'group' attribute of the layer like
layer = mapobj.getLayer(0)
group = layer.group
the variable 'group' has a value of None (or your own flavor of NULL).
This is exactly right.
Now, during use of the mapObj we might change the group attribute like
layer.group = 'foo'
and this works fine. However, we cannot now undefine the group
attribute.
The underlying SWIG accessor functions will not allow us to do this
layer.group = None
(which would be the most Pythonesque way to undefine an attribute)
because
the layerObj_group_set function requires a string argument. Setting the
group attribute to an empty string like
layer.group = ''
does not undefine the attribute.
It's important to be able to undefine attributes because there are many
functions in the mapserver that execute differently depending on whether
or not string attributes evaluate as equal to NULL.
I figure that there are two possible solutions:
1) Get the SWIG accessor functions to use typemaps that map our
scripting
languages None/NULL values to C NULLs. Unfortunately, I haven't been
able
to turn up any documentation or suggestions on how this would be done.
I know how to use typemaps when wrapping existing code, but suspect that
it's going to be different with the accessor functions that are
generated
by SWIG.
2) Refactor the mapserver code so that empty strings are treated as
NULL.
Are there better solutions?
--
Sean Gillies
sgillies at frii.com
http://www.frii.com/~sgillies
More information about the mapserver-dev
mailing list