Пример #1
0
def add_tweet(tweet_info):
    lat = None
    lng = None
    if tweet_info['coordinates']:
        lat = float(tweet_info['coordinates']['coordinates'][0])
        lng = float(tweet_info['coordinates']['coordinates'][1])
        
    new_tweet = Tweet()
    new_tweet.uid = tweet_info['user']['id']
    new_tweet.tid = tweet_info['id']
    new_tweet.text = Thumbs.genThumbs(tweet_info['text'])
    if lat and lng:
        new_tweet.lat = lat
        new_tweet.lng = lng
    new_tweet.time = datetime.strptime(tweet_info['created_at'], "%a %b %d %H:%M:%S +0000 %Y")

    new_tweet.put()
Пример #2
0
def add_tweet(tweet_info):
    if Tweet.isStored(tweet_info['id']):
        raise TweetAlreadyStoredException

    lat = None
    lng = None
    if tweet_info['coordinates']:
        lat = float(tweet_info['coordinates']['coordinates'][0])
        lng = float(tweet_info['coordinates']['coordinates'][1])
        
    new_tweet = Tweet()
    new_tweet.uid = tweet_info['user']['id']
    new_tweet.tid = tweet_info['id']
    new_tweet.text = tweet_info['text']
    if lat and lng:
        new_tweet.lat = lat
        new_tweet.lng = lng
    new_tweet.time = datetime.strptime(tweet_info['created_at'], "%a %b %d %H:%M:%S +0000 %Y")

    new_tweet.put()
Пример #3
0
def add_tweet(tweet_info):
    if Tweet.isStored(tweet_info['id']):
        raise TweetAlreadyStoredException

    lat = None
    lng = None
    if tweet_info['coordinates']:
        lat = float(tweet_info['coordinates']['coordinates'][0])
        lng = float(tweet_info['coordinates']['coordinates'][1])

    new_tweet = Tweet()
    new_tweet.uid = tweet_info['user']['id']
    new_tweet.tid = tweet_info['id']
    new_tweet.text = tweet_info['text']
    if lat and lng:
        new_tweet.lat = lat
        new_tweet.lng = lng
    new_tweet.time = datetime.strptime(tweet_info['created_at'],
                                       "%a %b %d %H:%M:%S +0000 %Y")

    new_tweet.put()
Пример #4
0
def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
    if not form.has_key('uid'):
        return "please input uid"
    if not form.has_key('tid'):
        return "please input tid"
    if not form.has_key('text'):
        return "please input text"
    if not form.has_key('lat'):
        return "please input lat"
    if not form.has_key('lng'):
        return "please input lng"

    tweet = Tweet()
    tweet.uid = int(form['uid'].value)
    tweet.tid = int(form['tid'].value)
    tweet.text = form['text'].value
    tweet.lat = float(form['lat'].value)
    tweet.lng = float(form['lng'].value)

    tweet.put()

    return "OK"
Пример #5
0
def application(environ, start_response):
    start_response("200 OK", [("Content-Type", "text/plain")])
    form = cgi.FieldStorage(fp=environ["wsgi.input"], environ=environ)
    if not form.has_key("uid"):
        return "please input uid"
    if not form.has_key("tid"):
        return "please input tid"
    if not form.has_key("text"):
        return "please input text"
    if not form.has_key("lat"):
        return "please input lat"
    if not form.has_key("lng"):
        return "please input lng"

    tweet = Tweet()
    tweet.uid = int(form["uid"].value)
    tweet.tid = int(form["tid"].value)
    tweet.text = form["text"].value
    tweet.lat = float(form["lat"].value)
    tweet.lng = float(form["lng"].value)

    tweet.put()

    return "OK"