Among other methods, I'm trying to "catch" the put() method of both db.Model
and db.polymodel.PolyModel, so that I can set the entity in Memcache (after
it's been put into the Datastore).

I'm using the same common mixin class for both. The setup looks something
like this:

from google.appengine.ext.db.polymodel import PolyModel
from google.appengine.ext import db

class ModelMixin(object):

  def __init__(self, *args, **kwds):
    self.do_something_cool()

  def do_something_cool(self):
    ...

  def put(self, *args, **kwds):
    super(ModelMixin, self).put(*args, **kwds)
    memcache.set('EntityKey:'+self.key(), db.model_to_protobuf(self))

class MyModel(ModelMixin, db.Model):
  def __init__(self, *args, **kwds):
    db.Model.__init__(self, *args, **kwds)
    ModelMixin.__init__(self, *args, **kwds)

class MyPolyModel(ModelMixin, PolyModel):
  def __init__(self, *args, **kwds):
    PolyModel.__init__(self, *args, **kwds)
    ModelMixin.__init__(self, *args, **kwds)

Subclassing from MyModel is working fine, but when I try and subclass
MyPolyModel, eg:

class Animal(MyPolyModel):
  ...

class Cat(Animal):
  ...

I get this error on the dev appserver (I haven't tried it in production):

AttributeError: type object 'Animal' has no attribute '__root_class__'

Can someone suggest a way to fix this?

I'm also worried that, even if I get this fixed, the entity kind of those
subclasses of MyPolyModel will be 'MyPolyModel' instead of eg. 'Animal'
(because the direct subclass of PolyModel is MyPolyModel and not Animal). I
hope there's a way around that as well, and welcome suggestions.

Nick

-- 
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-appeng...@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