Skip to content

hololinked.core.meta.Propertized

Bases: Parameterized

Base class providing additional functionality related to properties, like setting up a registry, allowing values to be set at __init__() etc. It is not meant to be subclassed directly by the end-user.

UML Diagram

Source code in .venv/lib/python3.13/site-packages/hololinked/core/meta.py
class Propertized(Parameterized):
    """
    Base class providing additional functionality related to properties,
    like setting up a registry, allowing values to be set at `__init__()` etc. 
    It is not meant to be subclassed directly by the end-user.

    [UML Diagram](https://docs.hololinked.dev/UML/PDF/Thing.pdf)
    """

    # There is a word called Property+ize in english dictionary
    # https://en.wiktionary.org/wiki/propertization

    id : str

    # creating name without underscore causes clash with the metaclass method 
    # with same name
    def create_param_container(self, **params):
        self._properties_registry = PropertiesRegistry(self.__class__, None, self)
        self._properties_registry._setup_parameters(**params)
        self._param_container = self._properties_registry # backwards compatibility with param

    @property
    def properties(self) -> PropertiesRegistry:
        """container for the property descriptors of the object."""
        return self._properties_registry

    @action()
    def _get_properties(self, **kwargs) -> typing.Dict[str, typing.Any]:
        """
        """
        return self.properties.get(**kwargs)

    @action()
    def _set_properties(self, **values : typing.Dict[str, typing.Any]) -> None:
        """ 
        set properties whose name is specified by keys of a dictionary

        Parameters
        ----------
        values: Dict[str, Any]
            dictionary of property names and its values
        """
        return self.properties.set(**values) # returns None

    @action()
    def _get_properties_in_db(self) -> typing.Dict[str, JSONSerializable]:
        """
        get all properties in the database

        Returns
        -------
        Dict[str, JSONSerializable]
            dictionary of property names and their values
        """
        return self.properties.get_from_DB()

    @action()
    def _add_property(self, name: str, prop: JSON) -> None:
        """
        add a property to the object

        Parameters
        ----------
        name: str
            name of the property
        prop: Property
            property object
        """
        raise NotImplementedError("this method will be implemented properly in a future release")
        prop = Property(**prop)
        self.properties.add(name, prop)
        self._prepare_resources()

Attributes

properties property

properties: PropertiesRegistry

container for the property descriptors of the object.