[OpenLayers-Users] OpenLayers.Ajax.Request() with Apache/mod_python

David E. Reksten der at dod.no
Wed Nov 28 11:34:41 EST 2007


On 28/11/2007, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Wed, Nov 28, 2007 at 04:50:45PM +0100, David E. Reksten wrote:
> > I have succesfully set up a WMS service using Geoserver/TileCache and
> > made a browser app with OpenLayers. It works beautifully. I have added
> > an EditingToolbar to draw polygons etc. and I'm now working out how to
> > send the features back to the server.
> >
> > I have configured Apache 2 with mod_python, but I'm unable to get
> > Apache to pass the text/xml POSTed by OpenLayers.Ajax.Request() to my
> > Python script, probably due to this issue:
> > https://issues.apache.org/jira/browse/MODPYTHON-29
>
> Are you setting a content-type request header?

I just lifted some code from an example I found somewhere:

var data = geojson.write(features);
new OpenLayers.Ajax.Request("http://myserver/test/mytest.py",
 {method: 'post',
  postBody: data,
  onComplete: function() { var mydummy = 1; } // NOOP
  });

> > Any ideas or suggestions on how to pass a GeoJSON string/object back
> > to Apache from OpenLayers? Is FeatureServer my best bet here? I'd
> > rather not stack my dependencies too high, if that's avoidable.
>
> Well, what is your server side code now? Is it a custom written
> mod_python handler? FeatureServer, as far as I know, works with
> mod_python -- I think I've successfully configured it that way -- so you
> might look to FeatureServer just for the inspiration of how to parse the
> requests.
>
> (Essentially, you shouldn't be calling util.FieldStorage() unless you've
> got params in the QUERY_STRING... and possibly not even then, due to the
> bug you pointed out.)

Yes, it is a custom mod_python handler (not CGI). I just tried some
really simple stuff, like this (excerpt):

def handler(http):
   http.allow_methods(["GET", "POST"])
   if http.method == "POST":
       http.content_type = 'text/plain'
       http.write("Hello World!")
       return apache.OK

But Apache doesn't execute my handler at all, it just reponds with
"501 Method Not Implemented". I'm quite new to this stuff, I'm afraid,
so I'm not too sure whether I'm on track or hopelessly lost...

Regards,
David



More information about the Users mailing list