Example #1
0
def application(environ, start_response):
    session = None
    return_to = None
    cookie = Cookie.SimpleCookie()

    if environ.has_key('HTTP_COOKIE'):
        cookie.load(environ["HTTP_COOKIE"])

    if cookie.has_key('sid'):
        session = getGeloSession(cookie['sid'].value)

    param = parse_qs(environ['QUERY_STRING'])

    if not param.has_key('oauth_token'):
        start_response('400 Bad Request', [('Content-Type', 'text/plain')])
        return 'oauth_token not found'

    acc_token = gelotter.oauth.authorize(param['oauth_token'][0])
    if (acc_token):
        token_key = acc_token.put()
        session.token_key.delete()
        session.token_key = token_key
        return_to = session.return_to
        session.return_to = ''
        session.put()

    if return_to:
        start_response('302 Found', [('Content-Type', 'text/plain'),
                                     ('Location', return_to)])
        return "OK"
    else:
        start_response('200 OK', [('Content-Type', 'text/plain')])
        return "OK"
Example #2
0
def application ( environ, start_response ):
    session = None
    return_to = None
    cookie = Cookie.SimpleCookie()
    
    if environ.has_key('HTTP_COOKIE'):
        cookie.load(environ["HTTP_COOKIE"])

    if cookie.has_key('sid'):
        session = getGeloSession(cookie['sid'].value)

    param = parse_qs(environ['QUERY_STRING'])

    if not param.has_key('oauth_token'):
        start_response('400 Bad Request', [('Content-Type',  'text/plain')])
        return 'oauth_token not found'

    acc_token = gelotter.oauth.authorize(param['oauth_token'][0])
    if(acc_token):
        token_key = acc_token.put()
        session.token_key.delete()
        session.token_key = token_key
        return_to = session.return_to
        session.return_to = ''
        session.put()

    if return_to:
        start_response('302 Found', [('Content-Type',  'text/plain'), 
                                     ('Location', return_to)])
        return "OK"
    else:
        start_response('200 OK', [('Content-Type',  'text/plain')])
        return "OK"
Example #3
0
def application ( environ, start_response ):
    session = None
    
    form = cgi.FieldStorage(fp=environ['wsgi.input'], 
                            environ=environ)

    cookie = Cookie.SimpleCookie()

    if environ.has_key('HTTP_COOKIE'):
        cookie.load(environ["HTTP_COOKIE"])

    if not cookie.has_key('sid'):
        return 'session not found'

    session = getGeloSession(cookie['sid'].value)
    session.time_updated = datetime.now()
    session.put()

    start_response('200 OK', [('Content-Type', 'text/plain')])
    result =  update(
        form['status'].value, 
        lat = form['lat'].value, 
        lng = form['lng'].value, 
        display_coordinates = 'true', 
        oauth_token = session.token_key.oauth_token, 
        oauth_token_secret = session.token_key.oauth_token_secret
        )
    return result
Example #4
0
def application(environ, start_response):
    session = None

    form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)

    cookie = Cookie.SimpleCookie()

    if environ.has_key('HTTP_COOKIE'):
        cookie.load(environ["HTTP_COOKIE"])

    if not cookie.has_key('sid'):
        return 'session not found'

    session = getGeloSession(cookie['sid'].value)
    session.time_updated = datetime.now()
    session.put()

    start_response('200 OK', [('Content-Type', 'text/plain')])
    tweets = user_timeline2(
        session.id,
        oauth_token=session.token_key.oauth_token,
        oauth_token_secret=session.token_key.oauth_token_secret)

    ret = []
    for t in tweets:
        lat = None
        lng = None
        if t['coordinates']:
            lat = float(t['coordinates']['coordinates'][0])
            lng = float(t['coordinates']['coordinates'][1])
        elem = []
        elem.append(
            str(
                datetime.strptime(t['created_at'],
                                  "%a %b %d %H:%M:%S +0000 %Y")))
        elem.append(Thumbs.genThumbs(t['text']))
        if lat and lng:
            elem.append([lat, lng])
        ret.append(elem)

    return json.dumps(ret)
Example #5
0
def application ( environ, start_response ):
    session = None
    
    form = cgi.FieldStorage(fp=environ['wsgi.input'], 
                            environ=environ)

    cookie = Cookie.SimpleCookie()

    if environ.has_key('HTTP_COOKIE'):
        cookie.load(environ["HTTP_COOKIE"])

    if not cookie.has_key('sid'):
        return 'session not found'

    session = getGeloSession(cookie['sid'].value)
    session.time_updated = datetime.now()
    session.put()

    start_response('200 OK', [('Content-Type', 'text/plain')])
    tweets = user_timeline2(session.id, 
                            oauth_token = session.token_key.oauth_token, 
                            oauth_token_secret = session.token_key.oauth_token_secret)

    ret = []
    for t in tweets:
        lat = None
        lng = None
        if t['coordinates']:
            lat = float(t['coordinates']['coordinates'][0])
            lng = float(t['coordinates']['coordinates'][1])
        elem = []
        elem.append(str(datetime.strptime(t['created_at'], "%a %b %d %H:%M:%S +0000 %Y")))
        elem.append(Thumbs.genThumbs(t['text']))
        if lat and lng:
            elem.append([lat, lng])
        ret.append(elem)

    return json.dumps(ret)