We use UUIDs for database sync.
If we just include as a default=uuid.uuid4() then this doesn't work
when creating multiple records in the same transaction (as they all
have identical UUIDs)

We therefore created our own custom function as follows:

# Reusable UUID field (needed as part of database synchronization)
import uuid
from gluon.sql import SQLCustomType
s3uuid = SQLCustomType(
                type ='string',
                native ='string',
                encoder = (lambda x: "'%s'" % (uuid.uuid4() if x==""
else x)),
                decoder = (lambda x: x)
            )

uuidstamp = db.Table(None, 'uuidstamp',
                     Field('uuid',
                          type=s3uuid,
                          length=64,
                          notnull=True,
                          unique=True,
                          readable=False,
                          writable=False,
                          default=""))

This was working fine up through 1.71.1.
Something since has broken it (I have reverted but good to get this
fixed before the next stable release)

Many thanks,
Fran.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to