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,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
17   
18  """manager-side identities of objects. 
19  Manager-side identities of objects that can request operations 
20  from the manager. 
21  """ 
22   
23  __version__ = "$Rev$" 
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 IdentityProviderPlug socket, 36 defined in L{flumotion.component.plugs.identity}. 37 38 Subclasses should only implement __str__ 39 """ 40
41 - def __str__(self):
42 raise NotImplementedError
43 44
45 -class LocalIdentity(Identity):
46 """ 47 I represent a local identity. 48 """ 49
50 - def __init__(self, name):
51 self.name = name
52
53 - def __str__(self):
54 return "<%s>" % self.name
55 56
57 -class RemoteIdentity(Identity):
58 """ 59 I represent the identity of a remote avatar. 60 61 I hold the username and host of the remote avatar. 62 """ 63
64 - def __init__(self, username, host):
65 self.username = username 66 self.host = host
67
68 - def __str__(self):
69 return '%s@%s' % (self.username or '<unknown user>', 70 self.host or '<unknown host>')
71