Nick,

> It _is_ a hack. A better approach would be to use a single class with
> appropriate properties, or create a new instance of a new class and discard
> the old one at such time as you need to make the change.

Thanks for your reply. I'm sure you're bored of this thread so I'll
try to summarise.

To take another example, SQLAlchemy supports what it calls "Single
Table Inheritance" - 
http://www.sqlalchemy.org/docs/orm/inheritance.html#single-table-inheritance
. In this approach, there is a field "type" that SQLAlchemy uses to
determine what class the row should be mapped to. So if you change the
'type' you change the class.

You seem to be saying that each record in the datastore should map to
one and only one Python class, so a similar approach doesn't work.

Polymodel Objects in the GAE Datastore have a property "class" which
stores a list of super classes. This property appears to be used by
the DataStore API in a similar way to how "type" is used  by
SQLAlchemy.  It's currently possible to change the value of this field
by setting the __class__ attribute of an instance and saving it back
to the DataStore. However, you state:

"You're breaking any number of invariants by doing this, so things may
break without notice at any time. "

Somewhat cryptic, but I'll take your word for it.

So perhaps the question boils down to whether or not there _is_ a
reliable way to change the value of the class property for polymodel
records? I'm guessing the answer is "no", but I'd like to check.

Thanks

Patrick

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to