Пример #1
0
    def __init__(self, request=None, response=None):
        self.now = datetime.datetime.now()
        self.tv = {}
        self.settings = SETTINGS.copy()
        self.sb_locations = SAFEBOX_LOCATIONS.copy()
        self.initialize(request, response)
        self.has_pass = False
        self.tv["version"] = os.environ['CURRENT_VERSION_ID']
        self.local = False
        if "127.0.0.1" in self.request.uri or "localhost" in self.request.uri:
            self.local = True
        # misc
        self.tv["current_url"] = self.request.uri
        # self.tv["fb_login_url"] = facebook.generate_login_url(self.request.path, self.uri_for('www-fblogin'))

        if "?" in self.request.uri:
            self.tv["current_base_url"] = self.request.uri[0:(self.request.uri.find('?'))]
        else:
            self.tv["current_base_url"] = self.request.uri

        try:
            self.tv["safe_current_base_url"] = urllib.quote(self.tv["current_base_url"])
        except:
            logging.exception("safe url error")

        self.tv["request_method"] = self.request.method

        self.session = self.get_session()
        self.user = self.get_current_user()
Пример #2
0
    def __init__(self, request=None, response=None):
        self.now = datetime.datetime.now()
        self.tv = {}
        self.settings = SETTINGS.copy()
        self.sb_locations = SAFEBOX_LOCATIONS.copy()
        self.initialize(request, response)
        self.has_pass = False
        self.tv["version"] = os.environ['CURRENT_VERSION_ID']
        self.local = False
        if "127.0.0.1" in self.request.uri or "localhost" in self.request.uri:
            self.local = True
        # misc
        self.tv["current_url"] = self.request.uri
        # self.tv["fb_login_url"] = facebook.generate_login_url(self.request.path, self.uri_for('www-fblogin'))

        if "?" in self.request.uri:
            self.tv["current_base_url"] = self.request.uri[0:(
                self.request.uri.find('?'))]
        else:
            self.tv["current_base_url"] = self.request.uri

        try:
            self.tv["safe_current_base_url"] = urllib.quote(
                self.tv["current_base_url"])
        except:
            logging.exception("safe url error")

        self.tv["request_method"] = self.request.method

        self.session = self.get_session()
        self.user = self.get_current_user()
Пример #3
0
 def __init__(self, request=None, response=None):
     self.now = datetime.datetime.now()
     self.tv = {}
     self.settings = SETTINGS.copy()
     self.initialize(request, response)
     self.has_pass = False
     self.tv["version"] = os.environ['CURRENT_VERSION_ID']
     self.local = False
     if "127.0.0.1" in self.request.uri or "localhost" in self.request.uri:
         self.local = True
Пример #4
0
    def __init__(self, request=None, response=None):
        self.now = datetime.datetime.now()
        self.ajax_response = THIS_RESPONSE.copy()
        self.tv = {}        
        self.settings = SETTINGS.copy()        
        self.initialize(request, response)        
        self.tv["version"] = os.environ['CURRENT_VERSION_ID']
        self.local = False        

        self.session = self.get_session()
        self.user = self.get_current_user()
Пример #5
0
import os
from settings import SETTINGS
from settings import SECRET_SETTINGS
import urllib, logging
from google.appengine.api import urlfetch

settings = SETTINGS.copy()
secret_settings = SECRET_SETTINGS.copy()

def generate_login_url(state, redirect, app_id = settings["fb_id"], scope = settings["fb_permissions"]):
    """https://www.facebook.com/dialog/oauth?
    client_id=YOUR_APP_ID
   &redirect_uri=YOUR_REDIRECT_URI
   &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
   &state=SOME_ARBITRARY_BUT_UNIQUE_STRING"""

    if not "http" in redirect:
        #add http
        redirect = "http://" + os.environ["HTTP_HOST"] + redirect

    url = "https://www.facebook.com/dialog/oauth"
    url += "?client_id=" + str(app_id)
    url += "&redirect_uri=" + str(urllib.quote(redirect,''))
    url += "&scope=" + ",".join(scope)
    url += "&state=" + str(urllib.quote(state))

    return url

def code_to_access_token(code, redirect, app_id = settings["fb_id"], app_secret = secret_settings["fb_secret"]):
    """https://graph.facebook.com/oauth/access_token?
    client_id=YOUR_APP_ID
Пример #6
0
import os
from settings import SETTINGS
from settings import SECRET_SETTINGS
import urllib, logging
from google.appengine.api import urlfetch

settings = SETTINGS.copy()
secret_settings = SECRET_SETTINGS.copy()


def generate_login_url(state,
                       redirect,
                       app_id=settings["fb_id"],
                       scope=settings["fb_permissions"]):
    """https://www.facebook.com/dialog/oauth?
    client_id=YOUR_APP_ID
   &redirect_uri=YOUR_REDIRECT_URI
   &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
   &state=SOME_ARBITRARY_BUT_UNIQUE_STRING"""

    if not "http" in redirect:
        #add http
        redirect = "http://" + os.environ["HTTP_HOST"] + redirect

    url = "https://www.facebook.com/dialog/oauth"
    url += "?client_id=" + str(app_id)
    url += "&redirect_uri=" + str(urllib.quote(redirect, ''))
    url += "&scope=" + ",".join(scope)
    url += "&state=" + str(urllib.quote(state))

    return url