本文整理匯總了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:
#.........這裏部分代碼省略.........