def handle_tweet(tweet): global num_tweets num_tweets += 1 print 'got tweet: %s' % bs(tweet.text) if num_tweets % 100 == 0: print "X" * 10, num_tweets # break content = Content() tweet_text = tweet.text tweetwhen = bs(tweet.created_at) s = tweet_text.split() #tags = set() for word in s: if word.startswith("#"): word = bs(word) if content.hashtags == None: content.hashtags = "" else: content.hashtags = content.hashtags + " " +word content.message = tweet_text content.timestamp = tweetwhen if tweet.coordinates: print "tweet had a location" lat = tweet.coordinates["coordinates"][0] lon = tweet.coordinates["coordinates"][1] point = Point(lat, lon) neighborhood = find_in_boxes(boxes, point) if neighborhood is None: print "tweet didn't have a neighborhood" return print type(tweet_text) print bs(tweet_text) print neighborhood.name content.neighborhood_id = neighborhood.id # content.hashtags = " ".join(tags) try: db.session.add(content) print ">>>>>> adding" db.session.commit() except Exception, e: print "error, not committing" traceback.print_exc()