Hi,
no...@ti... wrote:
> Hello,
>=20
> if I define:
>=20
> class A:
> __metaclass__ =3D dynamic.CustomObjectMeta
> entityName =3D 'A'
> mdl_define_properties =3D 1
>=20
> def setName( self, value ):
> pass
>=20
> name being a class property, when the metaclass __new__ method populates
> the instance with code it overrides setName with the stock one.
> My fix here is to check for the existence of the method before overriding
> and rename it to 'mdl_'+method_name (which might not be inline
> with your naming conventions) in case it's already there.
>=20
> patch follows
>=20
> comments anyone?
That should be handled, you're absolutely right. However, I would
suggest to make a 'warning' instead, and to overwrite the already
defined method m() with a new one calling simply self.willChange()
before calling m() --and the same for getAttribute()() but w/
self.willRead() instead.
What do you think?
-- S=E9bastien.
PS: for Ernesto: I did not forget about your post on properties, I just
did not take the time to get back on it yet, sorry.
>=20
> cheers
> --
> Delio
>=20
> diff -aur /home/delio/tmp/ModelingCore-0.9-pre-17.1/Modeling/dynamic.py .=
/dynamic.py
> --- /home/delio/tmp/ModelingCore-0.9-pre-17.1/Modeling/dynamic.py 2=
004-02-17 09:01:06.000000000 +1300
> +++ ./dynamic.py 2004-08-31 19:51:40.000000000 +1200
> @@ -265,6 +265,9 @@
> func_name, c=3Dgetter_code(prop)
> info(classdict, "adding getter: %s"%func_name)
> getter=3Dfunction_for_code(c, func_name)
> + if classdict.has_key( func_name ):
> + func_name =3D 'mdl_' + func_name
> + info(classdict, "getter already defined renaming to: %s"%func_name)
> classdict[func_name]=3Dgetter
>=20=20
> def define_getters(entity, classname, classdict):
> @@ -277,6 +280,9 @@
> for func_name, c in names_and_funcs:
> info(classdict, "adding setter: %s"%func_name)
> setter=3Dfunction_for_code(c, func_name)
> + if classdict.has_key( func_name ):
> + func_name =3D 'mdl_' + func_name
> + info(classdict, "setter already defined renaming to: %s"%func_na=
me)
> classdict[func_name]=3Dsetter
>=20=20
> def define_setters(entity, classname, classdict):
|