Package cubicweb :: Module cwconfig
[hide private]
[frames] | no frames]

Module cwconfig

source code


.. _ResourceMode:

Resource mode
-------------

A resource *mode* is a predifined set of settings for various resources
directories, such as cubes, instances, etc. to ease development with the
framework. There are two running modes with *CubicWeb*:

* **system**: resources are searched / created in the system directories (eg
  usually requiring root access):

  - instances are stored in :file:`<INSTALL_PREFIX>/etc/cubicweb.d`
  - temporary files (such as pid file) in :file:`/var/run/cubicweb`

  where `<INSTALL_PREFIX>` is the detected installation prefix ('/usr/local' for
  instance).

* **user**: resources are searched / created in the user home directory:

  - instances are stored in :file:`~/etc/cubicweb.d`
  - temporary files (such as pid file) in :file:`/tmp`



Notice that each resource path may be explicitly set using an environment
variable if the default doesn't suit your needs. Here are the default resource
directories that are affected according to mode:

* **system**: ::

        CW_INSTANCES_DIR = <INSTALL_PREFIX>/etc/cubicweb.d/
        CW_INSTANCES_DATA_DIR = /var/lib/cubicweb/instances/
        CW_RUNTIME_DIR = /var/run/cubicweb/

* **user**: ::

        CW_INSTANCES_DIR = ~/etc/cubicweb.d/
        CW_INSTANCES_DATA_DIR = ~/etc/cubicweb.d/
        CW_RUNTIME_DIR = /tmp

Cubes search path is also affected, see the :ref:`Cube` section.

By default, the mode automatically set to `user` if a :file:`.hg` directory is found
in the cubicweb package, else it's set to `system`. You can force this by setting
the :envvar:`CW_MODE` environment variable to either `user` or `system` so you can
easily:

* use system wide installation but user specific instances and all, without root
  privileges on the system (`export CW_MODE=user`)

* use local checkout of cubicweb on system wide instances (requires root
  privileges on the system (`export CW_MODE=system`)

If you've a doubt about the mode you're currently running, check the first line
outputed by the :command:`cubicweb-ctl list` command.

Also, if cubicweb is a mercurial checkout located in `<CW_SOFTWARE_ROOT>`:

* main cubes directory is `<CW_SOFTWARE_ROOT>/../cubes`. You can specify
  another one with :envvar:`CW_INSTANCES_DIR` environment variable or simply
  add some other directories by using :envvar:`CW_CUBES_PATH`

* cubicweb migration files are searched in `<CW_SOFTWARE_ROOT>/misc/migration`
  instead of `<INSTALL_PREFIX>/share/cubicweb/migration/`.


.. _ConfigurationEnv:

Environment configuration
-------------------------

Python
``````

If you installed *CubicWeb* by cloning the Mercurial forest or from source
distribution, then you will need to update the environment variable PYTHONPATH by
adding the path to the forest `cubicweb`:

Add the following lines to either :file:`.bashrc` or :file:`.bash_profile` to
configure your development environment ::

    export PYTHONPATH=/full/path/to/cubicweb-forest

If you installed *CubicWeb* with packages, no configuration is required and your
new cubes will be placed in `/usr/share/cubicweb/cubes` and your instances will
be placed in `/etc/cubicweb.d`.


CubicWeb
````````

Here are all environment variables that may be used to configure *CubicWeb*:

.. envvar:: CW_MODE

   Resource mode: user or system, as explained in :ref:`ResourceMode`.

.. envvar:: CW_CUBES_PATH

   Augments the default search path for cubes. You may specify several
   directories using ':' as separator (';' under windows environment).

.. envvar:: CW_INSTANCES_DIR

   Directory where cubicweb instances will be found.

.. envvar:: CW_INSTANCES_DATA_DIR

   Directory where cubicweb instances data will be written (backup file...)

.. envvar:: CW_RUNTIME_DIR

   Directory where pid files will be written

Classes [hide private]
  metaconfiguration
metaclass to automaticaly register configuration
  CubicWebNoAppConfiguration
base class for cubicweb configuration without a specific instance directory
  CubicWebConfiguration
base class for cubicweb server and web configurations
Functions [hide private]
 
configuration_cls(name)
return the configuration class registered with the given name
source code
 
possible_configurations(directory)
return a list of installed configurations in a directory according to *-ctl files
source code
 
guess_configuration(directory)
try to guess the configuration to use for a directory. If multiple configurations are found, ConfigurationError is raised
source code
 
_find_prefix(start_path='/home/syt/src/fcubicweb/cubicweb')
Runs along the parent directories of start_path (default to cubicweb source directory) looking for one containing a 'share/cubicweb' directory. The first matching directory is assumed as the prefix installation of cubicweb
source code
 
register_persistent_options(options) source code
 
instance_configuration(appid, config=None, debugmode=False)
return a configuration instance for the given instance identifier
source code
 
register_stored_procedures() source code
Variables [hide private]
  CONFIGURATIONS = [<class 'cubicweb.server.serverconfig.ServerC...
  SMTP_LOCK = Lock()
  PERSISTENT_OPTIONS = (('encoding', {'default': 'UTF-8', 'group...
  CFGTYPE2ETYPE_MAP = {'choice': 'String', 'float': 'Float', 'in...
  _forced_mode = None
Simple <textarea>, will return an unicode string.
  CWDEV = True
overrided on the server-side
  _INSTALL_PREFIX = '/usr'
  _EXT_REGISTERED = False
return a boolean telling if it's triggered by a db-api query or by a session query.
Function Details [hide private]

_find_prefix(start_path='/home/syt/src/fcubicweb/cubicweb')

source code 

Runs along the parent directories of start_path (default to cubicweb source directory) looking for one containing a 'share/cubicweb' directory. The first matching directory is assumed as the prefix installation of cubicweb

Returns the matching prefix or None.


Variables Details [hide private]

CONFIGURATIONS

Value:
[<class 'cubicweb.server.serverconfig.ServerConfiguration'>,
 <class 'cubicweb.etwist.twconfig.TwistedConfiguration'>,
 <class 'cubicweb.etwist.twconfig.AllInOneConfiguration'>]

PERSISTENT_OPTIONS

Value:
(('encoding',
  {'default': 'UTF-8',
   'group': 'ui',
   'help': u'user interface encoding',
   'sitewide': True,
   'type': 'string'}),
 ('language',
  {'default': 'en', 'group': 'ui', 'help': u'language of the user inte\
...

CFGTYPE2ETYPE_MAP

Value:
{'choice': 'String',
 'float': 'Float',
 'int': 'Int',
 'string': 'String',
 'yn': 'Boolean'}