Changeset - e8095430dbe9
[Not reviewed]
0 2 0
Lance Edgar (lance) - 7 years ago 2017-08-02 19:05:24
lance@edbob.org
Add `rattail.batch.consume_batch_id()` convenience function
2 files changed with 9 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/batch/__init__.py
Show inline comments
 
@@ -24,6 +24,7 @@
 
Batch System
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from .handlers import BatchHandler, get_batch_handler
 
from .util import consume_batch_id
rattail/batch/util.py
Show inline comments
 
@@ -26,12 +26,20 @@ Batch utilities
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
import inspect
 

	
 

	
 
def consume_batch_id(session):
 
    """
 
    Consumes and returns the next batch ID from PG sequence.
 
    """
 
    sql = "select nextval('batch_id_seq')"
 
    return session.execute(sql).scalar()
 

	
 

	
 
def get_batch_models(model):
 
    """
 
    Returns a list of batch models available in the given ``model`` module.
 
    """
 
    batches = []
 
    for name in sorted(dir(model)):
0 comments (0 inline, 0 general)