ok, I think I found the problem. Looks like get_or_insert is failing
when there are no entities existing for a model.
# Models
class TestModel(db.Model):
testval = db.StringProperty()
class TestModel2(db.Model):
testval = db.StringProperty()
# First test
def runtest(request):
from fanatasticweb.models import TestModel
from fanatasticweb.models import TestModel2
test1 = TestModel()
test1.testval = "Test put 1"
test1.put()
test2 = TestModel()
test2.testval = "Test put 2"
test2.put()
TestModel().get_or_insert("goi_test", testval="get_or_insert
test")
TestModel2().get_or_insert("goi_test2", testval="get_or_insert
test 2")
return HttpResponse("Test run, check TestModel in data viewer.")
In the SDK, everything works as you would expect.
On the production site, I'm not getting the TestModel2 data.
I also tried a reload of my test, thinking it might be a case where if
the first model already had entities it would create the second model
entries, but it still did not.
# Second test
def runtest(request):
from fanatasticweb.models import TestModel
from fanatasticweb.models import TestModel2
test1 = TestModel()
test1.testval = "Test put 1"
test1.put()
test2 = TestModel()
test2.testval = "Test put 2"
test2.put()
TestModel().get_or_insert("goi_test", testval="get_or_insert
test")
test4 = TestModel2()
test4.testval = "TestModel2 with a put first"
test4.put()
TestModel2().get_or_insert("goi_test2", testval="get_or_insert
test 2")
return HttpResponse("Test run, check TestModel in data viewer.")
On this test (where I do a put() to get data instantiated in
TestModel2 first), everything works as expected, all data is added.
Hope this helps.
On Dec 17, 8:44 pm, "[email protected]"
<[email protected]> wrote:
> Here's the actual code block.
>
> def save(self, request):
> from django.contrib import auth
> userKey = request.session["_auth_user_id"]
> new_user = db.get(request.session["_auth_user_id"])
> new_user.username = self.cleaned_data['username']
> new_user.is_active = True
> new_user.put()
>
> self.teams = []
> for field in self.cleaned_data:
> if field is not 'username':
> if self.cleaned_data[field]:
> myteam = FavoriteTeams(user = new_user, team =
> field)
> myteam.put()
> self.teams.append(field)
> result = FavoriteTeamsRanking.get_or_insert("teams",
> json=simplejson.dumps({'teams': {}}))
>
> -----------------------------
> the new_user.put()
> -----------------------------
>
> is going through
>
> -----------------------------
> result = FavoriteTeamsRanking.get_or_insert("teams",
> json=simplejson.dumps({'teams': {}}))
> -----------------------------
>
> result is coming back as a None value
>
> In the 1.1.7 SDK it is working correctly. The FavoriteTeamsRanking is
> not getting populated at all on the live site, and the only thing I
> can think of at first is that it's the second instance of a put in the
> request. However, I suppose get_or_insert can be broken? I've just run
> into this within the past 10 minutes and was hitting the groups for
> ideas of things to look at and saw this new post which seemed like it
> could be similar.
>
> I'm going to try and set up a test to see if I can track down what's
> going on a bit better and will post the test and results in a few
> minutes.
>
> On Dec 17, 8:33 pm, Marzia Niccolai <[email protected]> wrote:
>
> > Hi,
>
> > Today we made some changes to the production system, but did not anticipate
> > this having any effect on application's running with App Engine. The
> > solution for Gary's issue is the one he suggested, but Joseph, I was
> > wondering if you could elaborate more on the scenario you are experiencing?
>
> > Also, please know that we are working to reduce the impact that such changes
> > will have on applications, and thanks for all your patience while we look in
> > to the issues here.
>
> > -Marzia
>
> > On Wed, Dec 17, 2008 at 5:28 PM, [email protected] <
>
> > [email protected]> wrote:
>
> > > I'm noticing on my app, requests where I have multiple puts only
> > > appear to be doing the initial put, and not the following ones. Not
> > > sure if this is the same issue you are running into, but this is new
> > > as the functionality did exist before. Though, it does seem to
> > > possibly be working for other apps, so I'm not sure what's going on. I
> > > verified this by checking a get_or_insert after another put had been
> > > done, and it's not creating the data and also returning as a None
> > > value.
>
> > > On Dec 17, 7:27 pm, Garrett Davis <[email protected]> wrote:
> > > > Say, did someone make a change to the 'cloud' version of the
> > > > ModelForms module?
>
> > > > Several of my applications, which had been running on the 'cloud' for
> > > > months, had a reference to a UserProperty class defined in
> > > > google.appengine.ext.db.djangoforms
> > > > and they started crashing today, with an error message that said,
> > > > <type 'exceptions.AttributeError'>: 'module' object has no attribute
> > > > 'UserProperty'
>
> > > > I changed the references in my applications,
> > > > from the 'modelforms' module to another UserProperty class defined in
> > > > google.appengine.ext.db
> > > > and my applications are working again.
>
> > > > But I worry about the concept that the GAE infrastructure is subject
> > > > to un-announced changes that might again crash my applications.
>
> > > > Or did I miss an announcement or something?
> > > > Garrett Davis
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---