本文整理汇总了Python中lib.drupy.DrupyPHP.trigger_error方法的典型用法代码示例。如果您正苦于以下问题:Python DrupyPHP.trigger_error方法的具体用法?Python DrupyPHP.trigger_error怎么用?Python DrupyPHP.trigger_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.drupy.DrupyPHP
的用法示例。
在下文中一共展示了DrupyPHP.trigger_error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _query
# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import trigger_error [as 别名]
def _query(query_, debug = 0):
"""
Helper function for db_query().
"""
if (lib_bootstrap.variable_get('dev_query', 0)):
usec,sec = php.explode(' ', php.microtime())
timer = float(usec) + float(sec)
# If devel.plugin query logging is enabled, prepend a comment
# with the username and calling function
# to the SQL string. This is useful when running mysql's
# SHOW PROCESSLIST to learn what exact
# code is issueing the slow query.
bt = debug_backtrace()
# t() may not be available yet so we don't wrap 'Anonymous'
name = (lib_appglobals.user.name if (lib_appglobals.user.uid > 0) else \
variable_get('anonymous', 'Anonymous'))
# php.str_replace() to prevent SQL injection via username
# or anonymous name.
name = php.str_replace(['*', '/'], '', name)
query_ = '/* ' + name + ' : ' . bt[2]['function'] + ' */ ' + query_
result = DrupyMySQL.mysqli_query(lib_appglobals.active_db, query_)
if (lib_bootstrap.variable_get('dev_query', 0)):
query_ = bt[2]['function'] + "\n" + query_
usec,sec = php.explode(' ', php.microtime())
stop = float(usec) + float(sec)
diff = stop - timer
lib_appglobals.queries.append( [query_, diff] )
if (debug):
print '<p>query: ' + query_ + '<br />error:' + \
DrupyMySQL.mysqli_error(lib_appglobals.active_db) + '</p>'
if (not DrupyMySQL.mysqli_errno(lib_appglobals.active_db)):
return result
else:
# Indicate to drupal_error_handler that this is a database error.
DB_ERROR = True
php.trigger_error(lib_bootstrap.check_plain(\
DrupyMySQL.mysqli_error(lib_appglobals.active_db) + \
"\nquery: " + query_), php.E_USER_WARNING)
return False