conf/kolab.conf pykolab/cli pykolab/imap
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Mon Jan 27 13:30:36 CET 2014
conf/kolab.conf | 3 ++-
pykolab/cli/cmd_create_mailbox.py | 10 +++++++++-
pykolab/imap/__init__.py | 13 ++++++++++---
3 files changed, 21 insertions(+), 5 deletions(-)
New commits:
commit eef4fcb4a64c29a9c1c5fb670f8a5a6a813591b3
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Jan 27 13:29:57 2014 +0100
Add an option to specify the partition on which a mailbox is to be created
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.
More information about the commits
mailing list