Changeset 10605 for main/waeup.cas/trunk/waeup
- Timestamp:
- 10 Sep 2013, 14:24:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/server.py
r10602 r10605 4 4 import os 5 5 import random 6 import re 6 7 import time 7 8 try: … … 28 29 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 29 30 '01234567789-') 31 32 #: A regular expression that matches a div tag around a MSG_TEXT 33 RE_MSG_TAG = re.compile('\<div id="msg".*MSG_TEXT[^<]*</div>', re.DOTALL) 30 34 31 35 … … 233 237 # show logged-in screen 234 238 html = get_template('login_successful.html') 235 html = html.replace('MSG_TEXT', msg)239 html = set_message(msg, html) 236 240 resp = Response(html) 237 241 if not sso: 238 242 resp = set_session_cookie(db, resp) 239 243 return resp 244 245 246 def set_message(msg, html): 247 """Insert a message box in html template. 248 249 If the message is empty, not only the string `MSG_TEXT` is removed 250 from `html`, but also any encapsulating ``<div>`` tag with id 251 ``msg``. 252 253 This makes it possible to give message boxes certain additional 254 styles that will not show up if there is no message to display. 255 """ 256 if not msg: 257 if not '<div id="msg"' in html: 258 return html.replace('MSG_TEXT', '') 259 return RE_MSG_TAG.sub('', html) 260 return html.replace('MSG_TEXT', msg) 240 261 241 262 … … 325 346 html = html.replace('LT_VALUE', lt.ticket) 326 347 html = html.replace('SERVICE_FIELD_VALUE', service_field) 327 html = html.replace('MSG_TEXT', msg)348 html = set_message(msg, html) 328 349 return Response(html) 329 350
Note: See TracChangeset for help on using the changeset viewer.