Skip to content

Commit 1e86675

Browse files
author
J. David Ibanez
committed
Refacor "manage_options"
1 parent 7fb5a4f commit 1e86675

5 files changed

+49
-78
lines changed

LanguageManager.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
# Import from Zope
2424
from App.class_init import InitializeClass
25+
from App.Management import Tabs
2526
from AccessControl import ClassSecurityInfo
2627

2728
# Import from Localizer
2829
from LocalFiles import LocalDTMLFile
29-
from utils import lang_negotiator
30+
from utils import lang_negotiator, _
3031

3132

32-
class LanguageManager(object):
33+
class LanguageManager(Tabs):
3334
""" """
3435

3536
security = ClassSecurityInfo()
@@ -153,9 +154,19 @@ def get_selected_language(self, **kw):
153154
# ZMI
154155
########################################################################
155156
manage_options = (
156-
{'label': u'Languages', 'action': 'manage_languages',
157-
'help': ('Localizer', 'LM_languages.stx')},
158-
)
157+
{'action': 'manage_languages', 'label': u'Languages',
158+
'help': ('Localizer', 'LM_languages.stx')},)
159+
160+
161+
def filtered_manage_options(self, REQUEST=None):
162+
options = Tabs.filtered_manage_options(self, REQUEST=REQUEST)
163+
r = []
164+
for option in options:
165+
option = option.copy()
166+
option['label'] = _(option['label'])
167+
r.append(option)
168+
169+
return r
159170

160171

161172
security.declareProtected('View management screens', 'manage_languages')

LocalContent.py

+9-19
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,15 @@ class LocalContent(CatalogAware, LocalPropertyManager, PropertyManager,
7272
body = LocalAttribute('body')
7373

7474

75-
def manage_options(self):
76-
""" """
77-
options = \
78-
LocalPropertyManager.manage_options \
79-
+ PropertyManager.manage_options[:1] \
80-
+ ({'action': 'manage_import', 'label': u'Import',
81-
'help': ('Localizer', 'MC_importExport.stx')},
82-
{'action': 'manage_export', 'label': u'Export',
83-
'help': ('Localizer', 'MC_importExport.stx')}) \
84-
+ PropertyManager.manage_options[1:] \
85-
+ SimpleItem.manage_options
86-
87-
r = []
88-
for option in options:
89-
option = option.copy()
90-
option['label'] = _(option['label'])
91-
r.append(option)
92-
93-
return r
75+
manage_options = \
76+
LocalPropertyManager.manage_options \
77+
+ PropertyManager.manage_options[:1] \
78+
+ ({'action': 'manage_import', 'label': u'Import',
79+
'help': ('Localizer', 'MC_importExport.stx')},
80+
{'action': 'manage_export', 'label': u'Export',
81+
'help': ('Localizer', 'MC_importExport.stx')}) \
82+
+ PropertyManager.manage_options[1:] \
83+
+ SimpleItem.manage_options
9484

9585

9686
def __init__(self, id, sourcelang, languages):

LocalFolder.py

+5-15
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,11 @@ def __init__(self, id, title, languages):
5757
self._local_attributes = ()
5858

5959

60-
def manage_options(self):
61-
""" """
62-
options = Folder.manage_options[:1] \
63-
+ ({'label': u'Attributes',
64-
'action': 'manage_attributes'},) \
65-
+ LanguageManager.manage_options \
66-
+ Folder.manage_options[1:]
67-
68-
r = []
69-
for option in options:
70-
option = option.copy()
71-
option['label'] = _(option['label'])
72-
r.append(option)
73-
74-
return r
60+
manage_options = \
61+
Folder.manage_options[:1] \
62+
+ ({'action': 'manage_attributes', 'label': u'Attributes'},) \
63+
+ LanguageManager.manage_options \
64+
+ Folder.manage_options[1:]
7565

7666

7767
# Manage attributes

Localizer.py

+9-19
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# Import Localizer modules
3232
from LocalFiles import LocalDTMLFile
3333
from MessageCatalog import MessageCatalog
34-
from utils import lang_negotiator, needs_upgrade, _
34+
from utils import lang_negotiator, needs_upgrade
3535
from LanguageManager import LanguageManager
3636

3737

@@ -65,24 +65,14 @@ class Localizer(LanguageManager, Folder):
6565

6666
security = ClassSecurityInfo()
6767

68-
def manage_options(self):
69-
"""The manage options are defined here so they can be translated"""
70-
options = (
71-
{'action': 'manage_upgradeForm',
72-
'filter': needs_upgrade,
73-
'label': u'Upgrade',
74-
'help': ('Localizer', 'Localizer_upgrade.stx')},
75-
Folder.manage_options[0]) \
76-
+ LanguageManager.manage_options \
77-
+ Folder.manage_options[1:]
78-
79-
r = []
80-
for option in options:
81-
option = option.copy()
82-
option['label'] = _(option['label'])
83-
r.append(option)
84-
85-
return r
68+
manage_options = (
69+
{'action': 'manage_upgradeForm',
70+
'filter': needs_upgrade,
71+
'label': u'Upgrade',
72+
'help': ('Localizer', 'Localizer_upgrade.stx')},
73+
Folder.manage_options[0]) \
74+
+ LanguageManager.manage_options \
75+
+ Folder.manage_options[1:]
8676

8777

8878
def __init__(self, title, languages):

MessageCatalog.py

+10-20
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,16 @@ def manage_beforeDelete(self, item, container):
308308
#######################################################################
309309
# Management screens
310310
#######################################################################
311-
def manage_options(self):
312-
""" """
313-
options = (
314-
{'label': u'Messages', 'action': 'manage_messages',
315-
'help': ('Localizer', 'MC_messages.stx')},
316-
{'label': u'Properties', 'action': 'manage_propertiesForm'},
317-
{'label': u'Import', 'action': 'manage_Import_form',
318-
'help': ('Localizer', 'MC_importExport.stx')},
319-
{'label': u'Export', 'action': 'manage_Export_form',
320-
'help': ('Localizer', 'MC_importExport.stx')}) \
321-
+ LanguageManager.manage_options \
322-
+ SimpleItem.manage_options
323-
324-
r = []
325-
for option in options:
326-
option = option.copy()
327-
option['label'] = _(option['label'])
328-
r.append(option)
329-
330-
return r
311+
manage_options = (
312+
{'label': u'Messages', 'action': 'manage_messages',
313+
'help': ('Localizer', 'MC_messages.stx')},
314+
{'label': u'Properties', 'action': 'manage_propertiesForm'},
315+
{'label': u'Import', 'action': 'manage_Import_form',
316+
'help': ('Localizer', 'MC_importExport.stx')},
317+
{'label': u'Export', 'action': 'manage_Export_form',
318+
'help': ('Localizer', 'MC_importExport.stx')}) \
319+
+ LanguageManager.manage_options \
320+
+ SimpleItem.manage_options
331321

332322

333323
#######################################################################

0 commit comments

Comments
 (0)