A previous version of the AppEngine docs claimed that key_name values
couldn't be numbers (or start with numbers). Perhaps that is related
to the year old bug you describe?
The current AppEngine docs have been revised (only the double
underscore case remains), and a quick test confirms that 'numeric'
key_name are allowed (as long as they are expressed as strings).
o = Model.get_by_id( 42 )
o = Model.get_by_key_name( '56' )
The source of the value doesn't matter (URL, whatever). The type does
matter.
o = Model.get_by_id( int( v ) )
o = Model.get_by_key_name( str( v ) )
Deciding which to use, from a mixed source (ids and key_names), can
still be tricky. :)
--
G
Ms. Jen wrote:
> Avoid casting for what? The number 1 or for an id?
>
> Are you saying that one should not be attempting to request a
> datastore ID from a URL? From a search of this and other groups, over
> a year ago there was a bug in getting by the ID, but it is not a bug
> anymore.
>
> If I take out the in(self.request.get('id')), then I get an error that
> says:
> BadValueError: Unsupported type for property : <type
> 'builtin_function_or_method'>
>
> Do you have another way that you prefer to pass an identifier in the
> URL path that then the identifier may be passed to the next datastore
> search? If so, please send link.
--
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.