From 29f188a48d909badf29cbda3b65f751434bde002 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Mon, 4 Feb 2013 12:08:26 +0100 Subject: Import the list description from Mailman --- kittystore/storm/model.py | 1 + kittystore/storm/schema/__init__.py | 3 +++ kittystore/storm/schema/patch_6.py | 6 ++++++ kittystore/storm/store.py | 8 ++++++++ 4 files changed, 18 insertions(+) create mode 100644 kittystore/storm/schema/patch_6.py diff --git a/kittystore/storm/model.py b/kittystore/storm/model.py index 74524ed..c4b66d0 100644 --- a/kittystore/storm/model.py +++ b/kittystore/storm/model.py @@ -47,6 +47,7 @@ class List(Storm): name = Unicode(primary=True) display_name = Unicode() + description = Unicode() def __init__(self, name): self.name = unicode(name) diff --git a/kittystore/storm/schema/__init__.py b/kittystore/storm/schema/__init__.py index eebae1c..d73a49e 100644 --- a/kittystore/storm/schema/__init__.py +++ b/kittystore/storm/schema/__init__.py @@ -7,6 +7,7 @@ CREATES = { CREATE TABLE "list" ( name VARCHAR(255) NOT NULL, display_name TEXT, + description TEXT, PRIMARY KEY (name) );""", """ CREATE TABLE "thread" ( @@ -68,6 +69,7 @@ CREATES = { CREATE TABLE "list" ( name VARCHAR(255) NOT NULL, display_name TEXT, + description TEXT, PRIMARY KEY (name) );""", """ CREATE TABLE "thread" ( @@ -129,6 +131,7 @@ CREATES = { CREATE TABLE `list` ( name VARCHAR(255) NOT NULL, display_name TEXT, + description TEXT, PRIMARY KEY (name) );""", """ CREATE TABLE `thread` ( diff --git a/kittystore/storm/schema/patch_6.py b/kittystore/storm/schema/patch_6.py new file mode 100644 index 0000000..180e731 --- /dev/null +++ b/kittystore/storm/schema/patch_6.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +def apply(store): + """Add the description column""" + store.execute('ALTER TABLE "list" ADD COLUMN "description" TEXT;') + store.commit() diff --git a/kittystore/storm/store.py b/kittystore/storm/store.py index 7f22009..01c7554 100644 --- a/kittystore/storm/store.py +++ b/kittystore/storm/store.py @@ -90,6 +90,7 @@ class StormStore(object): l = List(list_name) self.db.add(l) l.display_name = mlist.display_name + l.description = mlist.description if not message.has_key("Message-Id"): raise ValueError("No 'Message-Id' header in email", message) msg_id = unicode(unquote(message['Message-Id'])) @@ -334,6 +335,13 @@ class StormStore(object): """ return list(self.db.find(List.name).order_by(List.name)) + def get_lists(self): + """Return the archived lists. + + :returns: A list containing the archived mailing-lists. + """ + return list(self.db.find(List).order_by(List.name)) + def get_messages(self, list_name, start, end): """ Return all emails between two given dates. -- cgit