source: TI12-security/trunk/NDG_XACML/ndg/xacml/core/expression.py @ 6792

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDG_XACML/ndg/xacml/core/expression.py@6793
Revision 6792, 1.6 KB checked in by pjkersha, 10 years ago (diff)

Made ndg.xacml.core.expression.Expression abstract: derived classes must implement the evaluate method used to evaluate a result in a rule condition.

Line 
1"""NDG Security Expression type definition
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "25/02/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: $"
12from abc import ABCMeta, abstractmethod
13
14from ndg.xacml.core import XacmlCoreBase
15
16
17class Expression(XacmlCoreBase):
18    """XACML Expression type"""
19    __metaclass__ = ABCMeta
20    ELEMENT_LOCAL_NAME = None
21    DATA_TYPE_ATTRIB_NAME = 'DataType'
22   
23    __slots__ = ('__dataType', )
24   
25    def __init__(self):
26        super(Expression, self).__init__()
27        self.__dataType = None
28       
29    def _get_dataType(self):
30        return self.__dataType
31
32    def _set_dataType(self, value):
33        if not isinstance(value, basestring):
34            raise TypeError('Expecting %r type for "dataType" '
35                            'attribute; got %r' % (basestring, type(value)))
36           
37        self.__dataType = value   
38
39    dataType = property(_get_dataType, _set_dataType, None, 
40                        "expression value data type") 
41   
42    @abstractmethod
43    def evaluate(self, context):
44        """Evaluate the result of the expression in a condition.  Derived
45        classes must implement
46       
47        @param context: the request context
48        @type context: ndg.xacml.core.context.request.Request
49        @return: attribute value(s) resulting from execution of this expression
50        in a condition
51        @rtype: AttributeValue/NoneType
52        """
53        raise NotImplementedError()
Note: See TracBrowser for help on using the repository browser.