From 877050bf69ae69eab272021ab648578599d2aaab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Pin?= Date: Sun, 7 Nov 2010 02:59:17 +0100 Subject: [PATCH 1/1] Importation initiale. --- FakeMailHost.py | 84 ++++++++++++++++++++++++++++++++++ __init__.py | 10 ++++ www/MailHost_icon.gif | Bin 0 -> 896 bytes www/addFakeMailHost_form.dtml | 48 +++++++++++++++++++ www/manageFakeMailHost.dtml | 45 ++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100755 FakeMailHost.py create mode 100755 __init__.py create mode 100644 www/MailHost_icon.gif create mode 100755 www/addFakeMailHost_form.dtml create mode 100755 www/manageFakeMailHost.dtml diff --git a/FakeMailHost.py b/FakeMailHost.py new file mode 100755 index 0000000..fba8a66 --- /dev/null +++ b/FakeMailHost.py @@ -0,0 +1,84 @@ +from Globals import InitializeClass, DTMLFile +from Products.MailHost import MailHost +from AccessControl import ClassSecurityInfo +from AccessControl.Permissions import view_management_screens, change_configuration +import string, re + +bad_path_chars_in=re.compile('[^a-zA-Z0-9-_~\,\. \/]').search + + + +manage_addFakeMailHostForm=DTMLFile('www/addFakeMailHost_form', globals()) +def manage_addFakeMailHost(dispatcher, id, title='', folderPath='', REQUEST=None) : + ' Add Fake mail Host' + parent = dispatcher.Destination() + fmh = FakeMailHost(id, folderPath, title='title' ) + parent._setObject(id, fmh) + if REQUEST is not None: + REQUEST['RESPONSE'].redirect(parent.absolute_url()+'/manage_main') + + +class FakeMailHost(MailHost.MailHost) : + """ Fake Mail Host """ + + meta_type = 'Fake Mail Host' + manage_main = DTMLFile('www/manageFakeMailHost', globals()) + manage_main._setName('manage_main') + smtp_host = '' + + security = ClassSecurityInfo() + + def __init__(self, id, folderPath, title='', ) : + self.id = id + self.title = title + self.setContainerPath(path=folderPath) + + + def _send(self, mfrom, mto, messageText, immediate=False) : + """ Create a document based on message inside base folder """ + folder = self._getMailContainer() + id = str(len(folder._objects)) + folder.manage_addProduct['OFSP'].manage_addFile(id, file='') + file = getattr(folder, id) + file.update_data(messageText, 'text/plain') + + security.declareProtected(change_configuration, 'manage_makeChanges' ) + def manage_makeChanges(self,title,folderPath, REQUEST=None): + 'make the changes' + + title=str(title) + self.title=title + self.setContainerPath(folderPath) + + if REQUEST is not None: + msg = 'Fake Mail Host %s updated' % self.id + return self.manage_main( self + , REQUEST + , manage_tabs_message=msg + ) + + security.declareProtected(view_management_screens, 'getFolderPath') + def getFolderPath(self) : + return '/'.join(self._folderPath) + + + def _getMailContainer(self) : + return self.unrestrictedTraverse(self._folderPath) + + security.declarePrivate('setContainerPath') + def setContainerPath(self, path=None): + if not path: + self._folderPath = [] + elif type(path) is type(''): + if bad_path_chars_in(path): + raise ValueError, ( + 'Path contains invalid characters in a Zope ' + 'object path' + ) + self._folderPath = string.split(path, '/') + elif type(path) in (type([]), type(())): + self._folderPath = list(path) # sequence + else: + raise ValueError, ('Bad path value %s' % path) + +InitializeClass(FakeMailHost) \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100755 index 0000000..ef1f2e8 --- /dev/null +++ b/__init__.py @@ -0,0 +1,10 @@ +import FakeMailHost + +def initialize(context) : + context.registerClass( + FakeMailHost.FakeMailHost, + permission='Add MailHost objects', + constructors=(FakeMailHost.manage_addFakeMailHostForm, + FakeMailHost.manage_addFakeMailHost), + icon='www/MailHost_icon.gif', + ) \ No newline at end of file diff --git a/www/MailHost_icon.gif b/www/MailHost_icon.gif new file mode 100644 index 0000000000000000000000000000000000000000..f93122880a529d1714ff0cfe164d84021b30a00c GIT binary patch literal 896 zcmZ?wbhEHb6krfw_|Cxa9|##30s;aW8X689H~{1{FgP$UEMRbGXkch?U~u>kRPi6k zYyb-U2XaQiXb23W5K#Qd!U*z?4u}Bd2?vf?21X7Uj|~eP82N>?VrEQmU|?WU@|xoz znB>IBY>*{$;lsj%{mg<{DL)=KFt&@y=ZKvA$mqq$l5}d0=4Is*vn@E4R8D?S^>1b6 b`|)RGfkxnT{&Klm$ptGfFZX9=Vz34PdwM$6 literal 0 HcmV?d00001 diff --git a/www/addFakeMailHost_form.dtml b/www/addFakeMailHost_form.dtml new file mode 100755 index 0000000..bc0dfe2 --- /dev/null +++ b/www/addFakeMailHost_form.dtml @@ -0,0 +1,48 @@ + + + +

+Fake MailHost object provide a way to create File objects based on mails +instead of sending them. +

+ +
+ + + + + + + + + + + + + + + + + +
+
Id
+
+ +
+
Title
+
+ +
+
Base folder path
+
+ +
+ +
+ +
+
+
+ + + diff --git a/www/manageFakeMailHost.dtml b/www/manageFakeMailHost.dtml new file mode 100755 index 0000000..85eca50 --- /dev/null +++ b/www/manageFakeMailHost.dtml @@ -0,0 +1,45 @@ + + + +
+ + + + + + + + + + + + + + + + + +
+
+ Id +
+
+
&dtml-id;
+
+
Title
+
+ +
+
Base folder path
+
+ +
+ +
+ +
+
+
+ + -- 2.20.1