Univention Bugzilla – Attachment 6099 Details for
Bug 35839
settings/udm_syntax and udm_hook don't offer --messagecatalog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
univention-directory-manager-modules-messagecatalog.patch
univention-directory-manager-modules-messagecatalog.patch (text/plain), 11.00 KB, created by
Arvid Requate
on 2014-09-08 13:25:32 CEST
(
hide
)
Description:
univention-directory-manager-modules-messagecatalog.patch
Filename:
MIME Type:
Creator:
Arvid Requate
Created:
2014-09-08 13:25:32 CEST
Size:
11.00 KB
patch
obsolete
>Index: listener/udm_extension.py >=================================================================== >--- listener/udm_extension.py (Revision 52987) >+++ listener/udm_extension.py (Arbeitskopie) >@@ -137,8 +137,8 @@ > try: > if not install_python_file(objectclass, target_subdir, new_relative_filename, new_object_data): > return >+ install_messagecatalog(dn, new, objectclass) > if objectclass == 'univentionUDMModule': >- install_messagecatalog(dn, new) > install_umcregistration(dn, new) > install_umcicons(dn, new) > finally: >@@ -151,10 +151,10 @@ > listener.setuid(0) > try: > remove_python_file(objectclass, target_subdir, old_relative_filename) >+ remove_messagecatalog(dn, old, univentionUDMSyntax) > if objectclass == 'univentionUDMModule': > remove_umcicons(dn, old) > remove_umcregistration(dn, old) >- remove_messagecatalog(dn, old) > finally: > listener.unsetuid() > >@@ -475,9 +475,15 @@ > if parent_dir: > cleanup_python_moduledir(python_basedir, target_subdir, parent_dir) > >-def install_messagecatalog(dn, attrs): >+def install_messagecatalog(dn, attrs, objectclass): > translationfile_ldap_attribute = "univentionMessageCatalog" > translationfile_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (translationfile_ldap_attribute,) >+ if objectclass == 'univentionUDMModule': >+ prefix = "univention-admin-handlers" >+ elif objectclass == 'univentionUDMSyntax': >+ prefix = "univention-admin-syntax" >+ elif objectclass == 'univentionUDMHook': >+ prefix = "univention-admin-hooks" > > values = {} > for ldap_attribute in attrs.keys(): >@@ -490,7 +496,7 @@ > module_name = attrs.get('cn')[0] > for language_tag, mo_data_binary in values.items(): > targetdir = os.path.join(LOCALE_BASEDIR, language_tag, 'LC_MESSAGES') >- filename = os.path.join(targetdir, "univention-admin-handlers-%s.mo" % (module_name.replace('/', '-'),) ) >+ filename = os.path.join(targetdir, "%s-%s.mo" % (prefix, module_name.replace('/', '-'),) ) > if not os.path.exists(targetdir): > ud.debug(ud.LISTENER, ud.ERROR, '%s: Error writing %s. Parent directory does not exist.' % (name, filename)) > continue >@@ -497,9 +503,15 @@ > with open(filename, 'w') as f: > f.write(mo_data_binary) > >-def remove_messagecatalog(dn, attrs): >+def remove_messagecatalog(dn, attrs, objectclass): > translationfile_ldap_attribute = "univentionMessageCatalog" > translationfile_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (translationfile_ldap_attribute,) >+ if objectclass == 'univentionUDMModule': >+ prefix = "univention-admin-handlers" >+ elif objectclass == 'univentionUDMSyntax': >+ prefix = "univention-admin-syntax" >+ elif objectclass == 'univentionUDMHook': >+ prefix = "univention-admin-hooks" > > language_tags = [] > for ldap_attribute in attrs.keys(): >@@ -512,7 +524,7 @@ > module_name = attrs.get('cn')[0] > for language_tag in language_tags: > targetdir = os.path.join(LOCALE_BASEDIR, language_tag, 'LC_MESSAGES') >- filename = os.path.join(targetdir, "univention-admin-handlers-%s.mo" % (module_name.replace('/', '-'),) ) >+ filename = os.path.join(targetdir, "%s-%s.mo" % (prefix, module_name.replace('/', '-'),) ) > if not os.path.exists(targetdir): > ud.debug(ud.LISTENER, ud.ERROR, '%s: Error writing %s. Parent directory does not exist.' % (name, filename)) > continue >Index: modules/univention/admin/handlers/settings/udm_hook.py >=================================================================== >--- modules/univention/admin/handlers/settings/udm_hook.py (Revision 52987) >+++ modules/univention/admin/handlers/settings/udm_hook.py (Arbeitskopie) >@@ -146,6 +146,17 @@ > may_change=1, > identifies=0 > ), >+ 'messagecatalog': univention.admin.property( >+ short_description=_('GNU message catalog for translations'), >+ long_description='GNU message catalog (syntax: <language tag> <Base64 encoded GNU message catalog>)', >+ syntax=univention.admin.syntax.Localesubdirname_and_GNUMessageCatalog, >+ multivalue=1, >+ include_in_default_search=0, >+ options=[], >+ required=0, >+ may_change=1, >+ identifies=0, >+ ), > } > > layout = [ >@@ -154,6 +165,7 @@ > ["name"], > ["filename"], > ["data"], >+ ["messagecatalog"], > ] ), > Group( _( 'Metadata' ), layout = [ > ["package"], >@@ -180,6 +192,7 @@ > mapping.register('packageversion', 'univentionOwnedByPackageVersion', None, univention.admin.mapping.ListToString) > mapping.register('ucsversionstart', 'univentionUCSVersionStart', None, univention.admin.mapping.ListToString) > mapping.register('ucsversionend', 'univentionUCSVersionEnd', None, univention.admin.mapping.ListToString) >+## messagecatalog is handled via object._post_map and object._post_unmap defined below > > class object(univention.admin.handlers.simpleLdap): > module=module >@@ -218,7 +231,44 @@ > if not apt.apt_pkg.version_compare(self['packageversion'], old_version) > -1: > raise univention.admin.uexceptions.valueInvalidSyntax, _('packageversion: Version must not be lower than the current one.') > >+ def _post_unmap( self, info, values ): >+ info['messagecatalog'] = [] >+ messagecatalog_ldap_attribute = "univentionMessageCatalog" >+ messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,) >+ for ldap_attribute, value_list in values.items(): >+ if ldap_attribute.startswith(messagecatalog_ldap_attribute_and_tag_prefix): >+ language_tag = ldap_attribute.split(messagecatalog_ldap_attribute_and_tag_prefix, 1)[1] >+ mo_data_base64 = univention.admin.mapping.unmapBase64(value_list) >+ info['messagecatalog'].append( (language_tag, mo_data_base64) ) >+ return info >+ >+ def _post_map( self, modlist, diff ): >+ messagecatalog_ldap_attribute = "univentionMessageCatalog" >+ messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,) >+ for property_name, old_value, new_value in diff: >+ if property_name == 'messagecatalog': >+ old_dict = dict( old_value ) >+ new_dict = dict( new_value ) >+ for language_tag, old_mo_data_base64 in old_dict.items(): >+ ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag)) >+ new_mo_data_base64 = new_dict.get(language_tag) >+ if not new_mo_data_base64: # property value has been removed >+ old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64) >+ modlist.append( ( ldap_attribute, old_mo_data_binary, None ) ) >+ else: >+ if new_mo_data_base64 != old_mo_data_base64: >+ old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64) >+ new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64) >+ modlist.append( ( ldap_attribute, old_mo_data_binary, new_mo_data_binary ) ) >+ for language_tag, new_mo_data_base64 in new_dict.items(): >+ ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag)) >+ if not old_dict.get(language_tag): # property value has been added >+ new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64) >+ modlist.append( ( ldap_attribute, None, new_mo_data_binary ) ) >+ break >+ return modlist > >+ > def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0): > > filter=univention.admin.filter.conjunction('&', [ >Index: modules/univention/admin/handlers/settings/udm_syntax.py >=================================================================== >--- modules/univention/admin/handlers/settings/udm_syntax.py (Revision 52987) >+++ modules/univention/admin/handlers/settings/udm_syntax.py (Arbeitskopie) >@@ -146,6 +146,17 @@ > may_change=1, > identifies=0 > ), >+ 'messagecatalog': univention.admin.property( >+ short_description=_('GNU message catalog for translations'), >+ long_description='GNU message catalog (syntax: <language tag> <Base64 encoded GNU message catalog>)', >+ syntax=univention.admin.syntax.Localesubdirname_and_GNUMessageCatalog, >+ multivalue=1, >+ include_in_default_search=0, >+ options=[], >+ required=0, >+ may_change=1, >+ identifies=0, >+ ), > } > > layout = [ >@@ -154,6 +165,7 @@ > ["name"], > ["filename"], > ["data"], >+ ["messagecatalog"], > ] ), > Group( _( 'Metadata' ), layout = [ > ["package"], >@@ -180,6 +192,7 @@ > mapping.register('packageversion', 'univentionOwnedByPackageVersion', None, univention.admin.mapping.ListToString) > mapping.register('ucsversionstart', 'univentionUCSVersionStart', None, univention.admin.mapping.ListToString) > mapping.register('ucsversionend', 'univentionUCSVersionEnd', None, univention.admin.mapping.ListToString) >+## messagecatalog is handled via object._post_map and object._post_unmap defined below > > class object(univention.admin.handlers.simpleLdap): > module=module >@@ -218,6 +231,43 @@ > if not apt.apt_pkg.version_compare(self['packageversion'], old_version) > -1: > raise univention.admin.uexceptions.valueInvalidSyntax, _('packageversion: Version must not be lower than the current one.') > >+ def _post_unmap( self, info, values ): >+ info['messagecatalog'] = [] >+ messagecatalog_ldap_attribute = "univentionMessageCatalog" >+ messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,) >+ for ldap_attribute, value_list in values.items(): >+ if ldap_attribute.startswith(messagecatalog_ldap_attribute_and_tag_prefix): >+ language_tag = ldap_attribute.split(messagecatalog_ldap_attribute_and_tag_prefix, 1)[1] >+ mo_data_base64 = univention.admin.mapping.unmapBase64(value_list) >+ info['messagecatalog'].append( (language_tag, mo_data_base64) ) >+ return info >+ >+ def _post_map( self, modlist, diff ): >+ messagecatalog_ldap_attribute = "univentionMessageCatalog" >+ messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,) >+ for property_name, old_value, new_value in diff: >+ if property_name == 'messagecatalog': >+ old_dict = dict( old_value ) >+ new_dict = dict( new_value ) >+ for language_tag, old_mo_data_base64 in old_dict.items(): >+ ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag)) >+ new_mo_data_base64 = new_dict.get(language_tag) >+ if not new_mo_data_base64: # property value has been removed >+ old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64) >+ modlist.append( ( ldap_attribute, old_mo_data_binary, None ) ) >+ else: >+ if new_mo_data_base64 != old_mo_data_base64: >+ old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64) >+ new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64) >+ modlist.append( ( ldap_attribute, old_mo_data_binary, new_mo_data_binary ) ) >+ for language_tag, new_mo_data_base64 in new_dict.items(): >+ ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag)) >+ if not old_dict.get(language_tag): # property value has been added >+ new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64) >+ modlist.append( ( ldap_attribute, None, new_mo_data_binary ) ) >+ break >+ return modlist >+ > > def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0, required=0, timeout=-1, sizelimit=0): >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 35839
: 6099