source: TI12-security/trunk/ndg_xacml/ndg/xacml/core/expression.py @ 7103

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/ndg_xacml/ndg/xacml/core/expression.py@7682
Revision 7103, 1.9 KB checked in by pjkersha, 11 years ago (diff)

Incomplete - task 2: XACML-Security Integration

  • updating epydoc ready for release.
  • Property svn:keywords set to Id
Line 
1"""NDG Security Expression type definition
2
3NERC DataGrid
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   
20    @cvar ELEMENT_LOCAL_NAME: XML local name for this element
21    @type ELEMENT_LOCAL_NAME: string
22    @cvar DATA_TYPE_ATTRIB_NAME: XML attribute name for data type
23    @type DATA_TYPE_ATTRIB_NAME: string
24   
25    @ivar __dataType: data type for this expression
26    @type __dataType: None / basestring
27    """
28    __metaclass__ = ABCMeta
29    ELEMENT_LOCAL_NAME = None
30    DATA_TYPE_ATTRIB_NAME = 'DataType'
31   
32    __slots__ = ('__dataType', )
33   
34    def __init__(self):
35        super(Expression, self).__init__()
36        self.__dataType = None
37       
38    def _get_dataType(self):
39        return self.__dataType
40
41    def _set_dataType(self, value):
42        if not isinstance(value, basestring):
43            raise TypeError('Expecting %r type for "dataType" '
44                            'attribute; got %r' % (basestring, type(value)))
45           
46        self.__dataType = value   
47
48    dataType = property(_get_dataType, _set_dataType, None, 
49                        "expression value data type") 
50   
51    @abstractmethod
52    def evaluate(self, context):
53        """Evaluate the result of the expression in a condition.  Derived
54        classes must implement
55       
56        @param context: the request context
57        @type context: ndg.xacml.core.context.request.Request
58        @return: attribute value(s) resulting from execution of this expression
59        in a condition
60        @rtype: AttributeValue/NoneType
61        """
62        raise NotImplementedError()
Note: See TracBrowser for help on using the repository browser.