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


Python Shift.load方法代码示例

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


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

示例1: testBasicPublish

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import load [as 别名]
 def testBasicPublish(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     newShift.publish({"private":False})
     # should exist in user/public db
     theShift = Shift.load(core.connect(SSUser.publicDb(self.fakemary.id)), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should exist in master/public db 
     theShift = Shift.load(core.connect("shiftspace/public"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should exist in shiftspace/shared db
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
     # should _not_ exist in user/private db
     theShift = Shift.load(core.connect(SSUser.privateDb(self.fakemary.id)), newShift.id)
     self.assertEqual(theShift, None)
开发者ID:xncroft,项目名称:shiftspace,代码行数:19,代码来源:shift_model_test.py

示例2: create

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import load [as 别名]
 def create(cls, userId, shiftId, text, subscribe=False):
     from server.models.ssuser import SSUser
     from server.models.shift import Shift
     from server.models.message import Message
     # first try the public feed
     theShift = Shift.load(core.connect("shiftspace/shared"), shiftId)
     shiftAuthor = SSUser.load(core.connect(), theShift.createdBy)
     theUser = SSUser.load(core.connect(), userId)
     server = core.server()
     # create the comment db if necessary
     dbexists = True
     if not theShift.hasThread():
         server.create(Comment.db(shiftId))
         dbexists = False
     # get the db
     db = core.connect(Comment.db(shiftId))
     # if db just created, sync the views and subscribe shift author
     if not dbexists:
         Comment.by_created.sync(db)
         Comment.all_subscribed.sync(db)
         shiftAuthor.subscribe(theShift)
     # subscribe the user making the comment
     if not theUser.isSubscribed(theShift) and subscribe:
         theUser.subscribe(theShift)
     # create comment and comment stub
     json = {
         "createdBy": userId,
         "shiftId": shiftId,
         "shiftAuthor": theShift.createdBy,
         "text": text,
         }
     newComment = Comment(**utils.clean(json))
     newComment.store(db)
     subscribers = theShift.subscribers()
     # make a private copy
     # TODO: need to think about the implications of a private copy here - David
     newComment.copyTo(SSUser.privateDb(theUser.id))
     # send each subscriber a message
     if len(subscribers) > 0:
         # TODO: needs to be optimized with a fast join - David
         for subscriber in subscribers:
             if subscriber != userId:
                 astr = ((subscriber == theShift.createdBy) and "your") or ("%s's" % shiftAuthor.userName)
                 json = {
                     "fromId": userId,
                     "toId": subscriber,
                     "title": "%s just commented on %s shift!" % (theUser.userName, astr),
                     "text": "%s just commented on %s shift!" % (theUser.userName, astr),
                     "meta": "comment"
                     }
                 Message.create(**utils.clean(json))
     # TODO: don't replicate if peer - David 11/21/09
     core.replicate(Comment.db(shiftId), "shiftspace/shared")
     return newComment
开发者ID:gmatters,项目名称:shiftspace,代码行数:56,代码来源:comment.py

示例3: testPublishToGroupAndUser

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import load [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

示例4: testPublishToUser

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

示例5: testPublishToFollowers

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import load [as 别名]
 def testPublishToFollowers(self):
     json = shiftJson()
     json["createdBy"] = self.fakemary.id
     newShift = Shift.create(json)
     self.fakejohn.follow(self.fakemary)
     fakejohn = SSUser.read(self.fakejohn.id)
     # should be in the list of people fakejohn is following
     self.assertTrue(self.fakemary.id in fakejohn.following())
     # should be in the list of fakemary's followers
     followers = self.fakemary.followers()
     self.assertTrue(self.fakejohn.id in followers)
     newShift.publish({"private":False})
     # should exist in shiftspace/shared db
     theShift = Shift.load(core.connect("shiftspace/shared"), newShift.id)
     self.assertEqual(theShift.summary, newShift.summary)
开发者ID:xncroft,项目名称:shiftspace,代码行数:17,代码来源:shift_model_test.py

示例6: testPublishToGroup

# 需要导入模块: from server.models.shift import Shift [as 别名]
# 或者: from server.models.shift.Shift import load [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


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