Changeset - 2fcd8cb6dc62
[Not reviewed]
0 1 0
Lance Edgar (lance) - 17 days ago 2024-04-30 19:42:58
lance@edbob.org
Do not assign `AppHandler.enum` in constructor

the app handler is created before config extensions are applied, and
the latter may determine which enum module should be used. so
use a property to fetch on-demand instead of assigning it so early
1 file changed with 8 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rattail/app.py
Show inline comments
 
@@ -96,12 +96,15 @@ class AppHandler(WuttaAppHandler):
 

	
 
    setting_utctime_format = '%Y-%m-%d %H:%M:%S'
 

	
 
    def __init__(self, config):
 
        super().__init__(config)
 
    @property
 
    def enum(self):
 
        """
 
        Property which returns a reference to the enum module.
 

	
 
        # nb. cannot assign self.model yet b/c the app handler is
 
        # likely created before versioning has been configured
 
        self.enum = self.config.get_enum()
 
        Ultimately this is the same as calling
 
        :meth:`rattail.config.RattailConfig.get_enum()`.
 
        """
 
        return self.config.get_enum()
 

	
 
    @property
 
    def model(self):
0 comments (0 inline, 0 general)