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


Python DrupyPHP.serialize方法代码示例

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


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

示例1: rebuild_cache

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import serialize [as 别名]
def rebuild_cache():
  """
   Rebuild the database cache of plugin files.
  
   @return
     The array of filesystem objects used to rebuild the cache.
  """
  # Get current list of plugins
  files = drupal_system_listing('\.plugin$', 'plugins', 'name', 0)
  # Extract current files from database.
  system_get_files_database(files, 'plugin')
  ksort(files)
  # Set defaults for plugin info
  defaults = {
    'dependencies' : [],
    'dependents' : [],
    'description' : '',
    'version' : None,
    'php' : DRUPAL_MINIMUM_PHP,
  }
  for filename,file in files.items():
    # Look for the info file.
    file.info = drupal_parse_info_file(php.dirname(file.filename) +  '/'  + \
      file.name + '.info')
    # Skip plugins that don't provide info.
    if (php.empty(file.info)):
      del(files[filename])
      continue
    # Merge in defaults and save.
    files[filename].info = file.info + defaults
    # Invoke hook_system_info_alter() to give installed plugins a chance to
    # modify the data in the .info files if necessary.
    drupal_alter('system_info', files[filename].info, files[filename])
    # Log the critical hooks implemented by this plugin.
    bootstrap = 0
    for hook in bootstrap_hooks():
      if (plugin_hook(file.name, hook)):
        bootstrap = 1
        break
    # Update the contents of the system table:
    if (php.isset(file, 'status') or (php.isset(file, 'old_filename') and \
        file.old_filename != file.filename)):
      db_query(\
        "UPDATE {system} SET info = '%s', name = '%s', " + \
        "filename = '%s', bootstrap = %d WHERE filename = '%s'", \
        php.serialize(files[filename].info), file.name, \
        file.filename, bootstrap, file.old_filename)
    else:
      # This is a new plugin.
      files[filename].status = 0
      db_query(\
        "INSERT INTO {system} (name, info, type, " + \
        "filename, status, bootstrap) VALUES " + \
        "('%s', '%s', '%s', '%s', %d, %d)", \
        file.name, php.serialize(files[filename].info), \
        'plugin', file.filename, 0, bootstrap)
  files = _plugin_build_dependencies(files)
  return files
开发者ID:brendoncrawford,项目名称:drupy,代码行数:60,代码来源:plugin.py

示例2: variable_set

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import serialize [as 别名]
def variable_set(name, value):
    """
   Set a persistent variable.
  
   @param name
     The name of the variable to set.
   @param value
     The value to set. This can be any PHP data type; these functions take care
     of serialization as necessary.
  """
    lib_database.merge("variable").key({"name": name}).fields({"value": php.serialize(value)}).execute()
    cache_clear_all("variables", "cache")
    settings.conf[name] = value
开发者ID:sabren,项目名称:drupy,代码行数:15,代码来源:bootstrap.py

示例3: set

# 需要导入模块: from lib.drupy import DrupyPHP [as 别名]
# 或者: from lib.drupy.DrupyPHP import serialize [as 别名]
def set(cid, data, table = 'cache', expire = None, headers = None):
  """
   Store data in the persistent cache.
  
   The persistent cache is split up into four database
   tables. Contributed plugins can add additional tables.
  
   'cache_page': This table stores generated pages for anonymous
   users. This is the only table affected by the page cache setting on
   the administrator panel.
  
   'cache_menu': Stores the cachable part of the users' menus.
  
   'cache_filter': Stores filtered pieces of content. This table is
   periodically cleared of stale entries by cron.
  
   'cache': Generic cache storage table.
  
   The reasons for having several tables are as follows:
  
   - smaller tables allow for faster selects and inserts
   - we try to put fast changing cache items and rather static
     ones into different tables. The effect is that only the fast
     changing tables will need a lot of writes to disk. The more
     static tables will also be better cachable with MySQL's query cache
  
   @param cid
     The cache ID of the data to store.
   @param data
     The data to store in the cache. Complex data types will be
     automatically serialized before insertion.
     Strings will be stored as plain text and not serialized.
   @param table
     The table table to store the data in. Valid core values are 'cache_filter',
     'cache_menu', 'cache_page', or 'cache'.
   @param expire
     One of the following values:
     - CACHE_PERMANENT: Indicates that the item should never be removed unless
       explicitly told to using cache_clear_all() with a cache ID.
     - CACHE_TEMPORARY: Indicates that the item should be removed at the next
       general cache wipe.
     - A Unix timestamp: Indicates that the item should be kept at least until
       the given time, after which it behaves like CACHE_TEMPORARY.
   @param headers
     A string containing HTTP php.header information for cached pages.
  """
  if expire is None:
    expire = lib_bootstrap.CACHE_PERMANENT
    fields = {
      'serialized' : 0,
      'created' : REQUEST_TIME,
      'expire' : expire,
      'headers' : headers
    }
  if (not php.is_string(data)):
    fields['data'] = php.serialize(data)
    fields['serialized'] = 1
  else:
    fields['data'] = data
    fields['serialized'] = 0
  lib_database.merge(table).key({'cid' : cid}).fields(fields).execute()
开发者ID:brendoncrawford,项目名称:drupy,代码行数:63,代码来源:cache.py


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