Hello,

Is it safe to change the __class__ attribute of a PolyModel instance
and then save it back to the datastore?

e.g.

class DraftProject(PolyModel):
    def someaction(self):
         print 'Action permitted at this status'

class ApprovedProject(DraftProject):
    def someaction(self):
         raise Exception('not allowed at this status')

p = DraftProject.get(object_key)
p.__class__ = ApprovedProject
p.put()


I've a got a model class that corresponds to a project in a workflow
application. The project can be at different statuses. Depending on
the status, some actions are permissible, and some are not. I'd like
to use the Template design pattern to model this (http://
en.wikipedia.org/wiki/Template_method_pattern)

If setting the class attribute directly is unsafe, could anyone
suggest a better way to model this?

Thanks

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