Enhance dal.py PEP8
This commit is contained in:
+8
-8
@@ -14,6 +14,11 @@ from pydal import DAL as DAL
|
|||||||
from pydal import Field
|
from pydal import Field
|
||||||
from pydal.objects import Row, Rows, Table, Query, Set, Expression
|
from pydal.objects import Row, Rows, Table, Query, Set, Expression
|
||||||
from pydal import SQLCustomType, geoPoint, geoLine, geoPolygon
|
from pydal import SQLCustomType, geoPoint, geoLine, geoPolygon
|
||||||
|
from gluon.serializers import custom_json, xml
|
||||||
|
from gluon.utils import web2py_uuid
|
||||||
|
from gluon import sqlhtml
|
||||||
|
from pydal.drivers import DRIVERS
|
||||||
|
|
||||||
|
|
||||||
def _default_validators(db, field):
|
def _default_validators(db, field):
|
||||||
"""
|
"""
|
||||||
@@ -78,14 +83,10 @@ def _default_validators(db, field):
|
|||||||
if (field.notnull or field.unique) and field_type not in excluded_fields:
|
if (field.notnull or field.unique) and field_type not in excluded_fields:
|
||||||
requires.insert(0, validators.IS_NOT_EMPTY())
|
requires.insert(0, validators.IS_NOT_EMPTY())
|
||||||
elif not field.notnull and not field.unique and requires:
|
elif not field.notnull and not field.unique and requires:
|
||||||
requires[0] = validators.IS_EMPTY_OR(requires[0], null='' if field.type in ('string', 'text', 'password') else None)
|
requires[0] = \
|
||||||
|
validators.IS_EMPTY_OR(requires[0], null='' if field.type in ('string', 'text', 'password') else None)
|
||||||
return requires
|
return requires
|
||||||
|
|
||||||
from gluon.serializers import custom_json, xml
|
|
||||||
from gluon.utils import web2py_uuid
|
|
||||||
from gluon import sqlhtml
|
|
||||||
|
|
||||||
|
|
||||||
DAL.serializers = {'json': custom_json, 'xml': xml}
|
DAL.serializers = {'json': custom_json, 'xml': xml}
|
||||||
DAL.validators_method = _default_validators
|
DAL.validators_method = _default_validators
|
||||||
DAL.uuid = lambda x: web2py_uuid()
|
DAL.uuid = lambda x: web2py_uuid()
|
||||||
@@ -96,8 +97,7 @@ DAL.representers = {
|
|||||||
DAL.Field = Field
|
DAL.Field = Field
|
||||||
DAL.Table = Table
|
DAL.Table = Table
|
||||||
|
|
||||||
#: add web2py contrib drivers to pyDAL
|
# add web2py contrib drivers to pyDAL
|
||||||
from pydal.drivers import DRIVERS
|
|
||||||
if not DRIVERS.get('pymysql'):
|
if not DRIVERS.get('pymysql'):
|
||||||
try:
|
try:
|
||||||
from .contrib import pymysql
|
from .contrib import pymysql
|
||||||
|
|||||||
Reference in New Issue
Block a user