Is it possible to run dev_appserver.py with the remote datastore?

后端 未结 2 1511
梦毁少年i
梦毁少年i 2020-12-18 05:12

I\'m developing a web app with Google\'s AppEngine. I\'d like to iterate on the code locally using dev_appserver.py. But it\'s hard to do this without all the d

2条回答
  •  难免孤独
    2020-12-18 05:48

    Yeah, it is possible.

    First, turn on remote-api in app.yaml and deploy the application on production.

    builtins:
    - remote_api: on
    

    Then, for example in appengine_config.py:

    import os
    from google.appengine.ext.remote_api import remote_api_stub
    from google.appengine.datastore.entity_pb import Reference
    
    remote_api_stub.ConfigureRemoteApi(app_id=None, path='/_ah/remote_api',
                                       auth_func=lambda: ('email', 'password'),
                                       servername='appid.appspot.com')
    
    if os.environ['SERVER_SOFTWARE'].startswith('Development'):
      Reference.app = lambda *args: os.environ['APPLICATION_ID'].replace('dev~', 's~')
    

    If you have old application ID you may need to edit .replace('dev'...) part.

提交回复
热议问题