Merge pull request #923 from gi0baro/validators
Fix serializers injection over new pydal
This commit is contained in:
@@ -14,7 +14,7 @@ from pydal import DAL as DAL
|
||||
from pydal import Field
|
||||
from pydal.objects import Row, Rows, Table, Query, Expression
|
||||
from pydal import SQLCustomType, geoPoint, geoLine, geoPolygon
|
||||
import copy_reg as copyreg
|
||||
|
||||
|
||||
def _default_validators(db, field):
|
||||
"""
|
||||
@@ -81,12 +81,12 @@ def _default_validators(db, field):
|
||||
requires[0] = validators.IS_EMPTY_OR(requires[0])
|
||||
return requires
|
||||
|
||||
from gluon import serializers as w2p_serializers
|
||||
from gluon.serializers import custom_json, xml
|
||||
from gluon.utils import web2py_uuid
|
||||
from gluon import sqlhtml
|
||||
|
||||
|
||||
DAL.serializers = w2p_serializers
|
||||
DAL.serializers = {'json': custom_json, 'xml': xml}
|
||||
DAL.validators_method = _default_validators
|
||||
DAL.uuid = lambda x: web2py_uuid()
|
||||
DAL.representers = {
|
||||
|
||||
@@ -15,10 +15,11 @@ from gluon.dal import DAL, Field
|
||||
|
||||
class TestDALSubclass(unittest.TestCase):
|
||||
def testRun(self):
|
||||
import gluon.serializers as mserializers
|
||||
from gluon.serializers import custom_json, xml
|
||||
from gluon import sqlhtml
|
||||
db = DAL(check_reserved=['all'])
|
||||
self.assertEqual(db.serializers, mserializers)
|
||||
self.assertEqual(db.serializers['json'], custom_json)
|
||||
self.assertEqual(db.serializers['xml'], xml)
|
||||
self.assertEqual(db.representers['rows_render'], sqlhtml.represent)
|
||||
self.assertEqual(db.representers['rows_xml'], sqlhtml.SQLTABLE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user