View | Details | Raw Unified | Return to bug 33359
Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/__init__.py (-2 / +6 lines)
 Lines 30-37    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
import copy, types, string, re
33
import types, re, sys
34
import mapping
35
import univention.config_registry
34
import univention.config_registry
36
import univention.debug
35
import univention.debug
37
36
 Lines 471-476   def __init__(self, id, short_description=None, long_description='', members=[]): Link Here 
471
		self.long_description=long_description
470
		self.long_description=long_description
472
		self.members=members
471
		self.members=members
473
472
473
univention.admin = sys.modules[__name__]
474
from univention.admin import modules, objects, syntax, hook, mapping
475
syntax.import_syntax_files()
476
hook.import_hook_files()
477
474
if __name__ == '__main__':
478
if __name__ == '__main__':
475
	prop = property( '_replace' )
479
	prop = property( '_replace' )
476
	for pattern in ( '<firstname>', '<firstname> <lastname>', '<firstname:upper>', '<:trim,upper><firstname> <lastname>     ', '<:lower><firstname> <lastname>', '<:umlauts><firstname> <lastname>' ):
480
	for pattern in ( '<firstname>', '<firstname> <lastname>', '<firstname:upper>', '<:trim,upper><firstname> <lastname>     ', '<:lower><firstname> <lastname>', '<:umlauts><firstname> <lastname>' ):
(-)a/management/univention-directory-manager-modules/modules/univention/admin/hook.py (-10 / +8 lines)
 Lines 30-45    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
import re, string, types, math, time, operator
34
import univention.debug
33
import univention.debug
35
import univention.admin.modules
34
import univention.admin.modules
36
import univention.admin.uexceptions
35
import univention.admin.uexceptions
37
import univention.admin.localization
36
from univention.admin import localization
38
import base64
37
import sys
39
import copy
38
import os
40
import sys, os
39
import traceback
41
40
42
translation=univention.admin.localization.translation('univention/admin')
41
translation=localization.translation('univention/admin')
43
_=translation.translate
42
_=translation.translate
44
43
45
#
44
#
 Lines 53-65   def import_hook_files(): Link Here 
53
					if f.endswith('.py'):
52
					if f.endswith('.py'):
54
						fn = os.path.join( dir, 'univention/admin/hooks.d/', f )
53
						fn = os.path.join( dir, 'univention/admin/hooks.d/', f )
55
						try:
54
						try:
56
							fd = open( fn, 'r' )
55
							with open(fn, 'r') as fd:
57
							exec fd in univention.admin.hook.__dict__
56
								exec fd in sys.modules[__name__].__dict__
58
							univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_hook_files: importing "%s"' % fn)
57
							univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_hook_files: importing "%s"' % fn)
59
						except:
58
						except:
60
							univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.syntax.import_hook_files: loading %s failed' % fn )
59
							univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.syntax.import_hook_files: loading %s failed' % fn )
61
							import traceback
60
							univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.syntax.import_hook_files: TRACEBACK:\n%s' % traceback.format_exc() )
62
							univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_hook_files: TRACEBACK:\n%s' % traceback.format_exc() )
63
61
64
62
65
63
(-)a/management/univention-directory-manager-modules/modules/univention/admin/modules.py (-8 / +2 lines)
 Lines 43-52    Link Here 
43
import univention.admin.uldap
43
import univention.admin.uldap
44
import univention.admin.syntax
44
import univention.admin.syntax
45
import univention.admin.hook
45
import univention.admin.hook
46
import univention.admin.localization
46
from univention.admin import localization
47
from univention.admin.layout import Tab, Group, ILayoutElement
47
from univention.admin.layout import Tab, Group, ILayoutElement
48
48
49
translation=univention.admin.localization.translation('univention/admin')
49
translation=localization.translation('univention/admin')
50
_=translation.translate
50
_=translation.translate
51
51
52
modules={}
52
modules={}
 Lines 978-986   def childModules(module_name): Link Here 
978
	module = get(module_name)
978
	module = get(module_name)
979
	return copy.deepcopy( getattr(module, 'childmodules', []) )
979
	return copy.deepcopy( getattr(module, 'childmodules', []) )
980
980
981
univention.admin.syntax.import_syntax_files()
982
univention.admin.hook.import_hook_files()
983
984
# The update will cause in a recursion, see https://forge.univention.org/bugzilla/show_bug.cgi?id=22439
985
# update()
986
(-)a/management/univention-directory-manager-modules/modules/univention/admin/syntax.py (-7 / +10 lines)
 Lines 38-44    Link Here 
38
import univention.debug
38
import univention.debug
39
import univention.admin.modules
39
import univention.admin.modules
40
import univention.admin.uexceptions
40
import univention.admin.uexceptions
41
import univention.admin.localization
41
from univention.admin import localization
42
try:
42
try:
43
	from univention.lib.ucs import UCS_Version
43
	from univention.lib.ucs import UCS_Version
44
	from univention.lib.umc_module import get_mime_type, get_mime_description, image_mime_type_of_buffer
44
	from univention.lib.umc_module import get_mime_type, get_mime_description, image_mime_type_of_buffer
 Lines 58-70    Link Here 
58
import locale
58
import locale
59
from operator import itemgetter
59
from operator import itemgetter
60
60
61
translation=univention.admin.localization.translation('univention/admin')
61
translation=localization.translation('univention/admin')
62
_=translation.translate
62
_=translation.translate
63
63
64
#
64
#
65
# load all additional syntax files from */site-packages/univention/admin/syntax.d/*.py
65
# load all additional syntax files from */site-packages/univention/admin/syntax.d/*.py
66
#
66
#
67
def import_syntax_files():
67
def import_syntax_files():
68
	global _  # don't allow syntax to overwrite our global _ function.
68
	gettext = _
69
	gettext = _
69
	for dir_ in sys.path:
70
	for dir_ in sys.path:
70
		syntax_py = os.path.join(dir_, 'univention/admin/syntax.py')
71
		syntax_py = os.path.join(dir_, 'univention/admin/syntax.py')
 Lines 75-86   def import_syntax_files(): Link Here 
75
76
76
			for fn in syntax_files:
77
			for fn in syntax_files:
77
				try:
78
				try:
78
					fd = open( fn, 'r' )
79
					with open(fn, 'r') as fd:
79
					exec fd in univention.admin.syntax.__dict__
80
						exec fd in sys.modules[__name__].__dict__
80
					univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_syntax_files: importing "%s"' % fn)
81
					univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_syntax_files: importing "%s"' % fn)
81
				except:
82
				except:
82
					univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.syntax.import_syntax_files: loading %s failed' % fn )
83
					univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.syntax.import_syntax_files: loading %s failed' % fn )
83
	univention.admin.syntax.__dict__['_'] = gettext
84
					univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.syntax.import_syntax_files: TRACEBACK:\n%s' % traceback.format_exc() )
85
				_ = gettext
86
	_ = gettext
84
87
85
choice_update_functions = []
88
choice_update_functions = []
86
def __register_choice_update_function(func):
89
def __register_choice_update_function(func):
 Lines 3050-3056   class Country(select): Link Here 
3050
3053
3051
	@classmethod
3054
	@classmethod
3052
	def update_choices(cls):
3055
	def update_choices(cls):
3053
		iso_3166 = univention.admin.localization.translation('iso_3166')
3056
		iso_3166 = localization.translation('iso_3166')
3054
		iso_3166.set_language(str(translation.locale))
3057
		iso_3166.set_language(str(translation.locale))
3055
		_iso_3166 = iso_3166.translate
3058
		_iso_3166 = iso_3166.translate
3056
3059
(-)a/management/univention-directory-manager-modules/modules/univention/admin/uexceptions.py (-2 / +2 lines)
 Lines 30-39    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
import univention.admin.localization
33
from univention.admin import localization
34
from univention.admin import configRegistry
34
from univention.admin import configRegistry
35
35
36
translation=univention.admin.localization.translation('univention/admin')
36
translation=localization.translation('univention/admin')
37
_=translation.translate
37
_=translation.translate
38
38
39
39
(-)a/management/univention-directory-manager-modules/modules/univention/admin/uldap.py (-2 / +2 lines)
 Lines 34-40    Link Here 
34
import univention.uldap
34
import univention.uldap
35
import string
35
import string
36
import time
36
import time
37
import univention.admin.localization
37
from univention.admin import localization
38
import univention.config_registry
38
import univention.config_registry
39
39
40
try:
40
try:
 Lines 43-49    Link Here 
43
except:
43
except:
44
	GPLversion=True
44
	GPLversion=True
45
45
46
translation=univention.admin.localization.translation('univention/admin')
46
translation=localization.translation('univention/admin')
47
_=translation.translate
47
_=translation.translate
48
48
49
configRegistry=univention.config_registry.ConfigRegistry()
49
configRegistry=univention.config_registry.ConfigRegistry()

Return to bug 33359