summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-27 13:29:57 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-01-27 13:29:57 +0100
commiteef4fcb4a64c29a9c1c5fb670f8a5a6a813591b3 (patch)
treea37253ce5a46a4aa5220d61d896086b160ea77fb
parent647634e70b04f7c624bd0cfdea755b294d029f8c (diff)
downloadpykolab-eef4fcb4a64c29a9c1c5fb670f8a5a6a813591b3.tar.gz
Add an option to specify the partition on which a mailbox is to be created
-rw-r--r--conf/kolab.conf3
-rw-r--r--pykolab/cli/cmd_create_mailbox.py10
-rw-r--r--pykolab/imap/__init__.py13
3 files changed, 21 insertions, 5 deletions
diff --git a/conf/kolab.conf b/conf/kolab.conf
index 30c75a2..8c36605 100644
--- a/conf/kolab.conf
+++ b/conf/kolab.conf
@@ -60,7 +60,8 @@ secondary_mail = {
; folder.
autocreate_folders = {
'Archive': {
- 'quota': 0
+ 'quota': 0,
+ 'partition': 'archive'
},
'Calendar': {
'annotations': {
diff --git a/pykolab/cli/cmd_create_mailbox.py b/pykolab/cli/cmd_create_mailbox.py
index 63ae0ad..6192b91 100644
--- a/pykolab/cli/cmd_create_mailbox.py
+++ b/pykolab/cli/cmd_create_mailbox.py
@@ -42,6 +42,14 @@ def cli_options():
help = _("Set metadata for folder to ANNOTATION=VALUE")
)
+ my_option_group.add_option(
+ '--partition',
+ dest = "partition",
+ action = "store",
+ default = None,
+ help = _("Create folder on PARTITION.")
+ )
+
def description():
return """Create a mailbox or sub-folder of an existing mailbox."""
@@ -63,7 +71,7 @@ def execute(*args, **kw):
imap = IMAP()
imap.connect()
- imap.create_folder(mailbox)
+ imap.create_folder(mailbox, partition=conf.partition)
if not conf.metadata == None:
imap.set_metadata(mailbox, conf.metadata.split('=')[0], conf.metadata.split('=')[1])
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 0f02dae..9995292 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -207,7 +207,7 @@ class IMAP(object):
else:
log.warning(_("Called imap.disconnect() on a server that we had no connection to."))
- def create_folder(self, folder_path, server=None):
+ def create_folder(self, folder_path, server=None, partition=None):
folder_path = self.folder_utf7(folder_path)
if not server == None:
@@ -215,7 +215,7 @@ class IMAP(object):
self.connect(server=server)
try:
- self._imap[server].cm(folder_path)
+ self._imap[server].cm(folder_path, partition=partition)
return True
except:
log.error(
@@ -228,7 +228,7 @@ class IMAP(object):
else:
try:
- self.imap.cm(folder_path)
+ self.imap.cm(folder_path, partition=partition)
return True
except:
log.error(_("Could not create folder %r") % (folder_path))
@@ -617,6 +617,13 @@ class IMAP(object):
additional_folders[additional_folder]['quota']
)
+ if additional_folders[additional_folder].has_key("partition"):
+ partition = additional_folders[additional_folder]["partition"]
+ try:
+ self.imap.rename(folder_name, folder_name, partition)
+ except:
+ log.error(_("Could not rename %s to reside on partition %s") % (folder_name, partition))
+
def user_mailbox_delete(self, mailbox_base_name):
"""
Delete a user mailbox.