From 98fe0519e1d57c8dd972acdef6dc98601c772b5e Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Mon, 21 Sep 2015 21:28:32 +0300 Subject: [PATCH] Fixes #141, fixes #143: remove restriction on adding new methods to entities --- pony/orm/core.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pony/orm/core.py b/pony/orm/core.py index b6ef8249c..4838465e7 100644 --- a/pony/orm/core.py +++ b/pony/orm/core.py @@ -2119,7 +2119,7 @@ def create_default_attr(entity): entity._attrs_.append(attr) entity._new_attrs_.append(attr) entity._adict_['classtype'] = attr - type.__setattr__(entity, 'classtype', attr) + entity.classtype = attr attr.process_entity_inheritance(entity) def process_entity_inheritance(attr, entity): if '_discriminator_' not in entity.__dict__: @@ -3127,10 +3127,6 @@ def next(self): lambda_re = re.compile(r'lambda\b') class EntityMeta(type): - def __setattr__(entity, name, val): - if name.startswith('_') and name.endswith('_'): - type.__setattr__(entity, name, val) - else: throw(NotImplementedError) def __new__(meta, name, bases, cls_dict): if 'Entity' in globals(): if '__slots__' in cls_dict: throw(TypeError, 'Entity classes cannot contain __slots__ variable') @@ -3235,7 +3231,7 @@ def __init__(entity, name, bases, cls_dict): attr = PrimaryKey(int, auto=True) attr.is_implicit = True attr._init_(entity, 'id') - type.__setattr__(entity, 'id', attr) # entity.id = attr + entity.id = attr new_attrs.insert(0, attr) pk_attrs = (attr,) index = Index(attr, is_pk=True)