Package gluon :: Module dal :: Class SQLCustomType
[hide private]
[frames] | no frames]

Class SQLCustomType

source code

object --+
         |
        SQLCustomType


allows defining of custom SQL types

Example::

    decimal = SQLCustomType(
        type ='double',
        native ='integer',
        encoder =(lambda x: int(float(x) * 100)),
        decoder = (lambda x: Decimal("0.00") + Decimal(str(float(x)/100)) )
        )

    db.define_table(
        'example',
        Field('value', type=decimal)
        )

:param type: the web2py type (default = 'string')
:param native: the backend type
:param encoder: how to encode the value to store it in the backend
:param decoder: how to decode the value retrieved from the backend
:param validator: what validators to use ( default = None, will use the
    default validator for type)

Instance Methods [hide private]
 
__init__(self, type='string', native=None, encoder=None, decoder=None, validator=None, _class=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
startswith(self, text=None) source code
 
endswith(self, text=None) source code
 
__getslice__(self, a=0, b=100) source code
 
__getitem__(self, i) source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, type='string', native=None, encoder=None, decoder=None, validator=None, _class=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)