1 """NDG XACML Context Resource type
2
3 NERC DataGrid
4 """
5 __author__ = "P J Kershaw"
6 __date__ = "24/03/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: resource.py 8010 2012-01-30 16:24:06Z rwilkinson $"
12 from ndg.xacml.core.context import RequestChildBase
13 import ndg.xacml.parsers.etree as etree
14
16 """XACML Context Resource type
17
18 @cvar ELEMENT_LOCAL_NAME: XML local element name for the resource
19 @type ELEMENT_LOCAL_NAME: string
20 @cvar RESOURCE_CONTENT_ELEMENT_LOCAL_NAME: XML local element name for the
21 resource content
22 @type RESOURCE_CONTENT_ELEMENT_LOCAL_NAME: string
23
24 @ivar __resourceContent: resource content
25 @type __resourceContent: any
26 """
27 ELEMENT_LOCAL_NAME = 'Resource'
28 RESOURCE_CONTENT_ELEMENT_LOCAL_NAME = 'ResourceContent'
29
30 __slots__ = ('__resourceContent',)
31
36
38 """Get resource content
39 @return: content
40 @rtype: any
41 """
42 return self.__resourceContent
43
44 - def _set_resourceContent(self, value):
45 """Set resource content
46 @param value: content
47 @type value: any
48 """
49 self.__resourceContent = value
50
51 resourceContent = property(_get_resourceContent, _set_resourceContent, None,
52 "Resource content")
53
55 '''Enable pickling
56
57 @return: object's attribute dictionary
58 @rtype: dict
59 '''
60 _dict = super(Resource, self).__getstate__()
61 for attrName in Resource.__slots__:
62
63
64 if attrName.startswith('__'):
65 attrName = "_Resource" + attrName
66 value = getattr(self, attrName)
67 _dict[attrName] = etree.serialiseIfElementTree(value)
68 return _dict
69
76