Dynamic delete property fail

21 views
Skip to first unread message

J.T

unread,
Jul 28, 2011, 11:10:10 PM7/28/11
to google-a...@googlegroups.com
Hi,

from google.appengine.ext     import db
class Person(db.Expando):
  first_name = db.StringProperty()
  last_name = db.StringProperty()
  hobbies = db.StringListProperty()

p = Person(first_name="Albert", last_name="Johnson")
p.hobbies = ["chess", "travel"]

del p.first_name



Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/admin/__init__.py", line 247, in post
    exec(compiled_code, globals())
  File "<string>", line 6, in <module>
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1831, in __delattr__
    object.__delattr__(self, key)
AttributeError: __delete__


This script is from https://code.google.com/intl/en/appengine/docs/python/datastore/datamodeling.html#The_Expando_Class
and test it in interactive console.




Robert Kluin

unread,
Aug 2, 2011, 1:01:24 AM8/2/11
to google-a...@googlegroups.com
Hi,
I think this is because you're trying to delete a property included
on the schema. The following should demonstrate this:

class Test(db.Expando):
first_name = db.StringProperty()

t = Test(first_name='Jim')
t.last_name = 'smith'

del t.last_name # ok
del t.first_name # boom

Robert

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/M7dzwQCaCPMJ.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

Reply all
Reply to author
Forward
0 new messages