def Contributor_add(av, name): record = Contributor.gql('WHERE avkey = :1', av).get() if record is None: NewDist = Contributor(avkey = av, avname = name) NewDist.put() token = "contr_auth_%s" % av memcache.set(token, True)
def get(self): message = '''<h1>List of Contributors</h1> <p>This lists all Contributors currently in the distribution system as of %s.</p> <table class="sortable" border=\"1\">''' % datetime.datetime.utcnow().isoformat(' ') message += '<tr><th>Row</th><th>Contributor</th><th>Key</th></tr><br />\n' query = Contributor.gql("") dists = [] for record in query: s = '<td>%s</td><td>%s</td>\n' % (record.avname, record.avkey) if (s in dists) == False: dists += [s] for i in range(0,len(dists)): message += '<tr><td>%d</td>%s' % (i+1, dists[i]) message += "</table>" self.response.out.write((head % 'Contributor List') + message + end)
def get(self): message = '''<h1>List of Contributors</h1> <p>This lists all Contributors currently in the distribution system as of %s.</p> <table class="sortable" border=\"1\">''' % datetime.datetime.utcnow( ).isoformat(' ') message += '<tr><th>Row</th><th>Contributor</th><th>Key</th></tr><br />\n' query = Contributor.gql("") dists = [] for record in query: s = '<td>%s</td><td>%s</td>\n' % (record.avname, record.avkey) if (s in dists) == False: dists += [s] for i in range(0, len(dists)): message += '<tr><td>%d</td>%s' % (i + 1, dists[i]) message += "</table>" self.response.out.write((head % 'Contributor List') + message + end)
def Contributor_authorized(av): #True if av is on the authorized distributor list, else False token = "contr_auth_%s" % av memrecord = memcache.get(token) if memrecord is None: #dist is not in memcache, check db dbrecord = Contributor.gql('WHERE avkey = :1', av).get() if dbrecord is None: memcache.set(token, False) return False else: memcache.set(token, True) return True else: #dist is in memcache. check value if memrecord: return True else: return False
def Contributor_delete(av, name): record = Contributor.gql('WHERE avkey = :1', av).get() if record is not None: record.delete() token = "contr_auth_%s" % av memcache.delete(token)