Changeset - 95d2b2dab72d
[Not reviewed]
0 1 0
Lance Edgar (lance) - 3 years ago 2022-02-09 18:01:27
lance@edbob.org
Add generic `get_next_counter_value()` method for importers

useful when autoincrement value is needed, e.g. for pseudo-key
1 file changed with 9 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/importing/importers.py
Show inline comments
 
@@ -528,6 +528,15 @@ class Importer(object):
 
        """
 
        return obj
 

	
 
    def get_next_counter_value(self, name, **kwargs):
 
        attr = '_next_counter_{}'.format(name)
 
        if hasattr(self, attr):
 
            next_value = getattr(self, attr)
 
        else:
 
            next_value = 1
 
        setattr(self, attr, next_value + 1)
 
        return next_value
 

	
 
    def get_local_objects(self, host_data=None):
 
        """
 
        Fetch all raw objects from the local system.
0 comments (0 inline, 0 general)