def ListAllMessages(): mlist = [] i = 0 for filename in os.listdir(settings.getMessagesDir()): if not filename.endswith(".dhnmessage"): continue msgpath = os.path.join(settings.getMessagesDir(), filename) # msgpath = settings.getMessagesDir() + os.sep + filename if not os.path.exists(msgpath): continue msg = LoadMessage(msgpath) messageuid = filename.split(".")[0] msgtupple = (messageuid, nameurl.GetName(msg[0]), nameurl.GetName(msg[1]), msg[3], msg[2]) mlist.append(msgtupple) i += 1 return mlist
def SaveMessage(clearmessage): msguid = UniqueID() dhnio.Dprint(6, "message.SaveMessage %s" % msguid) msgfilename = os.path.join(settings.getMessagesDir(), msguid + ".dhnmessage") msgfile = file(msgfilename, "w") msgfile.write(str(clearmessage)) msgfile.close() return msguid
def DeleteMessage(messageuid): msgpath = os.path.join(settings.getMessagesDir(), messageuid + ".dhnmessage") if not os.path.exists(msgpath): return False try: os.remove(msgpath) except: dhnio.DprintException() return False dhnio.Dprint(6, "message.DeleteMessage %s" % messageuid) return True
def ReadMessage(messageuid): msgpath = os.path.join(settings.getMessagesDir(), messageuid + ".dhnmessage") # msgpath = settings.getMessagesDir() + os.sep + messageuid + '.dhnmessage' if not os.path.exists(msgpath): return None return LoadMessage(msgpath)