当前位置: 首页>>代码示例>>Python>>正文


Python Query.passes_blacklist方法代码示例

本文整理汇总了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)
开发者ID:grantmcconnaughey,项目名称:django-sql-explorer,代码行数:10,代码来源:views.py

示例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"
            )
开发者ID:groveco,项目名称:django-sql-explorer,代码行数:20,代码来源:forms.py

示例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"
            )
开发者ID:ersherr,项目名称:django-sql-explorer,代码行数:21,代码来源:forms.py

示例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"
            )
开发者ID:grantmcconnaughey,项目名称:django-sql-explorer,代码行数:26,代码来源:forms.py


注:本文中的explorer.models.Query.passes_blacklist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。