The Infotrope Python Library
AKA The IPL
The IPL is a python library designed to handle primarily client support for all the protocols the project currently uses, in a form that's both easy to use for quick scripts, and powerful enough to use in full blown applications. It's geared heavily toward email.
Example
As a quick example:
# Locate my INBOX, show the text of the first message. import infotrope.serverman sm = infotrope.serverman.serverman() mailserver = sm['imap://myuser@imap.example.net/'] mailbox = mailserver.mailbox('INBOX') first_uid = mailbox.seqno(1) first_message = mailbox[ first_uid ] parts = first_message.parts() message_text_part = parts.find( 'TEXT', {'PLAIN':10,'HTML':1} ) # We prefer plain text messages. print "Got %s/%s part:\n" % ( message_text_part.type, message_text_part.subtype ) print first_message.body( message_text_part )
Features
The IPL is specifically designed to scale to huge mailboxes efficiently over low bandwidth, provides support for remote message assembly and other features of Lemonade compliant mail systems, handles full disconnected mode roaming configuration support via ACAP, and includes a basic (and, at the time of writing, incomplete) XMPP library.
It can, and by default does, use threads internally, but applications are shielded from the threading. It is designed to work from within event loop based applications as well as scripts, and is used both with GTK+ and wxWidgets. It has both synchronous and asynchronous APIs - many of the asynchronous calls require use of an event loop, so script-writers are encouraged into using the sync API. If you need to use the asynchronous calls, then do something like:
...
while some_flag:
sm.prod()
time.sleep(0.01)
and have a callback turn off some_flag.
Supported Protocols and Extensions
It supports the following protocols. Extensions are noted on each protocol page. ACAP provides roaming configuration and lightweight generic data access. IPL applications can use any, or none, of the configuration as they see fit. IMAP is used for mail access. IPL applications gain instant support for several extensions for maximum speed and efficiency. Submission? is used for initial submission of email, optionally via the Transmit module. SASL? is used for authentication, and in some cases to provide integrity layers. ManageSIEVE? is provided for Sieve script management. TLS? is used for privacy layers where possible.
Prerequisites
You need Python >= 2.2, and most probably, you want 2.4.
You may also probably want:
- Zlib: The IPL will use zlib, if installed (and findable) on your system. Tested on Linux and Windows.
- PyOpenSSL: The IPL prefers using PyOpenSSL to the in-built SSL support, and may require it depending on your Python version to get TLS operational.
- dnsPython: The IPL will use dnsPython to handle SRV requests for XMPP. One day, it may be used for asynchronous DNS queries too.
- pysqlite: The IPL will use pysqlite for caching data if possible. Use pysqlite2, although pysqlite itself might work.
- ctypes: The IPL requires ctypes for accessing zlib (ctypes is included in Python 2.5, but I've not done any testing with that yet).
