source: rattail/rattail/db/types.py @ 180c931

Last change on this file since 180c931 was 180c931, checked in by Lance Edgar <lance@…>, 3 years ago

Switch license to GPL v3 (no longer Affero)

refs #2

  • Property mode set to 100644
File size: 1.4 KB
Line 
1# -*- coding: utf-8 -*-
2################################################################################
3#
4#  Rattail -- Retail Software Framework
5#  Copyright © 2010-2017 Lance Edgar
6#
7#  This file is part of Rattail.
8#
9#  Rattail is free software: you can redistribute it and/or modify it under the
10#  terms of the GNU General Public License as published by the Free Software
11#  Foundation, either version 3 of the License, or (at your option) any later
12#  version.
13#
14#  Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
15#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17#  details.
18#
19#  You should have received a copy of the GNU General Public License along with
20#  Rattail.  If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24Data Types
25"""
26
27from __future__ import unicode_literals
28
29from sqlalchemy import types
30
31from rattail.gpc import GPC
32
33
34class GPCType(types.TypeDecorator):
35    """
36    SQLAlchemy type engine for GPC data.
37    """
38
39    impl = types.BigInteger
40
41    def process_bind_param(self, value, dialect):
42        if value is None:
43            return None
44        return int(value)
45
46    def process_result_value(self, value, dialect):
47        if value is None:
48            return None
49        return GPC(value)
Note: See TracBrowser for help on using the repository browser.