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


Python SSUser.publicDb方法代码示例

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


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

示例1: update

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import publicDb [as 别名]
    def update(self, fields, updateDbs=True):
        from server.models.ssuser import SSUser
        if fields.get("content"):
            self.content = fields.get("content")
        if fields.get("summary"):
            self.summary = self.content["summary"] = fields.get("summary")
        if fields.get("broken"):
            self.broken = fields.get("broken")
        if fields.get("dbs"):
            self.dbs = list(set(self.dbs.extend(fields.get("dbs"))))
        self.modified = datetime.now()
        
        # update the correct user db
        if self.publishData.private:
            db = SSUser.privateDb(self.createdBy)
        else:
            db = SSUser.publicDb(self.createdBy)
        
        self.store(core.connect(db))
        core.replicate(db, "shiftspace/shared")
        
        # update followers and groups
        if updateDbs:
            for db in self.publishData.dbs:
                dbtype, dbid = db.split("/")
                if dbtype == "group":
                    from server.models.group import Group
                    Group.read(dbid).updateShift(self)

        return Shift.joinData(self, self.createdBy)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:32,代码来源:shift.py

示例2: delete

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import publicDb [as 别名]
 def delete(self):
     from server.models.ssuser import SSUser
     db = core.connect(SSUser.privateDb(self.createdBy))
     if db.get(self.id):
         del db[self.id]
     else:
         db = core.connect(SSUser.publicDb(self.createdBy))
         if db.get(self.id):
             del db[self.id]
     core.replicate(db.name, "shiftspace/shared")
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:12,代码来源:shift.py

示例3: read

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import publicDb [as 别名]
 def read(cls, id, userId=None):
     from server.models.ssuser import SSUser
     if userId != None:
         # then try the user public
         db = core.connect(SSUser.publicDb(userId))
         theShift = Shift.load(db, id)
         if not theShift:
             # then user private
             db = core.connect(SSUser.privateDb(userId))
             theShift = Shift.load(db, id)
     else:
         theShift = Shift.load(core.connect("shiftspace/shared"), id)
     if theShift:
         return Shift.joinData(theShift, theShift.createdBy)
开发者ID:gmatters,项目名称:shiftspace,代码行数:16,代码来源:shift.py

示例4: testBasicPublish

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

示例5: read

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import publicDb [as 别名]
 def read(cls, id, userId=None, proxy=False):
     from server.models.ssuser import SSUser
     theShift = None
     # then try the user public
     if userId:
         db = core.connect(SSUser.publicDb(userId))
         theShift = Shift.load(db, id)
         if not theShift:
             # then user private
             db = core.connect(SSUser.privateDb(userId))
             theShift = Shift.load(db, id)
     else:
         db = core.connect("shiftspace/public")
         theShift = Shift.load(db, id)
     if userId and not theShift:
         theUser = SSUser.read(userId)
         aShift = Shift.load(core.connect("shiftspace/shared"), id)
         if theUser.canRead(aShift):
             theShift = aShift
     if proxy:
         theShift = Shift.load(core.connect("shiftspace/shared"), id)
     if theShift:
         return Shift.joinData(theShift, theShift.createdBy)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:25,代码来源:shift.py

示例6: publish

# 需要导入模块: from server.models.ssuser import SSUser [as 别名]
# 或者: from server.models.ssuser.SSUser import publicDb [as 别名]
    def publish(self, publishData=None):
        from server.models.ssuser import SSUser
        
        if publishData == None:
            return self
        
        db = core.connect(SSUser.privateDb(self.createdBy))
        dbs = []
        author = SSUser.read(self.createdBy)
        oldPublishData = dict(self.items())["publishData"]
        allowed = []
        
        # get the private status
        isPrivate = True
        if publishData and publishData.get("private") != None:
            isPrivate = publishData.get("private")
        else:
            isPrivate = self.isPrivate()
        
        # get the dbs being published to
        publishDbs = (publishData and publishData.get("dbs")) or []

        # get the list of dbs the user is actually allowed to publish to
        allowed = []
        if (publishData and isPrivate and len(publishDbs) > 0):
            from server.models.group import Group
            allowedGroups = author.writeable()
            allowed = list(set(allowedGroups).intersection(set(publishDbs)))
        
        # upate the private setting, the shift is no longer draft
        self.publishData.private = isPrivate
        self.publishData.draft = False
        
        # publish or update a copy to group/x, group/y, ...
        newGroupDbs = [s for s in allowed if s.split("/")[0] == "group"]
        oldGroupDbs = [s for s in oldPublishData.get("dbs") if s.split("/")[0] == "group"]
        newGroupDbs = list(set(newGroupDbs).difference(set(oldGroupDbs)))
        if newGroupDbs and len(newGroupDbs) > 0:
            dbs.extend(list(set(newGroupDbs)))

        # publish to any user we haven't published to before
        newUserDbs = [s for s in publishDbs if s.split("/")[0] == "user"]
        if newUserDbs and len(newUserDbs) > 0:
            userDbs = list(set(newUserDbs))
            dbs.extend(userDbs)
            self.shareWith([s.split("/")[1] for s in userDbs])

        self.publishData.dbs = dbs
        # store the human readable version
        targets = publishData.get("targets")
        if targets:
            self.publishData.targets = targets

        # update/add to group dbs
        self.updateInGroups(oldGroupDbs)
        self.addToGroups(newGroupDbs)
        
        # if public shift
        # create in user/public, delete from user/private
        # replicate shiftspace/public to shiftspace/shared
        if not isPrivate:
            publicdb = SSUser.publicDb(self.createdBy)
            if Shift.load(core.connect(publicdb), self.id):
                self.updateIn(publicdb)
            else:
                # TODO: copyTo should probably just be store - David
                self.copyTo(publicdb)
                privatedb = core.connect(SSUser.privateDb(self.createdBy))
                del privatedb[self.id]
                # we need to delete the private copy out of shiftspace/shared
                shared = core.connect("shiftspace/shared")
                del shared[self.id]
            # TODO: check that we have to force it in order to have it ready for replication - David
            db = core.connect(publicdb)
            core.replicate(publicdb, "shiftspace/public")
            core.replicate(publicdb, "shiftspace/shared")
        else:
            privatedb = SSUser.privateDb(self.createdBy)
            self.store(core.connect(privatedb))
            core.replicate(privatedb, "shiftspace/shared")
        
        return Shift.joinData(self, self.createdBy)
开发者ID:electrikfreak,项目名称:shiftspace,代码行数:84,代码来源:shift.py


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