google-cloud-datastore

What is the datasetId for Google Cloud Datastore JSON API

南笙酒味 提交于 2019-12-02 19:15:02
问题 As mentioned in this post, the datasetId is the name of the cloud project. It is working fine, if my project has a name like " project-name ". In my case, the project name is " domainName.com:project-name ". In this case what is datasetId . I tried with domain and removing the domain name, no luck. 回答1: The Cloud Datastore API is not currently supported for projects whose name begins with a domain/colon (e.g. "example.com:project"), but we plan to support this in the next version of the API.

In Google DataStore GQL, how can I group the WHERE terms?

荒凉一梦 提交于 2019-12-02 19:09:44
问题 I need to group terms in the WHERE clause. For example, WHERE (param1='foo1' OR param1='foo2') AND (param2='bar1' OR param2='bar2') But it's giving me a syntax error saying that the parentheses are "unexpected". The actual error is: GQL query error: Encountered "(" at line 1, column 29. Was expecting one of: "false", "null", "true", <INTEGER>, <DOUBLE>, <SINGLE_QUOTE_STRING>, <DOUBLE_QUOTE_STRING>, <UNQUOTED_NAME>, <QUOTED_NAME>, <NAME_BINDING_SITE>, <POSITION_BINDING_SITE> So, is there any

Appengine filter inequality and ordering fails

陌路散爱 提交于 2019-12-02 19:02:38
I think I'm overlooking something simple here, I can't imagine this is impossible to do. I want to filter by a datetime attribute and then order the result by a ranking integer attribute. When I try to do this: query.filter("submitted >=" thisweek).order("ranking") I get the following: BadArgumentError: First ordering property must be the same as inequality filter property, if specified for this query; received ranking, expected submitted Huh? What am I missing? Thanks. The datastore isn't capable of ordering a query that contains an inequality by any property other than the one used in the

Custom keys for Google App Engine models (Python)

蓝咒 提交于 2019-12-02 17:19:22
First off, I'm relatively new to Google App Engine, so I'm probably doing something silly. Say I've got a model Foo: class Foo(db.Model): name = db.StringProperty() I want to use name as a unique key for every Foo object. How is this done? When I want to get a specific Foo object, I currently query the datastore for all Foo objects with the target unique name, but queries are slow (plus it's a pain to ensure that name is unique when each new Foo is created). There's got to be a better way to do this! Thanks. I've used the code below in a project before. It will work as long as the field on

Checking uniqueness contraint during form validation in App Engine

拜拜、爱过 提交于 2019-12-02 17:05:25
问题 I am using Flask and WTforms in App Engine, trying to implement uniqueness contraint on one of the field. The question is big, please be patient and I have been stuck here from many hours, need some help from you people. Started learning App Engine, Flask and WTForms a month ago. Thanks in advance. Application has model 'Team' as shown below: class Team(db.Model): name = db.StringProperty(required=True) -- some other fields here -- Requirement: Name of the team has to be unique. I have

jQuery Autocomplete with Remote JSON Source + Google App Engine + Python

假如想象 提交于 2019-12-02 17:04:36
问题 So let's say I have a webapp which just lets users save their hobbies. So I have Kind like this: class Hobby(ndb.Model): hobby_name = ndb.StringProperty() Users just create Hobby entities using this form: <form action="/new-hobby" method="post"> <input type="text" name="hobby_name" id="new-hobby" /> <input type="submit" value="Save New Hobby" /> </form> Then this form is handled by this: # Handles /new-hobby class NewHobby(webapp2.RequestHandler): def post(self): hobby_name = self.request.get

Cloud Datastore: ways to avoid race conditions

老子叫甜甜 提交于 2019-12-02 17:02:34
问题 I have lots of views manipulating entities of same kind: def view1(request, key): user = ndb.Key(urlsafe=key).get() user.x = 1 user.put() ... def view2(request, key): user = ndb.Key(urlsafe=key).get() user.y = 2 user.put() ... Obviously, this is error-prone due to possible race conditions (last wins): view1 reads whole user entity data (x=None, y=None) view2 reads whole user entity data (x=None, y=None) view1 user.x = 1 (x=1, y=None) view2 user.y = 2 (x=None, y=2) view1 user.put() (x=1, y

google datastore token not authorized?

一笑奈何 提交于 2019-12-02 16:50:19
问题 jwt1=`echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e` jwt2=`echo -n '{\ "iss":"...@developer.gserviceaccount.com",\ "scope":"https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/datastore",\ "aud":"https://accounts.google.com/o/oauth2/token",\ "exp":'$(($(date +%s)+3600))',\ "iat":'$(date +%s)'}' | openssl base64 -e` jwt3=`echo -n "$jwt1.$jwt2" | tr -d '\n' | tr -d '=' | tr '/+' '_-'` jwt4=`echo -n "$jwt3" | openssl sha -sha256 -sign google.p12 | openssl

How to model a unique constraint in GAE ndb

笑着哭i 提交于 2019-12-02 16:23:25
问题 I want to have several "bundles" (Mjbundle), which essentially are bundles of questions (Mjquestion). The Mjquestion has an integer "index" property which needs to be unique, but it should only be unique within the bundle containing it. I'm not sure how to model something like this properly, I try to do it using a structured (repeating) property below, but there is yet nothing actually constraining the uniqueness of the Mjquestion indexes. What is a better/normal/correct way of doing this?

Linking to entity from list

社会主义新天地 提交于 2019-12-02 14:09:57
问题 I have a Consults page that lists consults in the datastore. The list loop is like this: {% for consult in consults %} <tr> <td><a href="consults/#">{{ consult.consult_date }}</a></td> <td>{{ consult.consult_time }}</td> <td>{{ consult.patient_first }}</td> <td>{{ consult.patient_last }}</td> <td><span class="badge badge-warning">{{ consult.consult_status }}</span></td> </tr> {%endfor%} The handler is like this: class ConsultsPage(webapp2.RequestHandler): def get(self): consults = Consults