Hi Patrick,
the people that wrote the python scripting plugins are no more active in
the project,
so I'm not sure if you'll get an answer.
Given that it's been a while since you asked, I guess nobody here knows the
answer either.
If you figure it out and want to provide patches or documentation upgrades
they
are more than welcomed!
Cheers
Andrea
On Wed, Sep 21, 2016 at 6:34 AM, P O'Toole <p.oto...@uwyo.edu> wrote:
> Hi, list.
>
>
>
> I recently installed the Python plugin and got a simple test going, and
> also built a Java-style REST endpoint just to compare.
>
>
>
> The Java endpoint and the Python endpoint both work fine via GET, but I've
> found that I'm unable to POST requests to either of the URLs. Instead, I
> get back HTTP/1.1 405 Method Not Allowed. Based off of the logs, it looks
> like Geoserver doesn't even receive the request since Tomcat just sends
> back the 405 right away.
>
>
>
> Here's how I'm set up in Python (after having successfully swapped out
> jython-2.5.2.jar for jython-2.7.0.jar):
>
>
>
> # /var/lib/tomcat/webapps/geoserver/data/scripts/apps/Analysis/main.py
>
> # Adapted from exercise in Colin Henderson's "Mastering Geoserver"
>
>
>
> from flask import Flask, Response
>
>
>
> app = Flask('Analysis')
>
> if __name__ == "__main__":
>
> app.run()
>
>
>
> # Works perfectly fine:
>
> @app.route("/<type>/within/<x>/<y>/<radius>")
>
> def CategoryRadius(type):
>
> return Response('{"You searched for type":' + '"' + type + '"}'
> ,mimetype='application/json')
>
>
>
> # Doesn't work:
>
> @app.route("/within",methods=["POST"])
>
> def CategoryRadiusPost():
>
> type = request.form['type']
>
> return Response('{"You searched for type":' + '"' + type + '"}'
> ,mimetype='application/json')
>
>
>
> And in Java:
>
>
>
> *package* org.geoserver.rest.hello;
>
>
>
> *import* java.util.List;
>
> *import* org.geoserver.rest.AbstractResource;
>
> *import* org.geoserver.rest.format.DataFormat;
>
> *import* org.restlet.data.Request;
>
> *import* org.restlet.data.Response;
>
>
>
> *import* java.util.ArrayList;
>
> *import* org.geoserver.rest.format.StringFormat;
>
> *import* org.restlet.data.MediaType;
>
>
>
> *public* *class* HelloResource *extends* AbstractResource {
>
>
>
> @Override
>
> *protected* List<DataFormat> createSupportedFormats(Request request,
> Response response) {
>
>
>
> List<DataFormat> formats = *new** ArrayList()*;
>
> formats.add(*new* StringFormat( MediaType.*TEXT_PLAIN* ));
>
>
>
> *return* formats;
>
> }
>
>
>
>
>
> @Override
>
> *public* *void* handleGet() {
>
> //get the appropriate format
>
> DataFormat format = getFormatGet();
>
>
>
> //transform the string "Hello World" to the appropriate response
>
> getResponse().setEntity(format.toRepresentation("Hello World"));
>
> }
>
>
>
> @Override
>
> *public* *void* handlePost() {
>
> getResponse().setEntity("Hello World", MediaType.
> *TEXT_PLAIN*);
>
> }
>
>
>
> } // HelloResource class OUT
>
>
>
> With applicationContext.xml looking like:
>
>
>
> <?*xml* version="1.0"?>
>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "
> http://www.springframework.org/dtd/spring-beans.dtd">
>
> <beans>
>
> <bean id="hello" class="org.geoserver.rest.hello.HelloResource"/>
>
> <bean id="helloMapping" class="org.geoserver.rest.RESTMapping">
>
> <property name="routes">
>
> <map>
>
> <entry>
>
> <key>
>
> <value>/hello.{format}</value>
>
> </key>
>
> <value>hello</value>
>
> </entry>
>
> </map>
>
> </property>
>
> </bean>
>
> </beans>
>
>
>
> From shell, I'm trying to retrieve the pages like so:
>
>
>
> curl http://localhost:8080/geoserver/script/apps/Analysis/within -u
> 'admin:<password>' -d "type=mammals" -d "x=1" -d "y=2" -d "radius=3" -i
>
> curl http://localhost:8080/geoserver/rest/hello.txt -u 'admin:<password>'
> -d "greeting=howdy" -i
>
> # Note: the -d flag causes POST to be used. Including -X POST does not
> change the outcome shown below.
>
>
>
> But both pages give me back the response:
>
>
>
> HTTP/1.1 405 Method Not Allowed
>
> Allow: GET
>
> Date: Wed, 21 Sep 2016 00:37:51 GMT
>
> Server: Noelios-Restlet-Engine/1.0..8
>
> Transfer-Encoding: chunked
>
>
>
> I looked at the gs-rest and gs-restconfig sources a little bit but from
> what I can tell this is a higher-level Tomcat configuration issue. Where do
> I make the adjustment to allow fetching pages after POST-ing at them? I
> already tried specifying <init-param><param-name>cors.
> allowed.methods</param-name><param-value>GET,POST</param-value></init-param>
> in Tomcat's web.xml under the CORS filter, but it's clearly being
> overridden by something that’s buried down deeper.
>
>
>
> Thanks
>
>
>
> - Patrick O'Toole
>
>
>
> Application Developer
>
> Wyoming Natural Diversity Database <http://uwyo.edu/wyndd>
>
> UW Berry Biodiversity Conservation Center
>
> Department 3381, 1000 E. University Av.
>
> Laramie, WY 82071
>
> P: 307-766-3018
>
> ------------------------------------------------------------
> ------------------
>
> _______________________________________________
> Geoserver-users mailing list
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>
--
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.
-------------------------------------------------------
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users