本文整理匯總了Python中zope.app.annotation.interfaces.IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']方法的典型用法代碼示例。如果您正苦於以下問題:Python IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']方法的具體用法?Python IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']怎麽用?Python IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zope.app.annotation.interfaces.IAnnotations
的用法示例。
在下文中一共展示了IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testExportNodeWithAnnotation
# 需要導入模塊: from zope.app.annotation.interfaces import IAnnotations [as 別名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import setdefault(ANNOT_KEY,{})['hash_type'] [as 別名]
def testExportNodeWithAnnotation(self):
"""
when membrane tool is annotated, hash-type node should get exported
attribute 'name' on the node should contain the hash-type
"""
# initially add the annotation on to the membrane_tool
annot = IAnnotations(self.portal.membrane_tool)
annot.setdefault(ANNOT_KEY, {})['hash_type'] = 'bcrypt'
node = self.adapter._exportNode()
self.failUnless('<hash-type name="bcrypt"/>' in node.toxml())
# clear the bogus annotation
del annot[ANNOT_KEY]
示例2: test_hashers
# 需要導入模塊: from zope.app.annotation.interfaces import IAnnotations [as 別名]
# 或者: from zope.app.annotation.interfaces.IAnnotations import setdefault(ANNOT_KEY,{})['hash_type'] [as 別名]
def test_hashers(self):
for htype in HASHERS:
login_id = 'hashtest_%s' % htype
member = self.portal_member
if not getAdapter(member, IHashPW, htype).isAvailable(): continue
mbtool = getToolByName(member, 'membrane_tool')
annot = IAnnotations(mbtool)
annot.setdefault(ANNOT_KEY, {})['hash_type'] = htype
member.setRoles('Member')
member.processForm(values=MEM_DATA)
password = member.getPassword()
hash_type, hashed = password.split(':', 1)
self.assertEqual(htype, hash_type)
self.failUnless(member.verifyCredentials(dict(login='portal_member',
**MEM_DATA)))