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: 7368 $" 
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 IdentityProviderPlug socket, 40 defined in L{flumotion.component.plugs.identity}. 41 42 Subclasses should only implement __str__ 43 """ 44
45 - def __str__(self):
46 raise NotImplementedError
47 48
49 -class LocalIdentity(Identity):
50 """ 51 I represent a local identity. 52 """ 53
54 - def __init__(self, name):
55 self.name = name
56
57 - def __str__(self):
58 return "<%s>" % self.name
59 60
61 -class RemoteIdentity(Identity):
62 """ 63 I represent the identity of a remote avatar. 64 65 I hold the username and host of the remote avatar. 66 """ 67
68 - def __init__(self, username, host):
69 self.username = username 70 self.host = host
71
72 - def __str__(self):
73 return '%s@%s' % (self.username or '<unknown user>', 74 self.host or '<unknown host>')
75