在Google App Engine上进行Jython开发 [英] Jython Development on Google App Engine

查看:103
本文介绍了在Google App Engine上进行Jython开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有使用Jython和Google App Engine的直接体验(好或坏)?

问明显的问题:你为什么想要? (C)Python由Google App Engine本地支持,到目前为止已经相当成熟并得到很好的支持。



要回答原始问题,我没有个人经验,但我可以给你一个总体概述:



目前最简单的方法是使用Jython的支持调用Java以使用App Engine Java SDK。这意味着虽然你会编写Python,但它看起来很像Java,而且你必须使用Java文档,而不是Python文档。



<但是,理论上可以在App Engine上的Jython中使用Python SDK。 SDK是纯Python,并且SDK和运行时间之间的所有交互都通过RPC来完成,但通过google.appengine.api.apiproxy_stub_map模块。 Java在com.google.apphosting.api.ApiProxy类中具有等同的接口 - 请参阅在GAE中进行单元测试了解如何配置它的一些细节。



考虑到以上这些,您可以使用Python API在Jython中:


  1. 编写一个Python apiproxy_stub,它可以简单地接受所有API调用并将它们发送到com.google.apphosting.api.ApiProxy类。

  2. 使用Jython应用程序捆绑Python SDK的相关部分(这很不幸)。
  3. 在您的初始化代码中,安装您为所有相关服务(datastore_v3,memcache,user,urlfetch和images)编写的apiproxy_stub子类。

如果您最终会这样做,请记录它并发布代码 - 我知道至少有一个其他用户会感兴趣。 :)

Does anyone have any direct experience (good or bad) using Jython with Google App Engine?

解决方案

To ask the obvious question: Why would you want to? (C)Python is supported natively by Google App Engine, and by now is fairly mature and very well supported.

To answer the original question, though: I don't have personal experience, but I can give you a general overview of what it'll be like:

The easiest way currently will be to use Jython's support for calling into Java to use the App Engine Java SDK. This means that although you'll be writing Python, it's going to look a lot like Java, and you'll have to use the Java docs, rather than the Python one.

It is, however, theoretically possible to use the Python SDK in Jython on App Engine. The SDK is pure Python, and all the interaction between the SDK and the runtime is done by way of RPCs though the google.appengine.api.apiproxy_stub_map module. Java has an equivalent interface in the com.google.apphosting.api.ApiProxy class - see the article on Unit Testing in GAE for some details on how to configure it.

Given all that, here's how you could use the Python API in Jython:

  1. Write a Python apiproxy_stub that simply takes all API calls and sends them to the com.google.apphosting.api.ApiProxy class.
  2. Bundle the relevant parts of the Python SDK with your Jython app (that's most of it, unfortunately).
  3. In your initialization code, install the apiproxy_stub subclass you wrote as the handler for all the relevant services - datastore_v3, memcache, user, urlfetch, and images.

If you do end up doing this, please document it and release the code - I know of at least one other user who would be interested. :)

这篇关于在Google App Engine上进行Jython开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆