SHARE
TWEET

Untitled

a guest Jun 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # settings.py:
  2.  
  3. SOCIAL_AUTH_PIPELINE = [
  4.     ...
  5.     'MyApp.file1.createUser',
  6.     ...
  7. ]
  8.  
  9. # file1.py :
  10.  
  11. from MyApp.models import FacebookUser
  12. import file2
  13.  
  14. def createUser(backend, user, request, response, *args, **kwargs):
  15.     if backend.name == 'facebook':
  16.  
  17.         global token
  18.         token = request['token']
  19.  
  20.     if request['user_type'] == "facebookUser" and not FacebookUser.objects.filter(user_id=user.id):
  21.  
  22.         FacebookUser.objects.create(user_id=user.id)
  23.         file2.doSomething()
  24.  
  25.     elif FacebookUser.objects.filter(user_id=user.id):
  26.         file2.doSomething()
  27.  
  28.  
  29. # file2.py :
  30.  
  31. from file1 import createUser
  32.  
  33. def doSomething():
  34.  
  35.     myToken = createUser().token   # <--- My problem is here. How can I access the global variable "token" from the createUser function in file1? The function createUser comes with arguments but how can I use it here?
  36.  
  37.     return myToken
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top