app-engine-ndb

NDB map(callback, produces_cursors=True)

我的梦境 提交于 2019-12-23 09:57:07
问题 The Google AppEngine NDB Documentation for map() states that: "All query options keyword arguments are supported." However, I have tried to use produces_cursors=True on map() and I'm not getting a cursor back. map(callback, pass_batch_into_callback=None, merge_future=None, **q_options) I'd like to use map() as I can set the callback to a tasklet. https://developers.google.com/appengine/docs/python/ndb/queryclass#kwdargs_options Edit - Providing code sample: @ndb.tasklet def callback(user):

In practice, how eventual is the “eventual consistency” in HRD?

柔情痞子 提交于 2019-12-23 07:49:16
问题 I am in the process of migrating an application from Master/Slave to HRD. I would like to hear some comments from who already went through the migration. I tried a simple example to just post a new entity without ancestor and redirecting to a page to list all entities from that model. I tried it several times and it was always consistent. Them I put 500 indexed properties and again, always consistent... I was also worried about some claims of a limit of one 1 put() per entity group per second

How to fetch image and save to blobstore?

可紊 提交于 2019-12-23 03:25:11
问题 I would like to fetch images (~250Kb) from another site and save them to blobstore. I would like to use Blobstore due to its quota (5Gb free) vs datastore (1Gb free). How can I do it? GAE docs say that I should create upload form to use blobstore, which I don't need. 回答1: I think this code will work: from __future__ import with_statement # first line of your code .... from google.appengine.api import urlfetch import mimetypes from google.appengine.api import files ..... image_name = 'your

GAE python NDB projection query working in development but not in production

我怕爱的太早我们不能终老 提交于 2019-12-23 02:29:18
问题 I've been hitting my head against the wall because my Google App Engine python project has a very simple NDB projection query which works fine on my local machine, but mysteriously fails when deployed to production. Adding to the mystery... as a test I added an identical projection on another property, and it works in both dev and production! Could anyone help please?! Here are more details: I have the following entity that represents an expense: class Entry(ndb.Model): datetime = ndb

Read and Write Operations involved with ComputedProperty in GAE NDB

早过忘川 提交于 2019-12-23 00:51:06
问题 I use GAE NDB Python 2.7 My two Models code: class A(ndb.Model): def X(self, value): :: # some statements to return a value return range def Y(self, value): :: # some statements to return a value return range def Z(self, value): :: # some statements to return a value return range property_1 = ndb.IntegerProperty(default=0, indexed=False) property_2 = ndb.IntegerProperty(default=0, indexed=False) property_3 = ndb.IntegerProperty(default=0, indexed=False) property_4 = ndb.IntegerProperty

Read and Write Operations involved with ComputedProperty in GAE NDB

╄→尐↘猪︶ㄣ 提交于 2019-12-23 00:50:09
问题 I use GAE NDB Python 2.7 My two Models code: class A(ndb.Model): def X(self, value): :: # some statements to return a value return range def Y(self, value): :: # some statements to return a value return range def Z(self, value): :: # some statements to return a value return range property_1 = ndb.IntegerProperty(default=0, indexed=False) property_2 = ndb.IntegerProperty(default=0, indexed=False) property_3 = ndb.IntegerProperty(default=0, indexed=False) property_4 = ndb.IntegerProperty

How to ignore case in an NDB/DB query

久未见 提交于 2019-12-22 10:44:02
问题 This seems like a simple question, but I don't see anything in the class definition. If I have the query Video.query(Video.tags.IN(topics)) topics are coming in as lowercase unicode strings, but Video.tags are mostly capitalized. I can loop through topics and capitalize them before querying with them, but is there a way to ignore case altogether? 回答1: It's not possible to ignore case in a query. Typically if you know you want to do a case insensitive search, you may store a "denormalized"

How to set an ndb keyProperty

纵然是瞬间 提交于 2019-12-22 09:33:45
问题 I'm having some trouble understanding how entities and keys work in Google App Engine NDB. I have a post entity and a user entity. How do I set the user_key on post to user ? In the interactive console, I have this so far: from google.appengine.ext import ndb from app.lib.posts import Post from app.lib.users import User from random import shuffle users = User.query() posts = Post.query().fetch() for post in posts: post.user_key = shuffle(users)[0] post.put() I'm just trying to set up some

What is the Google Appengine Ndb GQL query max limit?

那年仲夏 提交于 2019-12-22 06:37:33
问题 I am looking around in order to get an answer what is the max limit of results I can have from a GQL query on Ndb on Google AppEngine. I am using an implementation with cursors but it will be much faster if I retrieve them all at once. 回答1: Basically you don't have the old limit of 1000 entities per query anymore, but consider using a reasonable limit, because you can hit the time out error and it's better to get them in batches so users won't wait during load time. 回答2: This depends on lots

App Engine return JSON from JsonProperty

笑着哭i 提交于 2019-12-22 06:37:21
问题 I like how the JsonProperty automatically encodes a Python structure into JSON when the property is put into the data store, and automatically decodes it when retrieved. However, it would be nice to send that JSON data to a web browser without having to encode it again. Is there a way to get the raw JSON data (that is, prevent the decoding)? class DataForBrowser(ndb.Models) json = ndb.JsonProperty() def get_json(self): return ??? 回答1: So what you want is to have a dict that gets encoded when