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
 
@@ -39,13 +39,13 @@ from edbob.db.model import Base, uuid_column
 
from edbob.db.extensions.contact import Person, EmailAddress, PhoneNumber
 
from edbob.exceptions import LoadSpecError
 
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',
 
           'VendorContact', 'VendorPhoneNumber', 'Product', 'ProductCost',
 
           'ProductPrice', 'Customer', 'CustomerEmailAddress',
 
           'CustomerPhoneNumber', 'CustomerGroup', 'CustomerGroupAssignment',
rattail/gpc.py
Show inline comments
 
@@ -23,14 +23,12 @@
 
################################################################################
 

	
 
"""
 
``rattail.gpc`` -- Global Product Code
 
"""
 

	
 
from sqlalchemy import types
 

	
 
from rattail import barcodes
 

	
 

	
 
class GPC(object):
 
    """
 
    Class to abstract the details of Global Product Code data.  Examples of
 
@@ -86,24 +84,6 @@ class GPC(object):
 

	
 
    def __str__(self):
 
        return str(unicode(self))
 

	
 
    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
 
@@ -29,13 +29,13 @@
 
from __future__ import absolute_import
 

	
 
import re
 

	
 
from sqlalchemy import types
 

	
 
from rattail.gpc import GPCType
 
from rattail.sqlalchemy import GPCType
 

	
 

	
 
__all__ = ['get_sqlalchemy_type']
 

	
 

	
 
sil_type_pattern = re.compile(r'^(CHAR|NUMBER)\((\d+(?:\,\d+)?)\)$')
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)