i have a problem here : i want to make a plugin architecture using abstract base class , this is my base class :
# -*- coding: utf-8 -*- import abc class BASE_Connector: """ Mount point for plugins which refer to actions that can be performed. Plugins implementing this reference should provide the following methods: ======== ======================================================== connect the connection method that will initialize a transport layer __login the login method to use to login in to the server this one should be called from connect directly get this method is use for getting the files from the remote server close this method is called for closing the connection suddenly quit this method is more polite to close the connection ======== ======================================================== """ __metaclass__ = abc.ABCMeta @abc.abstractmethod def connect(self, host, user="", passwd="", port="", private_key_file="", timeout=100): """ connect to a remote server this function call the __login function after the connection is established -- host : remote server name -- user : the user name in the remote server Default : empty string for server that don't need authentication or use private key instead -- passwd : password of the user given Default : empty string for server that don't need authentication or use private key instead -- port : the connection port Default : it's known from the protocol -- private_key_file : the file containing the private key used special for ssh connection Default : empty string -- timeout : the timeout of the connection Default : empty string """ pass @abc.abstractmethod def __login(self): """ private method to login to the remote server . it use the user name and the password or the private key for that """ @abc.abstractmethod def get(self, remote_file_path, local_path="/tmp/ housead_matcher"): """ method to download the file from the remote server -- remote_file_path : the path of the file in the remote server -- local_path : the local path where the file will be save """ pass @abc.abstractmethod def close(self): """ Close the connection unilaterally(from this host) """ @abc.abstractmethod def quit(self): """ close the connection. This is the “polite” way to close a connection """ and i define my plugins in a differents module like this : class FTP_Connector(FTP, Base_Connector) : """ this class is for the connection to a ftp server """ def __init__(self): FTP.__init__() def connect(self, host, port, user, passwd, timeout=""): self.connect(host, port, timeout) self.___login(user, passwd) def ___login(self, username="", password=""): self.login(username, password) def get(self, remote_file_path, local_path): remote_file_path = os.path.expanduser(remote_file_path) local_path = os.path.expanduser(local_path) remote_directory, remote_file_name = os.path.split(remote_file_path) local_file = os.path.join(local_path, remote_file_name) self.cwd(remote_directory) self.retrlines("RETR " + remote_file_name, lambda s, w=local_file.write: w(s+"\n")) def close(self): self.close() def quit(self): self.quit() and when i test my code i get this error : Can't instantiate abstract class FTP_Connector with abstract methods _BASE_Connector__login i can understand why. but my problem is why why ? i can't put "private" method in the ABC class ??? -- http://mail.python.org/mailman/listinfo/python-list