diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-01-19 17:15:56 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-01-19 17:15:56 +0100 |
| commit | 18e22be138f4d273ce8f63c0ff2c8a437cf6ce5d (patch) | |
| tree | 63bd658de7b6fa0e91d521ca19322dd68bdc1492 /addons/web/controllers | |
| parent | f6e5bf847b1a7107c09b009a757823b0f9514fa4 (diff) | |
| parent | 0aab81cd3ac6881b2b64ccedb901b55badd421d4 (diff) | |
[MERGE] forward port of branch 8.0 up to 0aab81c
Diffstat (limited to 'addons/web/controllers')
| -rw-r--r-- | addons/web/controllers/main.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index e95e8f3c58b..cec9ae94837 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -744,24 +744,21 @@ class Database(http.Controller): return {'error': _('Could not drop database !'), 'title': _('Drop Database')} @http.route('/web/database/backup', type='http', auth="none") - def backup(self, backup_db, backup_pwd, token, **kwargs): + def backup(self, backup_db, backup_pwd, token, backup_format='zip'): try: - format = kwargs.get('format') - ext = "zip" if format == 'zip' else "dump" - db_dump = base64.b64decode( - request.session.proxy("db").dump(backup_pwd, backup_db, format)) - filename = "%(db)s_%(timestamp)s.%(ext)s" % { - 'db': backup_db, - 'timestamp': datetime.datetime.utcnow().strftime( - "%Y-%m-%d_%H-%M-%SZ"), - 'ext': ext - } - return request.make_response(db_dump, - [('Content-Type', 'application/octet-stream; charset=binary'), - ('Content-Disposition', content_disposition(filename))], - {'fileToken': token} - ) + openerp.service.security.check_super(backup_pwd) + ts = datetime.datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S") + filename = "%s_%s.%s" % (backup_db, ts, backup_format) + headers = [ + ('Content-Type', 'application/octet-stream; charset=binary'), + ('Content-Disposition', content_disposition(filename)), + ] + dump_stream = openerp.service.db.dump_db(backup_db, None, backup_format) + response = werkzeug.wrappers.Response(dump_stream, headers=headers, direct_passthrough=True) + response.set_cookie('fileToken', token) + return response except Exception, e: + _logger.exception('Database.backup') return simplejson.dumps([[],[{'error': openerp.tools.ustr(e), 'title': _('Backup Database')}]]) @http.route('/web/database/restore', type='http', auth="none") |
