古莫核心图书馆
gumo-core的Python项目详细描述
胶芯
配置
fromgumo.coreimportconfigureascore_configurecore_configure(google_cloud_project='<Google Cloud Platform Project Name>',google_cloud_location='<Project Main Location (Region)>',)
如果需要加载app.yaml的环境变量:
importosimportflaskfromgumo.coreimportMockAppEngineEnvironment# from gumo.core import configure as core_configure# The call to MockAppEngineEnvironment must precede any other initialization code.if__name__=='__main__':app_yaml_path=os.path.join(os.path.dirname(os.path.abspath(__file__)),'app.yaml')MockAppEngineEnvironment.load_app_yaml(app_yaml_path=app_yaml_path)# core_configure()# Application Configurations ...app=flask.Flask(__name__)if__name__=='__main__':app.run(host='0.0.0.0',port=8080,debug=True)
设置开发环境
$ git clone https://github.com/gumo-py/gumo-core.git
$ cd gumo-core
$ make setup
构建和测试
$ make build
$ make test
实体键
fromgumo.coreimportEntityKeyfromgumo.coreimportEntityKeyFactorykey=EntityKeyFactory().build(kind='Book',name='978-1-4028-9462-6')assertisinstance(key,EntityKey)assertkey.key_literal()=="Key('Book', '978-1-4028-9462-6')"assertkey.key_path()=='Book:978-1-4028-9462-6'assertkey.key_url()=='Book/978-1-4028-9462-6'