def post(self): post_channel = self.request.get('post_channel', '') post_user = self.request.get('post_user', '') post_url = self.request.get('post_url', '') post_extra = self.request.get('extra', '') # Related/tag if post_extra.startwith('#'): # TODO: check if post_extra[1:].isdigit(): type = 'related' else: type = 'tag' else: type = 'comment' 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: extra = Extra() extra.channelurl = channelurl extra.user = post_user setattr(extra, type, post_extra) extra.put() else: logging.warning('ChannelUrl not found: %s %s' % (post_channel, post_url))
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))
def post(self): if users.get_current_user(): node.author = users.get_current_user() post_channel = self.request.get('post_channel', '') post_user = self.request.get('post_user', '') post_url = self.request.get('post_url', '') # Add http:// when needed if not post_url.startswith('http'): post_url = 'http://' + post_url logging.debug('Post: C=%s U=%s P=%s' % (post_channel, post_user, post_url)) # 1. tarkista onko olemassa jo ko. Url, lisää jos ei, muuten päivitä (udate, valid?): valid-juttu joo ehkä jos tarpeen, ei muuten url = Url.all().filter('url =', post_url).get() if not url: url = Url() url.url = post_url url.put() # Title name = ''.join( re.findall('[a-zA-Z0-9_-]', post_channel + '_' + post_url))[:500] try: taskqueue.add(name=name, queue_name='urlfetch', url='/tasks/title', params={'post_url': post_url}) except taskqueue.TombstonedTaskError: logging.warning('TombstonedError %s' % post_url) except taskqueue.TaskAlreadyExistsError: logging.warning('TaskAlredyExists: %s' % post_url) # 2. tarkista onko olemassa jo ko. Channel, lisää jos ei channel = Channel.all().filter('name =', post_channel).get() if not channel: channel = Channel() channel.name = post_channel if post_channel.startswith('!'): channel.private = True channel.put() # 3. tarkista onko url jo olemassa channel-tasolla channelurl = ChannelUrl.all().filter('url =', url).filter('channel =', channel).get() if not channelurl: channelurl = ChannelUrl() channelurl.channel = channel channelurl.url = url #channelurl.user=post_user channelurl.put() else: logging.info('OLDIE! %s %s' % (channelurl.channel.name, channelurl.url.url)) # 4. Lisätään postaus post = Post() post.channelurl = channelurl post.user = post_user post.put()