def index(user, id): try: threads_index = DatetimeCabinet("/home/kite/threads.db") thread = None except IOError: response.status = 400 return # FIXME: use an index for threads entries ? for thr in threads_index[user]["threads_index"]: if thr["id"] == id: thread = thr if thread == None: abort(404, "Thread not found.") thread["unread"] = False threads_index.sync() response.content_type = "application/json" ret_json = { "messages": [], "subject": thread["subject"], "date": thread["date"], "id": thread["id"] } mdir = read_mail("/home/kite/Maildirs/%s" % user) for mail_id in thread["messages"]: ret_json["messages"].append(get_email(mdir, mail_id)) return serialize_json(ret_json, protection=False)
def index(user, id): try: threads_index = DatetimeCabinet("/home/kite/threads.db") thread = None except IOError: response.status = 400 return # FIXME: use an index for threads entries ? for thr in threads_index[user]["threads_index"]: if thr["id"] == id: thread = thr if thread == None: abort(404, "Thread not found.") thread["unread"] = False threads_index.sync() response.content_type = "application/json" ret_json = {"messages": [], "subject": thread["subject"], "date": thread["date"], "id": thread["id"] } mdir = read_mail("/home/kite/Maildirs/%s" % user) for mail_id in thread["messages"]: ret_json["messages"].append(get_email(mdir, mail_id)) return serialize_json(ret_json, protection=False)
def add_kite_user(username, password): usersdb = DatetimeCabinet("/home/kite/users.db") usersdb[username] = {"password": password} # FIXME: hash password usersdb.sync()
def add_kite_user(username, password): usersdb = DatetimeCabinet("/home/kite/users.db") usersdb[username] = {"password": password} # FIXME: hash password usersdb.sync()