Changeset - 8ff082611a3c
[Not reviewed]
0 1 0
Lance Edgar (lance) - 12 years ago 2012-08-10 13:47:33
lance@edbob.org
comment out some batch code (for now?)
1 file changed with 51 insertions and 51 deletions:
0 comments (0 inline, 0 general)
rattail/db/__init__.py
Show inline comments
 
@@ -27,7 +27,7 @@
 
"""
 

	
 
import edbob
 
from edbob.db.extensions import activate_extension
 
# from edbob.db.extensions import activate_extension
 

	
 
import rattail
 

	
 
@@ -44,58 +44,58 @@ def init(config):
 
    edbob.graft(rattail, enum)
 

	
 

	
 
def init_database(engine, session):
 
    """
 
    Initialize an ``edbob`` database for use with Rattail.
 
    """
 
# def init_database(engine, session):
 
#     """
 
#     Initialize an ``edbob`` database for use with Rattail.
 
#     """
 

	
 
    activate_extension('rattail', engine)
 
#     activate_extension('rattail', engine)
 

	
 
    columns = [
 
        ('F01',         'UPC',                  'GPC(14)'),
 
        ('F02',         'Description',          'CHAR(20)'),
 
        ('F03',         'Department Number',    'NUMBER(4,0)'),
 
        ('F22',         'Size',                 'CHAR(30)'),
 
        ('F155',        'Brand',                'CHAR(30)'),
 
        ('F238',        'Department Name',      'CHAR(30)'),
 
        ]
 
#     columns = [
 
#         ('F01',         'UPC',                  'GPC(14)'),
 
#         ('F02',         'Description',          'CHAR(20)'),
 
#         ('F03',         'Department Number',    'NUMBER(4,0)'),
 
#         ('F22',         'Size',                 'CHAR(30)'),
 
#         ('F155',        'Brand',                'CHAR(30)'),
 
#         ('F238',        'Department Name',      'CHAR(30)'),
 
#         ]
 

	
 
    for name, disp, dtype in columns:
 
        session.add(rattail.SilColumn(
 
                sil_name=name, display=disp, data_type=dtype))
 
        session.flush()
 
#     for name, disp, dtype in columns:
 
#         session.add(rattail.SilColumn(
 
#                 sil_name=name, display=disp, data_type=dtype))
 
#         session.flush()
 

	
 
    dictionaries = [
 
        ('DEPT_DCT', 'Department', [
 
                ('F03', True),
 
                'F238',
 
                ]),
 
        ('ITEM_DCT', 'Product', [
 
                ('F01', True),
 
                'F02',
 
                'F03',
 
                'F22',
 
                'F155',
 
                ]),
 
        # ('PRICE_DCT', 'Price', []),
 
        # ('FCOST_DCT', 'Future Cost', []),
 
        # ('FSPRICE_DCT', 'Future Sale Price', []),
 
        # ('CLASS_GROUP', 'Scale Class / Group', []),
 
        # ('NUTRITION', 'Scale Nutrition', []),
 
        # ('SCALE_TEXT', 'Scale Text', []),
 
        # ('VENDOR_DCT', 'Vendor', []),
 
        ]
 
#     dictionaries = [
 
#         ('DEPT_DCT', 'Department', [
 
#                 ('F03', True),
 
#                 'F238',
 
#                 ]),
 
#         ('ITEM_DCT', 'Product', [
 
#                 ('F01', True),
 
#                 'F02',
 
#                 'F03',
 
#                 'F22',
 
#                 'F155',
 
#                 ]),
 
#         # ('PRICE_DCT', 'Price', []),
 
#         # ('FCOST_DCT', 'Future Cost', []),
 
#         # ('FSPRICE_DCT', 'Future Sale Price', []),
 
#         # ('CLASS_GROUP', 'Scale Class / Group', []),
 
#         # ('NUTRITION', 'Scale Nutrition', []),
 
#         # ('SCALE_TEXT', 'Scale Text', []),
 
#         # ('VENDOR_DCT', 'Vendor', []),
 
#         ]
 

	
 
    for name, desc, cols in dictionaries:
 
        bd = rattail.BatchDictionary(name=name, description=desc)
 
        for col in cols:
 
            key = False
 
            if not isinstance(col, basestring):
 
                col, key = col
 
            q = session.query(rattail.SilColumn)
 
            q = q.filter(rattail.SilColumn.sil_name == col)
 
            col = q.one()
 
            bd.columns.append(
 
                rattail.BatchDictionaryColumn(sil_column=col, key=key))
 
        session.add(bd)
 
        session.flush()
 
#     for name, desc, cols in dictionaries:
 
#         bd = rattail.BatchDictionary(name=name, description=desc)
 
#         for col in cols:
 
#             key = False
 
#             if not isinstance(col, basestring):
 
#                 col, key = col
 
#             q = session.query(rattail.SilColumn)
 
#             q = q.filter(rattail.SilColumn.sil_name == col)
 
#             col = q.one()
 
#             bd.columns.append(
 
#                 rattail.BatchDictionaryColumn(sil_column=col, key=key))
 
#         session.add(bd)
 
#         session.flush()
0 comments (0 inline, 0 general)