I am having trouble deleting entities from keys in the GAE using 
python/ndb. I am able to retrieve the entity (problem) key from the page, 
but cannot figure out how to get it to delete. The GAE support page says 
it's as simple as retrieving the key and then deleting it, as seen below.

problem = problem_key.get()
problem.key.delete()

But this is not working. I'm pretty sure the key is being obtained 
correctly. The HTML looks like

{%for problem in problems %}
    <tr>
        <td>{{ problem.tags }}</td>
        <td><script type="math/tex">{{ problem.content }}</script></td>
        <td>{{ problem.answer }}</td>
        <td>{{ problem.quiz }}</td>
        <td>{{ problem.id }}</td>
        <td>{{ problem.date }}</td>
        <form action="/deleteProblem" method="POST">
            <td><button type="submit" name="problem_key" value="{{ problem.key 
}}">Delete Problem</button></td> 
        </form>
    </tr>{% endfor %}    

And my python code looks like:

class deleteHandler(BaseHandler):
    def post(self):
        prob_key = self.request.get('problem_key')
        problem = prob_key.get()
        problem.key.delete()
        self.redirect("/")

I'm getting:

problem = prob_key.get()     AttributeError: 'unicode' object has no attribute 
'get'

My best guess is that prob_key is getting assigned the actual unicode and 
so of course there is no get() method for it but I don't understand how to 
fix the problem based on Google's explanation of how it should function.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/eab4279b-feaf-45ff-8cd2-3522775bcd01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine]... Jory Pettit

Reply via email to