本文整理汇总了Python中socialregistration.utils._https函数的典型用法代码示例。如果您正苦于以下问题:Python _https函数的具体用法?Python _https怎么用?Python _https使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_https函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: facebook_js
def facebook_js():
id = getattr(settings, 'FACEBOOK_APP_ID', None)
key = getattr(settings, 'FACEBOOK_API_KEY', None)
perms = getattr(settings, 'FACEBOOK_REQUEST_PERMISSIONS', None)
if not id:
warnings.warn("django-socialregistration: Please update your settings.py and add a FACEBOOK_APP_ID key", Warning)
return {'facebook_app_id': id, 'facebook_api_key': key, 'is_https' : bool(_https()), 'facebook_req_perms' : perms }
开发者ID:albertsun,项目名称:django-socialregistration,代码行数:7,代码来源:facebook_tags.py
示例2: _callback_url
def _callback_url(request):
site_domain = Site.objects.get_current().domain
if site_domain != 'example.com':
# Site is properly configured. Use it
return 'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
)
# django.site is not configured. Figure out the domain from the request
# Why not just always do this?
url = request.build_absolute_uri( reverse('openid_callback') )
if _https():
url = re.sub('http://','https://',url)
return url
开发者ID:leopd,项目名称:django-socialregistration,代码行数:16,代码来源:views.py
示例3: facebook_js
def facebook_js():
id = getattr(settings, "FACEBOOK_APP_ID", None)
key = getattr(settings, "FACEBOOK_API_KEY", None)
perms = getattr(settings, "FACEBOOK_REQUEST_PERMISSIONS", None)
if not id:
warnings.warn(
"django-socialregistration: Please update your settings.py and add a FACEBOOK_APP_ID key", Warning
)
return {"facebook_app_id": id, "facebook_api_key": key, "is_https": bool(_https()), "facebook_req_perms": perms}
开发者ID:pinda,项目名称:django-socialregistration,代码行数:9,代码来源:facebook_tags.py
示例4: openid_callback
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html',
client_class = None):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = client_class(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
if client.is_valid():
identity = client.result.identity_url
if request.user.is_authenticated():
# Handling already logged in users just connecting their accounts
try:
profile = OpenIDProfile.objects.get(identity=identity)
except OpenIDProfile.DoesNotExist: # There can only be one profile with the same identity
profile = OpenIDProfile.objects.create(user=request.user,
identity=identity)
_connect(request.user, profile, client)
return HttpResponseRedirect(_get_next(request))
user = authenticate(identity=identity)
if user is None:
request.session['socialregistration_user'] = User()
request.session['socialregistration_profile'] = OpenIDProfile(
identity=identity
)
# Client is not pickleable with the request on it
client.request = None
request.session['socialregistration_client'] = client
return HttpResponseRedirect(reverse('socialregistration_setup'))
if not user.is_active:
return render_to_response(
account_inactive_template,
extra_context,
context_instance=RequestContext(request)
)
_login(request, user, OpenIDProfile.objects.get(user = user), client)
return HttpResponseRedirect(_get_next(request))
return render_to_response(
template,
dict(),
context_instance=RequestContext(request)
)
开发者ID:jablko,项目名称:django-socialregistration,代码行数:55,代码来源:views.py
示例5: openid_callback
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html'):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
if client.is_valid():
if request.user.is_authenticated():
# Handling already logged in users just connecting their accounts
try:
profile = OpenIDProfile.objects.get(identity=request.GET.get('openid.claimed_id'))
except OpenIDProfile.DoesNotExist: # There can only be one profile with the same identity
profile = OpenIDProfile.objects.create(user=request.user,
identity=request.GET.get('openid.claimed_id'))
return HttpResponseRedirect(_get_next(request))
user = authenticate(identity=request.GET.get('openid.claimed_id'))
if user is None:
request.session['socialregistration_user'] = User()
request.session['socialregistration_profile'] = OpenIDProfile(
identity=request.GET.get('openid.claimed_id')
)
for key, value in getattr(client, 'registration_data', {}).items():
request.session['social_suggested_%s' % key] = value
return HttpResponseRedirect(reverse('socialregistration_setup'))
else:
login(request, user)
return HttpResponseRedirect(_get_next(request))
if not user.is_active:
return render_to_response(
account_inactive_template,
extra_context,
context_instance=RequestContext(request)
)
login(request, user)
return HttpResponseRedirect(_get_next(request))
return render_to_response(
template,
dict(),
context_instance=RequestContext(request)
)
开发者ID:piquadrat,项目名称:django-socialregistration,代码行数:54,代码来源:views.py
示例6: openid_redirect
def openid_redirect(request):
"""
Redirect the user to the openid provider
"""
request.session["next"] = _get_next(request)
request.session["openid_provider"] = request.GET.get("openid_provider")
client = OpenID(
request,
"http%s://%s%s" % (_https(), Site.objects.get_current().domain, reverse("openid_callback")),
request.GET.get("openid_provider"),
)
return client.get_redirect()
开发者ID:statico,项目名称:django-socialregistration,代码行数:13,代码来源:views.py
示例7: openid_redirect
def openid_redirect(request):
"""
Redirect the user to the openid provider
"""
request.session["next"] = _get_next(request)
request.session["openid_provider"] = request.GET.get("openid_provider")
client = OpenID(
request,
"http%s://%s%s" % (_https(), request.get_host(), reverse("openid_callback")),
request.GET.get("openid_provider"),
)
try:
return client.get_redirect()
except DiscoveryFailure:
request.session["openid_error"] = True
return HttpResponseRedirect(settings.LOGIN_URL)
开发者ID:oduvan,项目名称:django-socialregistration,代码行数:16,代码来源:views.py
示例8: openid_callback
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html'):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
if client.is_valid():
if request.user.is_authenticated():
# Handling already logged in users just connecting their accounts
try:
profile, created = OpenIDProfile.objects.get_or_create(user=request.user, identity=request.GET.get('openid.claimed_id'))
except IntegrityError:
request.user.message_set.create(message=_('This openid has already been connected to a user.'))
return HttpResponseRedirect(_get_next(request))
user = authenticate(identity=request.GET.get('openid.claimed_id'))
if user is None:
request.session['socialregistration_user'] = User()
request.session['socialregistration_profile'] = OpenIDProfile(
identity=request.GET.get('openid.claimed_id')
)
return HttpResponseRedirect(reverse('socialregistration_setup'))
if not user.is_active:
return render_to_response(
account_inactive_template,
extra_context,
context_instance=RequestContext(request)
)
login(request, user)
return HttpResponseRedirect(_get_next(request))
return render_to_response(
template,
dict(),
context_instance=RequestContext(request)
)
开发者ID:devioustree,项目名称:django-socialregistration,代码行数:47,代码来源:views.py
示例9: openid_redirect
def openid_redirect(request):
"""
Redirect the user to the openid provider
"""
request.session['next'] = _get_next(request)
request.session['openid_provider'] = request.GET.get('openid_provider')
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.GET.get('openid_provider')
)
return client.get_redirect()
开发者ID:devioustree,项目名称:django-socialregistration,代码行数:17,代码来源:views.py
示例10: openid_redirect
def openid_redirect(request, client_class=None):
"""
Redirect the user to the openid provider
"""
request.session["next"] = _get_next(request)
request.session["openid_provider"] = request.GET.get("openid_provider")
client = client_class(
request,
"http%s://%s%s" % (_https(), Site.objects.get_current().domain, reverse("openid_callback")),
request.GET.get("openid_provider"),
)
try:
return client.get_redirect()
except DiscoveryFailure:
request.session["openid_error"] = True
return HttpResponseRedirect(settings.LOGIN_URL)
开发者ID:SimpleTax,项目名称:django-socialregistration,代码行数:17,代码来源:views.py
示例11: openid_callback
def openid_callback(
request,
template="socialregistration/openid.html",
extra_context=dict(),
account_inactive_template="socialregistration/account_inactive.html",
):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
"http%s://%s%s" % (_https(), Site.objects.get_current().domain, reverse("openid_callback")),
request.session.get("openid_provider"),
)
if client.is_valid():
identity = client.result.identity_url
if request.user.is_authenticated():
# Handling already logged in users just connecting their accounts
try:
profile = OpenIDProfile.objects.get(identity=identity)
except OpenIDProfile.DoesNotExist: # There can only be one profile with the same identity
profile = OpenIDProfile.objects.create(user=request.user, identity=identity)
return HttpResponseRedirect(_get_next(request))
user = authenticate(identity=identity)
if user is None:
request.session["socialregistration_user"] = User()
request.session["socialregistration_profile"] = OpenIDProfile(identity=identity)
return HttpResponseRedirect(reverse("socialregistration_setup"))
if not user.is_active:
return render_to_response(
account_inactive_template, extra_context, context_instance=RequestContext(request)
)
login(request, user)
return HttpResponseRedirect(_get_next(request))
return render_to_response(template, dict(), context_instance=RequestContext(request))
开发者ID:jorgebastida,项目名称:django-socialregistration,代码行数:41,代码来源:views.py
示例12: openid_redirect
def openid_redirect(request):
"""
Redirect the user to the openid provider
"""
request.session['next'] = _get_next(request)
request.session['openid_provider'] = request.GET.get('openid_provider')
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.GET.get('openid_provider')
)
try:
return client.get_redirect()
except DiscoveryFailure:
request.session['openid_error'] = True
return HttpResponseRedirect(settings.LOGIN_URL)
开发者ID:JordanReiter,项目名称:django-socialregistration,代码行数:21,代码来源:views.py
示例13: openid_redirect
def openid_redirect(request):
"""
Redirect the user to the openid provider
"""
request.session['next'] = _get_next(request)
request.session['openid_provider'] = request.GET.get('openid_provider')
request.session['socialregistration_connect_object'] = get_object(request.GET)
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.GET.get('openid_provider')
)
try:
logger.info("Received redirect to %s from OpenID" % client.get_redirect())
return client.get_redirect()
except DiscoveryFailure:
request.session['openid_error'] = True
logger.info("OpenID failure, sending user to login.")
return HttpResponseRedirect(settings.LOGIN_URL)
开发者ID:adamfast,项目名称:django-socialregistration,代码行数:24,代码来源:views.py
示例14: openid_callback
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html'):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
try:
request_args = util.normalDict(request.GET)
if request.method == 'POST':
request_args.update(util.normalDict(request.POST))
if request_args:
client.complete()
c = client.consumer
return_to = util.getViewURL(request, openid_callback)
response = client.result
ax_items = {}
if response.status == consumer.SUCCESS:
provider = request.session.get('openid_provider')
# Set the schema uri depending on who the openid provier is:
# request only name and email by default (same as Google schemas):
schemas = GoogleOpenIDSchemas()
if 'yahoo' in provider:
schemas = YahooOpenIDSchemas()
if 'myopenid' in provider:
schemas = MyOpenIDSchemas()
ax_response = {}
ax_response = ax.FetchResponse.fromSuccessResponse(response)
if ax_response:
# Name and email schemas are always set, but not others so check if they are not empty first:
birth_date = zip = gender = []
if schemas.birth_date_schema:
birth_date = ax_response.get(schemas.birth_date_schema)
if schemas.zip_schema:
zip = ax_response.get(schemas.zip_schema)
if schemas.gender_schema:
gender = ax_response.get(schemas.gender_schema)
ax_items = {
'display_name': ax_response.get(schemas.name_schema),
'email': ax_response.get(schemas.email_schema),
'birth_date': birth_date,
'home_zip': zip,
'gender': gender,
}
request.session['ax_items'] = ax_items
except Exception, e:
pass
开发者ID:coxmediagroup,项目名称:django-socialregistration,代码行数:65,代码来源:views.py
示例15: openid_callback
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html'):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
if client.is_valid():
identity = client.result.identity_url
if 'socialregistration_connect_object' in request.session and request.session['socialregistration_connect_object'] != None:
# this exists so that social credentials can be attached to any arbitrary object using the same callbacks.
# Under normal circumstances it will not be used. Put an object in request.session named 'socialregistration_connect_object' and it will be used instead.
# After the connection is made it will redirect to request.session value 'socialregistration_connect_redirect' or settings.LOGIN_REDIRECT_URL or /
try:
# get the profile for this facebook UID and type of connected object
profile = OpenIDProfile.objects.get(identity=identity, content_type=ContentType.objects.get_for_model(request.session['socialregistration_connect_object'].__class__), object_id=request.session['socialregistration_connect_object'].pk)
except OpenIDProfile.DoesNotExist:
OpenIDProfile.objects.create(content_object=request.session['socialregistration_connect_object'], identity=identity)
del request.session['socialregistration_connect_object']
else:
if request.user.is_authenticated():
# Handling already logged in users just connecting their accounts
try:
profile = OpenIDProfile.objects.get(identity=identity, content_type=ContentType.objects.get_for_model(User))
except OpenIDProfile.DoesNotExist: # There can only be one profile with the same identity
profile = OpenIDProfile.objects.create(content_object=request.user,
identity=identity)
return HttpResponseRedirect(_get_next(request))
user = authenticate(identity=identity)
if user is None:
request.session['socialregistration_user'] = User()
request.session['socialregistration_profile'] = OpenIDProfile(
identity=identity
)
return HttpResponseRedirect(reverse('socialregistration_setup'))
if not user.is_active:
return render_to_response(
account_inactive_template,
extra_context,
context_instance=RequestContext(request)
)
login(request, user)
return HttpResponseRedirect(_get_next(request))
return render_to_response(
template,
dict(),
context_instance=RequestContext(request)
)
开发者ID:imrehg,项目名称:django-socialregistration,代码行数:63,代码来源:views.py
示例16: facebook_js
def facebook_js(requested_perms=""):
return {'facebook_api_key' : getattr(settings, 'FACEBOOK_API_KEY', ''), 'is_https' : bool(_https()), 'requested_perms': requested_perms, 'MEDIA_URL': getattr(settings, 'MEDIA_URL', ''), 'STATIC_MEDIA_URL': getattr(settings, 'STATIC_MEDIA_URL', '')}
开发者ID:imrehg,项目名称:django-socialregistration,代码行数:2,代码来源:facebook_tags.py
示例17: hyves_js
def hyves_js():
return {'hyves_consumer_key' : settings.HYVES_CONSUMER_KEY,
'site': Site.objects.get_current(),
'is_https' : bool(_https())}
开发者ID:nvbn,项目名称:django-socialregistration,代码行数:4,代码来源:hyves_tags.py
示例18: facebook_js
def facebook_js():
return {'facebook_api_key' : get_setting_for_current_site('FACEBOOK_API_KEY'), 'is_https' : bool(_https())}
开发者ID:thoblr,项目名称:django-socialregistration,代码行数:2,代码来源:facebook_tags.py
示例19: facebook_js
def facebook_js():
return {"facebook_api_key": settings.FACEBOOK_API_KEY, "is_https": bool(_https())}
开发者ID:edstafford,项目名称:django-socialregistration,代码行数:2,代码来源:facebook_tags.py
示例20: facebook_js
def facebook_js():
return {'facebook_api_key' : settings.FACEBOOK_API_KEY, 'is_https' : bool(_https())}
开发者ID:9naQuame,项目名称:audigram,代码行数:2,代码来源:facebook_tags.py
注:本文中的socialregistration.utils._https函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论