[MERGE] upstream
authorFabien Meghazi <fme@openerp.com>
Wed, 26 Mar 2014 15:24:33 +0000 (16:24 +0100)
committerFabien Meghazi <fme@openerp.com>
Wed, 26 Mar 2014 15:24:33 +0000 (16:24 +0100)
bzr revid: fme@openerp.com-20140326152433-vegu5tuvr8vc1s8v

1  2 
addons/website/models/ir_http.py
addons/website/models/website.py
addons/website/static/src/js/website.editor.js

@@@ -92,33 -91,14 +92,38 @@@ class ir_http(orm.AbstractModel)
              assert path is not None
          except Exception:
              return self._handle_exception(werkzeug.exceptions.NotFound())
-         if path != request.httprequest.path:
+         generated_path = werkzeug.url_unquote_plus(path)
+         current_path = werkzeug.url_unquote_plus(request.httprequest.path)
+         if generated_path != current_path:
+             if request.lang != request.website.default_lang_code:
+                 path = '/' + request.lang + path
              return werkzeug.utils.redirect(path)
  
 +    def _serve_attachment(self):
 +        domain = [('type', '=', 'binary'), ('url', '=', request.httprequest.path)]
 +        attach = self.pool['ir.attachment'].search_read(request.cr, request.uid, domain, ['__last_update', 'datas', 'mimetype'], context=request.context)
 +        if attach:
 +            wdate = attach[0]['__last_update']
 +            datas = attach[0]['datas']
 +            response = werkzeug.wrappers.Response()
 +            server_format = openerp.tools.misc.DEFAULT_SERVER_DATETIME_FORMAT
 +            try:
 +                response.last_modified = datetime.datetime.strptime(wdate, server_format + '.%f')
 +            except ValueError:
 +                # just in case we have a timestamp without microseconds
 +                response.last_modified = datetime.datetime.strptime(wdate, server_format)
 +
 +            response.set_etag(hashlib.sha1(datas).hexdigest())
 +            response.make_conditional(request.httprequest)
 +
 +            if response.status_code == 304:
 +                return response
 +
 +            response.mimetype = attach[0]['mimetype']
 +            response.set_data(datas.decode('base64'))
 +            return response
 +
      def _handle_exception(self, exception=None, code=500):
          if isinstance(exception, werkzeug.exceptions.HTTPException) and hasattr(exception, 'response') and exception.response:
              return exception.response
Simple merge