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  """manager-side identities of objects. 
23  Manager-side identities of objects that can request operations 
24  from the manager. 
25  """ 
26   
27  __version__ = "$Rev: 6964 $" 
28   
29   
30 -class Identity:
31 """ 32 I represent the identity of an object that can ask the manager to 33 perform functions. 34 35 I exist for the AdminAction socket, defined in 36 L{flumotion.component.plugs.adminaction}, so that specific actions 37 can be taken when I request to perform a function. 38 39 I serve as a point of extensibility for the IdentityProvider socket, 40 defined in L{flumotion.component.plugs.identity}. 41 42 Subclasses should only implement __str__ 43 """
44 - def __str__(self):
45 raise NotImplementedError
46 47
48 -class LocalIdentity(Identity):
49 """ 50 I represent a local identity. 51 """
52 - def __init__(self, name):
53 self.name = name
54
55 - def __str__(self):
56 return "<%s>" % self.name
57 58
59 -class RemoteIdentity(Identity):
60 """ 61 I represent the identity of a remote avatar. 62 63 I hold the username and host of the remote avatar. 64 """
65 - def __init__(self, username, host):
66 self.username = username 67 self.host = host
68
69 - def __str__(self):
70 return '%s@%s' % (self.username or '<unknown user>', 71 self.host or '<unknown host>')
72