Created
August 20, 2012 23:27
-
-
Save dylanvee/3409230 to your computer and use it in GitHub Desktop.
ndb reference property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import ndb | |
class ReferenceProperty(ndb.KeyProperty): | |
def _validate(self, value): | |
if not isinstance(value, ndb.Model): | |
raise TypeError('expected an ndb.Model, got %s' % repr(value)) | |
def _to_base_type(self, value): | |
return value.key | |
def _from_base_type(self, value): | |
return value.get() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment