def getNames(): namesq = Name.gql("WHERE numRankings =:1", None) names = [] for name in namesq: _name = {"name": name.name, "id": name.key().id()} names.append(_name) return names
def registerName(name, taxonomicRankLevel): if Name.gql("WHERE name = :1", name).count() > 0: raise BaseError, "Name is already registered" tn = Name() tn.name = name tn.numRankings = 0 tn.taxonomicRankLevel = taxonomicRankLevel tn.put() return tn.key().id()
def voteImage(name, url): q = Name.gql("WHERE name = :1", name) _name = q.get() if _name < 1: raise BaseError, "Name does not exist in database!" _name.preferedImageURL = url _name.numRankings = 1 _name.put() return True
def getName(): namesq = Name.gql("WHERE numRankings =:1 LIMIT 1", None) for name in namesq: _name = {"name": name.name, "id": name.key().id()} return _name