Created
April 10, 2014 22:00
Revisions
-
maciekrb created this gist
Apr 10, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ class VariableGroup(EndpointsModel): _message_fields_schema = ('name', 'id', 'tags', 'identifier') acl = ndb.StructuredProperty(AclRule) tag_keys = ndb.KeyProperty(kind='Tag', repeated=True) group_id = ndb.StringProperty() name = ndb.StringProperty() @property def identifier(self): if self.group_id is None: self.group_id = int(random.random() * 10000) return "vgroup_{}".format(self.group_id) @EndpointsAliasProperty(repeated=True, property_type=Tag.ProtoModel()) def tags(self): if self.tag_keys: return ndb.get_multi(self.tag_keys) class Variable(EndpointsModel): _message_fields_schema = ('value', 'id', 'groupid') acl = ndb.StructuredProperty(AclRule) group_key = ndb.KeyProperty(kind='VariableGroup') value = ndb.GenericProperty() @EndpointsAliasProperty(repeated=True, property_type=Tag.ProtoModel()) def groupid(self): return self.group_key.id()