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


Python DrupyPHP.function_exists方法代码示例

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


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

示例1: drupal_page_cache_header

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def drupal_page_cache_header(cache):
    """
   Set HTTP headers in preparation for a cached page response.
  
   The general approach here is that anonymous users can keep a local
   cache of the page, but must revalidate it on every request.  Then,
   they are given a '304 Not Modified' response as long as they stay
   logged out and the page has not been modified.
  """
    # Set default values:
    last_modified = php.gmdate("D, d M Y H:i:s", cache.created) + " GMT"
    etag = '"' + drupy_md5(last_modified) + '"'
    # See if the client has provided the required HTTP headers:
    if_modified_since = (
        php.stripslashes(php.SERVER["HTTP_IF_MODIFIED_SINCE"])
        if php.isset(php.SERVER, "HTTP_IF_MODIFIED_SINCE")
        else False
    )
    if_none_match = (
        php.stripslashes(php.SERVER["HTTP_IF_NONE_MATCH"]) if php.isset(php.SERVER, "HTTP_IF_NONE_MATCH") else False
    )
    if (
        if_modified_since
        and if_none_match
        and if_none_match == etag  # etag must match
        and if_modified_since == last_modified
    ):  # if-modified-since must match
        php.header(php.SERVER["SERVER_PROTOCOL"] + " 304 Not Modified")
        # All 304 responses must send an etag if the 200 response for the same
        # object contained an etag
        php.header("Etag: %(etag)s" % {"etag": etag})
        exit()
    # Send appropriate response:
    php.header("Last-Modified: %(last_modified)s" % {"last_modified": last_modified})
    php.header("Etag: %(etag)s" % {"etag": etag})
    # The following headers force validation of cache:
    php.header("Expires: Sun, 19 Nov 1978 05:00:00 GMT")
    php.header("Cache-Control: must-revalidate")
    if variable_get("page_compression", True):
        # Determine if the browser accepts gzipped data.
        if php.strpos(php.SERVER["HTTP_ACCEPT_ENCODING"], "gzip") == False and php.function_exists("gzencode"):
            # Strip the gzip php.header and run uncompress.
            cache.data = php.gzinflate(php.substr(php.substr(cache.data, 10), 0, -8))
        elif php.function_exists("gzencode"):
            php.header("Content-Encoding: gzip")
    # Send the original request's headers. We send them one after
    # another so PHP's php.header() def can deal with duplicate
    # headers.
    headers = php.explode("\n", cache.headers)
    for php.header_ in headers:
        php.header(php.header_)
    print cache.data
开发者ID:sabren,项目名称:drupy,代码行数:54,代码来源:bootstrap.py

示例2: get_t

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def get_t():
    """
   Return the name of the localisation function. Use in code that needs to
   run both during installation and normal operation.
  """
    php.static(get_t, "t")
    if get_t.t == None:
        get_t.t = "st" if php.function_exists("install_main") else "t"
    return get_t.t
开发者ID:sabren,项目名称:drupy,代码行数:11,代码来源:bootstrap.py

示例3: drupal_get_title

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def drupal_get_title():
  """
   Get the title of the current page, for display on
   the page and in the title bar.
  
   @return
     The current page's title.
  """
  title = drupal_set_title();
  # during a bootstrap, menu.inc is not included
  # and thus we cannot provide a title
  if (title == None and php.function_exists('menu_get_active_title')):
    title = check_plain(menu_get_active_title());
  return title;
开发者ID:brendoncrawford,项目名称:drupy,代码行数:16,代码来源:path.py

示例4: hook

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def hook(plugin_, hook_):
  """
   Determine whether a plugin implements a hook.
  
   @param plugin
     The name of the plugin (without the .plugin extension).
   @param hook
     The name of the hook (e.g. "help" or "menu").
   @return
     True if the plugin is both installed and enabled, and the hook is
     implemented in that plugin.
  """
  global plugins
  function = hook_;
  if (lib_bootstrap.MAINTENANCE_MODE is True):
    return php.function_exists(function, plugins[plugin_])
  else:
    return lib_bootstrap.drupal_function_exists(function, plugins[plugin_]);
开发者ID:brendoncrawford,项目名称:drupy,代码行数:20,代码来源:plugin.py

示例5: drupal_function_exists

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def drupal_function_exists(function, scope=None):
    """
   Confirm that a function is available.
  
   If the function is already available, this function does nothing.
   If the function is not available, it tries to load the file where the
   function lives. If the file is not available, it returns False, so that it
   can be used as a drop-in replacement for php.function_exists().
   
   DRUPY(BC): This function needs to be heavily modified
  
   @param function
     The name of the function to check or load.
   @param scope
     Scope to check
   @return
     True if the function is now available, False otherwise.
  """
    # We arent using the registry, so lets just return a simple function_exists
    return php.function_exists(function, scope)
开发者ID:sabren,项目名称:drupy,代码行数:22,代码来源:bootstrap.py

示例6: drupal_get_normal_path

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import function_exists [as 别名]
def drupal_get_normal_path(path, path_language = ''):
  """
   Given a path alias, return the internal path it represents.
  
   @param path
     A Drupal path alias.
   @param path_language
     An optional language code to look up the path in.
  
   @return
     The internal path represented by the alias, or the original alias if no
     internal path was found.
  """
  result = path;
  src = drupal_lookup_path('source', path, path_language);
  if (src):
    result = src;
  if (php.function_exists('custom_url_rewrite_inbound')):
    # Modules may alter the inbound request path by reference.
    custom_url_rewrite_inbound(result, path, path_language);
  return result;
开发者ID:brendoncrawford,项目名称:drupy,代码行数:23,代码来源:path.py


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