def maybe_send_initial_map_email(self): if not self.root_user_id \ or self.root_user_id != self.twitter_id \ or not self.email: return txt = """ Hi %s, We finished you twitter social map: http://www.smarttypes.org/social_map?user_id=%s We hope you enjoy exploring your map. We hope you find new/interesting/exciting people, to lead you to places you never imagined. Our software is in it's wee infancy -- there's still a lot of functionality in the queue: group trends, sentiment, search, and subscriptions -- we have a lot of work to do. We're curious what you think. Please don't hesitate to drop me a line or give me a call if you have feedback, or want to get involved. We hope you find value in the app -- thanks for signing up -- happy exploring! Timmy Wilson Cleveland, OH 1.330.612.0916 """ % (self.twitter_user.screen_name, self.twitter_user.id) from_address = '*****@*****.**' email_utils.send_email(from_address, [self.email], txt, 'Your twitter social map is ready')
def complete_signin(request_key, verifier, postgres_handle): auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) session = TwitterSession.get_by_request_key(request_key, postgres_handle) if session.access_key: #this happens if we get multiple same exact responses from twitter #perhaps crazy clicking or back / forward browsing credentials = TwitterCredentials.get_by_access_key( session.access_key, postgres_handle) else: auth.set_request_token(request_key, session.request_secret) auth.get_access_token(verifier) # may have signed up already credentials = TwitterCredentials.get_by_access_key( auth.access_token.key, postgres_handle) if not credentials: credentials = TwitterCredentials.create(auth.access_token.key, auth.access_token.secret, postgres_handle) session.access_key = credentials.access_key if not credentials.twitter_user: #probably don't have the user in our db yet user = TwitterUser.upsert_from_api_user(credentials.api_handle.me(), postgres_handle) credentials.twitter_id = user.id credentials.save() #email screen_name = credentials.twitter_user.screen_name email_utils.send_email('*****@*****.**', ['*****@*****.**'], '%s signed up' % screen_name, 'smarttypes signup!') return session.save()
def maybe_send_initial_map_email(self): if not self.root_user_id \ or self.root_user_id != self.twitter_id \ or not self.email: return txt = """ Hi %s, We finished you twitter social map: http://www.smarttypes.org/social_map?user_id=%s We hope you enjoy exploring your map. We hope you find new/interesting/exciting people, to lead you to places you never imagined. Our software is in it's wee infancy -- there's still a lot of functionality in the queue: group trends, sentiment, search, and subscriptions -- we have a lot of work to do. We're curious what you think. Please don't hesitate to drop me a line or give me a call if you have feedback, or want to get involved. We hope you find value in the app -- thanks for signing up -- happy exploring! Timmy Wilson Cleveland, OH 1.330.612.0916 """ % (self.twitter_user.screen_name, self.twitter_user.id) from_address = '*****@*****.**' email_utils.send_email(from_address, [self.email], txt, 'Your twitter social map is ready')
def complete_signin(request_key, verifier, postgres_handle): auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) session = TwitterSession.get_by_request_key(request_key, postgres_handle) if session.access_key: #this happens if we get multiple same exact responses from twitter #perhaps crazy clicking or back / forward browsing credentials = TwitterCredentials.get_by_access_key(session.access_key, postgres_handle) else: auth.set_request_token(request_key, session.request_secret) auth.get_access_token(verifier) # may have signed up already credentials = TwitterCredentials.get_by_access_key(auth.access_token.key, postgres_handle) if not credentials: credentials = TwitterCredentials.create(auth.access_token.key, auth.access_token.secret, postgres_handle) session.access_key = credentials.access_key if not credentials.twitter_user: #probably don't have the user in our db yet user = TwitterUser.upsert_from_api_user(credentials.api_handle.me(), postgres_handle) credentials.twitter_id = user.id credentials.save() #email screen_name = credentials.twitter_user.screen_name email_utils.send_email('*****@*****.**', ['*****@*****.**'], '%s signed up' % screen_name, 'smarttypes signup!') return session.save()
def application(environ, start_response): path = environ.get('PATH_INFO', '').lstrip('/') for regex, controller in urls: match = re.search(regex, path) if match: request = Request(environ) try: postgres_handle = PostgresHandle(smarttypes.connection_string) try: session = None if request.cookies.get('session'): session = TwitterSession.get_by_request_key( request.cookies['session'], postgres_handle) response_dict = controller(request, session, postgres_handle) web_response = WebResponse(request, controller.__name__, response_dict, session) response_headers = web_response.get_response_headers() response_string = web_response.get_response_str() if getattr(postgres_handle, '_connection', False): postgres_handle.connection.commit() status_code = '200 OK' except RedirectException, (redirect_ex): if getattr(postgres_handle, '_connection', False): postgres_handle.connection.commit() status_code = '303 See Other' response_headers = [('Location', redirect_ex.redirect_url)] response_string = [""] except: if getattr(postgres_handle, '_connection', False): postgres_handle.connection.rollback() raise finally: if getattr(postgres_handle, '_connection', False): postgres_handle.connection.close() #start response start_response(status_code, response_headers) return response_string except Exception: #can't use print statements with mod_wsgi error_string = traceback.format_exc() start_response('500 Internal Server Error', [('Content-Type', 'text/plain')]) if smarttypes.config.IS_PROD: email_utils.send_email( '*****@*****.**', ['*****@*****.**', '*****@*****.**'], error_string, 'smarttypes site error') return [error_string]
def application(environ, start_response): path = environ.get('PATH_INFO', '').lstrip('/') for regex, controller in urls: match = re.search(regex, path) if match: request = Request(environ) try: postgres_handle = PostgresHandle(smarttypes.connection_string) try: session = None if request.cookies.get('session'): session = TwitterSession.get_by_request_key(request.cookies['session'], postgres_handle) response_dict = controller(request, session, postgres_handle) web_response = WebResponse(request, controller.__name__, response_dict, session) response_headers = web_response.get_response_headers() response_string = web_response.get_response_str() if getattr(postgres_handle, '_connection', False): postgres_handle.connection.commit() status_code = '200 OK' except RedirectException, (redirect_ex): if getattr(postgres_handle, '_connection', False): postgres_handle.connection.commit() status_code = '303 See Other' response_headers = [('Location', redirect_ex.redirect_url)] response_string = [""] except: if getattr(postgres_handle, '_connection', False): postgres_handle.connection.rollback() raise finally: if getattr(postgres_handle, '_connection', False): postgres_handle.connection.close() #start response start_response(status_code, response_headers) return response_string except Exception: #can't use print statements with mod_wsgi error_string = traceback.format_exc() start_response('500 Internal Server Error', [('Content-Type', 'text/plain')]) if smarttypes.config.IS_PROD: email_utils.send_email('*****@*****.**', ['*****@*****.**', '*****@*****.**'], error_string, 'smarttypes site error') return [error_string]
def complete_signin(request_key, verifier, postgres_handle): auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) session = TwitterSession.get_by_request_key(request_key, postgres_handle) auth.set_request_token(request_key, session.request_secret) auth.get_access_token(verifier) # may have signed up already credentials = TwitterCredentials.get_by_access_key(auth.access_token.key, postgres_handle) if not credentials: credentials = TwitterCredentials.create(auth.access_token.key, auth.access_token.secret, postgres_handle) session.access_key = credentials.access_key if not credentials.twitter_user: user = TwitterUser.upsert_from_api_user(credentials.api_handle.me(), postgres_handle) credentials.twitter_id = user.id credentials.save() screen_name = credentials.twitter_user.screen_name email_utils.send_email('*****@*****.**', ['*****@*****.**'], '%s signed up' % screen_name, 'smarttypes signup!') return session.save()