9 messages in com.googlegroups.google-appengine[google-appengine] Re: weirdness with...
FromSent OnAttachments
theo27 Apr 2008 01:57 
palp27 Apr 2008 03:31 
Jflesch27 Apr 2008 18:49 
Jflesch27 Apr 2008 18:51 
theo27 Apr 2008 22:07 
Jerome Flesch27 Apr 2008 22:20 
theo27 Apr 2008 22:21 
Jerome Flesch27 Apr 2008 22:36 
Marce28 Apr 2008 10:17 
Subject:[google-appengine] Re: weirdness with the datastore
From:theo (theo@gmail.com)
Date:04/27/2008 10:21:59 PM
List:com.googlegroups.google-appengine

And now... all of a sudden, magically, the problem is fixed.

I feel like appengine is undergoing changes behind the scenes and there isn't good communication between Google and developers. I understand that this is a free product and I am grateful to Google for providing it. A simply "we are upgrading appengine, so trust your dev server" message would go a really long way. Or, conversely, "dev server isn't perfect. If there is a conflict, it's probably because dev server is buggy".

That's the really wierd thing.

Game.gql("").count() returns the correct answer.  It seems like it is only when I restrict the search that I get errors.

On Apr 27, 6:51 pm, Jflesch <jfle@gmail.com> wrote:

I forgot to specify an example URL where it fails
:http://le-carton.appspot.com/user/jflesch<-- there should be an item here.

Actually, I have a similar problem when I use filter("user =", user"). It's a permanent problem (not just when I do an insert and count() just after). On the dev server it works perfectly, but once deployed, it always returns no result. You can try it by yourself if you want, my app is
here:http://le-carton.appspot.com/

The code behind is approximately:

### model.py:  class Nickname(db.Model):     nick = db.StringProperty(required = True)     user = db.UserProperty()

class Ad(db.Model):     title = db.StringProperty(required = True)     description = db.TextProperty(required = True)     price = db.FloatProperty(required = True)     currency = db.StringProperty(required = True, choices = set(CURRENCIES))     country = db.StringProperty(required = True, choices = set(COUNTRIES))     creation = db.DateTimeProperty(auto_now = False, auto_now_add = True)     lastModif = db.DateTimeProperty(auto_now = True, auto_now_add = True)     owner = db.UserProperty(required = True)     visible = db.BooleanProperty(required = True) # default = true, set to false the item is sold     photo = db.ReferenceProperty() # reference to photo     tags = db.ListProperty(db.Key, default = [])     keywords = db.ListProperty(unicode, default = []) # include tags and words from title and description

### core.py

class UserHandler(tools.BasicHandler):   def get(self):     self.init()

    # Extract the nick from the user from the URL     user_nick = cgi.escape(self.request.path.split("/")[-1])

    nick_entry = model.Nickname.all().filter("nick =", user_nick).get()

    if not nick_entry:       return self.notFound()

    # I always get the nick_entry as expected

    target_user = nick_entry.user

    ads_select = model.Ad.all().filter("owner = ", target_user)     ads_select = ads_select.filter("visible =", True)

    count = ads_select.count()

    ads_select = ads_select.order(self.define_order(self.request))     ads = ads_select.fetch((page+1)*model.ADS_PER_PAGE, page*model.ADS_PER_PAGE)

    self.template_values["ads"] = ads     tools.prepare_ads(self.template_values["ads"])

    # [...]

It may be a mistake in my code, but then, why does it work on the dev server and not once deployed ? Do you think it's worth to do a bug report ?

On 27 avr, 03:31, palp <palp@gmail.com> wrote:

If I had to guess, I'd say you may not be able to count on data you write to the datastore being replicated quickly enough for an immediate read to reflect it.  Since it's clustered, the read may be hitting a different node than the write.

I can say in practice, I've never seen this kind of behavior - of course a real world app will rarely write data then immediately read it.

On Apr 27, 4:58 am, theo <theo@gmail.com> wrote:

I'm running into some serious wierdness related to the datastore.  As a side all this code works properly on the dev server.

if I run the following code:

game = Game() game.owner = user game.put()

game_num = Game.gql("WHERE owner = :1", user).count()

self.response.out.write("game_num: %i" % game_num)

I get the following output:

game_num: 0

On the dev server, I'd get the correct number.  What is going on?