You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a means of making my own module outside of propnet that kept its own models and symbols, but propnet when started up, etc. could find them.
One way to do this might be ot have an environment varibale like PROPNET_MODULES that could reference places for it to look, or go the fireworks method and allow for some of configuration file that does this.
Something that might help with this pattern would be to move the Model/Symbol registry into class-registry pattern:
import abc
class ClassRegistry(abc.ABCMeta):
def __init__(cls, name, bases, nmspc):
super(ClassRegistry, cls).__init__(name, bases, nmspc)
cls._instances = dict()
def __call__(cls, *args, **kwargs):
# First get the name
if "name" in kwargs:
name = kwargs["id"]
elif len(args) < 1:
raise TypeError("Can't get a propnet object without a name")
else:
id = args[0]
args = args[1:]
# If there isn't already an instance with this name
# Let's make a new Model object
if name not in cls._instances:
new_object = super(ClassRegistry, cls).__call__(*args, **kwargs)
cls._instances[id] = new_object
return cls._instances[id]
class Model(metaclass=ClassRegistry):
...
The text was updated successfully, but these errors were encountered:
It would be nice to have a means of making my own module outside of propnet that kept its own models and symbols, but propnet when started up, etc. could find them.
One way to do this might be ot have an environment varibale like PROPNET_MODULES that could reference places for it to look, or go the fireworks method and allow for some of configuration file that does this.
Something that might help with this pattern would be to move the Model/Symbol registry into class-registry pattern:
The text was updated successfully, but these errors were encountered: