Changeset - 2f17b96e5409
[Not reviewed]
0 3 0
Lance Edgar (lance) - 3 months ago 2024-07-12 00:14:31
lance@edbob.org
fix: remove duplicate method for `AppHandler.load_object()`

that is now defined in wuttjamaican
3 files changed with 8 insertions and 46 deletions:
0 comments (0 inline, 0 general)
pyproject.toml
Show inline comments
 
@@ -49,7 +49,7 @@ dependencies = [
 
        "texttable",
 
        "typer",
 
        "typing-extensions",
 
        "WuttJamaican>=0.6.0",
 
        "WuttJamaican>=0.6.1",
 
        "xlrd",
 
]
 

	
rattail/app.py
Show inline comments
 
@@ -43,7 +43,7 @@ from mako.template import Template
 

	
 
from wuttjamaican.app import AppHandler as WuttaAppHandler, AppProvider as WuttaAppProvider
 

	
 
from rattail.util import (load_object, load_entry_points,
 
from rattail.util import (load_entry_points,
 
                          progress_loop, prettify,
 
                          pretty_quantity,
 
                          NOTSET)
 
@@ -260,37 +260,6 @@ class AppHandler(WuttaAppHandler):
 
                      DeprecationWarning, stacklevel=2)
 
        return load_entry_points(group, **kwargs)
 

	
 
    def load_object(self, spec):
 
        """
 
        Import and/or load and return the object designated by the
 
        given spec string.
 

	
 
        Default logic invokes :func:`rattail.util.load_object()` to
 
        obtain the object.
 

	
 
        The syntax of the spec string is not unique to Rattail, but is
 
        not a universal standard, so deserves a note here.  The spec
 
        is basically just ``modulepath:objname`` where ``modulepath``
 
        is the dotted name of the full module where the object
 
        resides, and ``objname`` is the name of the object within that
 
        module.  For instance, ``rattail.app:AppHandler`` would be the
 
        spec for *this* class.
 

	
 
        Note also that the use of the word "object" may be confusing,
 
        as it does not signify an "instance" but rather an object in
 
        the generic sense.  Most often a spec will either refer to a
 
        class or function within the module, although any valid named
 
        object is possible.
 

	
 
        :param spec: String like ``modulepath:objname`` as described
 
           above.
 

	
 
        :returns: The object referred to by ``spec``.  If the module
 
           could not be imported, or did not contain an object of the
 
           given name, then an error will raise.
 
        """
 
        return load_object(spec)
 

	
 
    def make_counter(self, session, key, **kwargs):
 
        """
 
        Create a new counter sequence in the DB, if needed.
 
@@ -549,7 +518,7 @@ class AppHandler(WuttaAppHandler):
 
        if not spec:
 
            spec = self.default_autocompleters.get(key)
 
        if spec:
 
            return load_object(spec)(self.config)
 
            return self.load_object(spec)(self.config)
 

	
 
        raise ValueError("cannot locate autocompleter for key: {}".format(key))
 

	
 
@@ -579,7 +548,7 @@ class AppHandler(WuttaAppHandler):
 
        if 'auth' not in self.handlers:
 
            spec = self.config.get('rattail', 'auth.handler',
 
                                   default='rattail.auth:AuthHandler')
 
            factory = load_object(spec)
 
            factory = self.load_object(spec)
 
            self.handlers['auth'] = factory(self.config, **kwargs)
 
        return self.handlers['auth']
 

	
 
@@ -832,7 +801,7 @@ class AppHandler(WuttaAppHandler):
 
        for Handler in Handlers.values():
 
            spec = self.get_designated_import_handler_spec(Handler.get_key())
 
            if spec and spec not in specs:
 
                specs[spec] = load_object(spec)
 
                specs[spec] = self.load_object(spec)
 

	
 
        # flatten back to simple list
 
        Handlers = list(specs.values())
 
@@ -1024,7 +993,7 @@ class AppHandler(WuttaAppHandler):
 
        if 'membership' not in self.handlers:
 
            spec = self.config.get('rattail', 'membership.handler',
 
                                   default='rattail.membership:MembershipHandler')
 
            factory = load_object(spec)
 
            factory = self.load_object(spec)
 
            self.handlers['membership'] = factory(self.config, **kwargs)
 
        return self.handlers['membership']
 

	
 
@@ -1038,7 +1007,7 @@ class AppHandler(WuttaAppHandler):
 
        if 'org' not in self.handlers:
 
            spec = self.config.get('rattail', 'org.handler',
 
                                   default='rattail.org:OrgHandler')
 
            factory = load_object(spec)
 
            factory = self.load_object(spec)
 
            self.handlers['org'] = factory(self.config, **kwargs)
 
        return self.handlers['org']
 

	
 
@@ -1054,7 +1023,7 @@ class AppHandler(WuttaAppHandler):
 
        if 'people' not in self.handlers:
 
            spec = self.config.get('rattail', 'people.handler',
 
                                   default='rattail.people:PeopleHandler')
 
            factory = load_object(spec)
 
            factory = self.load_object(spec)
 
            self.handlers['people'] = factory(self.config, **kwargs)
 
        return self.handlers['people']
 

	
tests/test_app.py
Show inline comments
 
@@ -104,13 +104,6 @@ class TestAppHandler(TestCase):
 
        now = self.app.make_utc()
 
        self.assertIsNotNone(now)
 

	
 
    def test_load_object(self):
 

	
 
        # just confirm the method works on a basic level; the
 
        # underlying function is tested elsewhere
 
        cls = self.app.load_object('rattail.core:Object')
 
        self.assertIs(cls, Object)
 

	
 
    def test_get_active_stores(self):
 
        try:
 
            import sqlalchemy as sa
0 comments (0 inline, 0 general)