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


Python DrupyPHP.time_方法代码示例

本文整理汇总了Python中lib.drupy.DrupyPHP.time_方法的典型用法代码示例。如果您正苦于以下问题:Python DrupyPHP.time_方法的具体用法?Python DrupyPHP.time_怎么用?Python DrupyPHP.time_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.drupy.DrupyPHP的用法示例。


在下文中一共展示了DrupyPHP.time_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import time_ [as 别名]
def write(key, value):
  # If saving of session data is disabled or if the client
  # doesn't have a session,
  # and one isn't being created ($value), do nothing.
  # This keeps crawlers out of
  # the session table. This reduces memory and server load,
  # and gives more useful
  # statistics. We can't eliminate anonymous session table rows
  # without breaking
  # the "Who's Online" block.
  if (not session_save_session() or \
      (php.empty(php.COOKIE[php.session_name()]) and php.empty(value))):
    return True
  result = db_result(db_query("SELECT COUNT(*) FROM {sessions} " + \
    "WHERE sid = '%s'", key))
  lib_database.query(\
    "UPDATE {sessions} SET " + \
    "uid = %d, cache = %d, hostname = '%s', " + \
    "session = '%s', timestamp = %d WHERE sid = '%s'", \
    lib_appglobals.user.uid, (lib_appglobals.user.cache if \
    php.isset(lib_appglobals.user.cache) else ''), \
    ip_address(), value, php.time_(), key)
  if (lib_database.affected_rows()):
    # Last access time is updated no more frequently than once
    # every 180 seconds.
    # This reduces contention in the users table.
    if (lib_appglobals.user.uid and \
        drupy_time() - lib_appglobals.user.access > \
        variable_get('session_write_interval', 180)):
      db_query("UPDATE {users} SET access = %d WHERE uid = %d", \
        php.time_(), lib_appglobals.user.uid)
  else:
    # If this query fails, another parallel request probably got here first.
    # In that case, any session data generated in this request is discarded.
    lib_databae.query(\
      "INSERT INTO {sessions} " + \
      "(sid, uid, cache, hostname, session, timestamp) " + \
      "VALUES ('%s', %d, %d, '%s', '%s', %d)", \
      key, lib_appglobals.user.uid, (lib_appglobals.user.cache if \
        php.isset(lib_appglobals.user.cache) else ''), \
        ip_address(), value, php.time_())
  return True
开发者ID:brendoncrawford,项目名称:drupy,代码行数:44,代码来源:session.py

示例2: timer_start

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import time_ [as 别名]
# and browser language detection if no defined path prefix
# identified.
#
LANGUAGE_NEGOTIATION_PATH = 2

#
# Domain based negotiation with fallback to default language
# if no language identified by domain.
#
LANGUAGE_NEGOTIATION_DOMAIN = 3

#
# For convenience, define a short form of the request time global.
#
# REQUEST_TIME = php.SERVER['REQUEST_TIME'];
REQUEST_TIME = php.time_()


def timer_start(name):
    """
   Start the timer with the specified name. If you start and stop
   the same timer multiple times, the measured intervals will be
   accumulated.
  
   @param name
     The name of the timer.
  """
    if lib_appglobals.timers == None:
        lib_appglobals.timers = {}
    if not php.isset(lib_appglobals.timers, name):
        lib_appglobals.timers[name] = {}
开发者ID:sabren,项目名称:drupy,代码行数:33,代码来源:bootstrap.py


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