Hi Phillip,
i'm coming along with using data-managers and query-links for the imap model.
the current way to use it is like this:
>>> from peak.api import *
>>> from acmgr.api import *
>>>
>>> class TestServer(connection.IMAPServer):
... connection = binding.bindTo('imap://jack-e:[email protected]')
...
>>> s = TestServer()
>>>
>>> storage.begin(s)
>>>
>>> f = s.folderDM[('INBOX',)]
>>>
>>> f1 = s.folderDM.newItem()
>>> f1.name = 'testing'
>>> f.addFolders(f1)
>>> f2 = s.folderDM.newItem()
>>> f2.name = 'sub01'
>>> f1.addFolders(f2)
>>> f3 = s.folderDM.newItem()
>>> f3.name = 'subsub01'
>>> f2.addFolders(f3)
>>>
>>> s.txnSvc.state.participants
[<acmgr.connection.imap.IMAPFolderDM object at 0x82cfefc>, <acmgr.connection.imap.IMAPFolderListQuery object at
0x8307b5c>, <acmgr.connection.imap.IMAPMessageListQuery object at 0x835dfd4>]
>>> storage.commit(s)
_save: INBOX
_new INBOX.testing
_new INBOX.testing.sub01
_new INBOX.testing.sub01.subsub01
>>> storage.begin(s)
>>> f1.folders
[<acmgr.connection.imapmodel.IMAPFolder object at 0x817d244>]
>>> f1.folders[0].name
'sub01'
>>> f1.folders[0].folders
[<acmgr.connection.imapmodel.IMAPFolder object at 0x835d554>]
>>> f1.folders[0].folders[0].name
'subsub01'
creating/retrieving folders works nice and i use the way you described for creating oid's:
def _new(self, ob):
if ob.parent is None:
folder = ob.name
else:
folder = '%s.%s' % (self.oidFor(ob.parent)[0], ob.name)
folder = naming.CompositeName.parse(folder, imapFolderPath)
ob._p_oid = (folder, )
print '_new', folder
conn = self.connection
status, body = conn.create(str(folder))
if not status == 'OK':
raise Exception, 'Cannot create Folder: %s' % folder
return ob._p_oid
so the next questions are:
- How should deleting objects be implemented ??
i haven't found anything in the code/interfaces that says something about
how to implement it. probably the Element is responsible to delete itself
.. but are there any methods that should be implemented in the dm to support that ?
- Is there any way to determine which values of an element have been changed ??
or is it intended to just save the complete state of an object on _save() ?
we're building a little tool for managing accounts/mailboxes
in ldap/imap .. that will be available at our cvs as example when ready.
thanks for your help
Ulrich Eck
------------------------------------------------------------------------
net-labs Systemhaus GmbH
Ebersberger Str. 46
85570 Markt Schwaben
fon: +49-8121-4747-11
fax: +49-8121-4747-77
email: ueck at net-labs.de
http://www.net-labs.de