Changeset - 10bdbc56ce0c
[Not reviewed]
0 4 0
Lance Edgar (lance) - 12 years ago 2012-11-26 13:17:32
lance@edbob.org
move GPCType to db module
4 files changed with 21 insertions and 22 deletions:
0 comments (0 inline, 0 general)
rattail/db/__init__.py
Show inline comments
 
@@ -29,6 +29,7 @@
 
import logging
 
import warnings
 

	
 
from sqlalchemy import types
 
from sqlalchemy.event import listen
 
from sqlalchemy.orm import object_mapper, RelationshipProperty
 

	
 
@@ -42,6 +43,24 @@ ignore_role_changes = None
 
log = logging.getLogger(__name__)
 

	
 

	
 
class GPCType(types.TypeDecorator):
 
    """
 
    SQLAlchemy type engine for GPC data.
 
    """
 

	
 
    impl = types.BigInteger
 

	
 
    def process_bind_param(self, value, dialect):
 
        if value is None:
 
            return None
 
        return int(value)
 

	
 
    def process_result_value(self, value, dialect):
 
        if value is None:
 
            return None
 
        return GPC(value)
 

	
 

	
 
def before_flush(session, flush_context, instances):
 
    """
 
    Listens for session flush events.  This function is responsible for adding
rattail/db/extension/model.py
Show inline comments
 
@@ -44,7 +44,7 @@ from edbob.sqlalchemy import getset_factory
 

	
 
from rattail import sil
 
from rattail import batches
 
from rattail.gpc import GPCType
 
from rattail.db import GPCType
 

	
 

	
 
__all__ = ['Change', 'Store', 'StoreEmailAddress', 'StorePhoneNumber',
rattail/gpc.py
Show inline comments
 
@@ -26,8 +26,6 @@
 
``rattail.gpc`` -- Global Product Code
 
"""
 

	
 
from sqlalchemy import types
 

	
 
from rattail import barcodes
 

	
 

	
 
@@ -101,21 +99,3 @@ class GPC(object):
 

	
 
    def __unicode__(self):
 
        return u'%014d' % self.value
 

	
 

	
 
class GPCType(types.TypeDecorator):
 
    """
 
    SQLAlchemy type engine for GPC data.
 
    """
 

	
 
    impl = types.BigInteger
 

	
 
    def process_bind_param(self, value, dialect):
 
        if value is None:
 
            return None
 
        return int(value)
 

	
 
    def process_result_value(self, value, dialect):
 
        if value is None:
 
            return None
 
        return GPC(value)
rattail/sil/sqlalchemy.py
Show inline comments
 
@@ -32,7 +32,7 @@ import re
 

	
 
from sqlalchemy import types
 

	
 
from rattail.gpc import GPCType
 
from rattail.db import GPCType
 

	
 

	
 
__all__ = ['get_sqlalchemy_type']
0 comments (0 inline, 0 general)