コード例 #1
0
def fixupErrorLogging(reg_container, reg):
    # Fix up Error Reporting Service --> Utility 
    # We do this by simply removing old Error Reporting Services and their
    # registrations and then add a new error reporting utility.

    errors = reg.component
    # Set the registration to unregistered and then delete it
    reg.status = InactiveStatus
    del zapi.getParent(reg)[zapi.name(reg)]
    # Get the properties from the old error reporting service and
    # delete it
    props = errors.getProperties()
    folder = zapi.getParent(errors)
    del folder._SampleContainer__data[zapi.name(errors)]
    
    # Only add a new error reporting utility, if there is none.
    if 'ErrorReporting' not in folder:
        # Create the error reporting utility and set its properties
        utility = ErrorReportingUtility()
        utility.setProperties(**props)
        folder['ErrorReporting'] = utility
        # Register the utility and set the registration active
        reg = UtilityRegistration('', IErrorReportingUtility, utility)
        reg_manager = folder.registrationManager
        key = reg_manager.addRegistration(reg)
        reg_manager[key].status = ActiveStatus
    else:
        # If there is one, then at least move the data
        folder['ErrorReporting'].__dict__.update(props)
コード例 #2
0
 def test_checkProperties(self):
     # Test Properties test
     errUtility = ErrorReportingUtility()
     setProp = {
         'keep_entries':10,
         'copy_to_zlog':1,
         'ignored_exceptions':()
         }
     errUtility.setProperties(**setProp)
     getProp = errUtility.getProperties()
     self.assertEqual(setProp, getProp)