Commit fa3ebedf authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Apply pylint rules on callback.py and my_validators.py.

parent b1d537f3
......@@ -7,23 +7,27 @@ from gluon import current
from plugin_dbui import CALLBACK_ERRORS, get_where_query
def INHIBIT_CASCADE_DELETE(set):
MSG_INHIBIT_DELETE = \
"Can't delete this record since several transactions refer to it."
def INHIBIT_CASCADE_DELETE(myset):
"""Inhibit the delete when at least one history row uses
the reference field.
@type set: gluon.dal.Set
@param set:
@type myset: gluon.dal.Set
@param myset:
@rtype: bool
@return:
"""
db, T = current.globalenv['db'], current.T
field = set.query.first
field = myset.query.first
# protection
# the query of the set should be "table.id == 45"
if field._db._adapter.EQ != set.query.op:
if field._db._adapter.EQ != myset.query.op:
return False
# protection
......@@ -40,11 +44,10 @@ def INHIBIT_CASCADE_DELETE(set):
# inhibit the delete if at least one history row use the reference field
query = get_where_query(db.history)
query = (query) & (set.query)
query = (query) & (myset.query)
if db(query).count():
field._table[CALLBACK_ERRORS] = \
T("Can't delete this record since several transactions refer to it.")
field._table[CALLBACK_ERRORS] = T(MSG_INHIBIT_DELETE)
return True
return False
......@@ -11,7 +11,6 @@ class IS_IN_USET(IS_IN_SET):
"""IS_IN_SET validator but working with unicode string.
"""
def __init__(self, theset, **kwargs):
myset = []
......@@ -32,7 +31,6 @@ class IS_IN_USET(IS_IN_SET):
IS_IN_SET.__init__(self, myset, **kwargs)
def __call__(self, value):
if isinstance(value, unicode):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment