views:

324

answers:

1

Given a Polymodel in Google App Engine, likeso:

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

class Base(polymodel.PolyModel):
  def add_to_referer(self):
     Referer(target=self).put()

class Referer(db.Model):
  target = db.ReferenceProperty()

  @classmethod    
  def who_referred(cls):
     for referer in Referer.all():
         obj = referer.target

This last line is giving an error likeso:

No implementation for kind 'Base'

Traceback is likeso:

>>> object = referer.target
/usr/local/google_appengine/google/appengine/ext/db/__init__.py in __get__:2804
/usr/local/google_appengine/google/appengine/ext/db/__init__.py in get:1179
/usr/local/google_appengine/google/appengine/ext/db/__init__.py in class_for_kind:220

Does anyone have any idea what's going on here? The expected behavior would be, obviously, that no error be thrown.

It may be relevant that Base and Referer are in separate files (and not imported).

This problem may be somewhat related to Python decorate a class to change parent object type, which is a question which still lurks in the back of my mind.

Thank you for reading.

A: 

Ah. I answered this immediately after I posted:

The file with Referer needs to import Base.

Perhaps someone else will happen upon this quirk, so I'll leave this question open.

Brian M. Hunt