From e732e42288513a46430e3ffd5c5caae61da8d60f 2012-08-30 12:11:15 From: Lance Edgar Date: 2012-08-30 12:11:15 Subject: [PATCH] move GPCType to sqlalchemy module --- diff --git a/rattail/db/extension/model.py b/rattail/db/extension/model.py index 7f43e2f0c28566aa15188819e19d384fc1b5020c..2026a2e04dfa0740d49062f00738689f1fb7f1ee 100644 --- a/rattail/db/extension/model.py +++ b/rattail/db/extension/model.py @@ -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', diff --git a/rattail/gpc.py b/rattail/gpc.py index f82625ce1e80450c3fe53b9dc824883bd224d39b..13e1d2654074c78cf86fce904a86f7e323ffd840 100644 --- a/rattail/gpc.py +++ b/rattail/gpc.py @@ -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) diff --git a/rattail/sil/sqlalchemy.py b/rattail/sil/sqlalchemy.py index ffe61f1b69180bd44602ea15b325ab18d07a6ae3..3171694ef1c1ffc621c4e3e73b9cc17c6fcdbc87 100644 --- a/rattail/sil/sqlalchemy.py +++ b/rattail/sil/sqlalchemy.py @@ -32,7 +32,7 @@ import re from sqlalchemy import types -from rattail.gpc import GPCType +from rattail.sqlalchemy import GPCType __all__ = ['get_sqlalchemy_type'] diff --git a/rattail/sqlalchemy.py b/rattail/sqlalchemy.py new file mode 100644 index 0000000000000000000000000000000000000000..11fb6f538ff6f392ac21676f4a0991f5b042279d --- /dev/null +++ b/rattail/sqlalchemy.py @@ -0,0 +1,51 @@ +#!/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 . +# +################################################################################ + +""" +``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)