google-cloud-datastore

Managing users authentication in Google App Engine

Deadly 提交于 2019-12-19 08:06:33
问题 I am working on a webapp based on google app engine. The application uses the google authentication apis. Basically every handler extends from this BaseHandler and as first operation of any get/post the checkAuth is executed. class BaseHandler(webapp2.RequestHandler): googleUser = None userId = None def checkAuth(self): user = users.get_current_user() self.googleUser = user; if user: self.userId = user.user_id() userKey=ndb.Key(PROJECTNAME, 'rootParent', 'Utente', self.userId) dbuser = MyUser

Change IntegerProperty to FloatProperty of existing AppEngine DataStore

别等时光非礼了梦想. 提交于 2019-12-19 03:16:18
问题 I built an appengine application (python) which need to convert existing datastore entities in integer value (100) to float value (100.00) for currency conversion issue. How's the right way doing this? Since my query returning error when i just change property type in my model. Old Model: class Learn(search.SearchableModel): pid = db.ReferenceProperty(Product, collection_name='picks') title = db.StringProperty() description = db.TextProperty() order = db.IntegerProperty() cost = db

Accessing related object key without fetching object in App Engine

纵然是瞬间 提交于 2019-12-19 02:34:06
问题 In general, it's better to do a single query vs. many queries for a given object. Let's say I have a bunch of 'son' objects each with a 'father'. I get all the 'son' objects: sons = Son.all() Then, I'd like to get all the fathers for that group of sons. I do: father_keys = {} for son in sons: father_keys.setdefault(son.father.key(), None) Then I can do: fathers = Father.get(father_keys.keys()) Now, this assumes that son.father.key() doesn't actually go fetch the object. Am I wrong on this? I

Initialize local datastore exception : No API environment is registered for this thread

天涯浪子 提交于 2019-12-18 19:32:12
问题 I would like to initialize my local data store with some data using a regular Java program (I do not want to start the Development Server and call a service/servlet), and I'm getting the following exception EXCEPTION : Exception in thread "main" java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:108) at com.google.appengine.api.datastore.DatastoreApiHelper

Beta Firebase Firestore won't work with projects using app engine

只谈情不闲聊 提交于 2019-12-18 19:02:03
问题 When I try to add the beta firestore to my Google cloud platform project I get the following message. Cannot enable Firestore for this project Currently Firestore cannot be enabled in projects already using Cloud Datastore or App Engine Is this going to last forever? I think I would like to replace some but not all of my datastore stuff with firestore to get realtime updates. Perhaps firestore uses datastore and appengine in its backend? Should I use two GCP projects to get around this

How to fix index error when querying GAE datastore?

孤人 提交于 2019-12-18 15:54:31
问题 When I try to run a query on the datastore ordered by date I get the following error: NeedIndexError: no matching index found. The suggested index for this query is: - kind: Message properties: - name: author - name: ref - name: date The query runs without error if I don't try to order by date. The appengine console under datastore indexes says: author ▲ , ref ▲ , date ▼ Serving What am I doing wrong? How can I run my query ordered by date? Thanks! Here is my entity definition: from google

How to structure movies database and user choices?

ε祈祈猫儿з 提交于 2019-12-18 13:42:18
问题 I would like to create movies database, where user will be able to mark movies he/she watched and liked: class Movies(ndb.Model): watched = ndb.UserProperty() liked = ndb.UserProperty() Will that work? I use Google accounts. How should I choose later all movies user liked? Upd . I've followed systempuntoout approach and use the following code to save user choices: user = users.get_current_user() if user: userschoices = models.UsersChoices( movie=ndb.Key(models.Movies, movie_id), # TODO: what

How to structure movies database and user choices?

懵懂的女人 提交于 2019-12-18 13:42:06
问题 I would like to create movies database, where user will be able to mark movies he/she watched and liked: class Movies(ndb.Model): watched = ndb.UserProperty() liked = ndb.UserProperty() Will that work? I use Google accounts. How should I choose later all movies user liked? Upd . I've followed systempuntoout approach and use the following code to save user choices: user = users.get_current_user() if user: userschoices = models.UsersChoices( movie=ndb.Key(models.Movies, movie_id), # TODO: what

Google Datastore queries and eventual consistency

只愿长相守 提交于 2019-12-18 13:27:57
问题 I would like to confirm my understanding of eventual consistency in the Google datastore. Suppose that I have an entity defined as follows (using ndb): class Record(ndb.Model): name = ndb.StringProperty() content = ndb.BlobProperty() I think I understand Scenarios 1, but I have doubts about Scenarios 2 and 3, so some advice would be highly appreciated. Scenario 1: I insert a new Record with name "Luca" and a given content. Then, I query the datastore: qry = Record.query(name=="Luca") for r in

How do you upload data in bulk to Google App Engine Datastore?

心已入冬 提交于 2019-12-18 12:37:32
问题 I have about 4000 records that I need to upload to Datastore. They are currently in CSV format. I'd appreciate if someone would point me to or explain how to upload data in bulk to GAE. 回答1: You can use the bulkloader.py tool: The bulkloader.py tool included with the Python SDK can upload data to your application's datastore. With just a little bit of set-up, you can create new datastore entities from CSV files. 回答2: I don't have the perfect solution, but I suggest you have a go with the App