[MERGE] Sync with trunk.
bzr revid: tde@openerp.com-20130322090938-xoh67sg08m3ylcrk
This commit is contained in:
commit
4e74279576
|
@ -207,7 +207,7 @@ class act_window(osv.osv):
|
|||
def _search_view(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for act in self.browse(cr, uid, ids, context=context):
|
||||
field_get = self.pool.get(act.res_model).fields_view_get(cr, uid,
|
||||
field_get = self.pool[act.res_model].fields_view_get(cr, uid,
|
||||
act.search_view_id and act.search_view_id.id or False,
|
||||
'search', context=context)
|
||||
res[act.id] = str(field_get)
|
||||
|
@ -820,7 +820,7 @@ Launch Manually Once: after having been launched manually, it sets automatically
|
|||
act_type = self.pool.get('ir.actions.actions').read(cr, uid, wizard.action_id.id, ['type'], context=context)
|
||||
|
||||
res = self.pool.get(act_type['type']).read(cr, uid, wizard.action_id.id, [], context=context)
|
||||
if act_type<>'ir.actions.act_window':
|
||||
if act_type['type'] != 'ir.actions.act_window':
|
||||
return res
|
||||
res.setdefault('context','{}')
|
||||
res['nodestroy'] = True
|
||||
|
|
|
@ -933,13 +933,6 @@ class ir_model_data(osv.osv):
|
|||
elif res_id:
|
||||
model_obj.write(cr, uid, [res_id], values, context=context)
|
||||
if xml_id:
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
'module':module,
|
||||
'res_id':res_id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
|
@ -951,17 +944,17 @@ class ir_model_data(osv.osv):
|
|||
'res_id': inherit_id.id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
'module':module,
|
||||
'res_id':res_id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
else:
|
||||
if mode=='init' or (mode=='update' and xml_id):
|
||||
res_id = model_obj.create(cr, uid, values, context=context)
|
||||
if xml_id:
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
'module': module,
|
||||
'res_id': res_id,
|
||||
'noupdate': noupdate
|
||||
},context=context)
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cr, uid,
|
||||
|
@ -973,6 +966,13 @@ class ir_model_data(osv.osv):
|
|||
'res_id': inherit_id.id,
|
||||
'noupdate': noupdate,
|
||||
},context=context)
|
||||
self.create(cr, uid, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
'module': module,
|
||||
'res_id': res_id,
|
||||
'noupdate': noupdate
|
||||
},context=context)
|
||||
if xml_id and res_id:
|
||||
self.loads[(module, xml_id)] = (model, res_id)
|
||||
for table, inherit_field in model_obj._inherits.iteritems():
|
||||
|
|
|
@ -557,7 +557,10 @@ class res_config_settings(osv.osv_memory):
|
|||
'params': {'modules': to_install_missing_names},
|
||||
}
|
||||
|
||||
config = self.pool.get('res.config').next(cr, uid, [], context=context) or {}
|
||||
# After the uninstall/install calls, the self.pool is no longer valid.
|
||||
# So we reach into the RegistryManager directly.
|
||||
res_config = openerp.modules.registry.RegistryManager.get(cr.dbname)['res.config']
|
||||
config = res_config.next(cr, uid, [], context=context) or {}
|
||||
if config.get('type') not in ('ir.actions.act_window_close',):
|
||||
return config
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
with mute_logger('openerp.tools.safe_eval'):
|
||||
safe_eval('open("/etc/passwd","r")')
|
||||
assert False, "safe_eval should not allow calling open() builtin"
|
||||
except NameError:
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
-
|
||||
|
|
|
@ -482,7 +482,7 @@ class browse_record(object):
|
|||
except KeyError, e:
|
||||
import sys
|
||||
exc_info = sys.exc_info()
|
||||
raise AttributeError, "Got %r while trying to get attribute `%s`." % (e, name), exc_info[2]
|
||||
raise AttributeError, "Got %r while trying to get attribute %s on a %s record." % (e, name, self._table._name), exc_info[2]
|
||||
|
||||
def __contains__(self, name):
|
||||
return (name in self._table._columns) or (name in self._table._inherit_fields) or hasattr(self._table, name)
|
||||
|
|
|
@ -35,4 +35,34 @@ class m(openerp.osv.osv.Model):
|
|||
def generate_undefined(self, cr, uid, ids, context=None):
|
||||
self.surely_undefined_symbol
|
||||
|
||||
|
||||
def generate_except_osv_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_except_osv, context)
|
||||
|
||||
def generate_except_orm_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_except_orm, context)
|
||||
|
||||
def generate_warning_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_warning, context)
|
||||
|
||||
def generate_redirect_warning_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_redirect_warning, context)
|
||||
|
||||
def generate_access_denied_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_access_denied, context)
|
||||
|
||||
def generate_access_error_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_access_error, context)
|
||||
|
||||
def generate_exc_access_denied_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_exc_access_denied, context)
|
||||
|
||||
def generate_undefined_safe_eval(self, cr, uid, ids, context=None):
|
||||
self.generate_safe_eval(cr, uid, ids, self.generate_undefined, context)
|
||||
|
||||
|
||||
def generate_safe_eval(self, cr, uid, ids, f, context):
|
||||
globals_dict = { 'generate': lambda *args: f(cr, uid, ids, context) }
|
||||
openerp.tools.safe_eval.safe_eval("generate()", mode='exec', globals_dict=globals_dict)
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
<field name="model">test.exceptions.model</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Test exceptions">
|
||||
<label string="Each button generates a specific exception on the server. The text on the right is the expected representation of the exception when displayed on the client."/>
|
||||
<label string="Each button generates a specific exception on the server. The text on the right is the expected representation of the exception when displayed on the client. Button marked with a '*' use safe_eval()."/>
|
||||
<separator string="" colspan="8"/>
|
||||
<group colspan="8" col="8">
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="8" col="8">
|
||||
<separator string="" colspan="8"/>
|
||||
<button name="generate_except_osv" string="except_osv" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
|
@ -41,6 +43,42 @@
|
|||
<button name="generate_undefined" string="Undefined" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Server error-traceback"/>
|
||||
</group>
|
||||
</group>
|
||||
<group colspan="4" col="8">
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_except_osv_safe_eval" string="except_osv*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_except_orm_safe_eval" string="except_orm*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_warning_safe_eval" string="Warning*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_redirect_warning_safe_eval" string="RedirectWarning*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Warning-description-redirection button"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_access_denied_safe_eval" string="AccessDenied*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access denied-traceback"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_access_error_safe_eval" string="AccessError*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access rights error-description"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_exc_access_denied_safe_eval" string="Exc AccessDenied*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Access denied-traceback"/>
|
||||
</group>
|
||||
<group colspan="8" col="8">
|
||||
<button name="generate_undefined_safe_eval" string="Undefined*" type="object" icon="gtk-ok" colspan="1"/>
|
||||
<label string="Server error-traceback"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -37,6 +37,8 @@ import logging
|
|||
|
||||
from .misc import ustr
|
||||
|
||||
import openerp
|
||||
|
||||
__all__ = ['test_expr', 'safe_eval', 'const_eval']
|
||||
|
||||
# The time module is usually already provided in the safe_eval environment
|
||||
|
@ -242,9 +244,19 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal
|
|||
c = test_expr(expr, _SAFE_OPCODES, mode=mode)
|
||||
try:
|
||||
return eval(c, globals_dict, locals_dict)
|
||||
except openerp.osv.orm.except_orm:
|
||||
raise
|
||||
except openerp.exceptions.Warning:
|
||||
raise
|
||||
except openerp.exceptions.RedirectWarning:
|
||||
raise
|
||||
except openerp.exceptions.AccessDenied:
|
||||
raise
|
||||
except openerp.exceptions.AccessError:
|
||||
raise
|
||||
except Exception, e:
|
||||
import sys
|
||||
exc_info = sys.exc_info()
|
||||
raise exc_info[0], '"%s" while evaluating\n%r' % (ustr(e), expr), exc_info[2]
|
||||
raise ValueError, '"%s" while evaluating\n%r' % (ustr(e), expr), exc_info[2]
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue