Beispiel #1
0
    def handle_action(self, uid, cid):
        note = self.request.get('note')
        if len(note) > MAX_NOTE_LEN:
            logging.warn('note too long: len=%d from_uid=%s' % (len(note), uid))
            return self.error(400)
        note = clean_html(note)

        cmt = self.get_cmt_from_cid(cid, uid)
        if cmt and cmt.cmt!=note:
            cmt.cmt = note
            cmt.put()
Beispiel #2
0
        now = datetime.now()
        try:
            rss = feedparser.parse(resp.content)
        except Exception,e:
            logging.error('unable to parse RSS feed from %s: %s' % (feed_url, resp.content))
            return

        for e in rss['entries']:
            link = e['link']
            m_cid = RE_CID.match(link)
            if not m_cid:
                logging.error('unable to extract CID from link: %s' % link)
                continue
            cid = int(m_cid.groups()[0])
            ad_key = db.Key.from_path('Ad', cid)
            title = clean_html(e['title'], [], [])  # not tags allowed
            desc = clean_html(e['summary'])         # default tags allowed
            updated_str = e['updated']
            try:
                offset = int(updated_str[-5:][:2])
            except:
                logging.error('unable to extract UTC offset for link=%s: %s' % (link, updated_str))
                offset = 0
            try:
                dt = datetime.strptime(updated_str[:len(updated_str)-6], '%Y-%m-%dT%H:%M:%S')
                updated = dt + timedelta(hours=offset/100)
            except ValueError:
                logging.error('unable to parse the datetime for link=%s: %s' % (link, updated_str))
                updated = now
            if not title:
                logging.warn('Got Ad (%s) with no title from RSS feed' % link)