VirtualMailManager/__init__.py
author Pascal Volk <neverseen@users.sourceforge.net>
Wed, 28 Apr 2010 05:37:14 +0000
branchv0.6.x
changeset 271 e915d4725706
parent 262 6eea85d8b91d
child 272 446483386914
permissions -rw-r--r--
INSTALL: dropped group mail related stuff. UPGRADE: be more details about nobody's primary group.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
# -*- coding: UTF-8 -*-
162
0ac9ef587769 Updated copyright notices to include the year 2010.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 152
diff changeset
     2
# Copyright (c) 2007 - 2010, Pascal Volk
0
bb0aa2102206 Initial import @sf.net
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# See COPYING for distribution information.
209
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     4
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     5
"""
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     6
    VirtualMailManager
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     7
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     8
    VirtualMailManager package initialization code
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
     9
"""
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    10
188
cf1b5f22dbd2 VMM/Handler: __init__ accepts now a config_type ('default'||'cli').
Pascal Volk <neverseen@users.sourceforge.net>
parents: 187
diff changeset
    11
import gettext
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    12
import locale
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    13
215
33f727efa7c4 PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 209
diff changeset
    14
from VirtualMailManager.constants.version import __author__, __date__, \
33f727efa7c4 PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 209
diff changeset
    15
     __version__
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    16
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    17
__all__ = [
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    18
    # version information from VERSION
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    19
    '__author__', '__date__', '__version__',
209
c705a9e38962 VMM{/Config}: reduced docstrings. Added doc to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 208
diff changeset
    20
    # defined stuff
262
6eea85d8b91d VMM: moved some non-init functions to the new common module.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 256
diff changeset
    21
    'ENCODING', 'Configuration', 'set_configuration',
185
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    22
]
6e1ef32fbd82 VMM/*: Moved some methods from classes to modules __init__.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 174
diff changeset
    23
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    24
152
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    25
# Try to set all of the locales according to the current
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    26
# environment variables and get the character encoding.
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    27
try:
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    28
    locale.setlocale(locale.LC_ALL, '')
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    29
except locale.Error:
3dbee02711cd Ignore unsupported locale setting and silently fall back to 'C'.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 141
diff changeset
    30
    locale.setlocale(locale.LC_ALL, 'C')
138
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    31
ENCODING = locale.nl_langinfo(locale.CODESET)
617f27715b01 Reorganized module import.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 102
diff changeset
    32
256
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    33
Configuration = None
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    34
215
33f727efa7c4 PEP-8-ified the work of the last days.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 209
diff changeset
    35
gettext.install('vmm', '/usr/local/share/locale', unicode=1)
199
0684790fff7c VMM: renamed function chk_domainname() -> check_domainname().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 188
diff changeset
    36
0684790fff7c VMM: renamed function chk_domainname() -> check_domainname().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 188
diff changeset
    37
256
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    38
def set_configuration(cfg_obj):
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    39
    """Assigns the *cfg_obj* to the global `Configuration`.
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    40
    *cfg_obj* has to be a `VirtualMailManager.Config.Config` instance."""
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    41
    from VirtualMailManager.Config import Config
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    42
    assert isinstance(cfg_obj, Config)
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    43
    global Configuration
ae80282301a3 VMM: added 'Configuration' variable and set_configuration().
Pascal Volk <neverseen@users.sourceforge.net>
parents: 254
diff changeset
    44
    Configuration = cfg_obj