Set accountname in BaseFolder, and don't pass it in initialization

We passed in the accountname to all derivatives of BaseFolder, such as
IMAPFolder(...,repository,...,accountname), although it is perfectly
possible to get the accountname from the Repository(). So remove this
unneeded parameter. Each backend had to define getaccountname() (although
the function is hardly used and most accessed .accountname directly).

On the other hand BaseFolder was using getaccountname but it never defined
the function. So make the sane thing, remove all definitions from backends
and define accountname() once in Basefolder. It was made a property and not
just a (public) attribute, so it will show up in our developer
documentation as public API.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth
2011-09-16 10:54:23 +02:00
committed by Nicolas Sebrecht
parent c93cd9bb1a
commit 410e2d35e9
10 changed files with 26 additions and 32 deletions

View File

@ -44,6 +44,11 @@ class BaseFolder(object):
def __str__(self):
return self.name
@property
def accountname(self):
"""Account name as string"""
return self.repository.accountname
def suggeststhreads(self):
"""Returns true if this folder suggests using threads for actions;
false otherwise. Probably only IMAP will return true."""
@ -239,7 +244,7 @@ class BaseFolder(object):
# self.getmessage(). So, don't call self.getmessage unless
# really needed.
if register: # output that we start a new thread
self.ui.registerthread(self.getaccountname())
self.ui.registerthread(self.accountname)
try:
message = None
@ -295,7 +300,7 @@ class BaseFolder(object):
self.ui.error(e, exc_info()[2])
except Exception, e:
self.ui.error(e, "Copying message %s [acc: %s]:\n %s" %\
(uid, self.getaccountname(),
(uid, self.accountname,
traceback.format_exc()))
raise #raise on unknown errors, so we can fix those
@ -443,5 +448,5 @@ class BaseFolder(object):
self.ui.error(e, exc_info()[2])
except Exception, e:
self.ui.error(e, exc_info()[2], "Syncing folder %s [acc: %s]" %\
(self, self.getaccountname()))
(self, self.accountname))
raise # raise unknown Exceptions so we can fix them