I am trying to implement a wrapper/proxy class for a java object (baseClient) in jython v2.1. Everything seems to be working ok except when the following statement is encountered:
if __client != None # __client is an instance of the ClientProxy class
raise AttributeError(attr)
is called in __getattr__()
, because self.__baseClient
doesn't have __ne__
attribute.
It's important to mention that I cannot upgrade because jython is a part of a system. Is there a way to get around this issue?
class ClientProxy:
def __init__(self, baseClient):
self.__baseClient = baseClient
self.__initialised = 1
def __getattr__(self, attr):
if not self.__dict__.has_key('_ClientProxy__initialised'):
raise AttributeError(attr)
else:
if hasattr(self.__baseClient, attr):
return getattr(self.__baseClient, attr)
else:
raise AttributeError(attr)
def __setattr__(self, attr, val):
if not self.__dict__.has_key('_ClientProxy__initialised'):
self.__dict__[attr] = val
return
if hasattr(self.__baseClient, attr):
self.__baseClient.__setattr__(attr, val)
else:
self.__dict__[attr] = val
Thanks a lot!