本文整理汇总了Python中social_auth.signals.socialauth_registered.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args, **kwargs):
"""Update user details using data from provider."""
changed = False # flag to track changes
for name, value in details.iteritems():
# do not update username, it was already generated
# do not update configured fields if user already existed
if name in (USERNAME, "id", "pk") or (not is_new and name in setting("SOCIAL_AUTH_PROTECTED_USER_FIELDS", [])):
continue
if value and value != getattr(user, name, None):
setattr(user, name, value)
changed = True
# Fire a pre-update signal sending current backend instance,
# user instance (created or retrieved from database), service
# response and processed details.
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
signal_kwargs = {"sender": backend.__class__, "user": user, "response": response, "details": details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response, socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
开发者ID:kjoconnor,项目名称:django-social-auth,代码行数:34,代码来源:user.py
示例2: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args,
**kwargs):
"""Update user details using data from provider."""
changed = False # flag to track changes
warn_setting('SOCIAL_AUTH_CHANGE_SIGNAL_ONLY', 'update_user_details')
# check if values update should be left to signals handlers only
if not setting('SOCIAL_AUTH_CHANGE_SIGNAL_ONLY'):
do_not_update_email = setting('SOCIAL_AUTH_DO_NOT_UPDATE_EMAIL') == True
for name, value in details.iteritems():
# do not update username, it was already generated
if name in (USERNAME, 'id', 'pk'):
continue
if do_not_update_email and name == 'email' and not user.email:
continue
if value and value != getattr(user, name, None):
setattr(user, name, value)
changed = True
# Fire a pre-update signal sending current backend instance,
# user instance (created or retrieved from database), service
# response and processed details.
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
signal_kwargs = {'sender': backend.__class__, 'user': user,
'response': response, 'details': details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response,
socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
开发者ID:Quard,项目名称:django-social-auth,代码行数:43,代码来源:user.py
示例3: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args,
**kwargs):
"""Override of social_auth method, to prevent details from getting updated."""
LOGGER.debug("socialprofile.models.update_user_details")
changed = False # flag to track changes
signal_response = lambda (receiver, response): response
signal_kwargs = {'sender': backend.__class__, 'user': user,
'response': response, 'details': details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response,
socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
开发者ID:MechanisM,项目名称:django-socialprofile,代码行数:19,代码来源:models.py
示例4: update_user_details
def update_user_details(self, user, response, details, is_new=False):
"""Update user details with (maybe) new data. Username is not
changed if associating a new credential."""
changed = False # flag to track changes
# check if values update should be left to signals handlers only
if not CHANGE_SIGNAL_ONLY:
logger.debug('Updating user details for user %s', user,
extra=dict(data=details))
for name, value in details.iteritems():
# do not update username, it was already generated by
# self.username(...) and loaded in given instance
if name != USERNAME and value and value != getattr(user, name,
None):
setattr(user, name, value)
changed = True
# Fire a pre-update signal sending current backend instance,
# user instance (created or retrieved from database), service
# response and processed details.
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
kwargs = {'sender': self.__class__, 'user': user,
'response': response, 'details': details}
changed |= any(filter(signal_response, pre_update.send(**kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response,
socialauth_registered.send(**kwargs)))
if changed:
user.save()
开发者ID:alexlovelltroy,项目名称:django-social-auth,代码行数:41,代码来源:__init__.py
示例5: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args, **kwargs):
"""Update user details using data from provider."""
# we don't want to change anything unless the user is new
if not is_new:
return
changed = False # flag to track changes
for name, value in details.iteritems():
# do not update username, it was already generated
if name == USERNAME:
continue
if value and value != getattr(user, name, None):
setattr(user, name, value)
changed = True
# Fire a pre-update signal sending current backend instance,
# user instance (created or retrieved from database), service
# response and processed details.
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
signal_kwargs = {'sender': backend.__class__, 'user': user,
'response': response, 'details': details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response,
socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
开发者ID:Dzidudu,项目名称:mzalendo,代码行数:40,代码来源:pipeline.py
示例6: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args, **kwargs):
"""Update user details using data from provider."""
changed = False # flag to track changes
warn_setting("SOCIAL_AUTH_CHANGE_SIGNAL_ONLY", "update_user_details")
# check if values update should be left to signals handlers only
if not getattr(settings, "SOCIAL_AUTH_CHANGE_SIGNAL_ONLY", False):
for name, value in details.iteritems():
# do not update username, it was already generated
if name == USERNAME:
continue
if value and value != getattr(user, name, None):
setattr(user, name, value)
changed = True
# Fire a pre-update signal sending current backend instance,
# user instance (created or retrieved from database), service
# response and processed details.
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
signal_kwargs = {"sender": backend.__class__, "user": user, "response": response, "details": details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response, socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
开发者ID:sbarysiuk,项目名称:django-social-auth,代码行数:37,代码来源:user.py
示例7: update_user_details
def update_user_details(backend, details, response, user, is_new=False, *args,
**kwargs):
"""Update user details using data from provider."""
if backend.name not in ('twitter', 'facebook'):
return
fields_name = backend.RESPONSE_FIELDS
profile = user.get_profile()
if not profile.bio and response.get(fields_name['bio'], None):
profile.bio = response[fields_name['bio']]
if not profile.user.first_name and response.get('first_name', None):
user.first_name = response['first_name']
if not profile.user.last_name and response.get('last_name', None):
user.last_name = response['last_name']
if not profile.web and response.get(fields_name['web'], None):
profile.web = response[fields_name['web']]
if not profile.image and response.get(fields_name['image'], None):
content = urllib.urlretrieve(response[fields_name['image']].encode('utf-8'
).replace("_normal", ""))
profile.image.save("%s.jpg" % user.id, File(open(content[0])), save=True)
if not profile.gender and response.get('gender', None):
profile.gender = response['gender']
if not profile.birthdate and response.get('birthday', None):
profile.birthdate = datetime.strptime(response['birthday'],
"%m/%d/%Y").date()
if not profile.city and response.get('location', None):
try:
profile.city = response['location'].get('name', None)
except AttributeError:
profile.city = response['location']
profile.geocode_location()
profile.save()
if not is_new:
return
return
changed = False # flag to track changes
for name, value in details.iteritems():
# do not update username, it was already generated
# do not update configured fields if user already existed
if name in (USERNAME, 'id', 'pk') or (not is_new and
name in setting('SOCIAL_AUTH_PROTECTED_USER_FIELDS', [])):
continue
if value and value != getattr(user, name, None):
setattr(user, name, value)
changed = True
# user instance (created or retrieved from database), service
# response and processed details.
# Fire a pre-update signal sending current backend instance,
#
# Also fire socialauth_registered signal for newly registered
# users.
#
# Signal handlers must return True or False to signal instance
# changes. Send method returns a list of tuples with receiver
# and it's response.
signal_response = lambda (receiver, response): response
signal_kwargs = {'sender': backend.__class__, 'user': user,
'response': response, 'details': details}
changed |= any(filter(signal_response, pre_update.send(**signal_kwargs)))
# Fire socialauth_registered signal on new user registration
if is_new:
changed |= any(filter(signal_response,
socialauth_registered.send(**signal_kwargs)))
if changed:
user.save()
profile.save()
开发者ID:kamotos,项目名称:django-social-auth,代码行数:72,代码来源:user.py
注:本文中的social_auth.signals.socialauth_registered.send函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论