google-cloud-datastore

How to convert a time string in a Google AppEngine db.TimeProperty?

懵懂的女人 提交于 2019-12-24 05:48:50
问题 As per question title, how to convert a Python string to a Google App Engine db.TimeProperty ? I tried to do: obj.time = strptime("10:00", "%H:%M") However I get the following error: BadValueError: Property time must be a time, but was time.struct_time(tm_year=1900, tm_mon=1, tm_mday=1, tm_hour=10, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=1, tm_isdst=-1) 回答1: I'm not familiar with the (superseded) db docs, but from the NDB Cheat Sheet db.TimeProperty() corresponds directly to ndb.TimeProperty()

New entity in repeated StructuredProperty stored as a _BaseValue

我是研究僧i 提交于 2019-12-24 04:59:24
问题 I have a HUser model (derived from Google's User class) which in turn contains 0 to n instances of social accounts. These accounts can be references to Facebook, Twitter or LinkedIn accounts. I have built an Account model, and defined a StructuredProperty in my User model with repeated=True , like this: class Account(ndb.Expando): account_type = ndb.StringProperty(required=True, choices=['fb', 'tw', 'li']) account_id = ndb.StringProperty() access_token = ndb.StringProperty() ... class HUser

How efficient is Google App Engine ndb.delete_multi()?

限于喜欢 提交于 2019-12-24 04:41:29
问题 I'm working on something to clear my database of ~10,000 entities, and my plan is to put it in a task that deletes 200 at a time using ndb.delete_multi() and then recursively calls itself again until there are no entities left. For now, I don't have the recursion in it yet so I could run the code a few times manually and check for errors, quota use, etc. The code is: entities = MyModel.query_all(ndb.Key('MyModel', '*defaultMyModel')).fetch(200) key_list = ndb.put_multi(entities) ndb.delete

Got “DatastoreException: Request is missing required authentication credential” if using Objectify 6.0 and <url-stream-handler> at the same time

允我心安 提交于 2019-12-24 03:53:33
问题 On an App Engine application, deployed on standard environment with java 8 activated, I get the exception below if I use both Objectify 6.0 AND the tag <url-stream-handler>urlfetch</url-stream-handler> in the appengine-web.xml file. com.google.cloud.datastore.DatastoreException: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Got “DatastoreException: Request is missing required authentication credential” if using Objectify 6.0 and <url-stream-handler> at the same time

此生再无相见时 提交于 2019-12-24 03:53:11
问题 On an App Engine application, deployed on standard environment with java 8 activated, I get the exception below if I use both Objectify 6.0 AND the tag <url-stream-handler>urlfetch</url-stream-handler> in the appengine-web.xml file. com.google.cloud.datastore.DatastoreException: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

How to select a single Entity by key (low level java datastore API)

故事扮演 提交于 2019-12-24 02:39:05
问题 I'm a bit confused on how to create a "Key" object to select exactly 1 row of my Entity ("Customer"). My code : Query query = new Query("Customer"); // **** how do I have to create this key ??? Key key = KeyFactory.createKey("Customer", 1); // **** FilterPredicate keyFilter = new FilterPredicate(Entity.KEY_RESERVED_PROPERTY, FilterOperator.EQUAL, key); query.setFilter(keyFilter); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare

toDerInputStream rejects tag type 123

别来无恙 提交于 2019-12-24 01:54:42
问题 I am trying to run the Get started with Datastore example at https://developers.google.com/datastore/docs/getstarted/start_java/ trying it both from the command line and from Eclipse. In both environments, it is not able to connect to datastore and gives an I/O error message 'toDerInputStream rejects tag type 123'. Looking around, this may be because the private key file is in json format and perhaps it should the p12 - other than that the error message draws a blank. Could anyone point to

db.model_from_protobuf() equivalents outside of AppEngine?

六月ゝ 毕业季﹏ 提交于 2019-12-24 01:53:02
问题 In Google AppEngine(GAE) environment, I can do following to convert a Protobuf bytestring back to a Datastore model: from google.appengine.ext import db byte_str = .... model = db.model_from_protobuf(byte_str.decode("base64")) Outside of GAE, I normally use the google-cloud-datastore client to access Datastore models: from google.cloud import datastore ... client = datastore.Client(project_id) query = client.query(kind='Event', order=('-date',)) for result in query.fetch(limit=100): print

org.datanucleus.sco.backed.ArrayList cannot be cast to java.util.Set

时光怂恿深爱的人放手 提交于 2019-12-23 23:32:56
问题 Since 4 days ago, in random short periods of time , my deployed application is throwing this error: org.datanucleus.sco.backed.ArrayList cannot be cast to java.util.Set We are using GWT 2.4 / Java 1.7 (We recently migrate from 1.6 to 1.7) It happens when retrieving or persisting an entity with a String set: import java.util.HashSet; import java.util.Set; ... @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") public class DbAccount { @PrimaryKey @Persistent

Delete files from blobstore using file serving URL

房东的猫 提交于 2019-12-23 20:45:32
问题 In my app (GWT on GAE) we are storing on our database the serving URL that is stored on blobstore. When user selects one of these files and clicks "delete", we need to delete the file from blobstore. This is our code, but it is not deleting the file at all: public void remove(String fileURL) { BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); String key = getBlobKeyFromURL(fileURL); BlobKey blobKey = new BlobKey(key); blobstoreService.delete(blobKey); } Where