Example #1
0
    def post(self):
        post_channel = self.request.get('post_channel', '')
        post_user = self.request.get('post_user', '')
        post_url = self.request.get('post_url', '')
        type = self.request.get('type', '')

        url = Url.all().filter('url =', post_url).get()
        channel = Channel.all().filter('name =', post_channel).get()
        channelurl = ChannelUrl.all().filter('channel =',
                                             channel).filter('url =',
                                                             url).get()
        if channelurl:
            rate = Rate()
            rate.channelurl = channelurl
            rate.user = post_user
            rate.type = type
            rate.put()
        else:
            logging.warning('ChannelUrl not found: %s %s' %
                            (post_channel, post_url))
Example #2
0
      logging.debug('user: %s, id: %s, value: %s' % (user,id,value))
      
    except Exception, e:
      logging.warning('Error %s' % (e))

  try:
    id=int(id)
  except:
    pass
  channelurl=ChannelUrl.get_by_id(id)
  if not channelurl:
    retval=simplejson.dumps({'id':0,'rate': ''})
    return HttpResponse(retval, mimetype="application/json")
  else:
    rate=Rate(user=user,value=value,channelurl=channelurl.key)
    rate.put()

    # Update Document (FullTextSearch)
    url=channelurl.url.get()
    doc_id=str(url.key.id())
    try:
      doc = search.Index(name='url').get(doc_id)
      if not doc:
        logging.warning('Document not found.')
        try:
          taskqueue.add(name=str(doc_id)+'_update',queue_name='document',url='/tasks/update_document', params={'doc_id': doc_id})
        except taskqueue.TombstonedTaskError:
          logging.warning('TombstonedTaskError %s_update' % (str(doc_id)))
        except taskqueue.TaskAlreadyExistsError:
          logging.warning('TaskAlreadyExistsError %s_update' % (str(doc_id)))    
      else: