Package ndg :: Package xacml :: Package core :: Module attribute
[hide private]

Source Code for Module ndg.xacml.core.attribute

  1  """NDG XACML Attribute type 
  2   
  3  NERC DataGrid 
  4  """ 
  5  __author__ = "P J Kershaw" 
  6  __date__ = "24/03/10" 
  7  __copyright__ = "(C) 2010 Science and Technology Facilities Council" 
  8  __contact__ = "Philip.Kershaw@stfc.ac.uk" 
  9  __license__ = "BSD - see LICENSE file in top-level directory" 
 10  __contact__ = "Philip.Kershaw@stfc.ac.uk" 
 11  __revision__ = "$Id: attribute.py 8010 2012-01-30 16:24:06Z rwilkinson $" 
 12  from ndg.xacml.utils import TypedList 
 13  from ndg.xacml.core import XacmlCoreBase 
 14  from ndg.xacml.core.attributevalue import AttributeValue 
15 16 17 -class Attribute(XacmlCoreBase):
18 """XACML Attribute type 19 20 @cvar ELEMENT_LOCAL_NAME: XML local name for this element 21 @type ELEMENT_LOCAL_NAME: string 22 @cvar ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME: XML local name for attribute value 23 child element 24 @type ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME: string 25 @cvar DATA_TYPE_ATTRIB_NAME: XML attribute name for data type 26 @type DATA_TYPE_ATTRIB_NAME: string 27 @cvar ATTRIBUTE_ID_ATTRIB_NAME: attribute ID XML attribute name 28 @type ATTRIBUTE_ID_ATTRIB_NAME: string 29 @cvar ISSUER_ATTRIB_NAME: issuer XML attribute name 30 @type ISSUER_ATTRIB_NAME: string 31 32 @ivar __attributeValues: list of attribute values 33 @type __attributeValues: ndg.xacml.utils.TypedList 34 @ivar __dataType: data type for this attribute 35 @type __dataType: basestring / NoneType 36 @ivar __attributeId: identifier for attribute 37 @type __attributeId: basestring / NoneType 38 @ivar __issuer: issuer id of this attribute 39 @type __issuer: basestring / NoneType 40 """ 41 ELEMENT_LOCAL_NAME = 'Attribute' 42 ATTRIBUTE_VALUE_ELEMENT_LOCAL_NAME = 'AttributeValue' 43 DATA_TYPE_ATTRIB_NAME = 'DataType' 44 ATTRIBUTE_ID_ATTRIB_NAME = 'AttributeId' 45 ISSUER_ATTRIB_NAME = 'Issuer' 46 47 __slots__ = ('__attributeValues', '__dataType', '__attributeId', '__issuer') 48
49 - def __init__(self):
50 super(Attribute, self).__init__() 51 self.__attributeValues = TypedList(AttributeValue) 52 self.__dataType = None 53 self.__attributeId = None 54 self.__issuer = None
55 56 @property
57 - def attributeValues(self):
58 """Get attribute values 59 60 @return: list of attribute values 61 @rtype: ndg.xacml.utils.TypedList 62 """ 63 return self.__attributeValues
64 65 @attributeValues.setter
66 - def attributeValues(self, value):
67 """Set attribute values 68 69 @param value: list of attribute values 70 @type value: ndg.xacml.utils.TypedList 71 @raise TypeError: incorrect input type 72 """ 73 if not isinstance(value, TypedList): 74 raise TypeError('Expecting %r type for "attributeValues" ' 75 'attribute; got %r' % (TypedList, type(value))) 76 77 self.__attributeValues = value
78
79 - def _get_dataType(self):
80 """Get data type 81 @return: attribute data type 82 @rtype: basestring / NoneType 83 """ 84 return self.__dataType
85
86 - def _set_dataType(self, value):
87 """Set data type 88 @param value: attribute data type 89 @type value: basestring 90 @raise TypeError: incorrect input type 91 """ 92 if not isinstance(value, basestring): 93 raise TypeError('Expecting %r type for "dataType" ' 94 'attribute; got %r' % (basestring, type(value))) 95 96 self.__dataType = value
97 98 dataType = property(_get_dataType, _set_dataType, None, 99 "Attribute data type") 100 101 @property
102 - def attributeId(self):
103 """Get Attribute Id 104 @return: attribute Id 105 @rtype: basestring / NoneType 106 """ 107 return self.__attributeId
108 109 @attributeId.setter
110 - def attributeId(self, value):
111 """Set Attribute Id 112 @param value: attribute id 113 @type value: basestring 114 @raise TypeError: incorrect input type 115 """ 116 if not isinstance(value, basestring): 117 raise TypeError('Expecting %r type for "attributeId" ' 118 'attribute; got %r' % (basestring, type(value))) 119 120 self.__attributeId = value
121 122 @property
123 - def issuer(self):
124 """Get Issuer 125 @return: attribute issuer 126 @rtype: basestring / NoneType 127 """ 128 return self.__issuer
129 130 @issuer.setter
131 - def issuer(self, value):
132 """Set Issuer 133 @param value: attribute issuer 134 @type value: basestring 135 @raise TypeError: incorrect input type 136 """ 137 if not isinstance(value, basestring): 138 raise TypeError('Expecting %r type for "issuer" ' 139 'attribute; got %r' % (basestring, type(value))) 140 141 self.__issuer = value
142
143 - def __getstate__(self):
144 '''Enable pickling 145 146 @return: class instance attributes dictionary 147 @rtype: dict 148 ''' 149 _dict = {} 150 for attrName in Attribute.__slots__: 151 # Ugly hack to allow for derived classes setting private member 152 # variables 153 if attrName.startswith('__'): 154 attrName = "_Attribute" + attrName 155 156 _dict[attrName] = getattr(self, attrName) 157 158 return _dict
159