Commit fd441a48 authored by Jérome Perrin's avatar Jérome Perrin

use isinstance to check types


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16771 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5e90d30c
...@@ -66,7 +66,7 @@ class StaticValue: ...@@ -66,7 +66,7 @@ class StaticValue:
value as is) value as is)
""" """
def __init__(self, value): def __init__(self, value):
if type(aq_base(value)) is Method: if isinstance(aq_base(value), Method):
value = Method(value.method_name) value = Method(value.method_name)
self.value = value self.value = value
...@@ -151,7 +151,7 @@ class TALESValue(StaticValue): ...@@ -151,7 +151,7 @@ class TALESValue(StaticValue):
class OverrideValue(StaticValue): class OverrideValue(StaticValue):
def __init__(self, override): def __init__(self, override):
if type(aq_base(override)) is Method: if isinstance(aq_base(override), Method):
override = Method(override.method_name) override = Method(override.method_name)
self.override = override self.override = override
...@@ -161,7 +161,7 @@ class OverrideValue(StaticValue): ...@@ -161,7 +161,7 @@ class OverrideValue(StaticValue):
class DefaultValue(StaticValue): class DefaultValue(StaticValue):
def __init__(self, field_id, value): def __init__(self, field_id, value):
self.key = field_id[3:] self.key = field_id[3:]
if type(aq_base(value)) is Method: if isinstance(aq_base(value), Method):
value = Method(value.method_name) value = Method(value.method_name)
self.value = value self.value = value
...@@ -771,9 +771,9 @@ class ERP5Form(ZMIForm, ZopePageTemplate): ...@@ -771,9 +771,9 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
for key, value in _dict.items(): for key, value in _dict.items():
if value=='': if value=='':
continue continue
if type(value) is Method: if isinstance((value, Method):
value = Method(value.method_name) value = Method(value.method_name)
elif type(value) is TALESMethod: elif isinstance(value, TALESMethod):
value = TALESMethod(value._text) value = TALESMethod(value._text)
elif value is not None and not isinstance(value, elif value is not None and not isinstance(value,
(str, unicode, int, long, bool, list, tuple, dict)): (str, unicode, int, long, bool, list, tuple, dict)):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment