Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
|
qyearsley
2015/01/07 06:59:46
Note, the "(c)" isn't necessary, and can be remove
stgao
2015/01/09 01:28:23
Good catch.
Done for files in this CL.
For other f
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from google.appengine.ext import ndb | |
| 6 | |
| 7 | |
| 8 class BaseModel(ndb.Model): # pragma: no cover | |
| 9 """A base class to provide computed properties from the key. | |
|
qyearsley
2015/01/07 06:59:46
This looks like a good idea. Possible alternative
stgao
2015/01/09 01:28:23
I like BaseBuildModel better.
Done.
| |
| 10 | |
| 11 The computed properties are master name, builder name, and build number. | |
| 12 Subclasses should set its key as: | |
| 13 ndb.Key('KindName', master_name, 'KindName', builder_name, | |
| 14 'KindName', build_number, 'Optional_KindName', optional_id, ...) | |
| 15 """ | |
| 16 | |
| 17 @ndb.ComputedProperty | |
| 18 def master_name(self): | |
| 19 return self.key.pairs()[0][1] | |
| 20 | |
| 21 @ndb.ComputedProperty | |
| 22 def builder_name(self): | |
| 23 return self.key.pairs()[1][1] | |
| 24 | |
| 25 @ndb.ComputedProperty | |
| 26 def build_number(self): | |
| 27 return self.key.pairs()[2][1] | |
| OLD | NEW |