Merge pull request #2704 from ChrisLR/components-delimiter-change

[Components Contrib] Changed DBField and NDBField delimiters from __ to ::
This commit is contained in:
Griatch 2022-04-15 07:37:16 +02:00 committed by GitHub
commit ca06dd7c7b
2 changed files with 3 additions and 3 deletions

View file

@ -39,7 +39,7 @@ class Health(Component):
Components may define DBFields or NDBFields at the class level. Components may define DBFields or NDBFields at the class level.
DBField will store its values in the host's DB with a prefixed key. DBField will store its values in the host's DB with a prefixed key.
NDBField will store its values in the host's NDB and will not persist. NDBField will store its values in the host's NDB and will not persist.
The key used will be 'component_name__field_name'. The key used will be 'component_name::field_name'.
They use AttributeProperty under the hood. They use AttributeProperty under the hood.
Example: Example:

View file

@ -21,7 +21,7 @@ class DBField(AttributeProperty):
owner (object): The component classF on which this is set owner (object): The component classF on which this is set
name (str): The name that was used to set the DBField. name (str): The name that was used to set the DBField.
""" """
key = f"{owner.name}__{name}" key = f"{owner.name}::{name}"
self._key = key self._key = key
db_fields = getattr(owner, "_db_fields", None) db_fields = getattr(owner, "_db_fields", None)
if db_fields is None: if db_fields is None:
@ -45,7 +45,7 @@ class NDBField(NAttributeProperty):
owner (object): The component class on which this is set owner (object): The component class on which this is set
name (str): The name that was used to set the DBField. name (str): The name that was used to set the DBField.
""" """
key = f"{owner.name}__{name}" key = f"{owner.name}::{name}"
self._key = key self._key = key
ndb_fields = getattr(owner, "_ndb_fields", None) ndb_fields = getattr(owner, "_ndb_fields", None)
if ndb_fields is None: if ndb_fields is None: