0

I am trying to use the remote datastore with my website running on localhost.

According to this, it should be quite straight forward: https://cloud.google.com/appengine/docs/python/tools/remoteapi#using_the_remote_api_in_a_local_client

but where in my project should I place the code ?

I am running python 2.7 on Mac OS X.

thanks

Thomas

ThomasD
  • 2,464
  • 6
  • 40
  • 56

1 Answers1

1

Remote API could be used either from remote or from local. Put the sample code in a script where you want to invoke remote API locally.

Stephen Lin
  • 4,852
  • 1
  • 13
  • 26
  • I want to use it as the general datastore for my project instead of the local datastore on my machine. But I don't know how to use the sample code. Should I put it in main.py or models.py or somewhere else ? Thanks – ThomasD Jan 07 '15 at 09:17
  • @ThomasD I think it's a good idea to put it in the main.py since the main logic is in it. – Stephen Lin Jan 07 '15 at 12:24
  • I am getting closer to a solution based on your comment and other questions here on SO. In my app.yaml I have defined a handler for my apis: - url: /api/.* script: api.py and for everything else: - url: .* script: main.py Right now I have added the code to both api.py and main.py. Is there a way I can only add the code once and it will then be for both api.py and main.py? – ThomasD Jan 07 '15 at 13:09
  • @ThomasD Of course. You can add it as a function in main.py and then import it to any other module you want, like api.py and use it. – Stephen Lin Jan 07 '15 at 13:11
  • ok, but I still need to reference it in both? There is no "super"-class where I can place the code ? Sorry if it is a basic python question, but I am still learning :-) – ThomasD Jan 07 '15 at 13:14
  • @ThomasD No need to have a super class. Just need to put main.py and api.py in the same folder so that you can successfully import it to the local namespace. – Stephen Lin Jan 07 '15 at 13:24
  • put it once in appengine_config.py. see http://stackoverflow.com/questions/22214258/is-it-possible-to-run-dev-appserver-py-with-the-remote-datastore – Dmytro Sadovnychyi Jan 08 '15 at 01:32