本文整理汇总了Python中auth_systems.AUTH_SYSTEMS类的典型用法代码示例。如果您正苦于以下问题:Python AUTH_SYSTEMS类的具体用法?Python AUTH_SYSTEMS怎么用?Python AUTH_SYSTEMS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AUTH_SYSTEMS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login_box_raw
def login_box_raw(request, return_url="/", auth_systems=None):
"""
a chunk of HTML that shows the various login options
"""
default_auth_system_obj = None
if helios_auth.DEFAULT_AUTH_SYSTEM:
default_auth_system_obj = AUTH_SYSTEMS[helios_auth.DEFAULT_AUTH_SYSTEM]
# make sure that auth_systems includes only available and enabled auth systems
if auth_systems != None:
enabled_auth_systems = (
set(auth_systems).intersection(set(helios_auth.ENABLED_AUTH_SYSTEMS)).intersection(set(AUTH_SYSTEMS.keys()))
)
else:
enabled_auth_systems = set(auth.ENABLED_AUTH_SYSTEMS).intersection(set(AUTH_SYSTEMS.keys()))
form = password.LoginForm()
return render_template_raw(
request,
"login_box",
{
"enabled_auth_systems": enabled_auth_systems,
"return_url": return_url,
"default_auth_system": helios_auth.DEFAULT_AUTH_SYSTEM,
"default_auth_system_obj": default_auth_system_obj,
"form": form,
},
)
示例2: test_eq
def test_eq(self):
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
u = models.User.update_or_create(
user_type=auth_system, user_id='foobar_eq', info={'name': 'Foo Bar Status Update'})
u2 = models.User.update_or_create(
user_type=auth_system, user_id='foobar_eq', info={'name': 'Foo Bar Status Update'})
self.assertEquals(u, u2)
示例3: test_can_create_election
def test_can_create_election(self):
"""
check that auth systems have the can_create_election call and that it's true for the common ones
"""
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
assert(hasattr(auth_system_module, 'can_create_election'))
if auth_system != 'clever':
assert(auth_system_module.can_create_election('foobar', {}))
示例4: can_create_election
def can_create_election(self):
"""
Certain auth systems can choose to limit election creation
to certain users.
"""
if not AUTH_SYSTEMS.has_key(self.user_type):
return False
return AUTH_SYSTEMS[self.user_type].can_create_election(self.user_id, self.info)
示例5: test_eligibility
def test_eligibility(self):
"""
test that users are reported as eligible for something
FIXME: also test constraints on eligibility
"""
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_status_update', info={'name':'Foo Bar Status Update'})
self.assertTrue(u.is_eligible_for({'auth_system': auth_system}))
示例6: test_status_update
def test_status_update(self):
"""
check that a user set up with status update ability reports it as such,
and otherwise does not report it
"""
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_status_update', info={'name':'Foo Bar Status Update'})
if hasattr(auth_system_module, 'send_message'):
self.assertNotEquals(u.update_status_template, None)
else:
self.assertEquals(u.update_status_template, None)
示例7: test_unique_users
def test_unique_users(self):
"""
there should not be two users with the same user_type and user_id
"""
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
models.User.objects.create(user_type = auth_system, user_id = 'foobar', info={'name':'Foo Bar'})
def double_insert():
models.User.objects.create(user_type = auth_system, user_id = 'foobar', info={'name': 'Foo2 Bar'})
self.assertRaises(IntegrityError, double_insert)
transaction.rollback()
示例8: test_create_or_update
def test_create_or_update(self):
"""
shouldn't create two users, and should reset the password
"""
for auth_system, auth_system_module in AUTH_SYSTEMS.iteritems():
u = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_cou', info={'name':'Foo Bar'})
def double_update_or_create():
new_name = 'Foo2 Bar'
u2 = models.User.update_or_create(user_type = auth_system, user_id = 'foobar_cou', info={'name': new_name})
self.assertEquals(u.id, u2.id)
self.assertEquals(u2.info['name'], new_name)
示例9: login_box_raw
def login_box_raw(request, return_url='/', auth_systems = None):
"""
a chunk of HTML that shows the various login options
"""
default_auth_system_obj = None
if auth.DEFAULT_AUTH_SYSTEM:
default_auth_system_obj = AUTH_SYSTEMS[auth.DEFAULT_AUTH_SYSTEM]
# make sure that auth_systems includes only available and enabled auth systems
if auth_systems != None:
enabled_auth_systems = set(auth_systems).intersection(set(auth.ENABLED_AUTH_SYSTEMS)).intersection(set(AUTH_SYSTEMS.keys()))
else:
enabled_auth_systems = set(auth.ENABLED_AUTH_SYSTEMS).intersection(set(AUTH_SYSTEMS.keys()))
form = password.LoginForm()
return render_template_raw(request, 'login_box', {
'enabled_auth_systems': enabled_auth_systems, 'return_url': return_url,
'default_auth_system': auth.DEFAULT_AUTH_SYSTEM, 'default_auth_system_obj': default_auth_system_obj,
'form' : form})
示例10: send_message
def send_message(self, subject, body):
if AUTH_SYSTEMS.has_key(self.user_type):
subject = subject.split("\n")[0]
AUTH_SYSTEMS[self.user_type].send_message(self.user_id, self.name, self.info, subject, body)
示例11: update_status
def update_status(self, status):
if AUTH_SYSTEMS.has_key(self.user_type):
AUTH_SYSTEMS[self.user_type].update_status(self.user_id, self.info, self.token, status)
示例12: can_update_status
def can_update_status(self):
if not AUTH_SYSTEMS.has_key(self.user_type):
return False
return AUTH_SYSTEMS[self.user_type].STATUS_UPDATES
示例13: public_url
def public_url(self):
if AUTH_SYSTEMS.has_key(self.user_type):
if hasattr(AUTH_SYSTEMS[self.user_type], 'public_url'):
return AUTH_SYSTEMS[self.user_type].public_url(self.user_id)
return None
示例14: send_notification
def send_notification(self, message):
if AUTH_SYSTEMS.has_key(self.user_type):
if hasattr(AUTH_SYSTEMS[self.user_type], 'send_notification'):
AUTH_SYSTEMS[self.user_type].send_notification(self.user_id, self.info, message)
示例15: login_box_raw
def login_box_raw(request, return_url='/', auth_systems=None, remove_unload=False):
"""
a chunk of HTML that shows the various login options
"""
default_auth_system_obj = None
if helios_auth.DEFAULT_AUTH_SYSTEM:
default_auth_system_obj = AUTH_SYSTEMS[helios_auth.DEFAULT_AUTH_SYSTEM]
# make sure that auth_systems includes only available and enabled
# helios_auth systems
if auth_systems != None:
enabled_auth_systems = set(auth_systems).intersection(set(helios_auth.ENABLED_AUTH_SYSTEMS)).intersection(set(AUTH_SYSTEMS.keys()))
else:
enabled_auth_systems = set(helios_auth.ENABLED_AUTH_SYSTEMS).intersection(set(AUTH_SYSTEMS.keys()))
auth_systems = list()
for auth_system in enabled_auth_systems:
auth_systems.append({'name': auth_system, 'display_name': AUTH_SYSTEMS[auth_system].get_name()})
form = password.LoginForm()
return render_template_raw(request, 'login_box', {
'auth_systems': auth_systems,
'return_url': return_url,
'default_auth_system': helios_auth.DEFAULT_AUTH_SYSTEM,
'default_auth_system_obj': default_auth_system_obj,
'form': form,
'remove_unload': remove_unload
})