~txerpa-openerp/openobject-client-web/txerpa

« back to all changes in this revision

Viewing changes to addons/openerp/controllers/root.py

  • Committer: Biel - txerpa.com
  • Date: 2013-08-09 12:30:58 UTC
  • mfrom: (4670.2.245 openobject-client-web)
  • Revision ID: biel.massot@txerpa.com-20130809123058-892zu673ti1j8yjd
Actualizo a la ultima revision de trunk. Hay muchos bugs correjidos desde 2012. Elimino la revision 4873 por problemas de rendimiento en el dashboard de Contabilidad

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#
20
20
###############################################################################
21
21
import cherrypy
 
22
import re
22
23
 
23
24
import openobject
24
25
from openerp.controllers import SecuredController, unsecured, actions, login as tiny_login, form, widgets
29
30
 
30
31
_MAXIMUM_NUMBER_WELCOME_MESSAGES = 3
31
32
 
 
33
def insert_xmlhttprequest_status_emulation(text, status=None):
 
34
    """ insert http reponse status on document body,
 
35
        so that XMLHttpRequest using <iframe/> hack when form
 
36
        contains binary data, can work correctly """
 
37
    if status is None:
 
38
        status = cherrypy.response.status
 
39
    body_starttag = re.search('<body.*?>', text)
 
40
    if body_starttag:
 
41
        # insert status attribute
 
42
        insert_pos = body_starttag.end() - 1
 
43
        return text[:insert_pos] + ' status="%d"' % (status) + text[insert_pos:]
 
44
    return text
 
45
 
32
46
def _cp_on_error():
33
47
    cherrypy.request.pool = openobject.pooler.get_pool()
34
48
 
35
49
    errorpage = cherrypy.request.pool.get_controller("/openerp/errorpage")
36
50
    message = errorpage.render()
37
51
    cherrypy.response.status = 500
 
52
    message = insert_xmlhttprequest_status_emulation(message, 500)
38
53
    cherrypy.response.body = [message]
39
54
 
40
55
cherrypy.config.update({'request.error_response': _cp_on_error})