-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatastructure.py
61 lines (48 loc) · 2.01 KB
/
datastructure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
###########################################################################
# Copyright (C) 2004 by kosh
#
# Copyright: See COPYING file that comes with this distribution
#
###########################################################################
#This software is released under GNU public license. See details in the URL:
#http://www.gnu.org/copyleft/gpl.html
#For Security control and init
from AccessControl import ClassSecurityInfo
import Globals
from userobject import UserObject
class DataStructure(UserObject):
"""This object is used to hold a python data structure.
The primary intent is so that structures can be calculated and stored.
It is designed to only be used from python (script,external method, product) and not
dtml/zpt etc."""
security = ClassSecurityInfo()
meta_type = "DataStructure"
data = None
security.declareProtected('View', 'view')
def view(self):
"Inline draw view"
return str(self.data)
edit = view
security.declarePrivate('createDataLoader')
def createDataLoader(self):
"return the data needed to rebuild this object as a dictionary that it can then take back to restore its information"
return {'data': self.data}
security.declarePrivate('dataLoader')
def dataLoader(self, dict):
"load the data from this dict into this object"
if 'data' in dict:
self.setObject('data', dict['data'])
security.declareProtected('Python Record Addition', 'setDataStructure')
def setDataStructure(self, data):
"set a data structure in this object"
self.setObject('data', data)
security.declareProtected('Change CompoundDoc', 'store')
store = setDataStructure
security.declareProtected('Python Record Addition', 'getDataStructure')
def getDataStructure(self):
"set a data structure in this object"
return self.data
Globals.InitializeClass(DataStructure)
import register
register.registerClass(DataStructure)