Description
If configuration file is not found, you get an empty wiki - header, title and footer - for every page. This is very common bug in new installations or upgrades.
Steps to reproduce
- Change the name of your wikiconfig.py, or use wrong name in farmconfig.py wikis list.
- You get this for every page:
Example
Details
MoinMoin Version |
1.3.x |
Workaround
Fix your configuration:
- Check the directories you set in your config.
- In the files moin.*, wikiconfig.py, farmconfig.py
- At least, in you WIKIINSTANCE/cgi-bin/moin.[cgi|fcg], be sure to add near the top a reference to the path which contains your config:
{{{import sys sys.path.insert(0, '..') }}}
- Set absolute paths.
- Check permissions of the directories.
- And look into the server logs, look for a warning telling you that the config was not found. If it was not, try to put it into your python path or modify the python path by modifying your server file (see comments in that file).
- when using farmwiki, check whether the "wikis" REs and config names are correct
Discussion
The problem is caused by the design of multiconfig, and it is very old. If a config file is not found, the default configuration is used. This was done to allow software tools to use non installed wiki. The problem is that this does not work for installed wikis, and the error is very confusing.
The warnings in the logs are hard to find, and there is no reason to check the log when the wiki "runs". Broken configuration should not let the wiki run.
This is the problem code in multiconfig:
1 def getConfig(url):
2 """ Make and return config object
3
4 If the config file is not found or broken, either because of a typo
5 in farmconfig or deleted file or some other error, we return a
6 default config, and a warning.
7
8 The default config works with a default installed wiki. If the wiki
9 is installed using different url_prefix and other settings, it might
10 not work, because other code does not do proper error checking.
11
12 This is the behavior of moin up to version 1.2
13
14 @param url: the url from request, possibly matching specific wiki
15 @rtype: DefaultConfig subclass instance
16 @return: config object for specific wiki
17 """
18 match = url_re().match(url)
19 if match and match.groups():
20 # Get config module name from match
21 for name, value in match.groupdict().items():
22 if value: break
23
24 # FIXME: we should cache config objects by wiki url and return
25 # here a ready to use config, instead of creating new instance
26 # for each request.
27
28 try:
29 module = __import__(name, globals(), {})
30 Config = getattr(module, 'Config', None)
31 if Config:
32 # Config found, return config instance
33 cfg = Config()
34 cfg.siteid = name
35 return cfg
36 else:
37 # Broken config file, probably old config from 1.2
38 err = 'could not find a "Config" class in "%s.py"; ' \
39 'default configuration used instead.' % (name)
40
41 except ImportError, why:
42 # Broken config file, probably indent problem
43 err = 'import of config "%s" failed due to "%s"; ' \
44 'default configuration used instead.' % (name, why)
45 else:
46 # Missing config file, or error in farmconfig.py
47 err = 'could not find a config file for url: %s; ' \
48 'default configuration used instead.' % (url)
49
50 # Warn and return a default config
51 import warnings
52 warnings.warn(err)
53 return DefaultConfig()
The problem with this system is that the default config works on the wiki on the development tree, but not for installed wikis, even if the wiki was installed according to the standard instructions.
fixes:
If a config file is not found, or the config file is broken, raise error.FatalError which will show a helpful error message.
- Check if we still need to support situation that needs the old behavior, and make a special fix for them, without effecting the usual setup. For example, maybe change the way the wiki is saved in the develoment tree, like adding a special development config.
IMHO we dont need to support the non-availability of config files. And I do not like to think about developer machines here, they should be smart enough to get this right anyway. We should rather think about users who like to migrate their old system which does not use a config file (of course there are even such 1.3 installs). But if the message is nice and gives good pointers, then I would like to see this small patch. I am sure that it will simplify many install sessions because you get a clear error message instead of a subtle warning in the logs. -- AlexanderSchremmer 2004-12-14 15:30:02
Progress
Setup a test wiki in the development directory to enabled make test. Probably using wikiconfig.py in the root directory
Took less than one minute to setup
Check again the default values in multiconfig - they should be the same defaults we use in wikiconfig.py, e.g, work out of the box for most users - even with empty Config class.
Add sanity check in multiconfig - check if data_dir and data_underlay_dir are accessible (exists, writable etc.)
Show clear error message for these case:
config file could not be imported - probably syntax error
Missing Config class - probably old format cofig
config file was not found - probably typo in the file name, using 'module.py' instead of 'module'
Data directory missing or not writable
Underlay directory missing or not writable
Other error while trying to create Config instance.
Plan
- Priority: high
- Assigned to:
- Status: fixed in patch-457