本文整理汇总了Python中ZODB.PersistentMapping.PersistentMapping.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentMapping.iteritems方法的具体用法?Python PersistentMapping.iteritems怎么用?Python PersistentMapping.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZODB.PersistentMapping.PersistentMapping
的用法示例。
在下文中一共展示了PersistentMapping.iteritems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AnzECASClient
# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import iteritems [as 别名]
class AnzECASClient(AnzCASClient):
''' Anz eCAS client extends anz.casclient to support European Council CAS'''
implements( IAnzCASClient )
meta_type = 'Anz eCAS Client'
casServerValidationUrl = ''
security = ClassSecurityInfo()
# Session variable use to save assertion
CAS_ASSERTION = '__ecas_assertion'
_properties = AnzCASClient._properties + (
{
'id': 'casServerValidationUrl',
'label': 'eCAS Server Validation URL',
'type': 'string',
'mode': 'w'
},
)
def __init__( self, id, title ):
super(AnzECASClient, self).__init__(id, title)
self._ecas_id = PersistentMapping()
def getEcasUserId(self, username):
userdb = getattr(self, '_ecas_id', None)
if userdb:
for ecas_id, user in self._ecas_id.iteritems():
if isEmail(username):
if user.email and user.email.lower() == username.lower():
return ecas_id
else:
if user.username == username:
return ecas_id
def getEcasIDUser(self, ecas_id):
"""Return internal user mapping for the ecas_id.
"""
userdb = getattr(self, '_ecas_id', {})
return userdb.get(ecas_id)
def getEcasIDEmail(self, ecas_id):
"""Return ecas user's email."""
ecas_user = self.getEcasIDUser(ecas_id)
if ecas_user:
return ecas_user.email
def getEcasIDUsername(self, ecas_id):
"""Return ecas user's username."""
ecas_user = self.getEcasIDUser(ecas_id)
if ecas_user:
return ecas_user.username
security.declarePrivate( 'challenge' )
def challenge( self, request, response, **kw ):
if request['QUERY_STRING']:
url = request['ACTUAL_URL'] + "?" + request['QUERY_STRING']
else:
url = request['ACTUAL_URL']
came_from = urllib2.quote(url)
response.setCookie('challenged', True, path='/')
response.redirect( '/Login/unauthorized?came_from=%s' % came_from, lock=1 )
return 1
def validateServiceTicket(self, service, ticket):
if self.ticketValidationSpecification == 'CAS 1.0':
validator = Cas10TicketValidator(
self.casServerUrlPrefix, self.renew )
else:
if self.acceptAnyProxy or self.allowedProxyChains:
validator = Cas20ProxyTicketValidator(
self.casServerUrlPrefix,
self._pgtStorage,
acceptAnyProxy=self.acceptAnyProxy,
allowedProxyChains=self.allowedProxyChains,
renew=self.renew )
else:
validator = ECas20ServiceTicketValidator(
self.casServerUrlPrefix, self.casServerValidationUrl, self._pgtStorage, self.renew )
return validator.validate(ticket, service, self.getProxyCallbackUrl() )
security.declarePrivate( 'authenticateCredentials' )
def authenticateCredentials( self, credentials ):
user_and_info = super(AnzECASClient, self).authenticateCredentials(credentials)
if not user_and_info:
return None
user, info = user_and_info
"""
# this code should not be here, but in an assignLocalRolesPlugin
# make sure the code following will not start a transaction without committing this one
# else we shall loose the session stored by casclient.py:extractCredentials
# and the next auth plugin will try to validate the ticket himself and fail
# because this one was provided by a different sso service than what the next plugin is bound to
try:
engine = self.unrestrictedTraverse('/ReportekEngine')
authMiddleware = engine.authMiddlewareApi
if authMiddleware:
#.........这里部分代码省略.........