Instead of changing db.Key's str encoding, one could change db.Key's
__cmp__(self, o) returned cmp(str(self), str(o)). This wouldn't break
any string keys in the wild or user code (which can't depend on how
db.Key.__cmp__ works anyway, just that it does). However, I don't
know if Google's intern
it's definitely possible to come up with a string encoding that
matches the internal key ordering. a naive encoding with the path
elements separated by slashes would work, e.g.:
/Blog/My Blog/Post/My first post/Comment/3
where Blog, Post, and Comment are kinds, My Blog and My first post are
key
not sure if this helps, but here is the __str__ method for Key
if (self.has_id_or_name()):
encoded = base64.urlsafe_b64encode(self.__reference.Encode())
return encoded.replace('=', '')
else:
raise datastore_errors.BadKeyError(
'Cannot string encode an incomplete
Argh!
Is there any reason why they can't be made consistent? (There don't
seem to be any user-visible guarantees on how key comparisons work.)
On Oct 25, 10:27 pm, ryan <[EMAIL PROTECTED]> wrote:
> hi andy! the sort orders of Keys and their string encodings are very
> similar, but they're not g
hi andy! the sort orders of Keys and their string encodings are very
similar, but they're not guaranteed to be consistent, no.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this