Skip to content
Snippets Groups Projects
Commit 0bb0056f authored by Stefano Borini's avatar Stefano Borini
Browse files

Moved description to the level of BaseFactory

parent 17758849
No related branches found
No related tags found
1 merge request!168Moved description to the level of BaseFactory
This commit is part of merge request !168. Comments created here will be created in the context of that merge request.
from envisage.plugin import Plugin
from traits.api import HasStrictTraits, Str, Instance
from traits.api import HasStrictTraits, Str, Unicode, Instance
from force_bdss.ids import factory_id
......@@ -12,6 +12,9 @@ class BaseFactory(HasStrictTraits):
#: A human readable name of the factory. Spaces allowed
name = Str()
#: A long description of the factory.
description = Unicode()
#: Reference to the plugin that carries this factory
#: This is automatically set by the system. you should not define it
#: in your subclass.
......@@ -21,6 +24,7 @@ class BaseFactory(HasStrictTraits):
super(BaseFactory, self).__init__(plugin=plugin, *args, **kwargs)
self.name = self.get_name()
self.description = self.get_description()
identifier = self.get_identifier()
try:
id = self._global_id(identifier)
......@@ -51,5 +55,8 @@ class BaseFactory(HasStrictTraits):
"get_identifier was not implemented in factory {}".format(
self.__class__))
def get_description(self):
return u"No description available."
def _global_id(self, identifier):
return factory_id(self.plugin.id, identifier)
......@@ -25,6 +25,7 @@ class TestBaseDataSourceFactory(unittest.TestCase):
factory = DummyDataSourceFactory(self.plugin)
self.assertEqual(factory.id, 'pid.factory.dummy_data_source')
self.assertEqual(factory.name, 'Dummy data source')
self.assertEqual(factory.description, u"No description available.")
self.assertEqual(factory.model_class, DummyDataSourceModel)
self.assertEqual(factory.data_source_class, DummyDataSource)
self.assertIsInstance(factory.create_data_source(), DummyDataSource)
......
from traits.api import Str, Type, Instance, provides
from traits.api import Type, Instance, provides, Unicode
from force_bdss.core.base_factory import BaseFactory
from force_bdss.ids import mco_parameter_id
......@@ -20,20 +20,12 @@ class BaseMCOParameterFactory(BaseFactory):
mco_factory = Instance('force_bdss.mco.base_mco_factory.BaseMCOFactory',
allow_none=False)
#: A long description of the parameter
description = Str()
# The model class to instantiate when create_model is called.
model_class = Type(
"force_bdss.mco.parameters.base_mco_parameter.BaseMCOParameter",
allow_none=False
)
def get_description(self):
raise NotImplementedError(
"get_description was not implemented in factory {}".format(
self.__class__))
def get_model_class(self):
raise NotImplementedError(
"get_model_class was not implemented in factory {}".format(
......@@ -46,7 +38,6 @@ class BaseMCOParameterFactory(BaseFactory):
*args,
**kwargs)
self.description = self.get_description()
self.model_class = self.get_model_class()
def create_model(self, data_values=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment