any way to protect __dict__?
M.-A. Lemburg
mal at lemburg.com
Tue Oct 26 03:53:25 EDT 1999
Chris Knight wrote:
>
> Hi all, I've been working on a class that has the __get/setattr__ function but
> I want to protect __dict__ so that all attribute access has to go through these
> functions. Is there a way to do such a thing?
>
> Perusing the C API, I'd guess I could do this through an object created in C.
> I haven't spent much time with the C API so I don't fully understand what the
> limitations of such an implementation might imply...
Protecting __dict__ only is difficult, since this is handled by the
class/instance implementation. One way to achieve what you have in
mind is to protect the whole object against access from other
objects and only enable a small set of allowed methods.
mxProxy will help you a long way in achieving this without having
to switch over to protected execution mode:
http://starship.skyport.net/~lemburg/mxProxy.html
--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 66 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
More information about the Python-list
mailing list