コード例 #1
0
 def post(self):
     key = self.request.get("Key")
     tag = self.request.get("Tag")
     aKey = ndb.Key(urlsafe=key)
     anArticle = aKey.get()
     user = getUser()
     if user:
         q1 = Tag.query()
         q1 = q1.filter(Tag.user == user.user_id())
         q1 = q1.filter(Tag.scan == tag)
         aTag = q1.get()
         if not aTag:
             aTag = Tag(scan=str(tag),
                        scanKey=str(tag),
                        user=user.user_id())
             aTag.put()
     self.response.out.write('Create Tag')
コード例 #2
0
 def post(self):
     key = self.request.get("Key")
     tag = self.request.get("Tag")
     aKey = ndb.Key(urlsafe=key)
     anArticle = aKey.get()
     user = getUser()
     if user:
         q1 = Tag.query()
         q1 = q1.filter(Tag.scan == tag)
         q1 = q1.filter(Tag.user == user.user_id())
         aTag = q1.get()
         if not aTag:
             aTag = Tag(scan=str(tag),
                        scanKey=str(tag),
                        user=user.user_id())
             aTag.put()
         q1 = ProxyTag.query()
         q1 = q1.filter(ProxyTag.tag == aTag.key)
         q1 = q1.filter(ProxyTag.article == anArticle.key)
         q1 = q1.filter(ProxyTag.user == user.user_id())
         aProxy = q1.get()
         if aProxy:
             if aProxy.score == -1:
                 self.response.out.write('Already Updated')
                 return
             aProxy.key.delete()
             aProxy = ProxyTag(tag=aTag.key,
                               article=anArticle.key,
                               user=user.user_id(),
                               score=-1).put()
             queue = taskqueue.Queue(name='default')
             task = taskqueue.Task(url='/RemoveFromFilter',
                                   target='worker',
                                   params={
                                       'article': anArticle.key.urlsafe(),
                                       'tag': aTag.scan,
                                       'user': user.user_id()
                                   })
             rpc = queue.add_async(task)
             # Wait for the rpc to complete and return the queued task.
             task = rpc.get_result()
             self.response.out.write('Updated')
         else:
             self.response.out.write('Not Present')