added GET/SETANNOTATION methods
This commit is contained in:
parent
a0abb24729
commit
d80ef02ec0
|
@ -222,6 +222,11 @@ data = authobject(response)
|
||||||
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{getannotation}{mailbox, entry, attribute}
|
||||||
|
Retrieve the specified \samp{ANNOTATION}s for \var{mailbox}.
|
||||||
|
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{getquota}{root}
|
\begin{methoddesc}{getquota}{root}
|
||||||
Get the \samp{quota} \var{root}'s resource usage and limits.
|
Get the \samp{quota} \var{root}'s resource usage and limits.
|
||||||
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
|
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
|
||||||
|
@ -357,6 +362,11 @@ msgnums = M.search(None, '(FROM "LDJ")')
|
||||||
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
|
\begin{methoddesc}{setannotation}{mailbox, entry, attribute\optional{, ...}}
|
||||||
|
Set \samp{ANNOTATION}s for \var{mailbox}.
|
||||||
|
The method is non-standard, but is supported by the \samp{Cyrus} server.
|
||||||
|
\end{methoddesc}
|
||||||
|
|
||||||
\begin{methoddesc}{setquota}{root, limits}
|
\begin{methoddesc}{setquota}{root, limits}
|
||||||
Set the \samp{quota} \var{root}'s resource \var{limits}.
|
Set the \samp{quota} \var{root}'s resource \var{limits}.
|
||||||
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
|
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
|
||||||
|
|
|
@ -18,8 +18,9 @@ Public functions: Internaldate2tuple
|
||||||
# IMAP4_SSL contributed by Tino Lange <Tino.Lange@isg.de> March 2002.
|
# IMAP4_SSL contributed by Tino Lange <Tino.Lange@isg.de> March 2002.
|
||||||
# GET/SETQUOTA contributed by Andreas Zeidler <az@kreativkombinat.de> June 2002.
|
# GET/SETQUOTA contributed by Andreas Zeidler <az@kreativkombinat.de> June 2002.
|
||||||
# PROXYAUTH contributed by Rick Holbert <holbert.13@osu.edu> November 2002.
|
# PROXYAUTH contributed by Rick Holbert <holbert.13@osu.edu> November 2002.
|
||||||
|
# GET/SETANNOTATION contributed by Tomas Lindroos <skitta@abo.fi> June 2005.
|
||||||
|
|
||||||
__version__ = "2.55"
|
__version__ = "2.56"
|
||||||
|
|
||||||
import binascii, os, random, re, socket, sys, time
|
import binascii, os, random, re, socket, sys, time
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ Commands = {
|
||||||
'EXPUNGE': ('SELECTED',),
|
'EXPUNGE': ('SELECTED',),
|
||||||
'FETCH': ('SELECTED',),
|
'FETCH': ('SELECTED',),
|
||||||
'GETACL': ('AUTH', 'SELECTED'),
|
'GETACL': ('AUTH', 'SELECTED'),
|
||||||
|
'GETANNOTATION':('AUTH', 'SELECTED'),
|
||||||
'GETQUOTA': ('AUTH', 'SELECTED'),
|
'GETQUOTA': ('AUTH', 'SELECTED'),
|
||||||
'GETQUOTAROOT': ('AUTH', 'SELECTED'),
|
'GETQUOTAROOT': ('AUTH', 'SELECTED'),
|
||||||
'MYRIGHTS': ('AUTH', 'SELECTED'),
|
'MYRIGHTS': ('AUTH', 'SELECTED'),
|
||||||
|
@ -66,6 +68,7 @@ Commands = {
|
||||||
'SEARCH': ('SELECTED',),
|
'SEARCH': ('SELECTED',),
|
||||||
'SELECT': ('AUTH', 'SELECTED'),
|
'SELECT': ('AUTH', 'SELECTED'),
|
||||||
'SETACL': ('AUTH', 'SELECTED'),
|
'SETACL': ('AUTH', 'SELECTED'),
|
||||||
|
'SETANNOTATION':('AUTH', 'SELECTED'),
|
||||||
'SETQUOTA': ('AUTH', 'SELECTED'),
|
'SETQUOTA': ('AUTH', 'SELECTED'),
|
||||||
'SORT': ('SELECTED',),
|
'SORT': ('SELECTED',),
|
||||||
'STATUS': ('AUTH', 'SELECTED'),
|
'STATUS': ('AUTH', 'SELECTED'),
|
||||||
|
@ -133,10 +136,10 @@ class IMAP4:
|
||||||
the command re-tried.
|
the command re-tried.
|
||||||
"readonly" exceptions imply the command should be re-tried.
|
"readonly" exceptions imply the command should be re-tried.
|
||||||
|
|
||||||
Note: to use this module, you must read the RFCs pertaining
|
Note: to use this module, you must read the RFCs pertaining to the
|
||||||
to the IMAP4 protocol, as the semantics of the arguments to
|
IMAP4 protocol, as the semantics of the arguments to each IMAP4
|
||||||
each IMAP4 command are left to the invoker, not to mention
|
command are left to the invoker, not to mention the results. Also,
|
||||||
the results.
|
most IMAP servers implement a sub-set of the commands available here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class error(Exception): pass # Logical errors - debug required
|
class error(Exception): pass # Logical errors - debug required
|
||||||
|
@ -186,11 +189,10 @@ class IMAP4:
|
||||||
else:
|
else:
|
||||||
raise self.error(self.welcome)
|
raise self.error(self.welcome)
|
||||||
|
|
||||||
cap = 'CAPABILITY'
|
typ, dat = self.capability()
|
||||||
self._simple_command(cap)
|
if dat == [None]:
|
||||||
if not cap in self.untagged_responses:
|
|
||||||
raise self.error('no CAPABILITY response from server')
|
raise self.error('no CAPABILITY response from server')
|
||||||
self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split())
|
self.capabilities = tuple(dat[-1].upper().split())
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
if self.debug >= 3:
|
if self.debug >= 3:
|
||||||
|
@ -345,6 +347,15 @@ class IMAP4:
|
||||||
return typ, dat
|
return typ, dat
|
||||||
|
|
||||||
|
|
||||||
|
def capability(self):
|
||||||
|
"""(typ, [data]) = <instance>.capability()
|
||||||
|
Fetch capabilities list from server."""
|
||||||
|
|
||||||
|
name = 'CAPABILITY'
|
||||||
|
typ, dat = self._simple_command(name)
|
||||||
|
return self._untagged_response(typ, dat, name)
|
||||||
|
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
"""Checkpoint mailbox on server.
|
"""Checkpoint mailbox on server.
|
||||||
|
|
||||||
|
@ -436,6 +447,14 @@ class IMAP4:
|
||||||
return self._untagged_response(typ, dat, 'ACL')
|
return self._untagged_response(typ, dat, 'ACL')
|
||||||
|
|
||||||
|
|
||||||
|
def getannotation(self, mailbox, entry, attribute):
|
||||||
|
"""(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
|
||||||
|
Retrieve ANNOTATIONs."""
|
||||||
|
|
||||||
|
typ, dat = self._simple_command('GETANNOTATION', mailbox, entry, attribute)
|
||||||
|
return self._untagged_response(typ, dat, 'ANNOTATION')
|
||||||
|
|
||||||
|
|
||||||
def getquota(self, root):
|
def getquota(self, root):
|
||||||
"""Get the quota root's resource usage and limits.
|
"""Get the quota root's resource usage and limits.
|
||||||
|
|
||||||
|
@ -643,6 +662,14 @@ class IMAP4:
|
||||||
return self._simple_command('SETACL', mailbox, who, what)
|
return self._simple_command('SETACL', mailbox, who, what)
|
||||||
|
|
||||||
|
|
||||||
|
def setannotation(self, *args):
|
||||||
|
"""(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
|
||||||
|
Set ANNOTATIONs."""
|
||||||
|
|
||||||
|
typ, dat = self._simple_command('SETANNOTATION', *args)
|
||||||
|
return self._untagged_response(typ, dat, 'ANNOTATION')
|
||||||
|
|
||||||
|
|
||||||
def setquota(self, root, limits):
|
def setquota(self, root, limits):
|
||||||
"""Set the quota root's resource limits.
|
"""Set the quota root's resource limits.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue