Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 data in my deployed app's datastore. I currently run a script to populate the local datastore, but it takes on the order of 15-20 minutes to populate.

Is it possible for dev_appserver.py to connect to my deployed app's datastore?

like image 392
danvk Avatar asked Mar 06 '14 03:03

danvk


2 Answers

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.

like image 150
Dmytro Sadovnychyi Avatar answered Sep 20 '22 00:09

Dmytro Sadovnychyi


Yes it is possible using Google Cloud Datastore. You will need a flag in your application to control which datastore you are using at any particular time, and an additional set of data model classes as an interface to the Cloud Datastore instance.

like image 40
Martin Berends Avatar answered Sep 19 '22 00:09

Martin Berends