def editChatroom(self, obj, params): oldTitle = params['oldTitle'] newRoom = params['newRoom'] #we have an index by the chat room name. If, while editing, someone changes the chat room name, we'll have to update the index if oldTitle != newRoom.getTitle(): #the title has been changed. Get rid of the old index and substitute it for the new one crNameIndex = IndexByCRName() crNameIndex.unindex(newRoom, oldTitle) crNameIndex.index(newRoom)
def editChatroom(self, obj, params): oldTitle = params['oldTitle'] newRoom = params['newRoom'] userId = params['userId'] #we have an index by the chat room name. If, while editing, someone changes the chat room name, we'll have to update the index if oldTitle != newRoom.getTitle(): #the title has been changed. Get rid of the old index and substitute it for the new one crNameIndex = IndexByCRName() crNameIndex.unindex(newRoom, oldTitle) crNameIndex.index(newRoom) # For dynamic loading this needs to be in alphabetical order, # therefore reindex on change. userIndex = IndexByUser() userIndex.reindex(userId, newRoom, oldTitle)
def deleteChatroom(cls, obj, params): """ Deletes the chat room in the database according to all kind of indexing types""" chatroom = params['room'] confId = obj._conferenceID #if we have the same room used in two or more different conferences, we just delete it from the #conferences list in the chat room and from the IndexByConf index chatroom.getConferences().pop(confId) confIndex = IndexByConf() confIndex.unindex(confId, chatroom) if len(chatroom.getConferences()) is 0: #there are no more references to the chat room, we completely delete it crNameIndex = IndexByCRName() crNameIndex.unindex(chatroom) idIndex = IndexByID() idIndex.unindex(chatroom) userIndex = IndexByUser() userIndex.unindex(chatroom.getOwner().getId(), chatroom)