Changeset - e732e4228851
[Not reviewed]
0 3 1
Lance Edgar (lance) - 12 years ago 2012-08-30 12:11:15
lance@edbob.org
move GPCType to sqlalchemy module
4 files changed with 53 insertions and 22 deletions:
0 comments (0 inline, 0 general)
rattail/db/extension/model.py
Show inline comments
 
@@ -42,7 +42,7 @@ from edbob.sqlalchemy import getset_factory
 

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

	
 

	
 
__all__ = ['Department', 'Subdepartment', 'Brand', 'Category', 'Vendor',
rattail/gpc.py
Show inline comments
 
@@ -26,8 +26,6 @@
 
``rattail.gpc`` -- Global Product Code
 
"""
 

	
 
from sqlalchemy import types
 

	
 
from rattail import barcodes
 

	
 

	
 
@@ -89,21 +87,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.sqlalchemy import GPCType
 

	
 

	
 
__all__ = ['get_sqlalchemy_type']
rattail/sqlalchemy.py
Show inline comments
 
new file 100644
 
#!/usr/bin/env python
 
# -*- coding: utf-8  -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2012 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
#  Rattail is free software: you can redistribute it and/or modify it under the
 
#  terms of the GNU Affero General Public License as published by the Free
 
#  Software Foundation, either version 3 of the License, or (at your option)
 
#  any later version.
 
#
 
#  Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
 
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
#  FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for
 
#  more details.
 
#
 
#  You should have received a copy of the GNU Affero General Public License
 
#  along with Rattail.  If not, see <http://www.gnu.org/licenses/>.
 
#
 
################################################################################
 

	
 
"""
 
``rattail.sqlalchemy`` -- SQLAlchemy Stuff
 
"""
 

	
 
from __future__ import absolute_import
 

	
 
from sqlalchemy import types
 

	
 
import rattail
 

	
 

	
 
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 rattail.GPC(value)
0 comments (0 inline, 0 general)