Downloading data from the datastore - python

I wanted to download the data on my online app's datastore, I followed the guide on code.google, I added this to my app.yaml file
builtins:
- remote_api: on
But when I updated using appcfg.py update src and called this:
appcfg.py download_data --application=myapp --url=http://myapp.appspot.com/remote_api_path --filename=first-test-backup`
I got an Authentication error, pretty much the same case mentioned here, so I tried putting this:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
before any catch-all handlers, but then got this error: threadsafe cannot be enabled with CGI handler when I tried to update, so according to this discussion, I replaced it by:
- url: /remote_api
script: google.appengine.ext.remote_api.handler.application
login: admin
Which gave me again the authentication error, I also tried adding ('/remote_api', google.appengine.ext.remote_api.handler) to app = webapp2.WSGIApplication, however still the authentication error persists.
I use a High Replication datastore, but according to code.google the only drawback is that I might not get the latest data.
How can I download my data?

Try this:
builtins:
- remote_api: on
And for url
appcfg.py download_data --application=~myapp --url=http://myapp.appspot.com/_ah/remote_api --filename=first-test-backup
Atttention _ah in url: http://myapp.appspot.com/_ah/remote_api

Related

Why is my url in the following google appengine (python) yaml config file not recognized?

I have the following config file for my google appengine app in python:
application: testapp-94974206
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /helloworld
script: helloworld.application
- url: /
script: helloworld.application
when calling the url with no prefix (/) I get my "helloworld" app called, while when calling with /helloworld I get a 404 not found error page. What is wrong with the declaration of "/helloworld" above?
My question is actually close to another one that has been already answered here.
It turns out that the /helloworld url is actually well routed by the appengine, but then the culprit is the WSGI router that parses the whole absolute URL and not just the one relative to /helloworld, as I thought it would.

My API doesn't show in the explorer and the logs just shows 500

As the title indicates my API isn't visible in the explorer and all my logs show is the following:
INFO 2013-03-08 13:39:08,182 dev_appserver.py:723] Internal redirection to http://127.0.0.1:8080/_ah/spi/BackendService.getApiConfigs
INFO 2013-03-08 13:39:08,198 dev_appserver.py:3104] "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 -
The relevant handler from my app.yaml file looks as follows:
13 # Endpoint handlers
14 - url: /_ah/spi/.*
15 script: main.app
And my code from main.py is as follows:
from google.appengine.ext import endpoints
from protorpc import messages
class Location(messages.Message):
reg_id = messages.StringField(1)
phone_number = messages.StringField(2)
latitude = messages.StringField(3)
longitude = messages.StringField(4)
#endpoints.api(name='locations', version='v1', description='Location API for where are you app')
class LocationApi(remote.Service):
#endpoints.method(Location, Location, name='location.insert', path='location', http_method='POST')
def insert(self, request):
return request
app = endpoints.api_server([LocationApi])
Anyone got a clue about what I'm doing wrong?
Please check the following:
As you should be able to see from the logs, you're getting an import error. In main.py add this
from protorpc import remote
From the documentation:
Note: If you want to test authenticated calls to your API using the Google API Explorer, you must also supply its client ID, which is available through the Endpoints library as endpoints.API_EXPLORER_CLIENT_ID.
Check your logs again to make sure the code actually runs. You're getting a 500 because of a Python exception being raise and there may be other issues with your code, though it doesn't seem like from what you've posted.
It works now that I list the endpoint handler before the other handlers.
This works:
handlers:
# Endpoint handler
- url: /_ah/spi/.*
script: endpoints.app
# Page handlers
- url: /.*
script: home.app
This doesn't work:
handlers:
# Page handlers
- url: /.*
script: home.app
# Endpoint handler
- url: /_ah/spi/.*
script: endpoints.app
The problem is that your python file can't find the import for:
from protorpc import remote
Therefore use the terminal, skip the GUI, navigate to the appengine sdk directory and put your project in there. For mac it is:
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/

Redirect doesn't seem to work on G.A.E

I'm using Python 2.7 and Google App engine. I've written a page that redirects a user to a form after Oauth has completed. This works perfectly on localhost, but it fails when I deploy to the app engine. What am I doing wrong?
The error message I get is "404. That’s an error. The requested URL /form was not found on this server. That’s all we know."
The server logs don't show my /form request at all.
Relevant snippets follow:
1.app.yaml
handlers:
- url: .*
script: public.main.app
builtins:
- remote_api: on
- admin_redirect: on
2.main.py
app = webapp2.WSGIApplication([
('/form?$', content.Home),
('/oauthcallback?$', content.CallbackHandler),],
debug=True)
3.content.py fxn for /oauthcallback
....
http = credentials.authorize(http)
self.redirect('/form')
Hooray!
Thanks guys for all your help.
#Dave Smith, that syntax: '/form?$' is perfectly alright.
It turns out that '/form' is reserved by the GAE. I renamed my entry and now it works perfectly.
See: https://developers.google.com/appengine/docs/python/config/appconfig#Reserved_URLs

How to make all the Handlers(pages) on a google app engine website https

Hi I want to make my all the handlers loaded as https in google app engine project. Can any one know a way to do it? is there a configuration which we could apply for all the handlers?
Do you use webapp2? With webapp2 you can specify the URI schemes allowed for a route:
webapp2.Route(r'/products', handler='handlers.ProductsHandler', name='products-list', schemes=['https'])
See: http://webapp-improved.appspot.com/guide/routing.html
In your app.yaml, use secure: always for each of the handlers where you'd like to require https. For example:
handlers:
- url: /youraccount/.*
script: accounts.py
login: required
secure: always
You can read more about the secure URLs in the documentation.

App Engine Multiple Email Addresses Returns 404

I am trying to process inbound emails (on dev server) sent to different addresses like:
- url: /_ah/jogo#.*rpg2e\.appspotmail\.com
script: jogo.py
- url: /_ah/contato#.*rpg2e\.appspotmail\.com
script: contato.py
- url: /.*
script: helloworld.py
but I get the following log message:
INFO 2012-07-27 20:05:31,759 dev_appserver.py:2952] "POST /_ah/mail/jogo#rpg2e.appspotmail.com HTTP/1.1" 404 -
I also tried:
- url: /_ah/jogo#rpg2e\.appspotmail\.com
script: jogo.py
- url: /_ah/contato#rpg2e\.appspotmail\.com
script: contato.py
- url: /.*
script: helloworld.py
to no avail.
If I simply use a handle_all it works like a charm, but I would like my script only to handle email sent to the correct handle#rpg2e.appspotmail.com
After spending some time searching the Web and within Stack Overflow, I came across many questions like mine, and the only working solution was to use the catch all approach. Some of them were even answered by Ikai Lane[1] with the same conclusion - only catch all works.
Then again, did anyone have success using multiple handlers?
[1] https://groups.google.com/forum/?fromgroups#!topic/google-appengine-java/UGTkMV9foJ0
From the Google App Engine Python - Receiving Mail
url: /_ah/mail/owner#.*your_app_id\.appspotmail\.com
script: handle_owner.py
login: admin
- url: /_ah/mail/support#.*your_app_id\.appspotmail\.com
script: handle_support.py
login: admin
You are missing the /mail/ portion of the required path. You're POSTING to /_ah/jogo#rpg2e.appspotmail.com instead of /_ah/mail/jogo#rpg2e.appspotmail.com. Try this instead:
- url: /_ah/mail/jogo#rpg2e\.appspotmail\.com
script: jogo.py
- url: /_ah/mail/contato#rpg2e\.appspotmail\.com
script: contato.py
Lastly, we all get a little tunnel vision every now and then when confronted with a problem, but it's worth noting the value in error messages. The error message tells us where App Engine is looking when it makes the POST request, which you could match up with your handlers:
INFO 2012-07-27 20:05:31,759 dev_appserver.py:2952] "POST /_ah/mail/jogo#rpg2e.appspotmail.com HTTP/1.1" 404

Categories

Resources