Package flumotion :: Package common :: Module identity
[hide private]

Source Code for Module flumotion.common.identity

 1  # -*- Mode: Python  -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3  # 
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 
 6  # All rights reserved. 
 7   
 8  # This file may be distributed and/or modified under the terms of 
 9  # the GNU General Public License version 2 as published by 
10  # the Free Software Foundation. 
11  # This file is distributed without any warranty; without even the implied 
12  # warranty of merchantability or fitness for a particular purpose. 
13  # See "LICENSE.GPL" in the source distribution for more information. 
14   
15  # Licensees having purchased or holding a valid Flumotion Advanced 
16  # Streaming Server license may use this file in accordance with the 
17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
18  # See "LICENSE.Flumotion" in the source distribution for more information. 
19   
20  # Headers in this file shall remain intact. 
21   
22  """ 
23  Manager-side identities of objects that can request operations from the manager. 
24  """ 
25   
26 -class Identity:
27 """ 28 I represent the identity of an object that can ask the manager to 29 perform functions. 30 31 I exist for the AdminAction socket, defined in 32 L{flumotion.component.plugs.adminaction}, so that specific actions 33 can be taken when I request to perform a function. 34 35 I serve as a point of extensibility for the IdentityProvider socket, 36 defined in L{flumotion.component.plugs.identity}. 37 38 Subclasses should only implement __str__ 39 """
40 - def __str__(self):
41 raise NotImplementedError
42
43 -class LocalIdentity(Identity):
44 """ 45 I represent a local identity. 46 """
47 - def __init__(self, name):
48 self.name = name
49
50 - def __str__(self):
51 return "<%s>" % self.name
52
53 -class RemoteIdentity(Identity):
54 """ 55 I represent the identity of a remote avatar. 56 57 I hold the username and host of the remote avatar. 58 """
59 - def __init__(self, username, host):
60 self.username = username 61 self.host = host
62
63 - def __str__(self):
64 return '%s@%s' % (self.username or '<unknown user>', 65 self.host or '<unknown host>')
66