本文整理汇总了Python中explorer.models.Query.available_params方法的典型用法代码示例。如果您正苦于以下问题:Python Query.available_params方法的具体用法?Python Query.available_params怎么用?Python Query.available_params使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类explorer.models.Query
的用法示例。
在下文中一共展示了Query.available_params方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import available_params [as 别名]
def validate(self, value):
query = Query(sql=value)
if not query.available_params():
error = query.error_messages()
if error:
raise ValidationError(
_(error),
params={'value': value},
code="InvalidSql"
)
示例2: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import available_params [as 别名]
def validate(self, value):
"""
Ensure that the SQL passes the blacklist and executes. Execution check is skipped if params are present.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
error = MSG_FAILED_BLACKLIST if not query.passes_blacklist() else None
if not error and not query.available_params():
error = query.try_execute()
if error:
raise ValidationError(
_(error),
code="InvalidSql"
)
示例3: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import available_params [as 别名]
def validate(self, value):
"""
Ensure that the SQL passes the blacklist and executes. Execution check is skipped if params are present.
:param value: The SQL for this Query model.
"""
query = Query(sql=value)
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words) if not passes_blacklist else None
if not error and not query.available_params():
try:
query.execute_query_only()
except DatabaseError as e:
error = str(e)
if error:
raise ValidationError(
_(error),
code="InvalidSql"
)