• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers._password_digest函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pymongo.helpers._password_digest函数的典型用法代码示例。如果您正苦于以下问题:Python _password_digest函数的具体用法?Python _password_digest怎么用?Python _password_digest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了_password_digest函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_password_digest

    def test_password_digest(self):
        self.assertRaises(TypeError, helpers._password_digest, 5)
        self.assertRaises(TypeError, helpers._password_digest, True)
        self.assertRaises(TypeError, helpers._password_digest, None)

        self.assert_(isinstance(helpers._password_digest("mike", "password"), unicode))
        self.assertEqual(helpers._password_digest("mike", "password"), u"cd7e45b3b2767dc2fa9b6b548457ed00")
        self.assertEqual(helpers._password_digest("mike", "password"), helpers._password_digest(u"mike", u"password"))
        self.assertEqual(helpers._password_digest("Gustave", u"Dor\xe9"), u"81e0e2364499209f466e75926a162d73")
开发者ID:apendleton,项目名称:mongo-python-driver,代码行数:9,代码来源:test_database.py


示例2: add_user

    def add_user(self, name, password, read_only=False):
        """Create user `name` with password `password`.

        Add a new user with permissions for this :class:`Database`.

        .. note:: Will change the password if user `name` already exists.

        :Parameters:
          - `name`: the name of the user to create
          - `password`: the password of the user to create
          - `read_only` (optional): if ``True`` it will make user read only

        .. versionchanged:: 2.2
           Added support for read only users

        .. versionadded:: 1.4
        """

        user = self.system.users.find_one({"user": name}) or {"user": name}
        user["pwd"] = helpers._password_digest(name, password)
        user["readOnly"] = common.validate_boolean("read_only", read_only)

        try:
            self.system.users.save(user, safe=True)
        except OperationFailure, e:
            # First admin user add fails gle in MongoDB >= 2.1.2
            # See SERVER-4225 for more information.
            if "login" in str(e):
                pass
            else:
                raise
开发者ID:poudro,项目名称:mongo-python-driver,代码行数:31,代码来源:database.py


示例3: add_user

	def add_user(self, name, password):
		#pymongo中的加了角色缺少readOnly属性
		#self._db.add_user(name, password)
		from pymongo import common, helpers
		pwd = helpers._password_digest(name, password)
		self._db.system.users.update({"user": name},
								 {"user": name,
								  "pwd": pwd,
								  "readOnly": False},
								 upsert=True, safe=True)
开发者ID:soulsharepj,项目名称:zdzl,代码行数:10,代码来源:setting.py


示例4: add_user

    def add_user(self, name, password):
        """Create user `name` with password `password`.

        Add a new user with permissions for this :class:`Database`.

        .. note:: Will change the password if user `name` already exists.

        :Parameters:
          - `name`: the name of the user to create
          - `password`: the password of the user to create

        .. versionadded:: 1.4
        """
        pwd = helpers._password_digest(name, password)
        self.system.users.update({"user": name}, {"user": name, "pwd": pwd}, upsert=True, safe=True)
开发者ID:benaranguren,项目名称:mongo-python-driver,代码行数:15,代码来源:database.py


示例5: add_user

    def add_user(self, name, password, read_only=False):
        """Create user `name` with password `password`.

        Add a new user with permissions for this :class:`Database`.

        .. note:: Will change the password if user `name` already exists.

        :Parameters:
          - `name`: the name of the user to create
          - `password`: the password of the user to create
          - `read_only` (optional): if ``True`` it will make user read only

        .. versionchanged:: 2.2
           Added support for read only users

        .. versionadded:: 1.4
        """
        pwd = helpers._password_digest(name, password)
        self.system.users.update(
            {"user": name}, {"user": name, "pwd": pwd, "readOnly": read_only}, upsert=True, safe=True
        )
开发者ID:BU-NU-CLOUD-SP16,项目名称:Lambda-on-OpenStack,代码行数:21,代码来源:database.py



注:本文中的pymongo.helpers._password_digest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers._unpack_response函数代码示例发布时间:2022-05-27
下一篇:
Python helpers._index_list函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap