121
120
return http.redirect_with_hash(*args, **kw)
122
def ensure_db(redirect='/web/database/selector'):
123
# This helper should be used in web client auth="none" routes
124
# if those routes needs a db to work with.
125
# If the heuristics does not find any database, then the users will be
126
# redirected to db selector or any url specified by `redirect` argument.
127
# If the db is taken out of a query parameter, it will be checked against
128
# `http.db_filter()` in order to ensure it's legit and thus avoid db
129
# forgering that could lead to xss attacks.
130
db = request.params.get('db')
133
if db and db not in http.db_filter([db]):
136
# if db not provided, use the session one
138
db = request.session.db
140
# if no database provided and no database in session, use monodb
142
db = db_monodb(request.httprequest)
144
# if no db can be found til here, send to the database selector
145
# the database selector will redirect to database manager if needed
147
werkzeug.exceptions.abort(werkzeug.utils.redirect(redirect, 303))
149
# always switch the session to the computed db
150
if db != request.session.db:
151
request.session.logout()
153
request.session.db = db
123
155
def module_topological_sort(modules):
124
156
""" Return a list of module names sorted so that their dependencies of the
125
157
modules are listed before the module itself
323
355
path = '/web/webclient/' + extension
324
356
if mods is not None:
325
path += '?' + urllib.urlencode({'mods': mods})
357
path += '?' + werkzeug.url_encode({'mods': mods})
327
path += '?' + urllib.urlencode({'db': db})
359
path += '?' + werkzeug.url_encode({'db': db})
329
361
remotes = [wp for fp, wp in files if fp is None]
330
362
return [path] + remotes
585
617
@http.route('/web', type='http', auth="none")
586
618
def web_client(self, s_action=None, **kw):
589
621
if request.session.uid:
590
622
html = render_bootstrap_template(request.session.db, "web.webclient_bootstrap")
595
627
@http.route('/web/login', type='http', auth="none")
596
628
def web_login(self, redirect=None, **kw):
597
http.ensure_db(with_registry=True)
599
631
values = request.params.copy()