fix: Preemptively fix API change in NDB. (#7361)

Glockenspiel broke due to 'query' now being required within a client context.  This change fixed Glockenspiel.  Blockly samples doesn't appear to be broken yet, but Glokenspeil broke at midnight yesterday.

Similar change being made to Blockly Games.
This commit is contained in:
Neil Fraser
2023-08-07 20:22:21 +02:00
committed by GitHub
parent 2a2b3b3ac5
commit 826510f242

View File

@@ -44,9 +44,9 @@ def xmlToKey(xml_content):
# Store XML and return a generated key.
xml_hash = int(hashlib.sha1(xml_content.encode("utf-8")).hexdigest(), 16)
xml_hash = int(xml_hash % (2 ** 64) - (2 ** 63))
lookup_query = Xml.query(Xml.xml_hash == xml_hash)
client = ndb.Client()
with client.context():
lookup_query = Xml.query(Xml.xml_hash == xml_hash)
lookup_result = lookup_query.get()
if lookup_result:
xml_key = lookup_result.key.string_id()