[mapserver-users] Python MapScript via WSGI examples

Kralidis, Tom (EC) tom.kralidis at canada.ca
Tue Nov 1 04:21:35 PDT 2016


Thanks for the feedback Jeff.  Comments interleaved:

> -----Original Message-----
> From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On
> Behalf Of Jeff McKenna
> Sent: 15 July 2016 17:56
> To: mapserver-users at lists.osgeo.org
> Subject: Re: [mapserver-users] Python MapScript via WSGI examples
> 
> On 2016-07-15 6:46 PM, Jeff McKenna wrote:
> > Hi Tom,
> >
> > I believe I have your test working here, on Windows with mod_wsgi,
> > Python 3.5.1, and MapScript7.  Googling your error I believe your
> > header problem occurs just for Python2 responses (maybe both Julien
> > and I are using Python3 ?)

We're bound to Python 2 (2.7.6) in this case.  To refresh, see example
in https://gist.github.com/tomkralidis/9adbd4864c03647aa7eb4f96a3c33297

> > What happens if you try to force the
> > content-type to
> > utf8 ?  Change line#40 to:
> >
> >   start_response('200 OK', [('Content-type', 'text/html;
> > charset=utf-8')])
> >
> > Just a guess as I have Python3.  A try anyway...
> >


For some reason it looks like for a GetMap request, the line:

content_type = mapscript.msIO_stripStdoutBufferContentType()

results in None, i.e. the headers do not get stripped from the output?

This is the case for either running the script directly as a process
or embedding within Apache (https://gist.github.com/tomkralidis/9adbd4864c03647aa7eb4f96a3c33297#file-apache-conf)

..Tom


> 
> Or maybe the output should be bytes, as:
> 
>    start_response('200 OK', [('Content-type', 'application/octet-stream;
> charset=utf-8')])
> 


This results in an immediate prompt to download the result, which is a broken
PNG image with the HTTP response headers still intact, i.e.:

Cache-Control: max-age=86400
Content-Type: image/png

‰PNG
.....

> I'd need a Python2 to test though.....hard without.
> 
> -jeff


More information about the MapServer-users mailing list