21 |
21 |
22 Resource mode |
22 Resource mode |
23 ------------- |
23 ------------- |
24 |
24 |
25 Standard resource mode |
25 Standard resource mode |
26 ``````````````````````````` |
26 `````````````````````` |
27 |
27 |
28 A resource *mode* is a predefined set of settings for various resources |
28 A resource *mode* is a predefined set of settings for various resources |
29 directories, such as cubes, instances, etc. to ease development with the |
29 directories, such as cubes, instances, etc. to ease development with the |
30 framework. There are two running modes with *CubicWeb*: |
30 framework. There are two running modes with *CubicWeb*: |
31 |
31 |
42 |
42 |
43 - instances are stored in :file:`~/etc/cubicweb.d` |
43 - instances are stored in :file:`~/etc/cubicweb.d` |
44 - temporary files (such as pid file) in :file:`/tmp` |
44 - temporary files (such as pid file) in :file:`/tmp` |
45 |
45 |
46 |
46 |
47 |
|
48 |
|
49 .. _CubicwebWithinVirtualEnv: |
47 .. _CubicwebWithinVirtualEnv: |
50 |
48 |
51 Within virtual environment |
49 Within virtual environment |
52 ``````````````````````````` |
50 `````````````````````````` |
53 |
51 |
54 If you are not administrator of you machine or if you need to play with some |
52 If you are not administrator of you machine or if you need to play with some |
55 specific version of |cubicweb| you can use `virtualenv`_ a tool to create |
53 specific version of |cubicweb| you can use virtualenv_ a tool to create |
56 isolated Python environments. |
54 isolated Python environments. |
57 |
55 |
58 - instances are stored in :file:`<VIRTUAL_ENV>/etc/cubicweb.d` |
56 - instances are stored in :file:`<VIRTUAL_ENV>/etc/cubicweb.d` |
59 - temporary files (such as pid file) in :file:`<VIRTUAL_ENV>/var/run/cubicweb` |
57 - temporary files (such as pid file) in :file:`<VIRTUAL_ENV>/var/run/cubicweb` |
60 |
58 |
61 .. _`virtualenv`: http://pypi.python.org/pypi/virtualenv |
59 .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
|
60 |
62 |
61 |
63 Custom resource location |
62 Custom resource location |
64 ```````````````````````````````` |
63 ```````````````````````` |
65 |
64 |
66 Notice that each resource path may be explicitly set using an environment |
65 Notice that each resource path may be explicitly set using an environment |
67 variable if the default doesn't suit your needs. Here are the default resource |
66 variable if the default doesn't suit your needs. Here are the default resource |
68 directories that are affected according to mode: |
67 directories that are affected according to mode: |
69 |
68 |
78 CW_INSTANCES_DIR = ~/etc/cubicweb.d/ |
77 CW_INSTANCES_DIR = ~/etc/cubicweb.d/ |
79 CW_INSTANCES_DATA_DIR = ~/etc/cubicweb.d/ |
78 CW_INSTANCES_DATA_DIR = ~/etc/cubicweb.d/ |
80 CW_RUNTIME_DIR = /tmp |
79 CW_RUNTIME_DIR = /tmp |
81 |
80 |
82 Cubes search path is also affected, see the :ref:`Cube` section. |
81 Cubes search path is also affected, see the :ref:`Cube` section. |
|
82 |
83 |
83 |
84 Setting Cubicweb Mode |
84 Setting Cubicweb Mode |
85 ````````````````````` |
85 ````````````````````` |
86 |
86 |
87 By default, the mode is set to 'system' for standard installation. The mode is |
87 By default, the mode is set to 'system' for standard installation. The mode is |
98 If you've a doubt about the mode you're currently running, check the first line |
98 If you've a doubt about the mode you're currently running, check the first line |
99 outputed by the :command:`cubicweb-ctl list` command. |
99 outputed by the :command:`cubicweb-ctl list` command. |
100 |
100 |
101 .. _`cubicweb is used from a mercurial repository`: CubicwebDevelopmentMod_ |
101 .. _`cubicweb is used from a mercurial repository`: CubicwebDevelopmentMod_ |
102 |
102 |
|
103 |
103 .. _CubicwebDevelopmentMod: |
104 .. _CubicwebDevelopmentMod: |
104 |
105 |
105 Development Mode |
106 Development Mode (source) |
106 ````````````````````` |
107 ````````````````````````` |
107 If :file:`.hg` directory is found into the cubicweb package, there are specific resource rules. |
108 |
|
109 If :file:`.hg` directory is found into the cubicweb package, there are |
|
110 specific resource rules. |
108 |
111 |
109 `<CW_SOFTWARE_ROOT>` is the source checkout's ``cubicweb`` directory: |
112 `<CW_SOFTWARE_ROOT>` is the source checkout's ``cubicweb`` directory: |
110 |
113 |
111 * main cubes directory is `<CW_SOFTWARE_ROOT>/../../cubes`. You can specify |
114 * main cubes directory is `<CW_SOFTWARE_ROOT>/../../cubes`. You can specify |
112 another one with :envvar:`CW_INSTANCES_DIR` environment variable or simply |
115 another one with :envvar:`CW_INSTANCES_DIR` environment variable or simply |
113 add some other directories by using :envvar:`CW_CUBES_PATH` |
116 add some other directories by using :envvar:`CW_CUBES_PATH` |
114 |
117 |
115 * cubicweb migration files are searched in `<CW_SOFTWARE_ROOT>/misc/migration` |
118 * cubicweb migration files are searched in `<CW_SOFTWARE_ROOT>/misc/migration` |
116 instead of `<INSTALL_PREFIX>/share/cubicweb/migration/`. |
119 instead of `<INSTALL_PREFIX>/share/cubicweb/migration/`. |
117 |
120 |
|
121 |
|
122 Development Mode (virtualenv) |
|
123 ````````````````````````````` |
|
124 |
|
125 If a virtualenv is found to be activated (i.e. a VIRTUAL_ENV variable is found |
|
126 in environment), the virtualenv root is used as `<INSTALL_PREFIX>`. This, in |
|
127 particular, makes it possible to work in `setuptools development mode`_ |
|
128 (``python setup.py develop``) without any further configuration. |
|
129 |
|
130 .. _`setuptools development mode`: https://pythonhosted.org/setuptools/setuptools.html#development-mode |
118 |
131 |
119 .. _ConfigurationEnv: |
132 .. _ConfigurationEnv: |
120 |
133 |
121 Environment configuration |
134 Environment configuration |
122 ------------------------- |
135 ------------------------- |
218 if len(modes) != 1: |
231 if len(modes) != 1: |
219 raise ConfigurationError('unable to guess configuration from %r %s' |
232 raise ConfigurationError('unable to guess configuration from %r %s' |
220 % (directory, modes)) |
233 % (directory, modes)) |
221 return modes[0] |
234 return modes[0] |
222 |
235 |
223 def _find_prefix(start_path=CW_SOFTWARE_ROOT): |
236 def _find_prefix(start_path=None): |
224 """Runs along the parent directories of *start_path* (default to cubicweb source directory) |
237 """Return the prefix path of CubicWeb installation. |
225 looking for one containing a 'share/cubicweb' directory. |
238 |
226 The first matching directory is assumed as the prefix installation of cubicweb |
239 Walk parent directories of `start_path` looking for one containing a |
227 |
240 'share/cubicweb' directory. The first matching directory is assumed as the |
228 Returns the matching prefix or None. |
241 prefix installation of CubicWeb. |
|
242 |
|
243 If run from within a virtualenv, the virtualenv root is used as |
|
244 `start_path`. Otherwise, `start_path` defaults to cubicweb package |
|
245 directory path. |
229 """ |
246 """ |
230 prefix = start_path |
247 if start_path is None: |
|
248 try: |
|
249 prefix = os.environ['VIRTUAL_ENV'] |
|
250 except KeyError: |
|
251 prefix = CW_SOFTWARE_ROOT |
|
252 else: |
|
253 prefix = start_path |
|
254 if not isdir(prefix): |
|
255 prefix = dirname(prefix) |
231 old_prefix = None |
256 old_prefix = None |
232 if not isdir(start_path): |
|
233 prefix = dirname(start_path) |
|
234 while (not isdir(join(prefix, 'share', 'cubicweb')) |
257 while (not isdir(join(prefix, 'share', 'cubicweb')) |
235 or prefix.endswith('.egg')) and prefix != old_prefix: |
258 or prefix.endswith('.egg')): |
|
259 if prefix == old_prefix: |
|
260 return sys.prefix |
236 old_prefix = prefix |
261 old_prefix = prefix |
237 prefix = dirname(prefix) |
262 prefix = dirname(prefix) |
238 if isdir(join(prefix, 'share', 'cubicweb')): |
263 return prefix |
239 return prefix |
|
240 return sys.prefix |
|
241 |
264 |
242 # persistent options definition |
265 # persistent options definition |
243 PERSISTENT_OPTIONS = ( |
266 PERSISTENT_OPTIONS = ( |
244 ('encoding', |
267 ('encoding', |
245 {'type' : 'string', |
268 {'type' : 'string', |
331 # nor remove appobjects based on unused interface [???] |
354 # nor remove appobjects based on unused interface [???] |
332 cleanup_unused_appobjects = True |
355 cleanup_unused_appobjects = True |
333 |
356 |
334 quick_start = False |
357 quick_start = False |
335 |
358 |
336 if (CWDEV and _forced_mode != 'system'): |
359 if 'VIRTUAL_ENV' in os.environ: |
|
360 _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes') |
|
361 mode = 'user' |
|
362 elif CWDEV and _forced_mode != 'system': |
337 mode = 'user' |
363 mode = 'user' |
338 _CUBES_DIR = join(CW_SOFTWARE_ROOT, '../../cubes') |
364 _CUBES_DIR = join(CW_SOFTWARE_ROOT, '../../cubes') |
339 else: |
365 else: |
340 mode = _forced_mode or 'system' |
366 mode = _forced_mode or 'system' |
341 _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes') |
367 _CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes') |