[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py Dedicated Exception class added for syndication errors.

Charlie Clark charlie at begeistert.org
Sun Oct 3 10:54:34 EDT 2010


Log message for revision 117199:
  Dedicated Exception class added for syndication errors.

Changed:
  U   Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py

-=-
Modified: Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py	2010-10-03 11:51:09 UTC (rev 117198)
+++ Products.CMFDefault/trunk/Products/CMFDefault/SyndicationTool.py	2010-10-03 14:54:34 UTC (rev 117199)
@@ -37,24 +37,29 @@
 from Products.CMFDefault.utils import _dtmldir
 
 
+class SyndicationError(Exception):
+    
+    pass
+    
+
 class SyndicationTool(UniqueObject, SimpleItem):
     """ The syndication tool manages the site-wide policy for
         syndication of folder content as RSS.
     """
     implements(ISyndicationTool)
-
+    
     id = 'portal_syndication'
     meta_type = 'Default Syndication Tool'
-
+    
     security = ClassSecurityInfo()
-
+    
     #Default Sitewide Values
     isAllowed = 0
     syUpdatePeriod = 'daily'
     syUpdateFrequency = 1
     syUpdateBase = DateTime()
     max_items = 15
-
+    
     #ZMI Methods
     manage_options = ( ( { 'label'  : 'Overview'
                          , 'action' : 'overview'
@@ -63,10 +68,10 @@
                          },
                         )
                      )
-
+    
     security.declareProtected(ManagePortal, 'overview')
     overview = HTMLFile('synOverview', _dtmldir)
-
+    
     security.declareProtected(ManagePortal, 'editProperties')
     def editProperties( self
                       , updatePeriod=None
@@ -82,7 +87,7 @@
         """
         if isAllowed is not None:
             self.isAllowed = isAllowed
-
+        
         if updatePeriod is not None:
             self.syUpdatePeriod = updatePeriod
         else:
@@ -90,7 +95,7 @@
                 del self.syUpdatePeriod
             except (AttributeError, KeyError):
                 pass
-
+        
         if updateFrequency is not None:
             self.syUpdateFrequency = int(updateFrequency)
         else:
@@ -98,7 +103,7 @@
                 del self.syUpdateFrequency
             except (AttributeError, KeyError):
                 pass
-
+        
         if updateBase is not None:
             if not hasattr(updateBase, 'ISO'):
                 updateBase = DateTime( updateBase )
@@ -108,7 +113,7 @@
                 del self.syUpdateBase
             except (AttributeError, KeyError):
                 pass
-
+        
         if max_items is not None:
             self.max_items = int(max_items)
         else:
@@ -116,7 +121,7 @@
                 del self.max_items
             except (AttributeError, KeyError):
                 pass
-
+    
     security.declarePublic( 'editSyInformationProperties' )
     def editSyInformationProperties( self
                                    , obj
@@ -133,45 +138,45 @@
         """
         if not _checkPermission( ManageProperties, obj ):
             raise AccessControl_Unauthorized
-
+        
         syInfo = getattr(obj, 'syndication_information', None)
-
+        
         if syInfo is None:
-            raise 'Syndication is Disabled'
-
+            raise SyndicationError('Syndication is Disabled')
+        
         if updatePeriod is not None:
             syInfo.syUpdatePeriod = updatePeriod
         else:
             syInfo.syUpdatePeriod = self.syUpdatePeriod
-
+        
         if updateFrequency is not None:
             syInfo.syUpdateFrequency = int(updateFrequency)
         else:
             syInfo.syUpdateFrequency = self.syUpdateFrequency
-
+        
         if updateBase is not None:
             if not hasattr(updateBase, 'ISO'):
                 updateBase = DateTime( updateBase )
             syInfo.syUpdateBase = updateBase
         else:
             syInfo.syUpdateBase = self.syUpdateBase
-
+        
         if max_items is not None:
             syInfo.max_items = int(max_items)
         else:
             syInfo.max_items = self.max_items
-
+    
     security.declarePublic('enableSyndication')
     def enableSyndication(self, obj):
         """
         Enable syndication for the obj
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is Disabled'
-
+            raise SyndicationError('Syndication is Disabled')
+        
         if hasattr(aq_base(obj), 'syndication_information'):
-            raise 'Syndication Information Exists'
-
+            raise SyndicationError('Syndication Information Exists')
+        
         syInfo = SyndicationInformation()
         obj._setObject('syndication_information', syInfo)
         syInfo = obj._getOb('syndication_information')
@@ -180,19 +185,20 @@
         syInfo.syUpdateBase = self.syUpdateBase
         syInfo.max_items = self.max_items
         syInfo.description = "Channel Description"
-
+    
     security.declarePublic('disableSyndication')
     def disableSyndication(self, obj):
         """
         Disable syndication for the obj; and remove it.
         """
         syInfo = getattr(obj, 'syndication_information', None)
-
+        
         if syInfo is None:
-            raise 'This object does not have Syndication Information'
-
+            raise SyndicationError('This object does not have Syndication \
+                Information')
+        
         obj._delObject('syndication_information')
-
+    
     security.declarePublic('getSyndicatableContent')
     def getSyndicatableContent(self, obj):
         """
@@ -204,7 +210,7 @@
         else:
             values = PortalFolderBase.contentValues(obj)
         return values
-
+    
     security.declarePublic('buildUpdatePeriods')
     def buildUpdatePeriods(self):
         """
@@ -217,14 +223,14 @@
                         , ('yearly',  'Yearly')
                         )
         return updatePeriods
-
+    
     security.declarePublic('isSiteSyndicationAllowed')
     def isSiteSyndicationAllowed(self):
         """
         Return sitewide syndication policy
         """
         return self.isAllowed
-
+    
     security.declarePublic('isSyndicationAllowed')
     def isSyndicationAllowed(self, obj=None):
         """
@@ -239,7 +245,7 @@
             return 0
         else:
             return self.isSiteSyndicationAllowed()
-
+    
     security.declarePublic('getUpdatePeriod')
     def getUpdatePeriod( self, obj=None ):
         """
@@ -247,22 +253,22 @@
         This is either on the object being passed or the
         portal_syndication tool (if a sitewide value or default
         is set)
-
+        
         NOTE:  Need to add checks for sitewide policies!!!
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is Not Allowed'
-
+            raise SyndicationError('Syndication is Not Allowed')
+        
         if obj is None:
             return self.syUpdatePeriod
-
+        
         syInfo = getattr(obj, 'syndication_information', None)
-
+        
         if syInfo is not None:
             return syInfo.syUpdatePeriod
         else:
             return 'Syndication is Not Allowed'
-
+    
     security.declarePublic('getUpdateFrequency')
     def getUpdateFrequency(self, obj=None):
         """
@@ -270,28 +276,28 @@
         the syn namespace.  This is either on the object being
         pass or the portal_syndication tool (if a sitewide value
         or default is set).
-
+        
         Note:  Need to add checks for sitewide policies!!!
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is not Allowed'
-
+            raise SyndicationError('Syndication is not Allowed')
+        
         if obj is None:
             return self.syUpdateFrequency
-
+        
         syInfo = getattr(obj, 'syndication_information',
                             None)
         if syInfo is not None:
             return syInfo.syUpdateFrequency
         else:
             return 'Syndication is not Allowed'
-
+    
     security.declarePublic('getUpdateBase')
     def getUpdateBase(self, obj=None):
         """
         Return the base date to be used with the update frequency
         and the update period to calculate a publishing schedule.
-
+        
         Note:  I'm not sure what's best here, creation date, last
         modified date (of the folder being syndicated) or some
         arbitrary date.  For now, I'm going to build a updateBase
@@ -300,12 +306,12 @@
         here...
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is not Allowed'
-
+            raise SyndicationError('Syndication is not Allowed')
+        
         if obj is None:
             when = self.syUpdateBase
             return when.ISO()
-
+        
         syInfo = getattr(obj, 'syndication_information',
                             None)
         if syInfo is not None:
@@ -313,19 +319,19 @@
                 return when.ISO()
         else:
             return 'Syndication is not Allowed'
-
+    
     security.declarePublic('getHTML4UpdateBase')
     def getHTML4UpdateBase(self, obj=None):
         """
         Return HTML4 formated UpdateBase DateTime
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is not Allowed'
-
+            raise SyndicationError('Syndication is not Allowed')
+        
         if obj is None:
             when = self.syUpdateBase
             return when.HTML4()
-
+        
         syInfo = getattr(obj, 'syndication_information',
                             None)
         if syInfo is not None:
@@ -333,17 +339,17 @@
             return when.HTML4()
         else:
             return 'Syndication is not Allowed'
-
+    
     def getMaxItems(self, obj=None):
         """
         Return the max_items to be displayed in the syndication
         """
         if not self.isSiteSyndicationAllowed():
-            raise 'Syndication is not Allowed'
-
+            raise SyndicationError('Syndication is not Allowed')
+        
         if obj is None:
             return self.max_items
-
+        
         syInfo = getattr(obj, 'syndication_information',
                             None)
         if syInfo is not None:



More information about the checkins mailing list