allow serialization of dal.py/DAL
This commit is contained in:
+11
-2
@@ -14,7 +14,7 @@ from pydal import DAL as pyDAL
|
|||||||
from pydal import Field
|
from pydal import Field
|
||||||
from pydal.objects import Row, Rows, Table, Query, Expression
|
from pydal.objects import Row, Rows, Table, Query, Expression
|
||||||
from pydal import SQLCustomType, geoPoint, geoLine, geoPolygon
|
from pydal import SQLCustomType, geoPoint, geoLine, geoPolygon
|
||||||
|
import copy_reg as copyreg
|
||||||
|
|
||||||
def _default_validators(db, field):
|
def _default_validators(db, field):
|
||||||
"""
|
"""
|
||||||
@@ -86,7 +86,7 @@ from gluon.utils import web2py_uuid
|
|||||||
from gluon import sqlhtml
|
from gluon import sqlhtml
|
||||||
|
|
||||||
|
|
||||||
class DAL(pyDAL):
|
class DAL(pyDAL):
|
||||||
serializers = w2p_serializers
|
serializers = w2p_serializers
|
||||||
validators_method = _default_validators
|
validators_method = _default_validators
|
||||||
uuid = lambda x: web2py_uuid()
|
uuid = lambda x: web2py_uuid()
|
||||||
@@ -97,6 +97,15 @@ class DAL(pyDAL):
|
|||||||
Field = Field
|
Field = Field
|
||||||
Table = Table
|
Table = Table
|
||||||
|
|
||||||
|
def DAL_unpickler(db_uid):
|
||||||
|
return DAL('<zombie>', db_uid=db_uid)
|
||||||
|
|
||||||
|
|
||||||
|
def DAL_pickler(db):
|
||||||
|
return DAL_unpickler, (db._db_uid,)
|
||||||
|
|
||||||
|
copyreg.pickle(DAL, DAL_pickler, DAL_unpickler)
|
||||||
|
|
||||||
#: add web2py contrib drivers to pyDAL
|
#: add web2py contrib drivers to pyDAL
|
||||||
from pydal.drivers import DRIVERS
|
from pydal.drivers import DRIVERS
|
||||||
if not DRIVERS.get('pymysql'):
|
if not DRIVERS.get('pymysql'):
|
||||||
|
|||||||
+1
-1
Submodule gluon/packages/dal updated: 2554dac7a4...f816d26b6a
Reference in New Issue
Block a user