1
0
forked from ScoDoc/ScoDoc

enhance request compat

This commit is contained in:
Emmanuel Viennet 2021-06-21 23:13:57 +02:00
parent f177e777a9
commit 7c1263060e
5 changed files with 7 additions and 8 deletions

View File

@ -48,6 +48,7 @@ class ZRequest(object):
self.QUERY_STRING = request.query_string.encode("utf-8") self.QUERY_STRING = request.query_string.encode("utf-8")
self.REQUEST_METHOD = request.method.encode("utf-8") self.REQUEST_METHOD = request.method.encode("utf-8")
self.AUTHENTICATED_USER = current_user self.AUTHENTICATED_USER = current_user
self.REMOTE_ADDR = request.remote_addr
if request.method == "POST": if request.method == "POST":
self.form = request.form # xxx encode en utf-8 ! self.form = request.form # xxx encode en utf-8 !
# Encode en utf-8 pour ScoDoc8 #sco8 # Encode en utf-8 pour ScoDoc8 #sco8

View File

@ -129,7 +129,6 @@ class DummyRequest:
self.URL = "http://scodoc/" self.URL = "http://scodoc/"
self.URL0 = self.URL self.URL0 = self.URL
self.BASE0 = "localhost" self.BASE0 = "localhost"
self.REMOTE_HOST = "localhost"
self.REMOTE_ADDR = "127.0.0.1" self.REMOTE_ADDR = "127.0.0.1"
self.HTTP_REFERER = "" self.HTTP_REFERER = ""
self.REQUEST_METHOD = "get" self.REQUEST_METHOD = "get"

View File

@ -1148,7 +1148,8 @@ def evaluation_create_form(
+ "Modification évaluation impossible pour %s" + "Modification évaluation impossible pour %s"
% scu.get_current_user_name(REQUEST) % scu.get_current_user_name(REQUEST)
+ "</p>" + "</p>"
+ '<p><a href="%s">Revenir</a></p>' % (str(REQUEST.HTTP_REFERER),) + '<p><a href="moduleimpl_status?moduleimpl_id=%s">Revenir</a></p>'
% (moduleimpl_id,)
+ html_sco_header.sco_footer(context, REQUEST) + html_sco_header.sco_footer(context, REQUEST)
) )
if readonly: if readonly:

View File

@ -42,18 +42,17 @@ def logdb(REQUEST=None, cnx=None, method=None, etudid=None, msg=None, commit=Tru
args = { args = {
"authenticated_user": str(REQUEST.AUTHENTICATED_USER), "authenticated_user": str(REQUEST.AUTHENTICATED_USER),
"remote_addr": REQUEST.REMOTE_ADDR, "remote_addr": REQUEST.REMOTE_ADDR,
"remote_host": REQUEST.REMOTE_HOST,
} }
else: else:
args = {"authenticated_user": None, "remote_addr": None, "remote_host": None} args = {"authenticated_user": None, "remote_addr": None}
args.update({"method": method, "etudid": etudid, "msg": msg}) args.update({"method": method, "etudid": etudid, "msg": msg})
ndb.quote_dict(args) ndb.quote_dict(args)
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
cursor.execute( cursor.execute(
"""INSERT INTO scolog """INSERT INTO scolog
(authenticated_user,remote_addr,remote_host,method,etudid,msg) (authenticated_user,remote_addr,method,etudid,msg)
VALUES VALUES
(%(authenticated_user)s,%(remote_addr)s,%(remote_host)s,%(method)s,%(etudid)s,%(msg)s)""", (%(authenticated_user)s,%(remote_addr)s,%(method)s,%(etudid)s,%(msg)s)""",
args, args,
) )
if commit: if commit:

View File

@ -959,8 +959,7 @@ def EtatAbsencesDate(
else: else:
H.append( H.append(
"""<h2>Erreur: vous n'avez pas choisi de date !</h2> """<h2>Erreur: vous n'avez pas choisi de date !</h2>
<a class="stdlink" href="%s">Continuer</a>""" """
% REQUEST.HTTP_REFERER
) )
return "\n".join(H) + html_sco_header.sco_footer(REQUEST) return "\n".join(H) + html_sco_header.sco_footer(REQUEST)