I just noticed the language-specific forum announcement. I will repost
in the python specific forum.

Sorry!

On Aug 3, 10:10 pm, Ben from He3 <[email protected]> wrote:
> Hi. I am new to Google App Engine so excuse what might be a question
> with an easy answer.
>
> I am trying to understand the 'best' way to handle a situation in my
> application where I have a many-to-one relationship created with a
> ReferenceProperty. When I delete the 'one' side of the relationship
> (the one without the ReferenceProperty) I am left with a lot of
> invalid references in the Many side of the relationship (the one
> without the relationship).
>
> class Context(db.Model):
>         label = db.StringProperty()
>
> class Action(db.Model):
>         label = db.StringProperty()
>         context = db.ReferenceProperty(Context, collection_name='actions')
>         status = db.IntegerProperty()
>
> The documentation advises that where a ReferenceProperty might have a
> key that is invalid, db.get() should be used on the key to determine
> if he key is valid. In a situation where I am trying to display many
> results in a webpage, I am not sure how this would look. Can (should)
> this be tested inside a Template during row output? If not, however
> should it be handled prior to calling the template?
>
> actions = db.GqlQuery('SELECT * FROM Action').all()
> for action in actions:
>    #Not sure
> rendered_template = template.render(template_path,
> {'actions_to_display':notsure})
>
> At the moment I am cleaning up my incorrect ReferenceProperty values
> as I go, but this does not look efficient either. It does have the
> advantage of being a rare occurence:
>
>                         referring_actions = context_to_delete.actions
>
>                         #update refering actions
>                         for referring_action in referring_actions:
>                                 referring_action.context = None
>                                 referring_action.save()
>
>                         #Delete Context
>                         context_to_delete.delete()
>
> How are other people dealing with this MANY-TO-ONE, deletion of the
> ONE scenario?
>
> Sorry if this has been asked before, I checked the FAQ, recipe book
> and performed some searches on the Group.
>
> Thanks for any 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