google-cloud-datastore

How to read old property values in a _pre_put_hook

送分小仙女□ 提交于 2019-12-05 03:04:39
I am trying to implement an ndb model audit so that all changes to properties are stored within each model instance. Here is the code of the _pre_put_hook I chose to implement that. def _pre_put_hook(self): # save a history record for updates if not (self.key is None or self.key.id() is None): old_object = self.key.get(use_cache=True) for attr in dir(self): if not callable(getattr(self, attr)) and not attr.startswith("_"): if getattr(self, attr) != getattr(old_object, attr): logging.debug('UPDATE: {0}'.format(attr)) logging.debug('OLD: {0} NEW: {1}'.format(getattr(old_object, attr), getattr

ORM for google cloud datastore

半城伤御伤魂 提交于 2019-12-05 01:29:40
问题 https://developers.google.com/datastore/docs/overview It looks like datastore in GAE but without ORM (object relation model). May I used the same ORM model as datastore on GAE for Cloud Datastore? or Is there any ORM support can be found for Cloud Datastore? 回答1: Google Cloud Datastore only provides a low-level API (proto and json) to send datastore RPCs. NDB and similar higher level libraries could be adapted to use a lower level wrapper like googledatastore (reference) instead of google

Google App Engine Java: how to remove unused indexes?

守給你的承諾、 提交于 2019-12-05 01:15:43
问题 If I found information about removing unused indexes, like in Uploading and Managing a Python App / Deleting Unused Indexes, it was only for the Python environment... Any way to tag an index in the [~project]/war/WEB-INF/datastore-indexes.xml file? 回答1: Since version 1.4.2 the Java SDK supports the vacuum_indexes action. Run this command to delete unused indices: ./<appengine-java-sdk-path>/bin/appcfg.sh vacuum_indexes <myapp-path>/war On Windows with the Eclipse SDK it's something like:

How to fix error: A project ID is required for this service but could not be determined

青春壹個敷衍的年華 提交于 2019-12-04 23:32:11
问题 I'm trying to insert data to Google Datastore from AppEngine and I'm getting an error: java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment. Please set a project ID using the builder. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:92) at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:324) at com.google.cloud.datastore.DatastoreOptions.<init>(DatastoreOptions.java:85)

Golang GAE - intID in struct for mustache

怎甘沉沦 提交于 2019-12-04 22:28:20
问题 Here is an Example of the app. The essential code is in: golang-code/handler/handler.go (After the subject should appear an ID!) Im trying to build a little blog system in Golang on Google Appengine and use Mustache as template engine. So, i have a struct: type Blogposts struct { PostTitle string PostPreview string Content string Creator string Date time.Time } The data is passed to GAE via datastore.Put(c, datastore.NewIncompleteKey(c, "Blogposts", nil), &blogposts) So, GAE assigns

Google app engine excessive small datastore operations

拟墨画扇 提交于 2019-12-04 22:28:15
问题 I'm having some trouble with the google app engine datastore. Ever since the new pricing model was introduced, the cost of running my app has increased massively. The culprit appears to be "Datastore small operations", which come in at more than 20 Million ops per day! Has anyone had this problem, I don't think I'm doing an excessive amount of key lookups, and I only have 5000 users, with roughly 10 - 20 requests per minute. Thanks in advance! Edit Ok got some stats, these are after abut 3

How can i recover Blobs after migration to HRD

眉间皱痕 提交于 2019-12-04 21:46:34
I just migrated to HRD and now its telling me i cant access my own blobs... Uncaught exception from servlet java.lang.SecurityException: This application does not have access to that blob. at com.google.appengine.api.blobstore.BlobstoreServiceImpl.fetchData(BlobstoreServiceImpl.java:200) at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.checkBlobKeyExists(ServeBlobsServlet.java:100) at com.droidastic.telljokes.server.servlet.ServeBlobsServlet.doGet(ServeBlobsServlet.java:64) I stored the keys as a string inside the datastore entities and then i create them like this: BlobKey key =

Datastore list of lists

筅森魡賤 提交于 2019-12-04 20:17:07
I need to make a list property that will contain lists, something like: db.ListProperty(list(str)) I know list(str) is not a supported value type so as I imagined I received a "ValueError" exception. Thought maybe there is a creative idea out there of how to overcome this :) Thanks! You could use pickle to serialize your list and store it in a BlobProperty field. Expanding on Adam's suggestion, you can push the pickling into its own Property class. Here is an example that handles validation, and converting the provided list into and out of a Blob type. The provided list can contain any data

Duplicate entries in High Replication Datastore

可紊 提交于 2019-12-04 20:03:14
We still have a rare case of duplicate entries when this POST method is called. I had asked for advice previously on Stack overflow and was given a solution , that is utilising the parent/child methodology to retain strongly consistent queries. I have migrated all data into that form and let it run for another 3 months. However the problem was never solved. The problem is right here with this conditional if recordsdb.count() == 1: It should be true in order to update the entry, but instead HRD might not always find the latest entry and creates a new entry instead. As you can see, we are

Custom properties not saved correctly for Expando models in repeated StructuredProperty

丶灬走出姿态 提交于 2019-12-04 19:00:46
I am trying to use an Expando model as a repeated StructuredProperty in another model. Namely, I would like to add an indefinite number of Accounts to my User model. As Accounts can have different properties depending on their types ( Accounts are references to social network accounts, and for example Twitter requires more information than Facebook for its OAuth process), I have designed my Account model as an Expando . I've added all basic information in the model definition, but I plan to add custom properties for specific social networks (e.g., a specific access_token_secret property for