From: Cliff H. <xl...@da...> - 2009-08-02 02:19:36
|
Here's exactly what I am trying to do: Jython 2.5.0 on Google Apps Engine/Java Using Eclipse 3.4 (Ganymede) with: - Pydev plugin - Google plugin My thoughts: 1. I make a Web Application Project in Eclipse (Name: Guestbook, package: guestbook) with the Google plugin, using the Java API. 2. I convert the project into a Pydev project - Set grammar to 2.5, and select Jython 3. I copy the jython.jar into war/WEB-INF/lib 4. I zip up the Jython library (Lib folder) into Lib.zip - I make a text file called "all.pth" with a single line of "Lib.zip" in it. 5. I create a war/WEB-INF/lib-python folder and place the Lib.zip and all.pth files in it. 6. I modify the war/WEB-INF/web.xml to the following: > <?xml version="1.0" encoding="utf-8"?> > <!DOCTYPE web-app PUBLIC > "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd"> > > <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> > <servlet> > <servlet-name>PyServlet</servlet-name> > <servlet-class>org.python.util.PyServlet</servlet-class> > <init-param> > <param-name>python.home</param-name> > <param-value>WEB-INF/lib-python</param-value> > </init-param> > <init-param> > <param-name>python.cachedir.skip</param-name> > <param-value>true</param-value> > </init-param> > </servlet> > > <servlet-mapping> > <servlet-name>PyServlet</servlet-name> > <url-pattern>*.py</url-pattern> > </servlet-mapping> > > <welcome-file-list> > <welcome-file>index.html</welcome-file> > </welcome-file-list> > </web-app> Then I started writing my Jython code. I tried something simple (deriving from the tutorial Google provided for Java, I'm making a Jython equivalent of the Guestbook app, I made a file Guestbook.py which starts off as a Hello, World app): import javax > > class Guestbook(javax.servlet.http.HttpServlet): > > def doGet(self, req, resp): > resp.contentType = "text/plain" > resp.writer.println("Hello, World") > I saved it under the war folder I then did Debug As -> "Web Application" which fires up the development environment server to test with. When I tried to run my servlet with the following: http://localhost:8080/Guestbook.py It just gives me the python source file to download. So, then trying Josh's suggestion, I modified the file war/WEB-INF/appengine-web.xml as follows: <?xml version="1.0" encoding="utf-8"?> > <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> > <application>myapp</application> > <version>1</version> > > <static-files> > <include path="/Guestbook.py"/> > </static-files> > > <!-- Configure java.util.logging --> > <system-properties> > <property name="java.util.logging.config.file" > value="WEB-INF/logging.properties"/> > </system-properties> > > </appengine-web-app> > I tried the same link as above, same result. When I made a folder called war/guestbook and placed the Guestbook.py file in it, and went to the following link instead: http://localhost:8080/guestbook/Guestbook.py it worked! When I tried uploading it to Google, it didn't, giving the error I showed previously: The request method GET is inappropriate for the URL /Guestbook.pySo now I'm stuck again... On Sat, Aug 1, 2009 at 1:42 PM, Cliff Hill <xl...@da...> wrote: > Curiously enough, my solution works when I run it locally in a test > environment, but results in an error 405 on the GAE servers with the > message: > > The request method GET is inappropriate for the URL /Guestbook.py So I'm a > bit stumped again. > > My solution was, when I made the web application project in Eclipse (using > the Google plugin), and then converted it into a Pydev application using > Jython, I copied the jython.jar into my war/WEB-INF/lib folder, and I made a > war/WEB-INF/lib-python folder like modjy, with the Lib.zip and all.pth files > it uses in their own examples, I set up the web.xml file with the > python.path setting pointing to the lib-python folder, and I added your > suggestion for the static-files option, with an include path of: > "/Guestbook.py" (I'm trying to duplicate Google's example for Java apps, > only in Jython). To make it work, I had to make a war/WEB-INF/guestbook > folder, and put my Guestbook.py in that folder, and then I could point my > browser to: http://localhost:8080/guestbook/Guestbook.py and it worked. > When I tried to put it to the production server, it didn't work (even > changing the include path like you suggested), either it tries to give me > the python file to download, or it does the error I outlined above. > > > On Sat, Aug 1, 2009 at 1:25 PM, Josh Juneau <jun...@gm...> wrote: > >> Cliff- >> >> Can you share your solution with us? It would be great to document. >> The solution I showed you worked in my environment on the app engine >> dev server. >> >> Thanks >> >> On 8/1/09, Cliff Hill <xl...@da...> wrote: >> > I tried what you said, and it didn't work. however, I seem to have made >> it >> > work now, without needing that. Thanks. >> > >> > On Sat, Aug 1, 2009 at 9:33 AM, Josh Juneau <jun...@gm...> >> wrote: >> > >> >> Cliff- >> >> I forgot to mention that your statically mapped files can be URLs as >> >> well. >> >> So for testing purposes on your machine the appengine-web.xml that I >> >> gave >> >> you previously would work. However, to deploy to the cloud you will >> need >> >> to >> >> use the URL to your .py files instead. For instance: >> >> >> >> <?xml version="1.0" encoding="UTF-8"?> >> >> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> >> >> <application>MyJythonApp</application> >> >> <version>1</version> >> >> <static-files> >> >> <include path="http://localhost:8080/NewJythonServlet.py"/> >> >> </static-files> >> >> <sessions-enabled>true</sessions-enabled> >> >> </appengine-web-app> >> >> >> >> Of course, >> >> when you deploy the app then the URL should match that of your >> >> application. >> >> >> >> >> >> Josh Juneau >> >> jun...@gm... >> >> http://jj-blogger.blogspot.com >> >> Twitter ID: javajuneau >> >> >> >> >> >> On Sat, Aug 1, 2009 at 10:28 AM, Josh Juneau <jun...@gm...> >> wrote: >> >> >> >>> Hi Cliff- >> >>> The Google App Engine is a bit weird with the PyServlet as it does not >> >>> want to handle the .py file as code, but rather as text like you had >> >>> mentioned. You should add your .py code to the appengine-web.xml file >> >>> as >> >>> "static files" and then set up the PyServlet in your web.xml as usual >> >>> (mapped to url-pattern of *.py). >> >>> >> >>> Suppose my Jython servlet name is NewJythonServlet.py and the path on >> my >> >>> OS to the file is /Jython-code/servlets/NewJythonServlet.py, I will >> need >> >>> to >> >>> set up my appengine-web.xml as follows: >> >>> >> >>> <?xml version="1.0" encoding="UTF-8"?> >> >>> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> >> >>> <application>MyJythonApp</application> >> >>> <version>1</version> >> >>> <static-files> >> >>> <include path="/Jython-code/servlets/NewJythonServlet.py"/> >> >>> </static-files> >> >>> <sessions-enabled>true</sessions-enabled> >> >>> </appengine-web-app> >> >>> >> >>> Once this is completed, you can deploy to GAE and run as follows >> >>> http://gae-server:8080/NewJythonServlet.py >> >>> >> >>> Let me know if this works out for you. >> >>> >> >>> Josh Juneau >> >>> jun...@gm... >> >>> http://jj-blogger.blogspot.com >> >>> Twitter ID: javajuneau >> >>> >> >>> >> >>> On Sat, Aug 1, 2009 at 7:11 AM, Cliff Hill <xl...@da...> >> wrote: >> >>> >> >>>> Is there anyone here who has successfully gotten Jython 2.5.0 to work >> >>>> with GAE? I was able to make modjy work with it, but I would rather >> not >> >>>> use >> >>>> modjy. I'm building a small site from scratch, and want to use >> >>>> PyServlet, >> >>>> but I am running into a snag -- after I set everything up, instead of >> >>>> processing my python code, the server is simply giving me my .py file >> >>>> to >> >>>> download. >> >>>> >> >>>> I can get more specifics if needed. >> >>>> >> >>>> -- >> >>>> "I'm not responcabel fer my computer's spleling errnors" - Xlorep >> >>>> DarkHelm >> >>>> Website: http://darkhelm.org >> >>>> >> >>>> >> >>>> >> >>>> >> ------------------------------------------------------------------------------ >> >>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> >>>> 30-Day >> >>>> trial. Simplify your report design, integration and deployment - and >> >>>> focus on >> >>>> what you do best, core application coding. Discover what's new with >> >>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> >>>> _______________________________________________ >> >>>> Jython-users mailing list >> >>>> Jyt...@li... >> >>>> https://lists.sourceforge.net/lists/listinfo/jython-users >> >>>> >> >>>> >> >>> >> >> >> > >> > >> > -- >> > "I'm not responcabel fer my computer's spleling errnors" - Xlorep >> DarkHelm >> > Website: http://darkhelm.org >> > Sent from Santa Maria, California, United States >> > >> >> -- >> Sent from my mobile device >> >> Josh Juneau >> jun...@gm... >> http://jj-blogger.blogspot.com >> Twitter ID: javajuneau >> > > > > -- > "I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm > Website: http://darkhelm.org > Sent from Santa Maria, California, United States > > > > -- > "I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm > Website: http://darkhelm.org > Sent from Santa Maria, California, United States > -- "I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm Website: http://darkhelm.org Sent from Santa Maria, California, United States |