Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:46:53+00:00 2026-06-12T10:46:53+00:00

I am using Python2.7, GAE and High Replication datastore. I am trying to perform

  • 0

I am using Python2.7, GAE and High Replication datastore.
I am trying to perform a transaction that first writes an entity and then reads it but the reading never finds the entity. This is a testcase I have:

class DemoTestCase(unittest.TestCase):
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
    self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)

  def tearDown(self):
    self.testbed.deactivate()

  def test1(self):
    db.run_in_transaction(self._write)
    db.run_in_transaction(self._read)

  def test2(self):
    db.run_in_transaction(self._write_read)

  def _write(self):
    self.root_key = db.Key.from_path("A", "root")
    a             = A(a=1, parent=self.root_key)
    self.a_key    = a.put()

  def _read(self):
    b = sample.read_a(self.a_key)
    self.assertEqual(1, b.a)
    self.assertEqual(1, A.all().ancestor(self.root_key).count(5))

  def _write_read(self):
    root_key = db.Key.from_path("A", "root")
    a     = A(a=1, parent=root_key)
    a_key = a.put()
    b     = sample.read_a(a_key)
    self.assertEqual(None, b)
    self.assertEqual(0, A.all().ancestor(root_key).count(5))

Both testcases are passing now.

Test1 is running a transaction which performs a write. Then it’s running a second transaction that performs two reads, one by key and one by ancestor-query. Reads work just fine in this case.

Test2 is running exactly the same code as test1, but this time everything gets run inside the same transaction. As you can see, reading the entity by key returns None. Doing a ancestor query returns 0 hits.

My question is: how can I, inside a transaction, read an entity that I just wrote? Or is this not possible?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:46:54+00:00Added an answer on June 12, 2026 at 10:46 am

    Well, sometimes it’s really helpful to re-read. A business rule may be triggered by the entity update and will need to reload it. BRs often are not aware of what triggered them and won’t have immediate access to the new entity.

    Don’t know for Python but, in Java using Objectify, updates are made visible while in the transaction by Objectify session (transaction) cache. If there’s something like a session cache in the Python persistence framework you are using, that may be a solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop a GAE application using python, but I fear that Google
I'm using GAE with python and I came across this problem, I'm trying to
I'm trying to learn GUI programming using python2 and GTKBuilder, but I get a
how do I return the entity ID using python in GAE? Assuming I have
I am trying to create a simple web app using Python on GAE. The
I am trying to build an application in GAE using python. I needs to
I'm using Python and GAE, and I'm trying to create a dictionary with keys
Overnight hack, trying to create an environment where GAE code (using Python libs/packages) could
Is it possible to somehow enable editing lists in GAE datastore viewer? I'm using
I have a python GAE app that sends emails like in the example using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.