def get_username_creator():
	username_creator = getattr(settings, 'REGISTRATION_EMAIL_ONLY_USERNAME_CREATOR', None)
	if username_creator is None:
		create_username = default_create_username
	elif isinstance(username_creator, basestring):
		try:
			create_username = import_item(username_creator)
		except ImportError:
			raise ImproperlyConfigured(
			'REGISTRATION_EMAIL_ONLY_USERNAME_CREATOR setting is invalid\n\n'
			'The value you provided (%s) cannot be imported' % username_creator
		)
	elif callable(username_creator):
		create_username = username_creator
	else:
		raise ImproperlyConfigured(
			'REGISTRATION_EMAIL_ONLY_USERNAME_CREATOR setting is invalid\n\n'
			'If specified, REGISTRATION_EMAIL_ONLY_USERNAME_CREATOR must be\n'
			'either a callable which returns a username or a string\n'
			'containing the import-able path to such a callable.'
		)
	return create_username
예제 #2
0
	def test_multiple(self):
		self.assertEqual(import_item('os.path.relpath'), os.path.relpath)
예제 #3
0
	def test_single(self):
		self.assertEqual(import_item('unittest.TestCase'), TestCase)