Thanks :-)

I'll try that

Cheers
Tonny

On 12 Okt., 13:21, Rodrigo Moraes <[email protected]> wrote:
> On Mon, Oct 12, 2009 at 4:45 AM, Tonny wrote:
> > in. I could write my own ReferenceProperty from scratch, subclassing
> > Property, but I would also like a simple
> > solution where I didn't reinvent all ready existing functionality.
>
> ignore my previous post. here's a solution that does exactly what your
> looking for. add this method to your model:
>
> def get_key_name_from_reference_property(self, prop_name):
>     key = getattr(self.__class__, prop_name).get_value_for_datastore(self)
>    return db.Key(key).key_name()
>
> then, you simply call it passing the ReferenceProperty name.
>
> class MyModel(db.Model):
>     some_other_entity = db.ReferenceProperty()
>
> entity = MyModel.get(...)
> referenced_key_name =
> entity.get_key_name_from_reference_property('some_other_entity')
>
> that's it.
>
> -- rodrigo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to