Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Weakref problem: no way to get original object from proxy object? (http://www.velocityreviews.com/forums/t399520-weakref-problem-no-way-to-get-original-object-from-proxy-object.html)

John Nagle 02-25-2007 10:07 PM

Weakref problem: no way to get original object from proxy object?
 
Is there some way to get a strong ref to the original object back
from a weakref proxy object? I can't find any Python function to do this.
".ref()" doesn't work on proxy objects.

John Nagle

Gabriel Genellina 02-26-2007 02:55 AM

Re: Weakref problem: no way to get original object from proxy object?
 
En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <nagle@animats.com>
escribió:

> Is there some way to get a strong ref to the original object back
> from a weakref proxy object? I can't find any Python function to do
> this.
> ".ref()" doesn't work on proxy objects.


Add a method to the original class that just returns self.

About your backref function: Yes, I usually use something like that, it's
annoying having to handle None always.

--
Gabriel Genellina


John Nagle 02-26-2007 06:34 AM

Re: Weakref problem: no way to get original object from proxy object?
 
Gabriel Genellina wrote:
> En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <nagle@animats.com>
> escribió:
>
>> Is there some way to get a strong ref to the original object back
>> from a weakref proxy object? I can't find any Python function to do
>> this.
>> ".ref()" doesn't work on proxy objects.

>
>
> Add a method to the original class that just returns self.


Yes, that works. Thanks.

John Nagle


All times are GMT. The time now is 12:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.