some smaller changes to make the attachment examples work
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2657 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
757d47ba12
commit
f1967e38eb
3 changed files with 29 additions and 21 deletions
|
@ -57,10 +57,10 @@ class MailCrawler(Crawler):
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
self.result.append(resource)
|
self.result.append(resource)
|
||||||
|
|
||||||
def createMetadata(self, metadata, **kw):
|
def createMetadata(self, metadata):
|
||||||
metadata = Metadata(metadata)
|
metadata = Metadata(metadata)
|
||||||
for k, v in kw.items():
|
## for k, v in kw.items():
|
||||||
metadata[k] = v
|
## metadata[k] = v
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
|
|
|
@ -207,7 +207,7 @@ class OutlookCrawler(MailCrawler):
|
||||||
attachedItem = attachedElems.Item(item)
|
attachedItem = attachedElems.Item(item)
|
||||||
attachedItem.SaveAsFile(fileHandle)
|
attachedItem.SaveAsFile(fileHandle)
|
||||||
os.close(fileHandle)
|
os.close(fileHandle)
|
||||||
metadat = self.createMetadata({}, filename=filePath)
|
metadat = self.createMetadata(dict(filename=filePath))
|
||||||
fileRes = FileResource(data=None,
|
fileRes = FileResource(data=None,
|
||||||
path=filePath,
|
path=filePath,
|
||||||
metadata=metadat)
|
metadata=metadat)
|
||||||
|
|
|
@ -34,9 +34,9 @@ class Attachments(list):
|
||||||
elemCount = 0
|
elemCount = 0
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
def __init__(self, files=[]):
|
def __init__(self, params=[]):
|
||||||
for elem in files:
|
for elem in params[0]:
|
||||||
fileitem = Attachment(filename=elem)
|
fileitem = Attachment(filename=elem[0], ParentMail=elem[1])
|
||||||
self.data.append(fileitem)
|
self.data.append(fileitem)
|
||||||
print "Attachment: ", fileitem.FileName
|
print "Attachment: ", fileitem.FileName
|
||||||
|
|
||||||
|
@ -50,12 +50,7 @@ class Attachments(list):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def count(self):
|
def count(self):
|
||||||
print self.elemCount
|
return len(data)
|
||||||
return self.elemCount
|
|
||||||
|
|
||||||
## @property
|
|
||||||
## def Data(self):
|
|
||||||
## return self.elemList
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.data)
|
return len(self.data)
|
||||||
|
@ -70,17 +65,19 @@ class Attachments(list):
|
||||||
class Attachment(object):
|
class Attachment(object):
|
||||||
|
|
||||||
File = ""
|
File = ""
|
||||||
|
parentMailObject = None
|
||||||
|
|
||||||
def __init__(self, filename=""):
|
def __init__(self, ParentMail, filename=""):
|
||||||
self.File = filename
|
self.File = filename
|
||||||
|
self.parentMailObject = ParentMail
|
||||||
|
|
||||||
def SaveAsFile(self, path=""):
|
def SaveAsFile(self, path=""):
|
||||||
print "Attachment saved"
|
print "Attachment saved"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Parent(self):
|
def Parent(self):
|
||||||
# return value of Attribute Parent is of type _MailItem
|
" return value of Attribute Parent is of type _MailItem"
|
||||||
pass
|
return self.parentMailObject
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Type(self):
|
def Type(self):
|
||||||
|
@ -93,8 +90,8 @@ class Attachment(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Application(self):
|
def Application(self):
|
||||||
# Actual instance of Outlook application
|
" Actual instance of Outlook application"
|
||||||
pass
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def FileName(self):
|
def FileName(self):
|
||||||
|
@ -114,6 +111,14 @@ class Mail(object):
|
||||||
self.Body = body
|
self.Body = body
|
||||||
for k, v in kw.items():
|
for k, v in kw.items():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
|
def addAttachment(self, **kw):
|
||||||
|
"""
|
||||||
|
this is a method which probably does not exist in a real mail
|
||||||
|
Currently this is a work around to add attachments to a mail
|
||||||
|
"""
|
||||||
|
for k, v in kw.items():
|
||||||
|
setattr(self, k, v)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _prop_map_get_(self):
|
def _prop_map_get_(self):
|
||||||
|
@ -123,17 +128,20 @@ class Mail(object):
|
||||||
|
|
||||||
|
|
||||||
class Items(object):
|
class Items(object):
|
||||||
|
|
||||||
|
self.temp = {}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = {}
|
|
||||||
self.data[0] = Mail(subj="Python Training",
|
self.data[0] = Mail(subj="Python Training",
|
||||||
sendName="Mark Pilgrim",
|
sendName="Mark Pilgrim",
|
||||||
to="allPythonics@python.org",
|
to="allPythonics@python.org",
|
||||||
body="The training will take place on Wed, 21st Dec.\
|
body="The training will take place on Wed, 21st Dec.\
|
||||||
Kindly check the enclosed invitation.",
|
Kindly check the enclosed invitation.",
|
||||||
BodyFormat=1,
|
BodyFormat=1
|
||||||
Attachments=Attachments(["Invitation.pdf", "21.pdf"])
|
##Attachments=Attachments([("Invitation.pdf", self.data[0]), ("21.pdf", self.data[0])])
|
||||||
)
|
)
|
||||||
|
self.data[0].addAttachment(Attachments=Attachments([("Invitation.pdf", self.data[0]), ("21.pdf", self.data[0])]))
|
||||||
|
self.temp = self.data[0]
|
||||||
self.data[1] = Mail(subj="Information Technolgies Inc. Test it!",
|
self.data[1] = Mail(subj="Information Technolgies Inc. Test it!",
|
||||||
sendName="IT.org",
|
sendName="IT.org",
|
||||||
to="allUser@internet.com",
|
to="allUser@internet.com",
|
||||||
|
|
Loading…
Add table
Reference in a new issue