[Checkins] SVN: CMF/branches/jens_tools_as_utilities/CMFDefault/ - use getUtility for MailHost

Yvo Schubbe y.2007- at wcm-solutions.de
Mon Jan 29 13:05:19 EST 2007


Log message for revision 72252:
  - use getUtility for MailHost
  - wrapped tools in two more places
  - added hack in PropertiesTool to get the site object (the old code doesn't work with re-wrapped tools)

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py	2007-01-29 17:55:53 UTC (rev 72251)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py	2007-01-29 18:05:18 UTC (rev 72252)
@@ -19,6 +19,9 @@
 from Acquisition import aq_inner, aq_parent
 from Globals import InitializeClass, DTMLFile
 from OFS.SimpleItem import SimpleItem
+from Products.MailHost.interfaces import IMailHost
+from zope.app.component.hooks import getSite
+from zope.component import getUtility
 from zope.interface import implements
 
 from Products.CMFCore.ActionProviderBase import ActionProviderBase
@@ -60,19 +63,22 @@
     security.declareProtected(ManagePortal, 'editProperties')
     def editProperties(self, props):
         '''Change portal settings'''
-        aq_parent(aq_inner(self)).manage_changeProperties(props)
-        self.MailHost.smtp_host = props['smtp_server']
+        # XXX: We need a better way to get the site!
+        site = getSite() or aq_parent(aq_inner(self))
+        site.manage_changeProperties(props)
+        getUtility(IMailHost).smtp_host = props['smtp_server']
         if hasattr(self, 'propertysheets'):
             ps = self.propertysheets
             if hasattr(ps, 'props'):
                 ps.props.manage_changeProperties(props)
 
     def title(self):
-        return self.aq_inner.aq_parent.title
+        # XXX: We need a better way to get the site!
+        site = getSite() or aq_parent(aq_inner(self))
+        return site.title
 
     def smtp_server(self):
-        return self.MailHost.smtp_host
+        return getUtility(IMailHost).smtp_host
 
 InitializeClass(PropertiesTool)
 registerToolInterface('portal_properties', IPropertiesTool)
-

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py	2007-01-29 17:55:53 UTC (rev 72251)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py	2007-01-29 18:05:18 UTC (rev 72252)
@@ -18,7 +18,7 @@
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
 from Globals import InitializeClass
-
+from Products.MailHost.interfaces import IMailHost
 from zope.component import getUtility
 from zope.interface import implements
 from zope.schema import ValidationError
@@ -132,7 +132,7 @@
 
         o Raise an exception if user ID is not found.
         """
-        membership = getUtility(IMembershipTool)
+        membership = getUtility(IMembershipTool).__of__(self)
         member = membership.getMemberById(forgotten_userid)
 
         if member is None:
@@ -152,7 +152,7 @@
         else:
             mail_text = method(**kw)
 
-        host = self.MailHost
+        host = getUtility(IMailHost)
         host.send( mail_text )
 
         return self.mail_password_response( self, REQUEST )
@@ -161,7 +161,7 @@
     def registeredNotify( self, new_member_id, password=None ):
         """ Handle mailing the registration / welcome message.
         """
-        membership = getUtility(IMembershipTool)
+        membership = getUtility(IMembershipTool).__of__(self)
         member = membership.getMemberById( new_member_id )
 
         if member is None:
@@ -184,7 +184,7 @@
         else:
             mail_text = method(**kw)
 
-        host = self.MailHost
+        host = getUtility(IMailHost)
         host.send( mail_text )
 
     security.declareProtected(ManagePortal, 'editMember')



More information about the Checkins mailing list