Package wtf :: Package opi :: Module listener :: Class SocketDecorator
[hide private]
[frames] | no frames]

Class SocketDecorator

source code

object --+
         |
        SocketDecorator
Known Subclasses:

Socket decorating container

Derive from this container in order to build new concrete containers. These containers are necessary for proper duplicate/warning/error handling, because we need some context for the socket. The socket ordering is also defined in these containers (via __cmp__).


See Also: UnixSocket, InetSocket

Instance Methods [hide private]
 
__init__(self, socket, bindspec)
Initialization
source code
int
__cmp__(self, other)
Compare 3-way with another object
source code
bool
__eq__(self, other)
Compary (2-way) by identity
source code
str
__repr__(self)
String representation of the object (suitable for debugging)
source code
 
__del__(self)
Destructor
source code
 
__getattr__(self, name)
Delegate all undefined symbol requests to the real socket
source code
 
bind(self)
Bind the socket according to its bindspec
source code
int
family(self)
Determine the socket address family
source code
any
key(self)
Determine the key of the socket, derived from the bindspec
source code
any
anykey(self)
Determine the key of the socket if bindspec would point to ANY
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
dict _famcomp = {1: 0, 2: 2, 10: 1}
Index for address family comparisons
Instance Variables [hide private]
str bindspec
The bind specification from the config
socket.socket realsocket
The actual socket object
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, socket, bindspec)
(Constructor)

source code 
Initialization
Parameters:
  • socket (socket.socket) - The socket object to decorate
  • bindspec (str) - The bind specification from config
Overrides: object.__init__

__cmp__(self, other)
(Comparison operator)

source code 

Compare 3-way with another object

Comparison is done by the socket family index. If the other object is not a SocketDecorator, the id() s are compared.

Parameters:
Returns: int
Comparison result (-1, 0, 1) for self being less, equal or greater than/to other
Raises:
  • NotImplementedError - The socket family of either socket is not in the index

__eq__(self, other)
(Equality operator)

source code 
Compary (2-way) by identity
Parameters:
Returns: bool
Are the objects identical?

__repr__(self)
(Representation operator)

source code 
String representation of the object (suitable for debugging)
Returns: str
The string representation
Overrides: object.__repr__

__getattr__(self, name)
(Qualification operator)

source code 
Delegate all undefined symbol requests to the real socket
Parameters:
  • name (str) - The symbol to look up

family(self)

source code 
Determine the socket address family
Returns: int
The family

key(self)

source code 

Determine the key of the socket, derived from the bindspec

This key can be considered a normalized version of the bindspec. It has to be hashable.

Returns: any
The key

anykey(self)

source code 
Determine the key of the socket if bindspec would point to ANY
Returns: any
The key

See Also: key