Newly added record in datastore is not refelcting in the application

I have been facing this problem in app engine. As I am new to App Engine, I don't know whether I am doing it right way or not.

Whenever a new record is inserted into datastore, this newly inserted record doesn't reflect in the application. It will appear only after next reload.

This is the simple code: Adding a user and just printing all users from the User table:

def add_user(name):
    u = User(name = name)
    u.put()
    all_users = [u.name for u in User.all().order('name')]
    #On printing 'all_users', it doesn't show recently added user

Is this the common behaviour in App Engine. Does it take time to add new record in datastore? Is there anything wrong in the way record is inserted? Please help..

Answers


You should never consider using sleep.

What you are seeing is "eventual consistency" in the HRD. Have a read of "Structuring Data for Strong Consistency" https://developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency which describes strategies for making strongly consistent queries.

As an aside, if you have just put() a user entity, you don't need to query for it, you already have it.


Need Your Help

why is margin top not working on div?

html css twitter-bootstrap

I am getting my head around bootstrap. At the moment struggling to get the margin on the bottom of the comboboxes group working this is the css:

Where to put business logic? Domain model and unit testing

unit-testing design-patterns design domain-driven-design strategy-pattern

I am developing an application (C#) which calculates the cost of a complex system. This system consists of many parts (and sub-parts) and each part may have different calculation algorithms. Initia...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.