예제 #1
0
파일: bootstrap.py 프로젝트: sabren/drupy
def drupal_get_schema(table=None, rebuild=False):
    """
   Get the schema definition of a table, or the whole database schema.
  
   The returned schema will include any modifications made by any
   module that implements hook_schema_alter().
  
   @param $table
     The name of the table. If not given, the schema of all tables is returned.
   @param $rebuild
     If true, the schema will be rebuilt instead of retrieved from the cache.
  """
    php.static(drupal_get_schema, "schema", [])
    if php.empty(drupal_get_schema.schema) or rebuild:
        # Try to load the schema from cache.
        cached = lib_cache.get("schema")
        if not rebuild and cached:
            drupal_get_schema.schema = cached.data
        # Otherwise, rebuild the schema cache.
        else:
            drupal_get_schema.schema = []
            # Load the .install files to get hook_schema.
            # On some databases this function may be called before bootstrap has
            # been completed, so we force the functions we need to load just in case.
            if drupal_function_exists("module_load_all_includes"):
                # There is currently a bug in module_list() where it caches what it
                # was last called with, which is not always what you want.
                # module_load_all_includes() calls module_list(), but if this function
                # is called very early in the bootstrap process then it will be
                # uninitialized and therefore return no modules.  Instead, we have to
                # "prime" module_list() here to to values we want, specifically
                # "yes rebuild the list and don't limit to bootstrap".
                # TODO: Remove this call after http://drupal.org/node/222109 is fixed.
                lib_plugin.list(True, False)
                lib_plugin.load_all_includes("install")
            # Invoke hook_schema for all modules.
            for module in module_implements("schema"):
                current = lib_plugin.invoke(module, "schema")
                if drupal_function_exists("_drupal_initialize_schema"):
                    _drupal_initialize_schema(module, current)
                schema = php.array_merge(schema, current)
            if drupal_function_exists("drupal_alter"):
                drupal_alter("schema", schema)
            if drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL:
                cache_set("schema", schema)
    if table is None:
        return schema
    elif php.isset(schema, table):
        return schema[table]
    else:
        return False
예제 #2
0
파일: bootstrap.py 프로젝트: vaibbhav/drupy
def drupal_get_schema(table=None, rebuild=False):
    """
   Get the schema definition of a table, or the whole database schema.
  
   The returned schema will include any modifications made by any
   module that implements hook_schema_alter().
  
   @param $table
     The name of the table. If not given, the schema of all tables is returned.
   @param $rebuild
     If true, the schema will be rebuilt instead of retrieved from the cache.
  """
    php.static(drupal_get_schema, 'schema', [])
    if (php.empty(drupal_get_schema.schema) or rebuild):
        # Try to load the schema from cache.
        cached = lib_cache.get('schema')
        if (not rebuild and cached):
            drupal_get_schema.schema = cached.data
        # Otherwise, rebuild the schema cache.
        else:
            drupal_get_schema.schema = []
            # Load the .install files to get hook_schema.
            # On some databases this function may be called before bootstrap has
            # been completed, so we force the functions we need to load just in case.
            if (drupal_function_exists('module_load_all_includes')):
                # There is currently a bug in module_list() where it caches what it
                # was last called with, which is not always what you want.
                # module_load_all_includes() calls module_list(), but if this function
                # is called very early in the bootstrap process then it will be
                # uninitialized and therefore return no modules.  Instead, we have to
                # "prime" module_list() here to to values we want, specifically
                # "yes rebuild the list and don't limit to bootstrap".
                # TODO: Remove this call after http://drupal.org/node/222109 is fixed.
                lib_plugin.list(True, False)
                lib_plugin.load_all_includes('install')
            # Invoke hook_schema for all modules.
            for module in module_implements('schema'):
                current = lib_plugin.invoke(module, 'schema')
                if (drupal_function_exists('_drupal_initialize_schema')):
                    _drupal_initialize_schema(module, current)
                schema = php.array_merge(schema, current)
            if (drupal_function_exists('drupal_alter')):
                drupal_alter('schema', schema)
            if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL):
                cache_set('schema', schema)
    if (table is None):
        return schema
    elif (php.isset(schema, table)):
        return schema[table]
    else:
        return False
예제 #3
0
def _drupal_maintenance_theme():
  # If theme is already set, assume the others are set too, and do nothing.
  if (lib_appglobals.theme is not None):
    return
  lib_unicode.check()
  # Install and update pages are 
  # treated differently to prevent theming overrides.
  if (php.defined('MAINTENANCE_MODE') and \
      (MAINTENANCE_MODE == 'install' or MAINTENANCE_MODE == 'update')):
    lib_appglobals.theme = 'minnelli'
  else:
    # Load plugin basics (needed for hook invokes).
    plugin_list_ = { 'system' : {}, 'filter' : {} }
    plugin_list_['system']['filename'] = 'plugins/system/system.py'
    plugin_list_['filter']['filename'] = 'plugins/filter/filter.py'
    lib_plugin.list(True, False, False, plugin_list_)
    drupal_load('plugin', 'system')
    drupal_load('plugin', 'filter')
    lib_appglobals.theme = variable_get('maintenance_theme', 'minnelli')
  themes = list_themes()
  # Store the identifier for retrieving theme settings with.
  lib_appglobals.theme_key = lib_appglobals.theme
  # Find all our ancestor themes and put them in an array.
  base_theme = []
  ancestor = lib_appglobals.theme
  while (ancestor and php.isset(themes[ancestor], base_theme)):
    new_base_theme = themes[themes[ancestor].base_theme]
    base_theme.append(new_base_theme)
    ancestor = themes[ancestor].base_theme
  _init_theme(themes[lib_appglobals.theme], php.array_reverse(base_theme), \
    '_theme_load_offline_registry')
  # These are usually added from system_init() -except maintenance.css.
  # When the database is inactive it's not called so we add it here.
  drupal_add_css(drupal_get_path('plugin', 'system') + \
    '/defaults.css', 'plugin')
  drupal_add_css(drupal_get_path('plugin', 'system') + \
    '/system.css', 'plugin')
  drupal_add_css(drupal_get_path('plugin', 'system') + \
    '/system-menus.css', 'plugin')
  drupal_add_css(drupal_get_path('plugin', 'system') + \
    '/maintenance.css', 'plugin')
예제 #4
0
def _drupal_maintenance_theme():
    # If theme is already set, assume the others are set too, and do nothing.
    if (lib_appglobals.theme is not None):
        return
    lib_unicode.check()
    # Install and update pages are
    # treated differently to prevent theming overrides.
    if (php.defined('MAINTENANCE_MODE') and \
        (MAINTENANCE_MODE == 'install' or MAINTENANCE_MODE == 'update')):
        lib_appglobals.theme = 'minnelli'
    else:
        # Load plugin basics (needed for hook invokes).
        plugin_list_ = {'system': {}, 'filter': {}}
        plugin_list_['system']['filename'] = 'plugins/system/system.py'
        plugin_list_['filter']['filename'] = 'plugins/filter/filter.py'
        lib_plugin.list(True, False, False, plugin_list_)
        drupal_load('plugin', 'system')
        drupal_load('plugin', 'filter')
        lib_appglobals.theme = variable_get('maintenance_theme', 'minnelli')
    themes = list_themes()
    # Store the identifier for retrieving theme settings with.
    lib_appglobals.theme_key = lib_appglobals.theme
    # Find all our ancestor themes and put them in an array.
    base_theme = []
    ancestor = lib_appglobals.theme
    while (ancestor and php.isset(themes[ancestor], base_theme)):
        new_base_theme = themes[themes[ancestor].base_theme]
        base_theme.append(new_base_theme)
        ancestor = themes[ancestor].base_theme
    _init_theme(themes[lib_appglobals.theme], php.array_reverse(base_theme), \
      '_theme_load_offline_registry')
    # These are usually added from system_init() -except maintenance.css.
    # When the database is inactive it's not called so we add it here.
    drupal_add_css(drupal_get_path('plugin', 'system') + \
      '/defaults.css', 'plugin')
    drupal_add_css(drupal_get_path('plugin', 'system') + \
      '/system.css', 'plugin')
    drupal_add_css(drupal_get_path('plugin', 'system') + \
      '/system-menus.css', 'plugin')
    drupal_add_css(drupal_get_path('plugin', 'system') + \
      '/maintenance.css', 'plugin')