I'd try taking my example on as a demo application. Some differences
are
1. You example below you to a put in TestModelB before the
get_or_insert. I believe in my example I found that this would work.
2. Everything in my example is happening in one request, whereas the
shell I believe you're ending up with each put/get_or_insert happening
per request. Not sure why that would matter, but I'm not fluent in the
internals, and any testing and research I can do is on the SDK, where
everything works correctly anyhow.
I did do my own test using the appshell, and my results were that it
worked correctly in that instance as well.
>>> class JoeTest1(db.Model):
testval = db.StringProperty()
>>> class JoeTest2(db.Model):
testval = db.StringProperty()
>>> list(JoeTest1.all())
[]
>>> list(JoeTest2.all())
[]
>>> test1 = JoeTest1(testval = "test1")
>>> test1.put()
datastore_types.Key.from_path('JoeTest1', 72664L, _app=u'shell')
>>> test2 = JoeTest2.get_or_insert("x", testval = "get_or_insert test")
>>> list(JoeTest1.all())
[<__main__.JoeTest1 object at 0xdee1f6793dad2940>]
>>> list(JoeTest2.all())
[<__main__.JoeTest2 object at 0xb82607baa49b66c0>]
>>> JoeTest1.all().get().key().name()
>>> JoeTest2.all().get().key().name()
u'x'
On Dec 18, 1:30 pm, ryan <[email protected]> wrote:
> true. i was cheating because i know the datastore internals, so i know
> what's relevant to problems like these and what isn't. Model vs.
> Expando, for example, generally isn't relevant.
>
> still, following your code much more closely,http://shell.appspot.com/
> still doesn't reproduce this. odd.
>
> >>> class TestModelA(db.Model):
>
> testval = db.StringProperty()>>> class TestModelB(db.Model):
>
> testval = db.StringProperty()>>> list(TestModelA.all())
> []
> >>> list(TestModelB.all())
> []
> >>> test1 = TestModelA(testval = "Test put 1")
> >>> test1.put()
>
> datastore_types.Key.from_path('TestModelA', 72663L, _app=u'shell')>>> test2 =
> TestModelB(testval = "Test put 2")
> >>> test2.put()
>
> datastore_types.Key.from_path('TestModelB', 73462L, _app=u'shell')>>>
> TestModelA().get_or_insert("goi_test", testval="get_or_insert test")
>
> <__main__.TestModelA object at 0x4a9988195796e710>>>>
> TestModelB().get_or_insert("goi_test2", testval="get_or_insert test 2")
>
> <__main__.TestModelB object at 0x386035de932ed718>>>> list(TestModelA.all())
>
> [<__main__.TestModelA object at 0xbad1185da0f83490>,
> <__main__.TestModelA object at 0xbad1185da0f83550>]>>> list(TestModelB.all())
>
> [<__main__.TestModelB object at 0x4a9988195796e3d0>,
> <__main__.TestModelB object at 0x4a9988195796e290>]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---