1 | """NDG XACML attribute type definition |
---|
2 | |
---|
3 | NERC 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: $" |
---|
12 | from ndg.xacml.core.expression import Expression |
---|
13 | |
---|
14 | |
---|
15 | class AttributeValue(Expression): |
---|
16 | """XACML Attribute Value type""" |
---|
17 | ELEMENT_LOCAL_NAME = 'AttributeValue' |
---|
18 | __slots__ = ('__value',) |
---|
19 | |
---|
20 | def __init__(self): |
---|
21 | super(AttributeValue, self).__init__() |
---|
22 | self.__value = None |
---|
23 | |
---|
24 | def _get_value(self): |
---|
25 | return self.__value |
---|
26 | |
---|
27 | def _set_value(self, value): |
---|
28 | if not isinstance(value, basestring): |
---|
29 | raise TypeError('Expecting %r type for "value" ' |
---|
30 | 'attribute; got %r' % (basestring, type(value))) |
---|
31 | |
---|
32 | self.__value = value |
---|
33 | |
---|
34 | value = property(_get_value, _set_value, None, "expression value") |
---|
35 | |
---|
36 | def evaluate(self, context): |
---|
37 | """Evaluate the result of the expression in a condition |
---|
38 | @param context: the request context |
---|
39 | @type context: ndg.xacml.core.context.request.Request |
---|
40 | @return: attribute value(s) resulting from execution of this expression |
---|
41 | in a condition |
---|
42 | @rtype: AttributeValue/NoneType |
---|
43 | """ |
---|
44 | return self.__value |
---|