google-cloud-datastore

App Engine - Datastore - Python: Delete element within a StructuredProperty

本秂侑毒 提交于 2019-12-11 10:17:41
问题 I have a StructuredProperty that looks like this: userDB(key=Key('userDB', 5580090230439936), name=u'Super User', orgs=[providers(name=u'Comp, Inc.', password=u'1111111', url=None, username=u'111111', value=u'comp'), providers(name=u'Systems, Inc.', password=u'2222222', url=None, username=u'222222', value=u'system')], update=None, userID=u'super@example.com') I would like to delete every provider who's 'value' == 'system'. class providers(EndpointsModel): name = ndb.StringProperty() value =

Efficiently retrieving entities that match any element of a set of ids

跟風遠走 提交于 2019-12-11 10:16:12
问题 I'm writing software to provide feedback to people across many categories. For example, I might have 30 employees and 40 standards of evaluation (e.g. "arrives on time," "is polite," "appears to brush his teeth," etc). At arbitrary times, the supervisor can submit a piece of feedback like "employee 3 gets a 5/5 for standard 8 (he smells great)" or "employee 10 gets a 1/5 for standard 12 (he just called a customer an idiot)." My idea is to store these small pieces of feedback individually,

Google AppEngine Getting 403 forbidden trying to update cron.yaml

二次信任 提交于 2019-12-11 10:14:08
问题 I am following the docs on how to backup datastore using AppEngine. I am performing a gcloud app deploy cron.yaml command on a GCE VM that is meant to update a cronjob in AppEngine. the GCE VM and AppEngine cron are in the same project, and I have granted AppEngine admin to the GCE VM via a default Service Account. When I run this on my local machine, it updates fine. However on the GCE instance, thats where issues arise Here are the files app.yaml runtime: python27 api_version: 1 threadsafe:

GAE Endpoints error: Expected FooBar Instance, got FooBar()

て烟熏妆下的殇ゞ 提交于 2019-12-11 10:05:59
问题 I'm managing an API with using Google Cloud Endpoints and am struggling with a strange, randomly happening, error. The error happens in production only, the unit tests pass property. I have the following model: class UserFacebookData(ndb.Model): facebook_id = ndb.StringProperty(required=True, indexed=True) facebook_token = ndb.StringProperty(required=True, indexed=True) class User(ndb.Model, Entity): created = ndb.DateTimeProperty(auto_now_add=True, indexed=True) username = ndb.StringProperty

How to find out if a model class is db or a ndb

三世轮回 提交于 2019-12-11 09:54:27
问题 I created a utility to exchange or zip all the entities for a kind. But how can I find out if the model_class used is a db.Model or an ndb.Model? def _encode_entity(self, entity): if self.ndb : entity_dict = entity.to_dict() self.entity_eid = entity.key.id() entity_dict['NDB'] = True else : entity_dict = db.to_dict(entity) self.entity_eid = entity.key().name() entity_dict['NDB'] = False .... Now I use : def queryKind(self): try : self.query = self.model_class.query() self.ndb = True except

Google App Engine get_current_user always return None, even if i'm logged

落花浮王杯 提交于 2019-12-11 09:26:49
问题 here's my code def subscribe_current_user(self): user1 = SocialNodeSubscription(parent=self.key) user1.subscribed = True current_user = users.get_current_user() logging.error(current_user) if current_user: user1.user=current_user else: raise users.UserNotFoundError user1.put() The problem is that get_current_user returns None even if i'm logged in. It stores a None in the field user1.user and it prints a None in the log console. How can i solve that? 回答1: Do you have login: required defined

Google app engine datastore query with cursor won't iterate all items

不羁的心 提交于 2019-12-11 08:32:41
问题 In my application I have a datastore query with a filter, such as: datastore.NewQuery("sometype").Filter("SomeField<", 10) I'm using a cursor to iterate batches of the result (e.g in different tasks). If the value of SomeField is changed while iterating over it, the cursor will no longer work on google app engine (works fine on devappserver). I have a test project here: https://github.com/fredr/appenginetest In my test I ran /db that will setup the db with 10 items with their values set to 0,

How to use datastore cursors with jpa on GAE

回眸只為那壹抹淺笑 提交于 2019-12-11 08:26:21
问题 Any body know how to use Datastore Cursors with JPA? 回答1: Can you try this (adapted from the JDO sample): List<Employee> results = (List<Employee>) query.execute(); // Use the first 20 results... Cursor cursor = JPACursorHelper.getCursor(results); String cursorString = cursor.toWebSafeString(); // Store the cursorString... // ... // Query query = the same query that produced the cursor // String cursorString = the string from storage Cursor cursor = Cursor.fromWebSafeString(cursorString);

Will this transaction method work?

纵饮孤独 提交于 2019-12-11 08:19:54
问题 I'm trying to write a transactional method for the app engine datastore but it's hard to test if it's working so I'm trying to validate my approach first. I have a post request that checks if a property is true, and if not true then do something else and set it to true. def post(self): key = self.request.get('key') obj = db.get(key) if obj.property is False: update_obj(ojb.key()) // transactional method to update obj and set value to True if obj.property is True: // do something else 回答1: I

GAE/JPA/DataNucleus: Strange exception while trying to persist entity (IllegalArgumentException: out of field index :-1)

偶尔善良 提交于 2019-12-11 07:36:13
问题 I'm getting an exception after I added this embedded field in my entity: @Entity public class Team extends DataObject { @Embedded private TeamEvolution teamEvolution = new TeamEvolution(); // NEW FIELD: @Embedded // @AttributeOverrides({ @AttributeOverride(name = "buffer", column = @Column) }) // @Enumerated private ScoutBuffer scoutBuffer; ... This guy is very simple: @Embeddable public class ScoutBuffer { private static final int BUFFER_SIZE = 150; @Basic private List<String> buffer; ... //