File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
packages/cubejs-backend-native/python/cube/src/conf Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,9 @@ def __init__(self):
125125 self .orchestrator_options = None
126126
127127 def __call__ (self , func ):
128+ if isinstance (func , str ):
129+ return AttrRef (self , func )
130+
128131 if not callable (func ):
129132 raise ConfigurationException ("@config decorator must be used with functions, actual: '%s'" % type (func ).__name__ )
130133
@@ -133,6 +136,25 @@ def __call__(self, func):
133136 else :
134137 raise ConfigurationException ("Unknown configuration property: '%s'" % func .__name__ )
135138
139+ class AttrRef :
140+ config : Configuration
141+ attribute : str
142+
143+ def __init__ (self , config : Configuration , attribue : str ):
144+ self .config = config
145+ self .attribute = attribue
146+
147+ def __call__ (self , func ):
148+ if not callable (func ):
149+ raise ConfigurationException ("@config decorator must be used with functions, actual: '%s'" % type (func ).__name__ )
150+
151+ if hasattr (self .config , self .attribute ):
152+ setattr (self .config , self .attribute , func )
153+ else :
154+ raise ConfigurationException ("Unknown configuration property: '%s'" % func .__name__ )
155+
156+ return func
157+
136158config = Configuration ()
137159# backward compatibility
138160settings = config
You can’t perform that action at this time.
0 commit comments