Glossary System¶
The glossary system (astra.glossary) provides centralized, human-readable descriptions for database fields.
It is used automatically by GlossaryFieldMixin to populate help_text on Peewee fields.
Glossary¶
class Glossary(BaseGlossary, metaclass=GlossaryType)
A class whose attributes are field-name-to-description mappings. Access any attribute to get its description string.
from astra.glossary import Glossary
Glossary.teff
# "Effective temperature [K]"
Glossary.logg
# "Surface gravity [dex]"
Glossary.sdss_id
# "SDSS unique source identifier"
Special prefix/suffix resolution¶
If a field name is not defined directly, the glossary resolves it by checking for known prefixes and suffixes:
Pattern |
Rule |
Example |
|---|---|---|
|
“Error on” + description of |
|
|
“Flags for” + description of |
|
|
“Initial” + description of |
|
|
“Reduced chi-square value for” + description of |
|
|
“Raw” + description of |
|
|
“Correlation coefficient between X and Y” |
|
Context usage¶
The Glossary can be instantiated with a context string to prepend to all descriptions:
from astra.glossary import Glossary
g = Glossary("SLAM")
g.teff
# "SLAM effective temperature [K]"
How fields use the glossary¶
When a field (e.g. FloatField, BitField) is bound to a model and no help_text is
provided, the GlossaryFieldMixin.bind() method automatically sets:
self.help_text = getattr(Glossary, self.name, None)
This means naming a model field teff will automatically give it the help text
"Effective temperature [K]" without any manual annotation.