Can't set attribute?!
alex23
wuwei23 at gmail.com
Tue Sep 1 22:54:10 EDT 2009
dolgion ch <dolgi... at gmail.com> wrote:
> the NETRPCGateway attribute self.db can't be set? why not? i've tried
> changing the RPCSession login function
> to set the variable like this as well:
>
> self.gateway.db = db
>
> which doesn't work either, same exception.....
>
> any suggestions?
The problem is this line in your definition of RPCSession:
__slots__ = ['host', 'port', 'protocol', 'storage', 'gateway']
Slots are a way of creating more light weight objects; you cannot have
add any new attributes to an object defined with __slots__, as they
don't have a dictionary for attribute storage.
http://docs.python.org/reference/datamodel.html#slots
As for why you can't set them on NETRPCGateway, my suspicion is that
RPCGateway defines similar slots, although I don't have access to the
code... is it the OSE netsvc/netrpc libs that you're using?
More information about the Python-list
mailing list