# HG changeset patch # User Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> # Date 1295548131 -3600 # Node ID bd595ad770fc60248889882fa76d46a327864322 # Parent 1e7b883645a32e341db6a9ea9d086b75e6e7b309 - replace json with anyjson - invalidate user id from search twitter query diff -r 1e7b883645a3 -r bd595ad770fc script/lib/iri_tweet/models.py --- a/script/lib/iri_tweet/models.py Thu Jan 20 12:53:01 2011 +0100 +++ b/script/lib/iri_tweet/models.py Thu Jan 20 19:28:51 2011 +0100 @@ -4,7 +4,7 @@ from sqlalchemy.orm import relationship, backref import datetime import email.utils -import simplejson +import anyjson Base = declarative_base() @@ -23,7 +23,7 @@ if obj is None: return None else: - return simplejson.dumps(obj) + return anyjson.serialize(obj) class Entity(Base): __tablename__ = "tweet_entity" diff -r 1e7b883645a3 -r bd595ad770fc script/lib/iri_tweet/utils.py --- a/script/lib/iri_tweet/utils.py Thu Jan 20 12:53:01 2011 +0100 +++ b/script/lib/iri_tweet/utils.py Thu Jan 20 19:28:51 2011 +0100 @@ -1,7 +1,7 @@ from models import * import datetime import email.utils -import json +import anyjson import logging import os.path import sys @@ -75,12 +75,12 @@ raise TwitterProcessorException("No json") if json_dict is None: - self.json_dict = json.loads(json_txt) + self.json_dict = anyjson.deserialize(json_txt) else: self.json_dict = json_dict if not json_txt: - self.json_txt = json.dumps(json_dict) + self.json_txt = json.serialize(json_dict) else: self.json_txt = json_txt @@ -244,8 +244,6 @@ #user user_fields = { - 'id' : self.json_dict['from_user_id'], - 'id_str' : self.json_dict['from_user_id_str'], 'lang' : self.json_dict['iso_language_code'], 'profile_image_url' : self.json_dict["profile_image_url"], 'screen_name' : self.json_dict["from_user"], diff -r 1e7b883645a3 -r bd595ad770fc script/rest/search_enmi.py --- a/script/rest/search_enmi.py Thu Jan 20 12:53:01 2011 +0100 +++ b/script/rest/search_enmi.py Thu Jan 20 19:28:51 2011 +0100 @@ -1,5 +1,6 @@ from iri_tweet import models, utils from sqlalchemy.orm import sessionmaker +import anyjson import sqlite3 import twitter @@ -49,7 +50,9 @@ results = twitter. search(q=options.query, rpp=options.rpp, page=page) for tweet in results["results"]: print tweet - processor = utils.TwitterProcessor(tweet, None, session, options.token_filename) + tweet_str = anyjson.serialize(tweet) + #invalidate user id + processor = utils.TwitterProcessor(tweet, tweet_str, session, options.token_filename) processor.process() session.flush() page += 1