當前位置: 首頁>>代碼示例>>Python>>正文


Python IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']方法代碼示例

本文整理匯總了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]
開發者ID:a25kk,項目名稱:stv2,代碼行數:14,代碼來源:test_install.py

示例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)))
開發者ID:a25kk,項目名稱:stv2,代碼行數:20,代碼來源:test_hashers.py


注:本文中的zope.app.annotation.interfaces.IAnnotations.setdefault(ANNOT_KEY,{})['hash_type']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。