Thanks, Nick. You are right. I ran into some issues, which i tracked it down to the key call but then I ended up testing the keys using values '123' etc... So the BadKeyError is from my bad key request and not unavailable key.
On May 13, 3:46 am, "Nick Johnson (Google)" <[email protected]> wrote: > Hi ecognium, > > Model.get does not return BadKeyError when attempting to fetch an > entity that does not exist - it returns None, as documented. > BadKeyError is raised when the key itself is invalid, because it lacks > a name or id, or has an invalid name. You probably want to check that > you're not generating invalid keys - such as one with a name that > starts with a digit. > > -Nick Johnson > > On Wed, May 13, 2009 at 9:55 AM, ecognium <[email protected]> wrote: > > > Hello Everyone, > > It looks like Model.get(keys) raises an exception (BadKeyError) > > when the key does not exist even though it is not mentioned here > >http://code.google.com/appengine/docs/python/datastore/modelclass.htm.... > > > On the other hand, Model.get_key_by_name(names) just returns None for > > the keys that do not exist. If I understand it correctly keys and > > key_names are not the same - i.e., i cannot use a key value inside the > > get_by_key_name() call.. so how can i get data using key without > > having to worry about determining which specific key was not valid? > > > I can create my own key names but I would like to use the default > > uniqueness guarantee of the keys. If there is no easy way to deal with > > this exception, is there an easy way to make the key_name same as the > > key value provided by default? > > > In case you are wondering why the keys will be invalid: I am allowing > > the users to bookmark certain objects.. so i store the key names in > > the user prefs data... If the object referenced gets deleted then the > > key information stored inside the userprefs will be outdated and when > > they query for their bookmarks, it causes an issue.. I wanted to avoid > > the whole process of going through every single user who may be using > > the deleted key and remove it real-time. so i thought i will just > > handle it as a batch job... > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
