def insertTag(self, tags): #logging.debug("insert start") if tags != '': taglist = self.splitTag(tags) nametaglist = self.splitTag(tags, 0) #logging.debug("name tag list : %s"%len(nametaglist)) #logging.debug("tag count : %s"%len(taglist)) cnt = 0 for tag in taglist: #logging.debug("tag name : %s"%nametaglist[cnt]) #logging.debug("tag : %s"%tag) tq = db.GqlQuery( "select * from TagList where ancestor is :1 and tag = :td", photodb.getKey(), td=tag) if tq.count() == 0: t = photodb.TagList(parent=photodb.getKey()) t.tag = tag t.tagname = nametaglist[cnt] t.comment = '' t.put() else: pass cnt = cnt + 1
def insertTag(self, tags): if tags != '': taglist = tags.split(',') for tag in taglist: tq = db.GqlQuery( "select * from TagList where ancestor is :1 and tag = :td", photodb.getKey(), td=tag) self.response.out.write("tlist = %s<br/>" % tag) if tq.count() == 0: t = photodb.TagList(parent=photodb.getKey()) t.tag = tag t.comment = '' t.put() else: self.response.out.write("%s is in db data<br/>" % tag)
def findTag(self, tag): tqs = db.GqlQuery( "select * from TagList where ancestor is :1 and tag = :td", photodb.getKey(), td=tag) if tqs.count() != 0: return tqs[0] else: return None
def deleteTag(self, tagname): #key = self.request.get('key') or '' #blobstore.delete(key) logging.debug("delete tag : %s" % tagname) qu = db.GqlQuery( "select * from TagList where ancestor is :1 and tag = :td", photodb.getKey(), td=tagname) db.delete(qu)
def updateTagComment(self, tagname, updatedcomment): #logging.debug("update comment : %s"%updatedcomment) tq = db.GqlQuery( "select * from TagList where ancestor is :1 and tag = :td", photodb.getKey(), td=tagname) if tq.count() != 0: t = tq.get() t.comment = updatedcomment t.put()
def insertPhoto(self, file_key): photo = photodb.PhotoTag(parent=photodb.getKey()) photo.author = userinfo.getUserID() photo.comment = '' taglist = self.splitTag(self.request.get('tags')) photo.tag = taglist photo.Imagekey = file_key key = photo.put() return key
def insertPhoto(self, file_key): photo = photodb.PhotoTag(parent=photodb.getKey()) photo.author = 'anomy' photo.comment = '' photo.tag = self.request.get('taglist') photo.Imagekey = file_key self.response.out.write("fkey = %s<br/>" % file_key) self.response.out.write("photofkey = %s<br/>" % photo.Imagekey.key()) key = photo.put() self.response.out.write("filename = %s<br/>" % key) self.insertTag(photo.tag)
def viewTaglist(self): tqs = db.GqlQuery( "select * from TagList where ancestor is :1 order by date desc", photodb.getKey()) return tqs
def viewPhotosbyTag(self, tag=''): # photos = db.GqlQuery("select * from PhotoTag " # "where ancestor is:1 order by date desc", # photodb.getKey()) photolist = [] if tag != '': photos = db.GqlQuery( "select * from PhotoTag " "where ancestor is:1 and tag = :td order by date asc", photodb.getKey(), td=tag) tagdb = self.findTag(tag) pcnt = 0 for photo in photos: photolist.append(album(photo, tagdb, pcnt)) pcnt = pcnt + 1 else: tlist = self.viewTaglist() for t1 in tlist: logging.debug("tname : %s" % t1.tag) if t1.tag == 'handson': photos = db.GqlQuery( "select * from PhotoTag " "where ancestor is:1 and tag = :td order by date desc", photodb.getKey(), td=t1.tag).fetch(1) pcnt = 0 for photo in photos: photolist.append(album(photo, t1, photo.date)) pcnt = pcnt + 1 else: photos = db.GqlQuery( "select * from PhotoTag " "where ancestor is:1 and tag = :td order by date desc", photodb.getKey(), td=t1.tag) temppl = [] for ppp in photos: temppl.append(ppp) if len(temppl) > 0: photo = random.choice(temppl) # logging.debug("photosize : %s"%len(temppl)) photolist.append(album(photo, t1, photo.date)) photolist.sort() # if tag != '': # pcnt = 0 # for photo in photos: # if photo.tag.find(tag) != -1: # photolist.append(album(photo,self.findTag(tag),pcnt)) # pcnt = pcnt + 1 # else: # tlist = self.viewTaglist() # for tl in tlist: # pcnt = 0 # for photo in photos: # if photo.tag.find(tl.tag) != -1: # photolist.append(album(photo,tl,pcnt)) # break; # pcnt = pcnt + 1 # photolist.sort() return photolist