zope.interface py3
parent
f2a43a948a
commit
7318e52b94
4
main.py
4
main.py
|
@ -6,7 +6,7 @@ from twisted.python import failure
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
from mech_smtp import SerpentSMTPFactory, smtp_portal
|
from mech_smtp import SerpentSMTPFactory, smtp_portal
|
||||||
from mech_imap import SerpentIMAPFactory, imap_portal
|
from mech_imap import SerpentIMAPFactory, imap_portal
|
||||||
|
@ -14,10 +14,10 @@ from serpent.usrpwd import dbs
|
||||||
from serpent.queue import squeue
|
from serpent.queue import squeue
|
||||||
from serpent.config import conf
|
from serpent.config import conf
|
||||||
|
|
||||||
|
@implementer(ICredentialsChecker)
|
||||||
class CredChecker(object):
|
class CredChecker(object):
|
||||||
'''Класс проверки данных авторизации.
|
'''Класс проверки данных авторизации.
|
||||||
Параметром в конструктор передаётся список (list()) объектов баз пользователей.'''
|
Параметром в конструктор передаётся список (list()) объектов баз пользователей.'''
|
||||||
implements(ICredentialsChecker)
|
|
||||||
credentialInterfaces = (credentials.IUsernamePassword,
|
credentialInterfaces = (credentials.IUsernamePassword,
|
||||||
credentials.IUsernameHashedPassword)
|
credentials.IUsernameHashedPassword)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
from twisted.cred import portal
|
from twisted.cred import portal
|
||||||
from twisted.internet import protocol, ssl
|
from twisted.internet import protocol, ssl
|
||||||
|
@ -13,9 +13,8 @@ from serpent.imap.mailbox import ExtendedMaildir
|
||||||
from serpent.misc import IMAP_HDELIM, IMAP_MBOX_REG, IMAP_ACC_CONN_NUM
|
from serpent.misc import IMAP_HDELIM, IMAP_MBOX_REG, IMAP_ACC_CONN_NUM
|
||||||
from shutil import rmtree, move
|
from shutil import rmtree, move
|
||||||
|
|
||||||
|
@implementer(imap4.IAccount)
|
||||||
class IMAPUserAccount(object):
|
class IMAPUserAccount(object):
|
||||||
implements(imap4.IAccount)
|
|
||||||
|
|
||||||
def __init__(self, mdir):
|
def __init__(self, mdir):
|
||||||
if not os.path.exists(mdir):
|
if not os.path.exists(mdir):
|
||||||
os.makedirs(mdir)
|
os.makedirs(mdir)
|
||||||
|
@ -146,9 +145,8 @@ class IMAPUserAccount(object):
|
||||||
inferiors.append(infname)
|
inferiors.append(infname)
|
||||||
return inferiors
|
return inferiors
|
||||||
|
|
||||||
|
@implementer(portal.IRealm)
|
||||||
class SerpentIMAPRealm(object):
|
class SerpentIMAPRealm(object):
|
||||||
implements(portal.IRealm)
|
|
||||||
|
|
||||||
def requestAvatar(self, avatarId, mind, *interfaces):
|
def requestAvatar(self, avatarId, mind, *interfaces):
|
||||||
if imap4.IAccount not in interfaces:
|
if imap4.IAccount not in interfaces:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
|
|
13
mech_smtp.py
13
mech_smtp.py
|
@ -6,7 +6,7 @@ from serpent.queue import squeue
|
||||||
|
|
||||||
|
|
||||||
from email.header import Header
|
from email.header import Header
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
from twisted.internet import defer, ssl
|
from twisted.internet import defer, ssl
|
||||||
from twisted.mail import smtp
|
from twisted.mail import smtp
|
||||||
|
@ -16,10 +16,8 @@ from twisted.cred.portal import IRealm, Portal
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(smtp.IMessageDelivery)
|
||||||
class SmtpMessageDelivery:
|
class SmtpMessageDelivery:
|
||||||
implements(smtp.IMessageDelivery)
|
|
||||||
|
|
||||||
def __init__(self, avatarId = None):
|
def __init__(self, avatarId = None):
|
||||||
self.avatarId = avatarId
|
self.avatarId = avatarId
|
||||||
|
|
||||||
|
@ -59,9 +57,8 @@ class SmtpMessageDelivery:
|
||||||
}
|
}
|
||||||
return lambda: SmtpMessage(msg)
|
return lambda: SmtpMessage(msg)
|
||||||
|
|
||||||
|
@implementer(smtp.IMessage)
|
||||||
class SmtpMessage:
|
class SmtpMessage:
|
||||||
implements(smtp.IMessage)
|
|
||||||
|
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
self.lines = []
|
self.lines = []
|
||||||
self.size = 0
|
self.size = 0
|
||||||
|
@ -126,10 +123,8 @@ class SerpentSMTPFactory(smtp.SMTPFactory):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IRealm)
|
||||||
class SmtpRealm:
|
class SmtpRealm:
|
||||||
implements(IRealm)
|
|
||||||
|
|
||||||
def requestAvatar(self, avatarId, mind, *interfaces):
|
def requestAvatar(self, avatarId, mind, *interfaces):
|
||||||
if smtp.IMessageDelivery in interfaces:
|
if smtp.IMessageDelivery in interfaces:
|
||||||
return smtp.IMessageDelivery, SmtpMessageDelivery(avatarId), lambda: None
|
return smtp.IMessageDelivery, SmtpMessageDelivery(avatarId), lambda: None
|
||||||
|
|
Loading…
Reference in New Issue