Пример #1
0
    def _predictor_init(self, set_conf=0, predictor=None):
        """ """
        __traceback_info__ = (self.module,)
        if predictor is None:
            predictor = self._load_predictor()
        else:
            self._v_predictor = predictor
        # check this is a valid predictor
        if not hasattr(predictor, "__class__"):
            raise Plone4BioException("Invalid predictor : predictor is not a class")
        if not IPredictor.providedBy(predictor):
            raise Plone4BioException("Invalid predictor : IPredictor is not implemented by %s" % predictor.__class__)
        # if not hasattr(predictor, 'run'):
        #     raise Plone4BioException('Invalid predictor : missing required "run" attribute')
        # manage configuration
        if set_conf and hasattr(predictor, "config"):
            conf = dict(predictor.config)
            self._config.update(conf)
            make_config_persistent(self._config)
            if hasattr(predictor, "config_metadata"):
                conf = dict(predictor.config_metadata)
                self._config_metadata.update(conf)
                make_config_persistent(self._config_metadata)
        predictor.config = dict(self._config)
        make_config_nonpersistent(predictor.config)
        predictor.config_metadata = dict(self._config_metadata)
        make_config_nonpersistent(predictor.config_metadata)

        # self.inputs = predictor.inputs
        # self.output = predictor.output
        # self.output_encoding = getattr(predictor, 'output_encoding', None)
        return predictor
Пример #2
0
    def _predictor_init(self, set_conf=0, predictor=None):
        """ """
        __traceback_info__ = (self.module, )
        if predictor is None:
            predictor = self._load_predictor()
        else:
            self._v_predictor = predictor
        # check this is a valid predictor
        if not hasattr(predictor, '__class__'):
            raise Plone4BioException(
                'Invalid predictor : predictor is not a class')
        if not IPredictor.providedBy(predictor):
            raise Plone4BioException(
                'Invalid predictor : IPredictor is not implemented by %s' %
                predictor.__class__)
        # if not hasattr(predictor, 'run'):
        #     raise Plone4BioException('Invalid predictor : missing required "run" attribute')
        # manage configuration
        if set_conf and hasattr(predictor, 'config'):
            conf = dict(predictor.config)
            self._config.update(conf)
            make_config_persistent(self._config)
            if hasattr(predictor, 'config_metadata'):
                conf = dict(predictor.config_metadata)
                self._config_metadata.update(conf)
                make_config_persistent(self._config_metadata)
        predictor.config = dict(self._config)
        make_config_nonpersistent(predictor.config)
        predictor.config_metadata = dict(self._config_metadata)
        make_config_nonpersistent(predictor.config_metadata)

        # self.inputs = predictor.inputs
        # self.output = predictor.output
        # self.output_encoding = getattr(predictor, 'output_encoding', None)
        return predictor
Пример #3
0
 def registerPredictor(self, predictor):
     """register a new predictor
     """
     # needed when call from transform.transforms.initialize which
     # register non zope transform
     module = str(predictor.__module__)
     predictor = Predictor(predictor.name(), module, predictor)
     if not IPredictor.providedBy(predictor):
         raise Plone4BioException('%s does not implement IPredictor' % predictor)
     name = predictor.name()
     __traceback_info__ = (name, predictor)
     if name not in self.objectIds():
         self._setObject(name, predictor)
         self._mapPredictor(predictor)
Пример #4
0
 def registerPredictor(self, predictor):
     """register a new predictor
     """
     # needed when call from transform.transforms.initialize which
     # register non zope transform
     module = str(predictor.__module__)
     predictor = Predictor(predictor.name(), module, predictor)
     if not IPredictor.providedBy(predictor):
         raise Plone4BioException('%s does not implement IPredictor' %
                                  predictor)
     name = predictor.name()
     __traceback_info__ = (name, predictor)
     if name not in self.objectIds():
         self._setObject(name, predictor)
         self._mapPredictor(predictor)