annotate MoinMoin/multiconfig.py @ 705:45df95cd2ed8

Merged with main
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 19 May 2006 23:28:45 +0200
parents 38aa322f35c9 ad2ac49d17fe
children fce105e8b3df
rev   line source
705
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
1 # -*- coding: iso-8859-1 -*-
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
2 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
3 MoinMoin - Multiple configuration handler and Configuration defaults class
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
4
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
5 @copyright: 2000-2004 by Jrgen Hermann <jh@web.de>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
6 @license: GNU GPL, see COPYING for details.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
7 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
8
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
9 import re, os, sys
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
10 from MoinMoin import error
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
11 import MoinMoin.auth as authmodule
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
12
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
13 _url_re_cache = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
14 _farmconfig_mtime = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
15 _config_cache = {}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
16
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
17
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
18 def _importConfigModule(name):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
19 """ Import and return configuration module and its modification time
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
20
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
21 Handle all errors except ImportError, because missing file is not
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
22 always an error.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
23
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
24 @param name: module name
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
25 @rtype: tuple
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
26 @return: module, modification time
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
27 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
28 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
29 module = __import__(name, globals(), {})
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
30 mtime = os.path.getmtime(module.__file__)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
31 except ImportError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
32 raise
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
33 except IndentationError, err:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
34 msg = 'IndentationError: %s\n' % str(err) + '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
35
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
36 The configuration files are python modules. Therefore, whitespace is
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
37 important. Make sure that you use only spaces, no tabs are allowed here!
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
38 You have to use four spaces at the beginning of the line mostly.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
39 '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
40 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
41 except Exception, err:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
42 msg = '%s: %s' % (err.__class__.__name__, str(err))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
43 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
44 return module, mtime
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
45
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
46
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
47 def _url_re_list():
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
48 """ Return url matching regular expression
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
49
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
50 Import wikis list from farmconfig on the first call and compile the
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
51 regexes. Later then return the cached regex list.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
52
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
53 @rtype: list of tuples of (name, compiled re object)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
54 @return: url to wiki config name matching list
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
55 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
56 global _url_re_cache, _farmconfig_mtime
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
57 if _url_re_cache is None:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
58 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
59 farmconfig, _farmconfig_mtime = _importConfigModule('farmconfig')
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
60 except ImportError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
61 # Default to wikiconfig for all urls.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
62 _farmconfig_mtime = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
63 _url_re_cache = [('wikiconfig', re.compile(r'.')), ] # matches everything
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
64 else:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
65 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
66 cache = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
67 for name, regex in farmconfig.wikis:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
68 cache.append((name, re.compile(regex)))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
69 _url_re_cache = cache
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
70 except AttributeError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
71 msg = """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
72 Missing required 'wikis' list in 'farmconfig.py'.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
73
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
74 If you run a single wiki you do not need farmconfig.py. Delete it and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
75 use wikiconfig.py.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
76 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
77 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
78 return _url_re_cache
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
79
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
80
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
81 def _makeConfig(name):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
82 """ Create and return a config instance
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
83
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
84 Timestamp config with either module mtime or farmconfig mtime. This
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
85 mtime can be used later to invalidate older caches.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
86
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
87 @param name: module name
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
88 @rtype: DefaultConfig sub class instance
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
89 @return: new configuration instance
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
90 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
91 global _farmconfig_mtime
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
92 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
93 module, mtime = _importConfigModule(name)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
94 configClass = getattr(module, 'Config')
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
95 cfg = configClass(name)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
96 cfg.cfg_mtime = max(mtime, _farmconfig_mtime)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
97 except ImportError, err:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
98 msg = 'ImportError: %s\n' % str(err) + '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
99
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
100 Check that the file is in the same directory as the server script. If
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
101 it is not, you must add the path of the directory where the file is
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
102 located to the python path in the server script. See the comments at
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
103 the top of the server script.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
104
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
105 Check that the configuration file name is either "wikiconfig.py" or the
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
106 module name specified in the wikis list in farmconfig.py. Note that the
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
107 module name does not include the ".py" suffix.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
108 '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
109 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
110 except AttributeError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
111 msg = '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
112 Could not find required "Config" class in "%(name)s.py". This might
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
113 happen if you are trying to use a pre 1.3 configuration file, or made a
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
114 syntax or spelling error.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
115
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
116 Please check your configuration file. As an example for correct syntax,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
117 use the wikiconfig.py file from the distribution.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
118 ''' % {'name': name}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
119 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
120 return cfg
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
121
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
122
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
123 def _getConfigName(url):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
124 """ Return config name for url or raise """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
125 for name, regex in _url_re_list():
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
126 match = regex.match(url)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
127 if match:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
128 return name
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
129 # nothing matched
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
130 msg = '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
131 Could not find a match for url: "%(url)s".
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
132
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
133 Check your URL regular expressions in the "wikis" list in
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
134 "farmconfig.py".
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
135 ''' % {'url': url}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
136 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
137
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
138
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
139 def getConfig(url):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
140 """ Return cached config instance for url or create new one
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
141
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
142 If called by many threads in the same time multiple config
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
143 instances might be created. The first created item will be
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
144 returned, using dict.setdefault.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
145
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
146 @param url: the url from request, possibly matching specific wiki
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
147 @rtype: DefaultConfig subclass instance
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
148 @return: config object for specific wiki
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
149 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
150 configName = _getConfigName(url)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
151 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
152 config = _config_cache[configName]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
153 except KeyError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
154 config = _makeConfig(configName)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
155 config = _config_cache.setdefault(configName, config)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
156 return config
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
157
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
158
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
159 # This is a way to mark some text for the gettext tools so that they don't
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
160 # get orphaned. See http://www.python.org/doc/current/lib/node278.html.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
161 def _(text): return text
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
162
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
163
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
164 class DefaultConfig:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
165 """ default config values """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
166
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
167 # All acl_right lines must use unicode!
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
168 acl_rights_default = u"Trusted:read,write,delete,revert Known:read,write,delete,revert All:read,write"
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
169 acl_rights_before = u""
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
170 acl_rights_after = u""
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
171 acl_rights_valid = ['read', 'write', 'delete', 'revert', 'admin']
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
172
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
173 actions_excluded = [] # ['DeletePage', 'AttachFile', 'RenamePage', 'test', ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
174 allow_xslt = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
175 attachments = None # {'dir': path, 'url': url-prefix}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
176 auth = [authmodule.moin_cookie]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
177
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
178 backup_compression = 'gz'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
179 backup_users = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
180 backup_include = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
181 backup_exclude = [
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
182 r"(.+\.py(c|o)$)",
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
183 r"%(cache_dir)s",
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
184 r"%(/)spages%(/)s.+%(/)scache%(/)s[^%(/)s]+$" % {'/': os.sep},
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
185 r"%(/)s(edit-lock|event-log|\.DS_Store)$" % {'/': os.sep},
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
186 ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
187 backup_storage_dir = '/tmp'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
188 backup_restore_target_dir = '/tmp'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
189
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
190 bang_meta = 1
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
191 caching_formats = ['text_html']
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
192 changed_time_fmt = '%H:%M'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
193 # chars_{upper,lower,digits,spaces} see MoinMoin/util/chartypes.py
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
194 # if you have gdchart, add something like
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
195 # chart_options = {'width = 720, 'height': 540}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
196 chart_options = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
197 config_check_enabled = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
198 cookie_domain = None # use '.domain.tld" for a farm with hosts in that domain
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
199 cookie_path = None # use '/wikifarm" for a farm with pathes below that path
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
200 cookie_lifetime = 12 # 12 hours from now
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
201 data_dir = './data/'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
202 data_underlay_dir = './underlay/'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
203 date_fmt = '%Y-%m-%d'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
204 datetime_fmt = '%Y-%m-%d %H:%M:%S'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
205 default_markup = 'wiki'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
206 docbook_html_dir = r"/usr/share/xml/docbook/stylesheet/nwalsh/html/" # correct for debian sarge
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
207 editor_default = 'text' # which editor is called when nothing is specified
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
208 editor_ui = 'freechoice' # which editor links are shown on user interface
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
209 editor_force = False
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
210 editor_quickhelp = { # editor markup hints quickhelp
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
211 'wiki': _("""\
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
212 Emphasis:: [[Verbatim('')]]''italics''[[Verbatim('')]]; [[Verbatim(''')]]'''bold'''[[Verbatim(''')]]; [[Verbatim(''''')]]'''''bold italics'''''[[Verbatim(''''')]]; [[Verbatim('')]]''mixed ''[[Verbatim(''')]]'''''bold'''[[Verbatim(''')]] and italics''[[Verbatim('')]]; [[Verbatim(----)]] horizontal rule.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
213 Headings:: [[Verbatim(=)]] Title 1 [[Verbatim(=)]]; [[Verbatim(==)]] Title 2 [[Verbatim(==)]]; [[Verbatim(===)]] Title 3 [[Verbatim(===)]]; [[Verbatim(====)]] Title 4 [[Verbatim(====)]]; [[Verbatim(=====)]] Title 5 [[Verbatim(=====)]].
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
214 Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
215 Links:: [[Verbatim(JoinCapitalizedWords)]]; [[Verbatim(["brackets and double quotes"])]]; url; [url]; [url label].
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
216 Tables:: || cell text |||| cell text spanning 2 columns ||; no trailing white space allowed after tables or titles.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
217
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
218 (!) For more help, see HelpOnEditing or SyntaxReference.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
219 """),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
220 'rst': _("""\
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
221 Emphasis: <i>*italic*</i> <b>**bold**</b> ``monospace``<br/>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
222 <br/><pre>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
223 Headings: Heading 1 Heading 2 Heading 3
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
224 ========= --------- ~~~~~~~~~
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
225
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
226 Horizontal rule: ----
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
227 Links: TrailingUnderscore_ `multi word with backticks`_ external_
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
228
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
229 .. _external: http://external-site.net/foo/
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
230
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
231 Lists: * bullets; 1., a. numbered items.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
232 </pre>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
233 <br/>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
234 (!) For more help, see the
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
235 <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
236 reStructuredText Quick Reference
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
237 </a>.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
238 """),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
239 }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
240 edit_locking = 'warn 10' # None, 'warn <timeout mins>', 'lock <timeout mins>'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
241 edit_rows = 20
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
242 email_subpage_template = u"$from-$date-$subj" # used for mail import
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
243 email_wiki_address = None # the e-mail address for e-mails that should go into the wiki
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
244 email_secret = ""
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
245
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
246 hacks = {} # { 'feature1': value1, ... }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
247 # Configuration for features still in development.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
248 # For boolean stuff just use config like this:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
249 # hacks = { 'feature': True, ...}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
250 # and in the code use:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
251 # if cfg.hacks.get('feature', False): <doit>
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
252 # A non-existing hack key should ever mean False, None, "", [] or {}!
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
253
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
254 hosts_deny = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
255 html_head = ''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
256 html_head_queries = '''<meta name="robots" content="noindex,nofollow">\n'''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
257 html_head_posts = '''<meta name="robots" content="noindex,nofollow">\n'''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
258 html_head_index = '''<meta name="robots" content="index,follow">\n'''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
259 html_head_normal = '''<meta name="robots" content="index,nofollow">\n'''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
260 html_pagetitle = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
261
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
262 interwiki_preferred = [] # list of wiki names to show at top of interwiki list
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
263
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
264 language_default = 'en'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
265 language_ignore_browser = False # ignore browser settings, use language_default
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
266 # or user prefs
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
267
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
268 lupy_search = False # disabled until lupy is finished
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
269
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
270 mail_login = None # or "user pwd" if you need to use SMTP AUTH
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
271 mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
272 mail_smarthost = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
273 mail_from = None # u'Jrgen Wiki <noreply@jhwiki.org>'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
274
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
275 navi_bar = [u'RecentChanges', u'FindPage', u'HelpContents', ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
276 nonexist_qm = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
277
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
278 page_credits = [
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
279 '<a href="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a>',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
280 '<a href="http://www.python.org/">Python Powered</a>',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
281 '<a href="http://validator.w3.org/check?uri=referer">Valid HTML 4.01</a>',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
282 ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
283 page_footer1 = ''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
284 page_footer2 = ''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
285
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
286 page_header1 = ''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
287 page_header2 = ''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
288
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
289 page_front_page = u'HelpOnLanguages' # this will make people choose a sane config
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
290 page_local_spelling_words = u'LocalSpellingWords'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
291 page_category_regex = u'^Category[A-Z]'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
292 page_dict_regex = u'[a-z0-9]Dict$'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
293 page_group_regex = u'[a-z0-9]Group$'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
294 page_template_regex = u'[a-z0-9]Template$'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
295
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
296 page_license_enabled = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
297 page_license_page = u'WikiLicense'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
298
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
299 # These icons will show in this order in the iconbar, unless they
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
300 # are not relevant, e.g email icon when the wiki is not configured
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
301 # for email.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
302 page_iconbar = ["up", "edit", "view", "diff", "info", "subscribe", "raw", "print",]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
303
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
304 # Standard buttons in the iconbar
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
305 page_icons_table = {
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
306 # key last part of url, title, icon-key
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
307 'help': ("%(q_page_help_contents)s", "%(page_help_contents)s", "help"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
308 'find': ("%(q_page_find_page)s?value=%(q_page_name)s", "%(page_find_page)s", "find"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
309 'diff': ("%(q_page_name)s?action=diff", _("Diffs"), "diff"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
310 'info': ("%(q_page_name)s?action=info", _("Info"), "info"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
311 'edit': ("%(q_page_name)s?action=edit", _("Edit"), "edit"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
312 'unsubscribe': ("%(q_page_name)s?action=subscribe", _("UnSubscribe"), "unsubscribe"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
313 'subscribe': ("%(q_page_name)s?action=subscribe", _("Subscribe"), "subscribe"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
314 'raw': ("%(q_page_name)s?action=raw", _("Raw"), "raw"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
315 'xml': ("%(q_page_name)s?action=show&amp;mimetype=text/xml", _("XML"), "xml"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
316 'print': ("%(q_page_name)s?action=print", _("Print"), "print"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
317 'view': ("%(q_page_name)s", _("View"), "view"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
318 'up': ("%(q_page_parent_page)s", _("Up"), "up"),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
319 }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
320 refresh = None # (minimum_delay, type), e.g.: (2, 'internal')
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
321 rss_cache = 60 # suggested caching time for RecentChanges RSS, in seconds
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
322 shared_intermap = None # can be string or list of strings (filenames)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
323 show_hosts = 1
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
324 show_interwiki = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
325 show_login = 1
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
326 show_names = True
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
327 show_section_numbers = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
328 show_timings = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
329 show_version = 0
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
330 siteid = 'default'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
331 stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
332 superuser = [] # list of unicode user names that have super powers :)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
333
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
334 surge_action_limits = { # allow max. <count> <action> requests per <dt> secs
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
335 # action: (count, dt)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
336 'all': (30, 30),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
337 'show': (30, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
338 'recall': (5, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
339 'raw': (20, 40), # some people use this for css
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
340 'AttachFile': (90, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
341 'diff': (30, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
342 'fullsearch': (5, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
343 'edit': (10, 120),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
344 'rss_rc': (1, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
345 'default': (30, 60),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
346 }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
347 surge_lockout_time = 3600 # secs you get locked out when you ignore warnings
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
348
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
349 theme_default = 'modern'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
350 theme_force = False
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
351 trail_size = 5
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
352 tz_offset = 0.0 # default time zone offset in hours from UTC
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
353 user_autocreate = False # do we auto-create user profiles
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
354 user_email_unique = True # do we check whether a user's email is unique?
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
355
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
356 # a regex of HTTP_USER_AGENTS that should be excluded from logging
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
357 # and receive a FORBIDDEN for anything except viewing a page
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
358 ua_spiders = ('archiver|cfetch|crawler|curl|gigabot|googlebot|holmes|htdig|httrack|httpunit|jeeves|larbin|leech|'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
359 'linkbot|linkmap|linkwalk|mercator|mirror|msnbot|nutbot|omniexplorer|puf|robot|scooter|'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
360 'sherlock|slurp|sitecheck|spider|teleport|voyager|webreaper|wget')
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
361
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
362 # Wiki identity
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
363 sitename = u'Untitled Wiki'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
364 url_prefix = '/wiki'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
365 logo_string = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
366 interwikiname = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
367
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
368 url_mappings = {}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
369
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
370 user_checkbox_fields = [
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
371 ('mailto_author', lambda _: _('Publish my email (not my wiki homepage) in author info')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
372 ('edit_on_doubleclick', lambda _: _('Open editor on double click')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
373 ('remember_last_visit', lambda _: _('Jump to last visited page instead of frontpage')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
374 ('show_nonexist_qm', lambda _: _('Show question mark for non-existing pagelinks')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
375 ('show_page_trail', lambda _: _('Show page trail')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
376 ('show_toolbar', lambda _: _('Show icon toolbar')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
377 ('show_topbottom', lambda _: _('Show top/bottom links in headings')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
378 ('show_fancy_diff', lambda _: _('Show fancy diffs')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
379 ('wikiname_add_spaces', lambda _: _('Add spaces to displayed wiki names')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
380 ('remember_me', lambda _: _('Remember login information')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
381 ('want_trivial', lambda _: _('Subscribe to trivial changes')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
382
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
383 ('disabled', lambda _: _('Disable this account forever')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
384 # if an account is disabled, it may be used for looking up
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
385 # id -> username for page info and recent changes, but it
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
386 # is not usable for the user any more:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
387 ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
388 user_checkbox_defaults = {'mailto_author': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
389 'edit_on_doubleclick': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
390 'remember_last_visit': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
391 'show_nonexist_qm': nonexist_qm,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
392 'show_page_trail': 1,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
393 'show_toolbar': 1,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
394 'show_topbottom': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
395 'show_fancy_diff': 1,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
396 'wikiname_add_spaces': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
397 'remember_me': 1,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
398 'want_trivial': 0,
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
399 }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
400 # don't let the user change those
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
401 # user_checkbox_disable = ['disabled', 'want_trivial']
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
402 user_checkbox_disable = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
403
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
404 # remove those checkboxes:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
405 #user_checkbox_remove = ['edit_on_doubleclick', 'show_nonexist_qm', 'show_toolbar', 'show_topbottom',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
406 # 'show_fancy_diff', 'wikiname_add_spaces', 'remember_me', 'disabled',]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
407 user_checkbox_remove = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
408
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
409 user_form_fields = [
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
410 ('name', _('Name'), "text", "36", _("(Use Firstname''''''Lastname)")),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
411 ('aliasname', _('Alias-Name'), "text", "36", ''),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
412 ('password', _('Password'), "password", "36", ''),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
413 ('password2', _('Password repeat'), "password", "36", _('(Only when changing passwords)')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
414 ('email', _('Email'), "text", "36", ''),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
415 ('css_url', _('User CSS URL'), "text", "40", _('(Leave it empty for disabling user CSS)')),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
416 ('edit_rows', _('Editor size'), "text", "3", ''),
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
417 ##('theme', _('Preferred theme'), [self._theme_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
418 ##('', _('Editor Preference'), [self._editor_default_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
419 ##('', _('Editor shown on UI'), [self._editor_ui_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
420 ##('', _('Time zone'), [self._tz_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
421 ##('', _('Date format'), [self._dtfmt_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
422 ##('', _('Preferred language'), [self._lang_select()])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
423 ]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
424 user_form_defaults = { # key: default
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
425 'name': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
426 'aliasname': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
427 'password': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
428 'password2': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
429 'email': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
430 'css_url': '',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
431 'edit_rows': "20",
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
432 }
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
433 # don't let the user change those, but show them:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
434 #user_form_disable = ['name', 'aliasname', 'email',]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
435 user_form_disable = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
436
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
437 # remove those completely:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
438 #user_form_remove = ['password', 'password2', 'css_url', 'logout', 'create', 'account_sendmail',]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
439 user_form_remove = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
440
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
441 # attributes we do NOT save to the userpref file
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
442 user_transient_fields = ['id', 'valid', 'may', 'auth_username', 'trusted', 'password', 'password2', 'auth_method', 'auth_attribs']
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
443
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
444 user_homewiki = 'Self' # interwiki name for where user homepages are located
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
445
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
446 unzip_single_file_size = 2.0 * 1000**2
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
447 unzip_attachments_space = 200.0 * 1000**2
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
448 unzip_attachments_count = 51 # 1 zip file + 50 files contained in it
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
449
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
450 xmlrpc_putpage_enabled = 0 # if 0, putpage will write to a test page only
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
451 xmlrpc_putpage_trusted_only = 1 # if 1, you will need to be http auth authenticated
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
452
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
453 SecurityPolicy = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
454
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
455 def __init__(self, siteid):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
456 """ Init Config instance """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
457 self.siteid = siteid
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
458 if self.config_check_enabled:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
459 self._config_check()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
460
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
461 # define directories
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
462 self.moinmoin_dir = os.path.abspath(os.path.dirname(__file__))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
463 data_dir = os.path.normpath(self.data_dir)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
464 self.data_dir = data_dir
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
465 for dirname in ('user', 'cache', 'plugin'):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
466 name = dirname + '_dir'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
467 if not getattr(self, name, None):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
468 setattr(self, name, os.path.join(data_dir, dirname))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
469
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
470 # Try to decode certain names which allow unicode
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
471 self._decode()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
472
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
473 self._check_directories()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
474
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
475 if not isinstance(self.superuser, list):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
476 msg = """The superuser setting in your wiki configuration is not a list
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
477 (e.g. ['Sample User', 'AnotherUser']).
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
478 Please change it in your wiki configuration and try again."""
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
479 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
480
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
481 self._loadPluginModule()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
482
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
483 # Preparse user dicts
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
484 self._fillDicts()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
485
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
486 # Normalize values
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
487 self.language_default = self.language_default.lower()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
488
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
489 # Use site name as default name-logo
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
490 if self.logo_string is None:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
491 self.logo_string = self.sitename
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
492
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
493 # Check for needed modules
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
494
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
495 # FIXME: maybe we should do this check later, just before a
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
496 # chart is needed, maybe in the chart module, instead doing it
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
497 # for each request. But this require a large refactoring of
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
498 # current code.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
499 if self.chart_options:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
500 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
501 import gdchart
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
502 except ImportError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
503 self.chart_options = None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
504
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
505 # post process
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
506 # we replace any string placeholders with config values
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
507 # e.g u'%(page_front_page)s' % self
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
508 self.navi_bar = [elem % self for elem in self.navi_bar]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
509 self.backup_exclude = [elem % self for elem in self.backup_exclude]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
510
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
511 # list to cache lupy searcher objects
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
512 self.lupy_searchers = []
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
513
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
514 # check if mail is possible and set flag:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
515 self.mail_enabled = (self.mail_smarthost is not None or self.mail_sendmail is not None) and self.mail_from
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
516
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
517 def _config_check(self):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
518 """ Check namespace and warn about unknown names
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
519
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
520 Warn about names which are not used by DefaultConfig, except
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
521 modules, classes, _private or __magic__ names.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
522
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
523 This check is disabled by default, when enabled, it will show an
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
524 error message with unknown names.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
525 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
526 unknown = ['"%s"' % name for name in dir(self)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
527 if not name.startswith('_') and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
528 not DefaultConfig.__dict__.has_key(name) and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
529 not isinstance(getattr(self, name), (type(sys), type(DefaultConfig)))]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
530 if unknown:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
531 msg = """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
532 Unknown configuration options: %s.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
533
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
534 For more information, visit HelpOnConfiguration. Please check your
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
535 configuration for typos before requesting support or reporting a bug.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
536 """ % ', '.join(unknown)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
537 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
538
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
539 def _decode(self):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
540 """ Try to decode certain names, ignore unicode values
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
541
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
542 Try to decode str using utf-8. If the decode fail, raise FatalError.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
543
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
544 Certain config variables should contain unicode values, and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
545 should be defined with u'text' syntax. Python decode these if
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
546 the file have a 'coding' line.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
547
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
548 This will allow utf-8 users to use simple strings using, without
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
549 using u'string'. Other users will have to use u'string' for
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
550 these names, because we don't know what is the charset of the
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
551 config files.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
552 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
553 charset = 'utf-8'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
554 message = u'''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
555 "%(name)s" configuration variable is a string, but should be
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
556 unicode. Use %(name)s = u"value" syntax for unicode variables.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
557
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
558 Also check your "-*- coding -*-" line at the top of your configuration
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
559 file. It should match the actual charset of the configuration file.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
560 '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
561
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
562 decode_names = (
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
563 'sitename', 'logo_string', 'navi_bar', 'page_front_page',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
564 'page_category_regex', 'page_dict_regex',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
565 'page_group_regex', 'page_template_regex', 'page_license_page',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
566 'page_local_spelling_words', 'acl_rights_default',
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
567 'acl_rights_before', 'acl_rights_after', 'mail_from'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
568 )
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
569
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
570 for name in decode_names:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
571 attr = getattr(self, name, None)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
572 if attr:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
573 # Try to decode strings
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
574 if isinstance(attr, str):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
575 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
576 setattr(self, name, unicode(attr, charset))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
577 except UnicodeError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
578 raise error.ConfigurationError(message %
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
579 {'name': name})
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
580 # Look into lists and try to decode strings inside them
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
581 elif isinstance(attr, list):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
582 for i in xrange(len(attr)):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
583 item = attr[i]
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
584 if isinstance(item, str):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
585 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
586 attr[i] = unicode(item, charset)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
587 except UnicodeError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
588 raise error.ConfigurationError(message %
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
589 {'name': name})
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
590
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
591 def _check_directories(self):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
592 """ Make sure directories are accessible
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
593
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
594 Both data and underlay should exists and allow read, write and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
595 execute.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
596 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
597 mode = os.F_OK | os.R_OK | os.W_OK | os.X_OK
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
598 for attr in ('data_dir', 'data_underlay_dir'):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
599 path = getattr(self, attr)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
600
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
601 # allow an empty underlay path or None
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
602 if attr == 'data_underlay_dir' and not path:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
603 continue
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
604
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
605 path_pages = os.path.join(path, "pages")
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
606 if not (os.path.isdir(path_pages) and os.access(path_pages, mode)):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
607 msg = '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
608 %(attr)s "%(path)s" does not exists, or has incorrect ownership or
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
609 permissions.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
610
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
611 Make sure the directory and the subdirectory pages are owned by the web
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
612 server and are readable, writable and executable by the web server user
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
613 and group.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
614
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
615 It is recommended to use absolute paths and not relative paths. Check
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
616 also the spelling of the directory name.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
617 ''' % {'attr': attr, 'path': path,}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
618 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
619
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
620 def _loadPluginModule(self):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
621 """ import plugin module under configname.plugin
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
622
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
623 To be able to import plugin from arbitrary path, we have to load
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
624 the base package once using imp.load_module. Later, we can use
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
625 standard __import__ call to load plugins in this package.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
626
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
627 Since each wiki has unique plugins, we load the plugin package
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
628 under the wiki configuration module, named self.siteid.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
629 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
630 import sys, imp
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
631
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
632 name = self.siteid + '.plugin'
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
633 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
634 # Lock other threads while we check and import
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
635 imp.acquire_lock()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
636 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
637 # If the module is not loaded, try to load it
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
638 if not name in sys.modules:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
639 # Find module on disk and try to load - slow!
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
640 plugin_parent_dir = os.path.abspath(os.path.join(self.plugin_dir, '..'))
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
641 fp, path, info = imp.find_module('plugin', [plugin_parent_dir])
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
642 try:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
643 # Load the module and set in sys.modules
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
644 module = imp.load_module(name, fp, path, info)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
645 sys.modules[self.siteid].plugin = module
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
646 finally:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
647 # Make sure fp is closed properly
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
648 if fp:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
649 fp.close()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
650 finally:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
651 imp.release_lock()
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
652 except ImportError, err:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
653 msg = '''
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
654 Could not import plugin package "%(path)s/plugin" because of ImportError:
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
655 %(err)s.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
656
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
657 Make sure your data directory path is correct, check permissions, and
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
658 that the data/plugin directory has an __init__.py file.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
659 ''' % {'path': self.data_dir, 'err': str(err)}
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
660 raise error.ConfigurationError(msg)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
661
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
662 def _fillDicts(self):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
663 """ fill config dicts
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
664
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
665 Fills in missing dict keys of derived user config by copying
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
666 them from this base class.
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
667 """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
668 # user checkbox defaults
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
669 for key, value in DefaultConfig.user_checkbox_defaults.items():
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
670 if not self.user_checkbox_defaults.has_key(key):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
671 self.user_checkbox_defaults[key] = value
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
672
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
673 def __getitem__(self, item):
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
674 """ Make it possible to access a config object like a dict """
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
675 return getattr(self, item)
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
676
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
677 # remove the gettext pseudo function
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
678 del _
45df95cd2ed8 Merged with main
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 704 656
diff changeset
679