Hi Peter and others,
your idea was good, but it does not work with Django ORM Models:
Traceback (most recent call last):
File "/localhome/modw/django/core/handlers/base.py", line 87, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/localhome/modw/foo/views/filter.py", line 473, in add
return edit(request, 'add')
File "/localhome/modw/foo/views/filter.py", line 493, in edit
filter=form.save()
File "/localhome/modw/foo/views/filter.py", line 457, in save
action=form.save()
File "/localhome/modw/django/forms/models.py", line 315, in save
if self.instance.pk is None:
File "/localhome/modw/django/db/models/base.py", line 292, in _get_pk_val
return getattr(self, meta.pk.attname)
AttributeError: 'MyAction' object has no attribute 'filter_action_ptr_id'
Peter said:
Thomas said:
for debugging I want to raise an exception if an attribute is
changed on an object. Since it is only for debugging I don't want
to change the integer attribute to a property.
Why?
This should raise an exception:
myobj.foo=1
Background:
Somewhere this value gets changed. But I don't now where.
If you change your mind:
class A(object):
def __init__(self):
self.foo = 42
a = A()
b = A()
class B(A):
@property
def foo(self):
return self.__dict__["foo"]
b.__class__ = B
a.foo = "whatever"
print b.foo
b.foo = "whatever"
Peter