VMM: added 'Configuration' variable and set_configuration(). v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Sun, 18 Apr 2010 15:42:46 +0000
branchv0.6.x
changeset 256 ae80282301a3
parent 255 d2ddd4a6528d
child 257 5b8fde01e4f0
VMM: added 'Configuration' variable and set_configuration(). Handler.__init__() now exports its config via set_configuration().
TODO
VirtualMailManager/Handler.py
VirtualMailManager/__init__.py
--- a/TODO	Sat Apr 17 21:39:00 2010 +0000
+++ b/TODO	Sun Apr 18 15:42:46 2010 +0000
@@ -13,3 +13,9 @@
         + aliases
         + destinations/alias
         + alias domains
+
+Database:
+   public.users.passwd: increase to "character varying(150)"
+   	why? `doveadm pw -s SSHA512.hex -p 1`
+   public.users.digestmd5: add "character varying(48)"
+	Outlook will love it. (`doveadm pw -s DIGEST-MD5.hex -p 1 -u 0`)
--- a/VirtualMailManager/Handler.py	Sat Apr 17 21:39:00 2010 +0000
+++ b/VirtualMailManager/Handler.py	Sun Apr 18 15:42:46 2010 +0000
@@ -21,7 +21,7 @@
 from pyPgSQL import PgSQL  # python-pgsql - http://pypgsql.sourceforge.net
 
 import VirtualMailManager.constants.ERROR as ERR
-from VirtualMailManager import ENCODING, exec_ok
+from VirtualMailManager import ENCODING, exec_ok, set_configuration
 from VirtualMailManager.Account import Account
 from VirtualMailManager.Alias import Alias
 from VirtualMailManager.AliasDomain import AliasDomain
@@ -73,8 +73,10 @@
         if not skip_some_checks:
             self._Cfg.check()
             self._chkenv()
-            self._scheme = self._Cfg.dget('misc.password_scheme')
-            self._postconf = Postconf(self._Cfg.dget('bin.postconf'))
+            # will be moved to the new password module and Alias
+            #self._scheme = self._Cfg.dget('misc.password_scheme')
+            #self._postconf = Postconf(self._Cfg.dget('bin.postconf'))
+        set_configuration(self._Cfg)
 
     def __findCfgFile(self):
         for path in ['/root', '/usr/local/etc', '/etc']:
--- a/VirtualMailManager/__init__.py	Sat Apr 17 21:39:00 2010 +0000
+++ b/VirtualMailManager/__init__.py	Sun Apr 18 15:42:46 2010 +0000
@@ -24,7 +24,8 @@
     # version information from VERSION
     '__author__', '__date__', '__version__',
     # defined stuff
-    'ENCODING', 'exec_ok', 'expand_path', 'get_unicode', 'is_dir',
+    'ENCODING', 'Configuration', 'exec_ok', 'expand_path', 'get_unicode',
+    'is_dir', 'set_configuration',
 ]
 
 
@@ -36,12 +37,23 @@
     locale.setlocale(locale.LC_ALL, 'C')
 ENCODING = locale.nl_langinfo(locale.CODESET)
 
+Configuration = None
+
 gettext.install('vmm', '/usr/local/share/locale', unicode=1)
 
 
 _ = lambda msg: msg
 
 
+def set_configuration(cfg_obj):
+    """Assigns the *cfg_obj* to the global `Configuration`.
+    *cfg_obj* has to be a `VirtualMailManager.Config.Config` instance."""
+    from VirtualMailManager.Config import Config
+    assert isinstance(cfg_obj, Config)
+    global Configuration
+    Configuration = cfg_obj
+
+
 def get_unicode(string):
     """Converts `string` to `unicode`, if necessary."""
     if isinstance(string, unicode):