The reference property contains the Key of the object referred to.
You can get this key with

key = MyModel.assigned.get_value_for_datastore(obj2)
obj1 = db.get(key)
if obj is None:
   pass  # invalid reference

Or you can put a "try: except" around the code and as such find out if
the object exist.

http://code.google.com/appengine/docs/python/datastore/propertyclass.html#Property_get_value_for_datastore

2009/8/18 Joshua Smith <[email protected]>:
>
> I have a bunch of objects that reference other objects that were
> deleted.
>
> This document:
>
> http://code.google.com/appengine/docs/python/datastore/entitiesandmodels.html
>
> Says I can test for this case using:
>
> obj1 = obj2.reference
>
> if not obj1:
>  # Referenced entity was deleted.
>
> However, when I try this, I get:
>
> Traceback (most recent call last):
>  File "/base/python_lib/versions/1/google/appengine/ext/webapp/
> __init__.py", line 507, in __call__
>    handler.get(*groups)
>  File "/base/data/home/apps/mesonissue/2.335707029305139999/main.py",
> line 216, in get
>    obj = r.assigned
>  File "/base/python_lib/versions/1/google/appengine/ext/db/
> __init__.py", line 2704, in __get__
>    raise Error('ReferenceProperty failed to be resolved')
> Error: ReferenceProperty failed to be resolved
>
> So apparently, this documentation is wrong.  Other places say that I
> should use db.get() to test for the object being there, but I cannot
> figure out what I'm supposed to pass to db.get().  If I pass db.get
> (obj2.reference) then I get that same exception.
>
> Help?
> >
>

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