Changeset - 8f4ad3ab11f3
[Not reviewed]
0 2 0
Lance Edgar (lance) - 3 months ago 2024-07-17 17:54:40
lance@edbob.org
fix: rename auth handler; avoid app in provider constructor

if we reference `self.app` within the Provider constructor, then it
can (in some cases?) cause a recursion loop error
2 files changed with 33 insertions and 16 deletions:
0 comments (0 inline, 0 general)
rattail/app.py
Show inline comments
 
@@ -77,7 +77,7 @@ class AppHandler(WuttaAppHandler):
 
    """
 
    default_app_title = "Rattail"
 
    default_model_spec = 'rattail.db.model'
 
    default_auth_handler_spec = 'rattail.auth:AuthHandler'
 
    default_auth_handler_spec = 'rattail.auth:RattailAuthHandler'
 
    default_people_handler_spec = 'rattail.people:PeopleHandler'
 
    default_autocompleters = {
 
        'brands': 'rattail.autocomplete.brands:BrandAutocompleter',
 
@@ -2251,14 +2251,6 @@ class RattailProvider(WuttaAppProvider):
 
    :class:`~wuttjamaican:wuttjamaican.app.AppProvider` and adds the
 
    following to it:
 

	
 
    .. attribute:: enum
 

	
 
       Reference to the ``enum`` module for the app.
 

	
 
    .. attribute:: model
 

	
 
       Reference to the ``model`` module for the app.
 

	
 
    .. attribute:: handlers
 

	
 
       Dictionary of "secondary" handlers used by the provider, if
 
@@ -2267,15 +2259,31 @@ class RattailProvider(WuttaAppProvider):
 

	
 
    def __init__(self, config):
 
        super().__init__(config)
 
        self.enum = self.app.enum
 
        self.model = self.app.model
 
        self.handlers = {}
 

	
 
    @property
 
    def enum(self):
 
        """ """
 
        # TODO
 
        # warnings.warn("AppProvider.enum is deprecated; "
 
        #               "please use AppProvider.app.enum instead",
 
        #               DeprecationWarning, stacklevel=2)
 
        return self.app.enum
 

	
 
    @property
 
    def model(self):
 
        """ """
 
        # TODO
 
        # warnings.warn("AppProvider.model is deprecated; "
 
        #               "please use AppProvider.app.model instead",
 
        #               DeprecationWarning, stacklevel=2)
 
        return self.app.model
 

	
 
    def load_object(self, *args, **kwargs):
 
        """
 
        Convenience method which calls
 
        :meth:`AppHandler.load_object()`.
 
        """
 
        """ """
 
        warnings.warn("AppProvider.load_object() is deprecated; "
 
                      "please use AppProvider.app.load_object() instead",
 
                      DeprecationWarning, stacklevel=2)
 
        return self.app.load_object(*args, **kwargs)
 

	
 

	
rattail/auth.py
Show inline comments
 
@@ -37,7 +37,7 @@ from wuttjamaican import auth as base
 
from rattail.app import MergeMixin
 

	
 

	
 
class AuthHandler(base.AuthHandler, MergeMixin):
 
class RattailAuthHandler(base.AuthHandler, MergeMixin):
 
    """
 
    Default :term:`auth handler` for Rattail.
 

	
 
@@ -324,3 +324,12 @@ class AuthHandler(base.AuthHandler, MergeMixin):
 
                return True
 
            return False
 
        return True
 

	
 

	
 
class AuthHandler(RattailAuthHandler):
 

	
 
    def __init__(self, *args, **kwargs):
 
        warnings.warn("rattail.auth.AuthHandler is deprecated; "
 
                      "please use RattailAuthHandler instead",
 
                      DeprecationWarning, stacklevel=2)
 
        super().__init__(*args, **kwargs)
0 comments (0 inline, 0 general)