当前位置: 首页>>代码示例>>Python>>正文


Python Group.db方法代码示例

本文整理汇总了Python中server.models.group.Group.db方法的典型用法代码示例。如果您正苦于以下问题:Python Group.db方法的具体用法?Python Group.db怎么用?Python Group.db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server.models.group.Group的用法示例。


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

示例1: publish

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import db [as 别名]
 def publish(self, id):
     # NOTE: should maybe take publishData url parameter - David 9/5/2009
     loggedInUser = helper.getLoggedInUser()
     theShift = Shift.read(id, loggedInUser)
     if not theShift:
         return error("Resource does not exist.", ResourceDoesNotExistError)
     if theShift.type != "shift":
         return error("Resource is not of type shift", ResourceTypeError)
     publishData = json.loads(helper.getRequestBody())
     # convert targets to actual database references
     if publishData.get("targets"):
         from server.models.group import Group
         from server.models.ssuser import SSUser
         theUser = SSUser.read(loggedInUser)
         targets = publishData["targets"]
         # convert short names to group ids
         shortNames = [target[1:] for target in targets if target[0] == "&"]
         groupIds = Group.shortNamesToIds(shortNames)
         # convert user name to user ids
         userNames = [target[1:] for target in targets if target[0] == "@"]
         userIds = SSUser.namesToIds(userNames)
         # create list of dbs being published to
         dbs = [Group.db(groupId) for groupId in groupIds]
         dbs.extend([SSUser.db(userId) for userId in userIds])
         # validate
         writeable = theUser.writeable()
         if set(writeable) != set(dbs):
             return error("Operation not permitted. You don't have permission to publish to some of these gruops", PermissionError)
         publishData["dbs"] = dbs
     return data(theShift.publish(publishData))
开发者ID:gmatters,项目名称:shiftspace,代码行数:32,代码来源:shift.py

示例2: adminable

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import db [as 别名]
 def adminable(cls, userId, dbname=True):
     from server.models.group import Group
     db = core.connect()
     ids = core.values(Permission.by_adminable(db, key=userId))
     if dbname:
         return [Group.db(id) for id in ids]
     else:
         return ids
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:10,代码来源:permission.py

示例3: testPublishToGroup

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import db [as 别名]
 def testPublishToGroup(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     json = groupJson()
     json["createdBy"] = self.fakemary.id
     newGroup = Group.create(json)
     # make sure fakemary owns the group
     newPerm = Permission.readByUserAndGroup(self.fakemary.id, newGroup.id)
     self.assertTrue(newPerm.level == 4)
     # create read permission for fakejohn
     newPerm = Permission.create("shiftspace", newGroup.id, self.fakejohn.id, level=1)
     fakejohn = SSUser.read(self.fakejohn.id)
     self.assertTrue(Group.db(newGroup.id) in fakejohn.readable())
     publishData = {
         "dbs": [Group.db(newGroup.id)]
         }
     newShift.publish(publishData)
     # should exists in shiftspace/shared
     db = core.connect("shiftspace/shared")
     theShift = Shift.load(db, newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     newGroup.delete()
开发者ID:xncroft,项目名称:shiftspace,代码行数:25,代码来源:shift_model_test.py

示例4: testPublishToGroupAndUser

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import db [as 别名]
 def testPublishToGroupAndUser(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     json = groupJson()
     json["createdBy"] = self.fakemary.id
     newGroup = Group.create(json)
     newPerm = Permission.create("shiftspace", newGroup.id, self.fakejohn.id, level=1)
     publishData = {
         "dbs": [Group.db(newGroup.id), SSUser.db(self.fakebob.id)]
         }
     newShift.publish(publishData)
     # should exist in subscriber's feed
     db = core.connect("shiftspace/shared")
     theShift = Shift.load(db, newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     newGroup.delete()
     # should exist in shiftspace/shared
     # TODO: inbox if user is peer - David 11/18/09
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
开发者ID:xncroft,项目名称:shiftspace,代码行数:23,代码来源:shift_model_test.py

示例5: testGroupDb

# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import db [as 别名]
 def testGroupDb(self):
     json = groupJson()
     json["createdBy"] = self.fakemary
     newGroup = Group.create(json)
     self.assertEqual(Group.db(newGroup.id), "group/%s" % newGroup.id)
     newGroup.deleteInstance()
开发者ID:ShiftSpace,项目名称:shiftspace,代码行数:8,代码来源:group_model_test.py


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