[Python-Dev] Weakref design questions

Martin v. Loewis martin@v.loewis.de
19 Oct 2002 05:39:09 +0200


Brian Quinlan <brian@sweetapp.com> writes:

> That is definitely one possible way to do it. However, I am wrapping a
> complete DOM, with dozens of objects containing, collectively, hundreds
> of methods. 
> 
> Adding an explicit check to each method seemed like a lot more pain than
> using proxies.

You don't have to add it to every method. You can perform the check in
tp_getattro before performing the method lookup. Alternatively, you
can change the ob_type of the object to simply drop the methods that
are not available anymore.

Regards,
Martin