[Mapserver-dev] Issue with undefining string attributes
using mapscript
Steve Lime
steve.lime at dnr.state.mn.us
Mon Mar 10 12:52:53 EST 2003
Hi Folks: This is a swig issue. So changing the C code is not where we
want to go. Sometimes an empty string is perfectly acceptable (for
example the CLASS TEXT parameter) so screwing with the C code is not an
option. I dealt with this issue and Perl MapScript awhile back. Working
with the Swig author we found the problem and had a fix. It was going
into their development code. I'll check back through old emails to
confirm this and post a summary.
Steve
>>> Sean Gillies <sgillies at frii.com> 03/10/03 11:03 AM >>>
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
_______________________________________________
Mapserver-dev mailing list
Mapserver-dev at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-dev
More information about the mapserver-dev
mailing list