Actually, what I meant was:

I cannot have an entity with both key_name and id.

They seem to be mutually exclusive for an entity.

2009/6/23 Ian Lewis <ianmle...@gmail.com>:
> Ritesh,
>
> Also, BTW, The reason that obj1 and obj2 can have different types of keys is
> because the key is not saved on a model level. It is saved at the entity
> level. Each entity can have id or key_names.
>
> Apparently obj2 was saved without a key name and was given a numeric key.
> obj1 was saved with a key_name.
>
> So to answer your question, yes, within a model/Kind you can have some
> entities that have a numeric id and some that have key names.
>
> Ian
>
> 2009/6/24 Ian Lewis <ianmle...@gmail.com>
>>
>> Ritesh,
>>
>> Keys can either have a numeric id or a key_name. In order to access the
>> key name for entities that you saved with a key_name you need to use the
>> key_name() method.
>>
>> instead of obj.key().id(),  try obj.key().name()
>>
>> Incedentally you can also use obj.key().id_or_name() to get either the id
>> or the name depending on which you are using.
>>
>> On Wed, Jun 24, 2009 at 3:08 PM, Ritesh Nadhani <rite...@gmail.com> wrote:
>>>
>>> Hi
>>>
>>> When I save a model with (key_name=...) value, the key does not seem
>>> to have an id.
>>>
>>> Eg.
>>>
>>> Mode1(key_name='xxx').put()
>>>
>>> obj.key().id() - None
>>>
>>> Model2()
>>>
>>> obj2.key().id() - 1
>>>
>>> Is this intented?
>>>
>>> Can I have both key_name and id in a mode?
>>>
>>> --
>>> Ritesh
>>> http://www.riteshn.com
>>>
>>>
>>
>>
>>
>> --
>> =======================================
>> 株式会社ビープラウド  イアン・ルイス
>> 〒150-0012
>> 東京都渋谷区広尾1-11-2アイオス広尾ビル604
>> email: ianmle...@beproud.jp
>> TEL:03-5795-2707
>> FAX:03-5795-2708
>> http://www.beproud.jp/
>> =======================================
>
>
>
> --
> =======================================
> 株式会社ビープラウド  イアン・ルイス
> 〒150-0012
> 東京都渋谷区広尾1-11-2アイオス広尾ビル604
> email: ianmle...@beproud.jp
> TEL:03-5795-2707
> FAX:03-5795-2708
> http://www.beproud.jp/
> =======================================
>
> >
>



-- 
Ritesh
http://www.riteshn.com

--~--~---------~--~----~------------~-------~--~----~
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