Changeset - 3a7899e01176
[Not reviewed]
0 11 0
Lance Edgar (lance) - 2 months ago 2024-08-21 08:58:57
lance@edbob.org
fix: use app.get_title() and app.get_node_title(); avoid deprecated calls

now that wuttjamaican app handler has both methods
11 files changed with 42 insertions and 47 deletions:
0 comments (0 inline, 0 general)
rattail/app.py
Show inline comments
 
@@ -130,15 +130,6 @@ class AppHandler(WuttaAppHandler):
 
            self.model = importlib.import_module(spec)
 
        return self.model
 

	
 
    def get_node_title(self, default='Rattail'):
 
        """
 
        Returns the configured title for the local app node.
 
        """
 
        title = self.config.get('rattail', 'node_title')
 
        if title:
 
            return title
 
        return self.get_title(default=default)
 

	
 
    def get_version(self, **kwargs):
 
        """ """
 

	
rattail/emails.py
Show inline comments
 
@@ -469,18 +469,17 @@ class upgrade_failure(Email):
 
    default_subject = "Upgrade failure for ${system_title}"
 

	
 
    def sample_data(self, request):
 
        app = request.rattail_config.get_app()
 
        upgrade = app.make_object(
 
        upgrade = self.app.make_object(
 
            description="upgrade to the latest!",
 
            notes="nothing special",
 
            executed=app.make_utc(),
 
            executed=self.app.make_utc(),
 
            executed_by="Fred Flintstone",
 
            exit_code=42,
 
        )
 
        return {
 
            'upgrade': upgrade,
 
            'upgrade_url': '#',
 
            'system_title': self.config.app_title(),
 
            'system_title': self.app.get_title(),
 
        }
 

	
 

	
 
@@ -491,18 +490,17 @@ class upgrade_success(Email):
 
    default_subject = "Upgrade success for ${system_title}"
 

	
 
    def sample_data(self, request):
 
        app = request.rattail_config.get_app()
 
        upgrade = app.make_object(
 
        upgrade = self.app.make_object(
 
            description="upgrade to the latest!",
 
            notes="nothing special",
 
            executed=app.make_utc(),
 
            executed=self.app.make_utc(),
 
            executed_by="Fred Flintstone",
 
            exit_code=0,
 
        )
 
        return {
 
            'upgrade': upgrade,
 
            'upgrade_url': '#',
 
            'system_title': self.config.app_title(),
 
            'system_title': self.app.get_title(),
 
        }
 

	
 

	
 
@@ -514,7 +512,7 @@ class user_feedback(Email):
 

	
 
    def sample_data(self, request):
 
        return {
 
            'app_title': request.rattail_config.app_title(default="Rattail"),
 
            'app_title': self.app.get_title(),
 
            'user': None,
 
            'user_name': "Fred Flintstone",
 
            'referrer': request.route_url('home'),
rattail/features/handlers.py
Show inline comments
 
@@ -75,9 +75,10 @@ class FeatureHandler(GenericHandler):
 
        return Schema(**kwargs)
 

	
 
    def get_defaults(self):
 
        app_title = self.app.get_title()
 
        return {
 
            'app_prefix': self.config.app_title().lower(),
 
            'app_cap_prefix': self.config.app_title(),
 
            'app_prefix': app_title.lower(),
 
            'app_cap_prefix': app_title,
 
        }
 

	
 
    def do_generate(self, feature, **kwargs):
rattail/importing/csv.py
Show inline comments
 
@@ -211,7 +211,7 @@ class FromCSVToRattail(FromCSVToSQLAlchemyMixin, FromFileHandler, importing.ToRa
 

	
 
    @property
 
    def local_title(self):
 
        return self.config.node_title()
 
        return self.app.get_node_title()
 

	
 
    def get_model(self):
 
        if self.config:
rattail/importing/exporters.py
Show inline comments
 
@@ -95,7 +95,7 @@ class FromRattailToCSV(FromSQLAlchemyToCSVMixin, FromRattailHandler, ToCSVHandle
 

	
 
    @property
 
    def host_title(self):
 
        return self.config.node_title()
 
        return self.app.get_node_title()
 

	
 
    def get_model(self):
 
        if self.config:
rattail/importing/local.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2023 Lance Edgar
 
#  Copyright © 2010-2024 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -39,13 +39,12 @@ class FromRattailSelfToRattail(importing.FromRattailHandler, importing.ToSQLAlch
 

	
 
    @property
 
    def host_title(self):
 
        title = self.config.node_title(default="Rattail")
 
        return f"{title} (self)"
 
        node_title = self.app.get_node_title()
 
        return f"{node_title} (self)"
 

	
 
    @property
 
    def local_title(self):
 
        title = self.config.node_title(default="Rattail")
 
        return title
 
        return self.app.get_node_title()
 

	
 
    def begin_local_transaction(self):
 
        self.session = self.host_session
rattail/importing/rattail.py
Show inline comments
 
@@ -46,7 +46,7 @@ class FromRattailHandler(FromSQLAlchemyHandler):
 

	
 
    @property
 
    def host_title(self):
 
        return self.config.app_title(default="Rattail")
 
        return self.app.get_title()
 

	
 
    def make_host_session(self):
 
        return self.app.make_session()
 
@@ -61,7 +61,7 @@ class ToRattailHandler(ToSQLAlchemyHandler):
 

	
 
    @property
 
    def local_title(self):
 
        return self.config.app_title(default="Rattail")
 
        return self.app.get_title()
 

	
 
    def make_session(self):
 
        kwargs = {}
 
@@ -187,11 +187,16 @@ class FromRattailToRattailImport(FromRattailToRattailBase, FromRattailHandler, T
 

	
 
    @property
 
    def host_title(self):
 
        return "{} ({})".format(self.config.app_title(default="Rattail"), self.dbkey)
 
        app_title = self.app.get_title()
 
        return f"{app_title} ({self.dbkey})"
 

	
 
    @property
 
    def local_title(self):
 
        return self.config.node_title(default="Rattail (local)")
 
        app_title = self.app.get_title()
 
        node_title = self.app.get_node_title()
 
        if node_title != app_title:
 
            return node_title
 
        return f"{app_title} (local)"
 

	
 
    def make_host_session(self):
 
        return self.app.make_session(bind=self.config.appdb_engines[self.dbkey])
 
@@ -211,11 +216,12 @@ class FromRattailToRattailExport(FromRattailToRattailBase, FromRattailHandler, T
 

	
 
    @property
 
    def host_title(self):
 
        return self.config.node_title()
 
        return self.app.get_node_title()
 

	
 
    @property
 
    def local_title(self):
 
        return "{} ({})".format(self.config.app_title(default="Rattail"), self.dbkey)
 
        app_title = self.app.get_title()
 
        return f"{app_title} ({self.dbkey})"
 

	
 
    def make_session(self):
 
        return self.app.make_session(bind=self.config.appdb_engines[self.dbkey])
rattail/importing/versions.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2023 Lance Edgar
 
#  Copyright © 2010-2024 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -44,8 +44,8 @@ class FromRattailToRattailVersions(FromRattailHandler, ToRattailHandler):
 

	
 
    @property
 
    def local_title(self):
 
        app_title = self.config.app_title(default="Rattail")
 
        return "{} (versioning)".format(app_title)
 
        app_title = self.app.get_title()
 
        return f"{app_title} (versioning)"
 

	
 
    def get_importers(self):
 
        importers = OrderedDict()
 
@@ -105,14 +105,14 @@ class FromRattailToRattailVersions(FromRattailHandler, ToRattailHandler):
 
        return importers
 

	
 
    def begin_local_transaction(self):
 
        super(FromRattailToRattailVersions, self).begin_local_transaction()
 
        super().begin_local_transaction()
 
        self.uow = versioning_manager.unit_of_work(self.session)
 
        self.transaction = self.uow.create_transaction(self.session)
 
        if self.comment:
 
            self.transaction.meta = {'comment': self.comment}
 

	
 
    def get_importer_kwargs(self, key, **kwargs):
 
        kwargs = super(FromRattailToRattailVersions, self).get_importer_kwargs(key, **kwargs)
 
        kwargs = super().get_importer_kwargs(key, **kwargs)
 
        kwargs['transaction'] = self.transaction
 
        return kwargs
 

	
 
@@ -127,7 +127,7 @@ class VersionImporter(FromRattail, ToRattail):
 

	
 
    @property
 
    def simple_fields(self):
 
        fields = super(VersionImporter, self).simple_fields
 
        fields = super().simple_fields
 
        fields.remove('operation_type')
 
        fields.remove('transaction_id')
 
        fields.remove('end_transaction_id')
 
@@ -139,7 +139,7 @@ class VersionImporter(FromRattail, ToRattail):
 
                           .filter(self.model_class.operation_type != continuum.Operation.DELETE)
 

	
 
    def normalize_local_object(self, obj):
 
        data = super(VersionImporter, self).normalize_local_object(obj)
 
        data = super().normalize_local_object(obj)
 
        # cache local (version) object, for updating end_transaction_id
 
        # (note that this is called for host side as well, hence check)
 
        if isinstance(obj, self.model_class):
rattail/mail.py
Show inline comments
 
@@ -312,7 +312,7 @@ class EmailHandler(object):
 
    def make_context(self, **context):
 
        context['rattail_config'] = self.config
 
        context['app'] = self.app
 
        context['app_title'] = self.config.app_title(default="Rattail")
 
        context['app_title'] = self.app.get_title()
 
        # TODO: deprecate / remove this
 
        context['localtime'] = localtime
 
        return context
 
@@ -535,9 +535,9 @@ class Email(object):
 
            if not prefix:
 

	
 
                # otherwise just use app node title
 
                prefix = self.config.node_title()
 
                prefix = self.app.get_node_title()
 
                if prefix:
 
                    prefix = "[{}]".format(prefix)
 
                    prefix = f"[{prefix}]"
 

	
 
        # fall back to hard-coded default if no prefix yet
 
        # TODO: not sure that's possible since we try node title above
rattail/poser/handler.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2023 Lance Edgar
 
#  Copyright © 2010-2024 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -328,7 +328,7 @@ class PoserHandler(GenericHandler):
 
                            for word in key.split('_')])
 

	
 
        context = {
 
            'app_title': self.config.app_title(),
 
            'app_title': self.app.get_title(),
 
            'key': key,
 
            'name': name,
 
            'cap_name': cap_name,
rattail/upgrades.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2023 Lance Edgar
 
#  Copyright © 2010-2024 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -61,7 +61,7 @@ class UpgradeHandler(GenericHandler):
 

	
 
        systems.insert(0, {
 
            'key': 'rattail',
 
            'label': self.config.app_title(),
 
            'label': self.app.get_title(),
 
            'command': self.config.get('rattail.upgrades', 'command'),
 
        })
 

	
0 comments (0 inline, 0 general)