def get(self): user = users.get_current_user() userid = user.user_id() q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if q1.count() == 0: message = ''' You do not have any SL names linked to this acount. Enter a SL username to be verified. You will get an IM to complte the verifcation. <br /> '''+form self.response.out.write(head+message+end)#promt to add name to list else: q1.filter("verifed =", True) if not q1.count() == 0: message = "Verifed names:<br />" for x in q1: message += x.sl_name+"<br />" av = x.sl_key subdictown = {} subdictsecown = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictown: subdictown[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in (subdictown or subdictsecown):#since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecown[id] = relations.key2name(id) out = '' for sub in subdictown: out += '<a href="/map/?key=%s">%s</a> own <br />' % (sub, subdictown[sub]) for sub in subdictsecown: out += '<a href="/map/?key=%s">%s</a> secown <br />' % (sub, subdictsecown[sub]) message += out q2.filter("verifed =", False) if not q2.count() == 0: message += "You have the following names waiting to be verifed: <br />" for x in q2: message += x.sl_name+"<br />" message += form #at least one acount verifed self.response.out.write(head+message+end) else: message = "You have the following names waiting to be verifed: <br />" results = q2.fetch(10) for x in results: message += x.sl_name+"<br />" message += form self.response.out.write(head+message+end)#show the acocounts not verifed and promt or more
def getownerlist(userid): ownerlist = memcache.get(userid + "ownerlist") if ownerlist is not None: sublist = memcache.get(userid + "subs").keys() checksubs = memcache.get_multi(sublist) for sub in checksubs: if checksubs[sub] is not None: memcache.delete_multi(sublist) ownerlist = getownerlist(userid) break return ownerlist else: q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if not q1.count() == 0: q1.filter("verifed =", True) if not q1.count() == 0: ownerlist = 'Verifed names:<br /><table border="1">' subdict = {} subdictown = {} subdictsecown = {} for x in q1: ownerlist += '<tr><td colspan="2">' + x.sl_name + "</td></tr>" av = x.sl_key subdictownloc = {} subdictsecownloc = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictownloc: subdictownloc[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in ( subdictownloc or subdictsecownloc ): #since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecownloc[id] = relations.key2name(id) out = '' subdictown.update(subdictownloc) subdictsecown.update(subdictsecownloc) subsortedown = sorted(subdictownloc.items(), key=itemgetter(1)) subsortedsecown = sorted(subdictsecownloc.items(), key=itemgetter(1)) for sub in subsortedown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Owner</td></tr>' % ( sub[0], sub[1]) for sub in subsortedsecown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Sec. Owner</td></tr>' % ( sub[0], sub[1]) ownerlist += out ownerlist += '</table>' q2.filter("verifed =", False) if not q2.count() == 0: ownerlist += "You have the following names waiting to be verifed: <br />" for x in q2: ownerlist += x.sl_name + "<br />" ownerlist += form subdict.update(subdictown) subdict.update(subdictsecown) memcache.set(userid + "ownerlist", ownerlist, 600) memcache.set(userid + "subs", subdict, 600) memcache.set(userid + "ownsubs", subdictown, 600) memcache.set(userid + "secownsubs", subdictsecown, 600) return ownerlist else: logging.warning( '%s is trying to get %s page but does not have any verified users' % (useremail, param2)) return "error" else: logging.warning( '%s is trying to get %s page but does not have any verified or unvierified users' % (useremail, param2)) return "error"
def getownerlist(userid): ownerlist = memcache.get(userid+"ownerlist") if ownerlist is not None: sublist = memcache.get(userid+"subs").keys() checksubs = memcache.get_multi(sublist) for sub in checksubs: if checksubs[sub] is not None: memcache.delete_multi(sublist) ownerlist = getownerlist(userid) break return ownerlist else: q1 = GoogleSLIds.all().filter("google_id =", userid) q2 = GoogleSLIds.all().filter("google_id =", userid) q3 = GoogleSLIds.all().filter("google_id =", userid) if not q1.count() == 0: q1.filter("verifed =", True) if not q1.count() == 0: ownerlist = 'Verifed names:<br /><table border="1">' subdict = {} subdictown = {} subdictsecown = {} for x in q1: ownerlist += '<tr><td colspan="2">'+x.sl_name+"</td></tr>" av = x.sl_key subdictownloc = {} subdictsecownloc = {} ownersubs = relations.getby_subj_type(av, 'owns') for sub in ownersubs: id = sub.obj_id if id not in subdictownloc: subdictownloc[id] = relations.key2name(id) else: #delete duplicates sub.delete() secownersubs = relations.getby_subj_type(av, 'secowns') for sub in secownersubs: id = sub.obj_id if id not in (subdictownloc or subdictsecownloc):#since you can be both an owner and a secowner, ignore those here already in the owner list subdictsecownloc[id] = relations.key2name(id) out = '' subdictown.update(subdictownloc) subdictsecown.update(subdictsecownloc) subsortedown = sorted(subdictownloc.items(), key=itemgetter(1)) subsortedsecown = sorted(subdictsecownloc.items(), key=itemgetter(1)) for sub in subsortedown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Owner</td></tr>' % (sub[0], sub[1]) for sub in subsortedsecown: out += '<tr><td><a href="/map/?key=%s">%s</a></td><td>Sec. Owner</td></tr>' % (sub[0], sub[1]) ownerlist += out ownerlist +='</table>' q2.filter("verifed =", False) if not q2.count() == 0: ownerlist += "You have the following names waiting to be verifed: <br />" for x in q2: ownerlist += x.sl_name+"<br />" ownerlist += form subdict.update(subdictown) subdict.update(subdictsecown) memcache.set(userid+"ownerlist", ownerlist, 600) memcache.set(userid+"subs", subdict, 600) memcache.set(userid+"ownsubs", subdictown, 600) memcache.set(userid+"secownsubs", subdictsecown, 600) return ownerlist else: logging.warning('%s is trying to get %s page but does not have any verified users' % (useremail, param2)) return "error" else: logging.warning('%s is trying to get %s page but does not have any verified or unvierified users' % (useremail, param2)) return "error"