escaping single quotes
Sean Gillies
sgillies at FRII.COM
Tue May 3 15:43:09 PDT 2005
On May 3, 2005, at 2:54 PM, Ryan, Adam wrote:
>> -----Original Message-----
>> From: Sean Gillies [mailto:sgillies at frii.com]
>>
>>
>> Adam, I have a new idea: when you have apostrophes in your records,
>> write your expression using double quotes only, like so
>>
>> qstring = '("[FNAME]" =~ "Foo")'
>>
>> I guessing that MapServer can't properly evaluate expressions
>> in which
>> a single quote appears on the left side as a string-casting operator,
>> and on the right side as a literal value.
>>
>> Sean
>>
>>
>> --
>> Sean Gillies
>> sgillies at frii dot com
>> http://zcologia.com
>>
>
> Yes, that does work if there is data with ' but without ". If there
> are any
> ", this blows up, in which case you would use all ' in your
> expression. If
> there are both ' and " then there is no solution but to edit your data,
> which stinks, and it must be known ahead of time (or tested for) to
> check if
> your data contains either of the offending characters. Plus,
> searching for
> text with either is no go; you can't search for O'Conner with the
> above work
> around.
>
> This is frustrating. I tend to find some work arounds less palatable
> than
> others, but then the software is free and thus gripping is, for the
> most
> part, kept to oneselve (unless it helps).
>
> On a completely different topic, thanks for pointing me towards
> twisted some
> time ago. I just looked at it again this weekend and put togther a
> little
> server that spits out map images at 80% of the speed it takes
> mapserv.exe/mode=map. Granted there is no functionality BUT drawing
> and
> returning, but that small performance hit I took switching to Python
> mapscript from mapserv.exe could be eliminated, and then some.
>
> Thanks again.
>
> Adam
>
>
You can search for "O'Conner"
qstring = '("[FNAME]" == "O\'Conner")'
, but you are right, this is a pain. If only Steve had chosen to
signify string casting on the left hand side with a str([FNAME])
instead of "[FNAME]" or '[FNAME]'. My Python cartographic library does
not suffer from this problem because it does not use MapServer's mini
language for expressions -- it uses Python expressions. PCL, does
however, suffer from incompleteness at this stage :)
Yeah, Twisted is ideal for specialized web services. This weekend I
put together a module and script that implement a very lightweight WFS.
Check it out: http://zcologia.com/news/31. During the exercise I
finally got a grip on Deferreds, which you would want to use in your
own twisted mapserver when it begins to render maps that don't return
immediately (due to making WMS or WFS client connections or intensive
database queries).
I saw that you're coming out to the OSG05 meeting ... it'll be fun to
hack together at some GIS problems with Python for an afternoon.
cheers,
Sean
More information about the MapServer-users
mailing list