Changeset - 40da47603709
[Not reviewed]
0 2 0
Lance Edgar - 9 years ago 2015-08-17 12:43:26
ledgar@sacfoodcoop.com
Add `config` arg to `labels.LabelFormatter` constructor.
2 files changed with 7 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rattail/db/model/labels.py
Show inline comments
 
@@ -57,14 +57,14 @@ class LabelProfile(Base):
 

	
 
    # TODO: Copy elsewhere, deprecate and remove this logic (not strictly an
 
    # API call from within data model, but should go with the others, below).
 
    def get_formatter(self):
 
    def get_formatter(self, config):
 
        if not self._formatter and self.formatter_spec:
 
            try:
 
                formatter = load_object(self.formatter_spec)
 
            except AttributeError:
 
                pass
 
            else:
 
                self._formatter = formatter()
 
                self._formatter = formatter(config)
 
                self._formatter.format = self.format
 
        return self._formatter        
 

	
 
@@ -80,7 +80,7 @@ class LabelProfile(Base):
 
                self._printer = printer(config)
 
                for name in printer.required_settings:
 
                    setattr(printer, name, self.get_printer_setting(name))
 
                self._printer.formatter = self.get_formatter()
 
                self._printer.formatter = self.get_formatter(config)
 
        return self._printer
 

	
 
    # TODO: Copy elsewhere, deprecate and remove this logic (API call from
rattail/labels.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2014 Lance Edgar
 
#  Copyright © 2010-2015 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -211,9 +211,11 @@ class LabelFormatter(Object):
 
    """
 
    Base class for all label formatters.
 
    """
 

	
 
    format = None
 

	
 
    def __init__(self, config):
 
        self.config = config
 

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