Hey Colin,

I've been using this:

def key_to_path(model):
    key = model.key()
    output = []

    while key:
        name = key.name()
        if name is None:
            output.append(key.id())
        else:
            output.append(name)

        output.append(key.kind())
        key = key.parent()

    output.reverse()
    return output


2009/5/26 Nick Johnson (Google) <nick.john...@google.com>:
>
> Hi Colin,
>
> You're correct - there's currently no built-in method to do this, and
> recursively (or iteratively, with a stack) calling key.parent() is
> your best option.
>
> -Nick Johnson
>
> On Mon, May 25, 2009 at 3:17 AM, hawkett <hawk...@gmail.com> wrote:
>>
>> Hi,
>>
>>   There is a method Key.from_path() - which lets you supply the path
>> to construct the key.  Is there a way to retrieve the path from a key
>> object? i.e. Key.path()?  If not, is there a way to determine the path
>> from the key?  Is recursively calling Key.parent() until you get
>> 'None' the only way to do this?  It would be nice to make a single
>> call to get a list of the keys to the parent.
>>
>>   Thanks,
>>
>> Colin
>>
>
> >
>



-- 
It is better to be wrong than to be vague.
  — Freeman Dyson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to