views:

113

answers:

2

I'm experiencing a critical problem with my App Engine datastore, and it seems to be completely immune to debugging: I'm unable to modify entities after constructing them.

The problem is even present when working from a console defined in app.yaml that does not share any code with my main application. Here's an example from the console:

>>> foo = Topic(name='bar')

>>> foo.name

'bar'

>>> foo.name = 'foo'

>>> foo.name

'bar'

This same behavior affects all entity kinds and all properties in the application. Whether the entity has been saved makes no difference.

I've tried going back to revs from days, weeks, and months ago, and the problem is still present, even though I would have definitely noticed it if it was actually around weeks and months ago, since it breaks the app logic. It is present on different machines running both Ubuntu and OSX, and it is also present on all app versions on production, and it is present on at least one other application I've tested. It's still present after wiping my SDK datastore, using a different port, flushing my memcache and taskqueue, reinstalling the SDK, and every other debugging trick I can think of in my desperation.

The one place that isn't affected is the administration console. The same sequence of code gets the expected result of a modified entity. Even after I import every module or class I can think of that might be causing trouble, the console still always works as expected. Another indication that there's nothing in my code that's causing this problem (and that I'm not going completely insane).

I'm fairly certain that as of a couple days ago, I could modify entities from within my app just as I can from the administration console. After all, immutable entities aren't very useful.

Some advice would be really, really appreciated. I'm afraid that this problem will prevent me from continuing development until I can get it fixed.

A: 

It's probably a stupid question, but are you calling .put() after modifying your entities? I can't really tell from your code example if your subsequent fetch of the property after setting it is supposed to be in the same session, or another one.

Also, can you please paste the relevant Model definition? And tell us if you're using any App-Engine specific libraries that may be interfering with your models.

Nick Johnson
The example is in the same session. As I mentioned, I can call put but it doesn't save the modified values. It's almost as if there's a 'magic' layer of caching that somehow appeared...but since I'm not much of a believer in magic, I'm going to continue to try to debug this. It might be the strangest App Engine bug/gotcha I've ever run into, because it just seems like black magic.
jamtoday
It would still be helpful to see the code involved. Also, have you tried reproducing a simplified example - eg, in the interactive console at /_ah/admin?
Nick Johnson
+1  A: 

What kind of console are you using? If it's derived from shell.appspot.com or similar, it is most likely that the console's saving and restoring globals at each >>> prompt is causing these pains.

If you use the interactive console at /_ah/admin/interactive (on by default in dev_appserver.py) please try putting all related code in the input window and executing it in one fell swoop; this will prevent any save/restore behavior from getting in the way of your experiments.