class Employee(model.Model): name = model.StringProperty() age = model.IntegerProperty('Age') rank = model.IntegerProperty() @classmethod def seniors(cls, min_age, min_rank): q = cls.query().filter(cls.age >= min_age, cls.rank <= min_rank) q = q.order(cls.name, -cls.age) return q
class All(model.Model): s = model.StringProperty() i = model.IntegerProperty() f = model.FloatProperty() t = model.TextProperty() b = model.BlobProperty() k = model.KeyProperty()
class _DisplayState(model.Model): """Structured Property for listing User Keys and the state of the Message / Thread for that user """ user_key = model.KeyProperty() # State assumes a certain flow, i.e. a message cannot be # archived until it has been read. # 0 - unread # 1 - read # 2 - archived # 3 - deleted # 4 - reported state = model.IntegerProperty(default=0) @staticmethod def label_to_integer(label): if label == 'unread': return 0 if label == 'read': return 1 if label == 'archived': return 2 if label == 'deleted': return 3 if label == 'reported': return 4
class MyModel(model.Model): b = model.BooleanProperty() p = model.IntegerProperty() q = model.StringProperty() d = model.FloatProperty() k = model.KeyProperty() u = model.UserProperty() xy = model.GeoPtProperty()
class MyModel(model.Model): bb = model.BooleanProperty('b') pp = model.IntegerProperty('p') qq = model.StringProperty('q') dd = model.FloatProperty('d') kk = model.KeyProperty('k') uu = model.UserProperty('u') xxyy = model.GeoPtProperty('xy')
class CachedTile(model.Model): tile = model.BlobKeyProperty(required=True) rendered = model.DateTimeProperty(required=True) operation_cost = model.IntegerProperty(required=True) render_time = model.FloatProperty(required=True) level = model.IntegerProperty(required=True) #_use_datastore = False _use_memcache = False @property def position(self): """Returns the level/x/y tuple for this tile.""" return tuple(int(x) for x in self.key.id().split('/')[1:]) @classmethod def key_for_tile(cls, type, level, x, y): return model.Key(cls, '%s/%s/%s/%s' % (type, level, x, y))
def testPropertyRepr(self): p = model.Property() self.assertEqual(repr(p), 'Property()') p = model.IntegerProperty('foo', indexed=False, repeated=True) self.assertEqual( repr(p), "IntegerProperty('foo', indexed=False, repeated=True)") class Address(model.Model): street = model.StringProperty() city = model.StringProperty() p = model.StructuredProperty(Address, 'foo') self.assertEqual(repr(p), "StructuredProperty(Address, 'foo')")
class Baz(model.Model): bar = model.StructuredProperty(Bar) bak = model.StructuredProperty(Bak) rank = model.IntegerProperty()
class Employee(model.Model): name = model.StringProperty() rank = model.IntegerProperty()
class MyModel(model.Model): number = model.IntegerProperty()
class Froo(model.Model): name = model.StringProperty() rate = model.IntegerProperty() age = model.IntegerProperty()
class MyModel(model.Model): a = model.StringProperty(choices=['a', 'b', 'c']) b = model.IntegerProperty(choices=[1, 2, 3], repeated=True)
class MyModel(model.Model): n = model.IntegerProperty(u'\u4321') @classmethod def _get_kind(cls): return u'\u1234'.encode('utf-8')
class MyModel(model.Model): p = model.IntegerProperty()
class Address(model.Model): street = model.StringProperty() city = model.StringProperty() zip = model.IntegerProperty()
class MyModel(model.Model): p = model.IntegerProperty() q = model.StringProperty() d = model.FloatProperty() k = model.KeyProperty()
class Greeting(model.Model): message = model.StringProperty() userid = model.IntegerProperty() # Not used here, but later
class Person(model.Model): address = model.StructuredProperty(Address) age = model.IntegerProperty(repeated=True) name = model.StringProperty() k = model.KeyProperty()
class Address(model.Model): line = model.StringProperty(repeated=True) city = model.StringProperty() zip = model.IntegerProperty() tags = model.StructuredProperty(Tag)
class Tag(model.Model): names = model.StringProperty(repeated=True) ratings = model.IntegerProperty(repeated=True)
class Foo(model.Model): name = model.StringProperty() rate = model.IntegerProperty() tags = model.StringProperty(repeated=True)
class MyUser(models.User): newsletter = model.BooleanProperty() age = model.IntegerProperty()
class FibonacciMemo(model.Model): arg = model.IntegerProperty() value = model.IntegerProperty()
class MyModel(model.Model): pp = model.IntegerProperty('p') qq = model.StringProperty('q') dd = model.FloatProperty('d') kk = model.KeyProperty('k')