Ignore:
Timestamp:
16/03/10 11:56:31 (11 years ago)
Author:
pjkersha
Message:

Added XACML Target ElementTree based parser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDGSecurity/python/ndg_security_common/ndg/security/common/authz/xacml/parsers/etree/reader.py

    r6733 r6734  
    66import logging 
    77log = logging.getLogger(__name__) 
    8 from abc import ABCMeta, abstractmethod 
     8"""NDG Security XACML ElementTree reader module containing reader base class  
    99 
     10NERC DataGrid Project 
     11""" 
     12__author__ = "P J Kershaw" 
     13__date__ = "16/03/10" 
     14__copyright__ = "(C) 2010 Science and Technology Facilities Council" 
     15__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     16__license__ = "BSD - see LICENSE file in top-level directory" 
     17__contact__ = "Philip.Kershaw@stfc.ac.uk" 
     18__revision__ = "$Id: $" 
    1019from xml.etree import ElementTree 
    1120 
     21from ndg.security.common.authz.xacml import PolicyComponent 
     22from ndg.security.common.authz.xacml.parsers import AbstractReader 
    1223 
    13 class AbstractReader: 
    14     """Abstract base class for ElementTree implementation of XACML reader""" 
    15     __metaclass__ = ABCMeta 
     24 
     25class EtreeAbstractReader(AbstractReader): 
     26    """Base class for ElementTree implementation of XACML reader""" 
    1627      
    1728    def __init__(self): 
     
    2233        """Restore original global namespace map""" 
    2334        ElementTree._namespace_map = self.__namespace_map_backup 
    24          
    25     @classmethod 
    26     def __subclasshook__(cls, C): 
    27         """Derived class must implement __call__""" 
    28         if cls is AbstractReader: 
    29             if any("__call__" in B.__dict__ for B in C.__mro__): 
    30                 return True 
    31              
    32         return NotImplemented 
    33          
    34     @abstractmethod 
    35     def __call__(self, obj): 
    36         """Abstract Parse XACML method 
    37         @raise NotImplementedError:  
    38         """ 
    39         raise NotImplementedError() 
    40      
    41     @classmethod 
    42     def parse(cls, obj): 
    43         """Parse from input object and return new XACML object""" 
    44         reader = cls() 
    45         return reader(obj) 
    4635     
    4736    @staticmethod 
     
    6049             
    6150        return elem 
    62                      
    63      
    64 class RuleReader(object): 
    65     def __call__(self, obj): 
    66         pass 
     51          
     52# Set up new class as an abstract base itself              
     53AbstractReader.register(EtreeAbstractReader) 
    6754 
    68 #AbstractReader.register(RuleReader) 
    6955 
    7056class VariableDefinitionReader(object): 
Note: See TracChangeset for help on using the changeset viewer.