iteration wrappers

Some simple iteration wrappers lotus notes:

from win32com.client import Dispatch
session = Dispatch('Lotus.NotesSession')

def iterateDocuments(view):
   """ wrapper for iterating documents from a view, fe:
       for doc in iterateDocuments(inbox): print doc.GetItemValue('Subject') """
   doc = view.GetFirstDocument()
   while doc:
      yield doc
      doc = view.GetNextDocument(doc)

def iterateDatabases(server, filetype=1247):
   """ wrapper for iterating databases from a server, fe:
       for db in iterateDatabases('server'): print db.Title """
   db = server.GetFirstDatabase(filetype)
   while db:
      yield db
      db = server.GetNextDatabase()

def iterateEntries(ACL):
   """ wrapper for iterating ACL entries for a database, fe:
   for entry in iterateEntries(db.ACL):
         if entry.IsPerson: print entry.Name"""
   entry = ACL.GetFirstEntry()
   while entry:
      yield entry
      entry = ACL.GetNextEntry(entry)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.