SQLCustomType is not documented because I am not promising backward
compatibility for it in the new DAL (The functionality will be there
but the API may change). Anyway here is a docstring example for a
possible definition of type "decimal" (mind that web2py has a type
decimal so you do not need customtype for this):

        decimal = SQLCustomType
(
            type ='double',  # as web2py sees it
            native ='integer',    # as db sees it
            encoder =(lambda x: int(float(x) * 100)), # as conversion
is done
            decoder = (lambda x: Decimal("0.00") + Decimal(str(float
(x)/100)) )
            )

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



On Dec 23, 10:16 am, Johann Spies <[email protected]> wrote:
> OK. Apologies.  I forgot I can specify the length.
>
> Do you have documentation on SQLCustomType somewhere.  I did quick
> search in your book and could not find any reference to it.
>
> Regards.
> Johann

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to