Home | Trees | Indices | Help |
|
---|
|
MailboxFactory is a factory class for Mailbox objects. You can define mailboxes of different types in an INI-style config file (the file has to parsable by ConfigParser.ConfigParser; the exceptions defined in ConfigParser may be thrown if the config file is not well-formed.) Each section in the config file describes one mailbox. An example of a valid config file 'mailboxes.cfg' is the following: [Standard] type = IMAP mailbox = INBOX server = mail.physik.fu-berlin.de username = goerz password = secret ssl = True port = 933 [Sent] type = IMAP mailbox = Sent server = mail.physik.fu-berlin.de username = goerz password = secret [Backup] type = mbox path = /home/goerz/Mail/backup.mbox The type of the mailbox is described by the 'type' parameters. The types known by default are 'imap', 'mbox', 'maildir', 'MH', 'Babyl', and 'MMDF', all of which have corresponding subclasses of mailbox.Mailbox (all except ImapMailbox are defined in the standard library). The type specification is not case sensitive. The remaining parameters in a specific section depend on the type. The Mailbox classes from the standard library need only a path; IMAP needs type, mailbox, server, username, and password. The ssl and port parameters are optional. ssl is enabled by default; the port, if unspecified, is the standard port (933 for ssl, 433 otherwise). MailboxFactory has capabilities to extend the set of known types by using the set_type method. The MailboxFactory partly supports a read-only dictionary interface.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Initialize MailboxFactory files. The mailbox objects that can be generated must be described in configfilename. |
Create the Mailbox object that is described in section 'name' in the config file. For example, >>> mailboxes = MailboxFactory("mailboxes.cfg") >>> mb = mailboxes.get('Standard') mb would now be an object of type ImapMailbox if mailboxes.cfg contained the data as the example in the class docstring. |
Shorthand for the get method. For example, >>> mailboxes = MailboxFactory("mailboxes.cfg") >>> mb = mailboxes['Standard'] |
Return an ImapServer instance from the server data that is described in section 'name'. The section must have the form of an imap mailbox (as described above). A TypeError will be raised if the section is not of type IMAP. The 'mailbox' key is ignored. For example, you could create an ImapServer like this: >>> mailboxes = MailboxFactory("mailboxes.cfg") >>> server = mailboxes.get_server('StandardServer') |
Make a new typename of Mailbox known. This allows you to handle new types of Mailbox objects beyond IMAP and the mailboxes of the standard library. factory is the class that generates the Mailbox object and must be a subclass of mailbox.Mailbox pathgenerator is a callable that receives a dict of options set in a section of the config file, and returns the 'path' that is passed as the first argument to the factory. For the standard mailboxes of the standard library, the 'path' is just a string, the path of the mailbox in the filesystem. For IMAP, the path is a tuple (server, name). For new types, this may be anything. For example the constructor of this class makes the 'mbox' type known as: self.set_type('mbox', mailbox.mbox, standard_pathgenerator) In combination, factory(pathgenerator(dict_of_options_in_configfile_section)) should create a Mailbox object of the appropriate type. |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Aug 6 18:48:54 2010 | http://epydoc.sourceforge.net |