1 """NDG Security Expression type definition
2
3 NERC 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: expression.py 8010 2012-01-30 16:24:06Z rwilkinson $"
12 from abc import ABCMeta, abstractmethod
13
14 from ndg.xacml.core import 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
37
40
47
48 dataType = property(_get_dataType, _set_dataType, None,
49 "expression value data type")
50
51 @abstractmethod
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()
63
65 '''Enable pickling
66
67 @return: object's attribute dictionary
68 @rtype: dict
69 '''
70 _dict = super(Expression, self).__getstate__()
71 for attrName in Expression.__slots__:
72
73
74 if attrName.startswith('__'):
75 attrName = "_Expression" + attrName
76
77 _dict[attrName] = getattr(self, attrName)
78
79 return _dict
80