From 96fdd9b3915ca82fd112eb0ab9639f2cf343faa5 2012-08-31 11:57:30 From: Lance Edgar Date: 2012-08-31 11:57:30 Subject: [PATCH] Backout changeset 14e7e8f7a2e5 (see note) Apparently PythonService.exe doesn't acknowledge the 'absolute_import' feature from __future__...? So we can't have a 'rattail.sqlalchemy' module and instead must keep 'GPCType' within 'rattail.gpc'. --- diff --git a/rattail/db/extension/model.py b/rattail/db/extension/model.py index 2026a2e04dfa0740d49062f00738689f1fb7f1ee..7f43e2f0c28566aa15188819e19d384fc1b5020c 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.sqlalchemy import GPCType +from rattail.gpc import GPCType __all__ = ['Department', 'Subdepartment', 'Brand', 'Category', 'Vendor', diff --git a/rattail/gpc.py b/rattail/gpc.py index 13e1d2654074c78cf86fce904a86f7e323ffd840..f82625ce1e80450c3fe53b9dc824883bd224d39b 100644 --- a/rattail/gpc.py +++ b/rattail/gpc.py @@ -26,6 +26,8 @@ ``rattail.gpc`` -- Global Product Code """ +from sqlalchemy import types + from rattail import barcodes @@ -87,3 +89,21 @@ 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 3171694ef1c1ffc621c4e3e73b9cc17c6fcdbc87..ffe61f1b69180bd44602ea15b325ab18d07a6ae3 100644 --- a/rattail/sil/sqlalchemy.py +++ b/rattail/sil/sqlalchemy.py @@ -32,7 +32,7 @@ import re from sqlalchemy import types -from rattail.sqlalchemy import GPCType +from rattail.gpc import GPCType __all__ = ['get_sqlalchemy_type'] diff --git a/rattail/sqlalchemy.py b/rattail/sqlalchemy.py deleted file mode 100644 index 11fb6f538ff6f392ac21676f4a0991f5b042279d..0000000000000000000000000000000000000000 --- a/rattail/sqlalchemy.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/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)