Closed CarolinaFernandez closed 11 years ago
When a user installs OCF from scratch (via OFVER) and the manage.py syncdb
is executed, the apps at INSTALLED_APPS
are not available anymore (because settings loading was moved to urls.py
file, see #158 ) and thus the tables won't be created.
To solve this, a quick fix was added into plugin.py
where the INSTALLED_APPS
setting for each plugin is added to the settings if not already present (which will be the case when the entry point is manage.py
instead of a normal HttpRequest).
File: expedient/src/python/expedient/clearinghouse/defaultsettings/plugin.py
# Set path for plugins (set at 'expedient/common/utils/plugins/pluginloader.py')
PLUGINS_PATH = os.path.join(settings.SRC_DIR,"python","plugins")
#sys.path.append(PLUGIN_LOADER.plugins_path)
sys.path.append(os.path.join(PLUGINS_PATH))
# Ugly hack to add "INSTALLED_APPS" to the settings
# even when OCF is loaded via manage.py (remember that
# setting will only load now when urls.py is loaded)
import ast
import ConfigParser
confparser = ConfigParser.RawConfigParser()
setting = "installed_apps"
for plugin_name in os.listdir(PLUGINS_PATH):
if os.path.isdir(os.path.join(PLUGINS_PATH, plugin_name)):
confparser.readfp(open(os.path.join(PLUGINS_PATH, plugin_name, "settings.conf")))
if confparser.has_section("general"):
conf_setting = list()
if hasattr(settings, setting.upper()):
conf_setting = getattr(settings, setting.upper()) or conf_setting
try:
plugin_setting = ast.literal_eval(confparser.get("general", "installed_apps"))
# Users may set one app only and not wrap this into a list. Wrap it here
if not isinstance(plugin_setting, list):
plugin_setting = [ '%s' % str(plugin_setting) ]
# If no setting for plugins has been set in INSTALLED_APPS, add these now
if [ p for p in plugin_setting if p not in conf_setting ]:
setattr(settings, setting.upper(), conf_setting + plugin_setting)
except:
pass
Models from plugins are not being synchronized when a user installs OCF from scratch (via OFVER). This has something to do with the
INSTALLED_APPS
setting loaded at Django startup.Error trace reported by Alessio del Chiaro (30/05/13 12:27):