[Zope3-checkins]
SVN: Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/
Changed FTPFactory setup so that Crtl-C works cleanly.
Michael Kerrin
michael.kerrin at openapp.biz
Tue Apr 26 14:24:20 EDT 2005
Log message for revision 30189:
Changed FTPFactory setup so that Crtl-C works cleanly.
Changed:
U Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/__init__.py
U Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/server.py
-=-
Modified: Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/__init__.py
===================================================================
--- Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/__init__.py 2005-04-26 17:03:09 UTC (rev 30188)
+++ Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/__init__.py 2005-04-26 18:24:20 UTC (rev 30189)
@@ -11,6 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""FTP server factories.
+"""
from zope.app.server.server import ServerType
from zope.app.server.ftp.server import FTPRequestFactory, FTPFactory
Modified: Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/server.py
===================================================================
--- Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/server.py 2005-04-26 17:03:09 UTC (rev 30188)
+++ Zope3/branches/srichter-twisted-integration/src/zope/app/server/ftp/server.py 2005-04-26 18:24:20 UTC (rev 30189)
@@ -18,7 +18,7 @@
from zope.interface import implements
from twisted.cred import portal, checkers, credentials
-from twisted.protocols import ftp
+from twisted.protocols import ftp, policies
from twisted.internet import reactor, defer
from zope.publisher.ftp import FTPRequest
@@ -59,8 +59,11 @@
raise NotImplementedError, \
"Only IFTPShell interface is supported by this realm"
-class FTPFactory(ftp.FTPFactory):
+class FTPFactory(policies.LimitTotalConnectionsFactory):
+ protocol = ftp.FTP
+ overflowProtocol = ftp.FTPOverflowProtocol
allowAnonymous = False
+ timeOut = 600
def __init__(self, request_factory):
r = FTPRealm(request_factory)
@@ -69,7 +72,22 @@
credentials.IUsernamePassword)
self.portal = p
+ self.instances = []
+ def buildProtocol(self, addr):
+ p = policies.LimitTotalConnectionsFactory.buildProtocol(self, addr)
+ if p is not None:
+ p.wrappedProtocol.portal = self.portal
+ p.wrappedProtocol.timeOut = self.timeOut
+ self.instances.append(p.wrappedProtocol)
+ return p
+
+ def stopFactory(self):
+ # make sure ftp instance's timeouts are set to None
+ # to avoid reactor complaints
+ [p.setTimeout(None) for p in self.instances if p.timeOut is not None]
+ policies.LimitTotalConnectionsFactory.stopFactory(self)
+
class FTPRequestFactory(object):
"""FTP Request factory
More information about the Zope3-Checkins
mailing list