In general, if you want to do something Only Once per user, like your
thread title says, you need to use transactions, else you risk doing
the thing twice.  Right now, your code looks like it could be creating
more than one entity in the database for the same nickname.  Have you
looked in your datastore to see if that's happening?  Or maybe just
adding something like
if result.count() > 1:
   raise DuplicateNickException

I have a feeling this will help:
http://code.google.com/appengine/docs/datastore/modelclass.html#Model_get_or_insert

Also check out the last section of this page:
http://code.google.com/appengine/docs/datastore/transactions.html


On Sep 26, 9:08 pm, fedekun <[EMAIL PROTECTED]> wrote:
> Hi, i want to save some settings for each user, and the way i'm doing it so
> far is
>
> title = self.request.get("title")
>
> result = UsersSettings.gql("WHERE owner=:1",
> users.get_current_user().nickname())
> if result.count() == 0:
>         result = UsersSettings()
>
> result.title = title
> result.owner = users.get_current_user().nickname()
>
> db.put(result)
>
> What i want to do is create it if it doesnt exists or else modify it, but i
> cant figure out why it does not modify it, it creates it but i cannot modify
> it :(
> --
> Best Regards.
> fedekun
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to