Home | Trees | Indices | Help |
|
---|
|
1 """NDG XACML ElementTree Attribute Selector Reader 2 3 NERC DataGrid 4 """ 5 __author__ = "P J Kershaw" 6 __date__ = "18/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: attributeselectorreader.py 7109 2010-06-28 12:54:57Z pjkersha $" 12 from ndg.xacml.utils import str2Bool 13 from ndg.xacml.core.attributeselector import AttributeSelector 14 from ndg.xacml.parsers import XMLParseError 15 from ndg.xacml.parsers.etree import QName 16 from ndg.xacml.parsers.etree.expressionreader import ExpressionReader 17 1820 '''ElementTree based parser for XACML Attribute Selector type 21 22 @cvar TYPE: XACML class type that this reader will read values into 23 @type TYPE: abc.ABCMeta 24 ''' 25 TYPE = AttributeSelector 266828 """Parse XML Attribute Selector element 29 30 @param elem: ElementTree XML element 31 @type elem: xml.etree.Element 32 33 @param attributeSelector: attribute selector to be updated with parsed 34 values 35 @type attributeSelector: ndg.xacml.core.attributeSelector.AttributeSelector 36 37 @raise XMLParseError: error parsing attribute ID XML attribute 38 39 @return: updated attribute selector 40 @rtype: ndg.xacml.core.attributeSelector.AttributeSelector 41 """ 42 43 xacmlType = self.__class__.TYPE 44 45 localName = QName.getLocalPart(elem.tag) 46 if localName != xacmlType.ELEMENT_LOCAL_NAME: 47 raise XMLParseError("No \"%s\" element found" % 48 xacmlType.ELEMENT_LOCAL_NAME) 49 50 # Unpack *required* attributes from top-level element 51 attributeValues = [] 52 for attributeName in (xacmlType.REQUEST_CONTEXT_PATH_ATTRIB_NAME,): 53 attributeValue = elem.attrib.get(attributeName) 54 if attributeValue is None: 55 raise XMLParseError('No "%s" attribute found in "%s" element' % 56 (attributeName, 57 xacmlType.ELEMENT_LOCAL_NAME)) 58 59 attributeValues.append(attributeValue) 60 61 attributeSelector.requestContextPath, = attributeValues 62 63 mustBePresent = elem.attrib.get(xacmlType.MUST_BE_PRESENT_ATTRIB_NAME) 64 if mustBePresent is not None: 65 attributeSelector.mustBePresent = str2Bool(mustBePresent) 66 67 return attributeSelector
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Apr 5 08:44:41 2012 | http://epydoc.sourceforge.net |