Skip to content

Commit

Permalink
avoid implicit session creation outside zmi
Browse files Browse the repository at this point in the history
 Add REQUEST variable is_zmi to limit manage_lang determination (#190)
  • Loading branch information
drfho authored Oct 4, 2023
1 parent cf8040d commit 14214eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions Products/zms/ZMSItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def zmi_page_request(self, *args, **kwargs):
RESPONSE.setHeader('Content-Type', 'text/html;charset=%s'%request['ZMS_CHARSET'])
if not request.get( 'preview'):
request.set( 'preview', 'preview')
request.set( 'is_zmi', True)
langs = self.getLanguages(request)
if request.get('lang') not in langs:
request.set('lang', langs[0])
Expand Down
27 changes: 14 additions & 13 deletions Products/zms/_multilangmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,20 @@ def get_manage_lang(self):
"""
manage_lang = None
req = getattr( self, 'REQUEST', None)
if req is not None:
sess = standard.get_session(self)
if 'manage_lang' in req:
manage_lang = req.get('manage_lang')
else:
if sess is not None and 'reset_manage_lang' not in req.form:
manage_lang = sess.get('manage_lang')
if manage_lang is None:
lang = req.get('lang')
if lang in self.getLangIds():
manage_lang = self.getLang(lang).get('manage')
if sess is not None:
sess.set('manage_lang', manage_lang)
if req.get( 'is_zmi', False):
if req is not None:
sess = standard.get_session(self)
if 'manage_lang' in req:
manage_lang = req.get('manage_lang')
else:
if sess is not None and 'reset_manage_lang' not in req.form:
manage_lang = sess.get('manage_lang')
if manage_lang is None:
lang = req.get('lang')
if lang in self.getLangIds():
manage_lang = self.getLang(lang).get('manage')
if sess is not None:
sess.set('manage_lang', manage_lang)
if manage_lang is None:
manage_lang = 'eng'
return manage_lang
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/_objinputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def getUrlInput(self, fmName, elName, elTextName='', size=None, value='', enable
# @return String
# ----------------------------------------------------------------------------
def getDateTimeInput(self, fmName, elName, size=8, value=None, enabled=True, fmt_str='DATETIME_FMT', css='form-control'):
manage_lang = self.get_manage_lang()
manage_lang = self.REQUEST.get('manage_lang', self.getPrimaryLanguage())
html = []
input_type = 'date'
if not isinstance(value, str):
Expand Down

0 comments on commit 14214eb

Please sign in to comment.