[gen] Added boolean Tool.loadTranslationsAtStartup that, if False, prevents to overwrite, on a production site, translations edited through-the-web by users. If True, at every Zope startup, Translation objects are overwritten by the content of their corresponding po files on disk.

This commit is contained in:
Gaetan Delannay 2012-06-03 21:55:26 +02:00
parent 8f57163c2a
commit 5b255ce55d
3 changed files with 24 additions and 19 deletions

View file

@ -326,8 +326,13 @@ class ZopeInstaller:
appyTool.create('translations', noSecurity=True,
id=language, title=title)
appyTool.log('Translation object created for "%s".' % language)
# Now, we synchronise every Translation object with the corresponding
# "po" file on disk.
# Execute custom installation code if any
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
# Now, if required, we synchronise every Translation object with the
# corresponding "po" file on disk.
if appyTool.loadTranslationsAtStartup:
appFolder = self.config.diskFolder
appName = self.config.PROJECTNAME
i18nFolder = os.path.join(appFolder, 'tr')
@ -340,8 +345,6 @@ class ZopeInstaller:
appyTool.log('Translation "%s" updated from "%s".' % \
(translation.id, poName))
# Execute custom installation code if any
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
def configureSessions(self):
'''Configure the session machinery.'''

View file

@ -213,9 +213,9 @@ toolFieldPrefixes = ('defaultValue', 'podTemplate', 'formats', 'resultColumns',
'searchFields', 'optionalFields', 'showWorkflow',
'showAllStatesInPhase')
defaultToolFields = ('title', 'mailHost', 'mailEnabled', 'mailFrom',
'appyVersion', 'users', 'groups', 'translations', 'pages',
'unoEnabledPython','openOfficePort',
'numberOfResultsPerPage')
'appyVersion', 'users', 'groups', 'translations',
'loadTranslationsAtStartup', 'pages', 'unoEnabledPython',
'openOfficePort', 'numberOfResultsPerPage')
class Tool(ModelClass):
# In a ModelClass we need to declare attributes in the following list.
@ -242,10 +242,11 @@ class Tool(ModelClass):
page=gen.Page('groups', show=isManager),
queryable=True, queryFields=('title', 'login'),
showHeaders=True, shownInfo=('title', 'login', 'roles'))
pt = gen.Page('translations', show=isManager)
translations = gen.Ref(Translation, multiplicity=(0,None), add=False,
link=False, show='view',
back=gen.Ref(attribute='trToTool', show=False),
page=gen.Page('translations', show=isManager))
link=False, show='view', page=pt,
back=gen.Ref(attribute='trToTool', show=False))
loadTranslationsAtStartup = gen.Boolean(default=True, show=False, page=pt)
pages = gen.Ref(Page, multiplicity=(0,None), add=True, link=False,
show='view', back=gen.Ref(attribute='toTool3', show=False),
page=gen.Page('pages', show=isManager))

1
gen/ui/icons.pt Normal file
View file

@ -0,0 +1 @@
<span metal:define-macro="icons"></span>