本文整理汇总了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;未经允许,请勿转载。 |
请发表评论