[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, appyTool.create('translations', noSecurity=True,
id=language, title=title) id=language, title=title)
appyTool.log('Translation object created for "%s".' % language) 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 appFolder = self.config.diskFolder
appName = self.config.PROJECTNAME appName = self.config.PROJECTNAME
i18nFolder = os.path.join(appFolder, 'tr') i18nFolder = os.path.join(appFolder, 'tr')
@ -340,8 +345,6 @@ class ZopeInstaller:
appyTool.log('Translation "%s" updated from "%s".' % \ appyTool.log('Translation "%s" updated from "%s".' % \
(translation.id, poName)) (translation.id, poName))
# Execute custom installation code if any
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
def configureSessions(self): def configureSessions(self):
'''Configure the session machinery.''' '''Configure the session machinery.'''

View file

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

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

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