本文整理汇总了Python中explorer.models.Query.passes_blacklist方法的典型用法代码示例。如果您正苦于以下问题:Python Query.passes_blacklist方法的具体用法?Python Query.passes_blacklist怎么用?Python Query.passes_blacklist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类explorer.models.Query
的用法示例。
在下文中一共展示了Query.passes_blacklist方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import passes_blacklist [as 别名]
def post(self, request):
sql = request.POST.get('sql')
show_results = request.POST.get('show', True)
query = Query(sql=sql, title="Playground")
passes_blacklist, failing_words = query.passes_blacklist()
error = MSG_FAILED_BLACKLIST % ', '.join(failing_words) if not passes_blacklist else None
run_query = not bool(error) if show_results else False
return self.render_with_sql(request, query, run_query=run_query, error=error)
示例2: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import passes_blacklist [as 别名]
def validate(self, value):
"""
Ensure that the SQL passes the blacklist.
: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 error:
raise ValidationError(
error,
code="InvalidSql"
)
示例3: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import passes_blacklist [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"
)
示例4: validate
# 需要导入模块: from explorer.models import Query [as 别名]
# 或者: from explorer.models.Query import passes_blacklist [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"
)