因此,google云端点数据存储库
endpoints-proto-datastore的Python项目详细描述
端点原型数据存储
这个库打算与python版本的google一起使用 云端点。如果你想了解更多关于谷歌云的信息 端点,请访问我们的documentation。运行每个样本, 您应该将endpoints_proto_datastorefolder包含在 这个项目。
通过扩展ndb.Model类和 endpointslibrary,这个库允许您直接与 在api方法而不是protorpc请求中建模实体。为了 示例,而不是:
@endpoints.method(MyModelMessage,MyModelMessage,path='mymodel',http_method='POST',name='mymodel.insert')defInsertModel(self,request):my_model=MyModel(attr1=request.attr1,attr2=request.attr2,...)transformed_model=DoSomething(my_model)returnMyModelMessage(attr1=transformed_model.attr1,attr2=transformed_model.attr2,...)
我们可以直接使用请求中的实体:
@MyModel.method(path='mymodel',http_method='POST',name='mymodel.insert')defInsertModel(self,my_model):returnDoSomething(my_model)
甚至不必定义protorpc消息类!
开始使用examples。
项目设置、安装和配置
要在应用程序引擎应用程序中使用此库,您可以
下载endpoints_proto_datastore库并在根目录中解压缩 应用程序引擎应用程序的。例如,在基于Unix的计算机上:
(${GAE_PROJECT_ROOT})$ wget "https://github.com/GoogleCloudPlatform/"``"endpoints-proto-datastore/blob/"``"zipfile-branch/"``"endpoints_proto_datastore.zip?raw=true"\ -O endpoints_proto_datastore.zip (${GAE_PROJECT_ROOT})$ unzip endpoints_proto_datastore.zip (${GAE_PROJECT_ROOT})$ rm endpoints_proto_datastore.zip
或者,您可以通过将此存储库添加到 你的项目是gitsubmodule:
(${YOUR_GIT_ROOT})$ git submodule add https://github.com/GoogleCloudPlatform/endpoints-proto-datastore
这将在^{tt5}中创建整个项目$ 项目中的文件夹。因为Python packages需要__init__.py 用于导入的文件,并且此项目的根目录不应是 python包,您需要将endpoints-proto-datastore添加到 python导入路径。
最简单的方法是在 { } }文件(如果尚未存在该文件,则创建该文件):< >
importosimportsysENDPOINTS_PROJECT_DIR=os.path.join(os.path.dirname(__file__),'endpoints-proto-datastore')sys.path.append(ENDPOINTS_PROJECT_DIR)
注意:如果应用程序引擎项目存储在git存储库中 不在根目录下,您可能需要将符号链接添加到 endpoints-proto-datastore/endpoints_proto_datastore目录和 把它放在你的应用引擎项目的根目录下。
要安装应用程序引擎,请访问Development Environment页。
功能、问题和支持
- 请求功能、报告错误或请求新的示例或片段 文件的;请file an issue。
- 对于疑难解答或一般性问题,请 ask a question在stackoverflow上使用endpoints-proto-datastore 标签。
测试
所有测试都封装在endpoints_proto_datastore_test_runner.py 模块。要运行测试,只需执行
$ python ${PATH_TO_TEST_RUNNER}/endpoints_proto_datastore_test_runner.py
此测试运行程序假设您的路径上有app engine sdk工具 并将使用dev_appserver.py脚本的位置 确定sdk的位置。例如,在基于unix的系统上 它相当于:
$ dirname `readlink \`which dev_appserver.py\``
促成变化
要为贡献的示例创建文档,请使用pycco。例如:
$ pycco example_name/main.py
许可
- 见LICENSE
- 注意:测试运行程序包含来自twisted的一些代码 项目,即listed under terms other than Apache 2.0。