32 |
def __init__ (self, OID, parent_OID): |
def __init__ (self, OID, parent_OID): |
33 |
self._OID = OID |
self._OID = OID |
34 |
self._parent_OID = parent_OID |
self._parent_OID = parent_OID |
35 |
|
self._childrenOIDlist = [] |
36 |
|
|
37 |
def getChildByOID(self,OID): |
def getChildByOID(self,OID): |
38 |
return None |
return None |
39 |
|
|
40 |
def getAllChildren(self): |
def getAllChildren(self): |
41 |
return None |
# at the moment a dictonary (indexed by OIDs) is returned, |
42 |
|
# later, an object of type objectlist should be returned |
43 |
|
# this objectlist should be sortable and searchable and be |
44 |
|
# threadsafe and implement locking |
45 |
|
list={} |
46 |
|
for i in self._childrenOIDlist: |
47 |
|
list[i]=getObject(i) |
48 |
|
return list |
49 |
|
|
50 |
def newChild(self): |
def newChild(self): |
51 |
pass |
pass |
87 |
|
|
88 |
|
|
89 |
def getChildByOID(self,OID): |
def getChildByOID(self,OID): |
90 |
|
if isObjectinCache(OID): |
91 |
|
return getObject(OID) |
92 |
|
|
93 |
data=self._datasource.getIndexedRowData(OID,self._tablename, |
data=self._datasource.getIndexedRowData(OID,self._tablename, |
94 |
self._oidrow,self._rownames) |
self._oidrow,self._rownames) |
95 |
if data and len(data)>0: |
if data and len(data)>0: |
113 |
def getAllChildren(self): |
def getAllChildren(self): |
114 |
# load all possible children / attention, there is no search in the cache |
# load all possible children / attention, there is no search in the cache |
115 |
# at the moment |
# at the moment |
116 |
|
objInCache=geasMetaObject.getAllChildren(self) |
117 |
objects={} |
objects={} |
118 |
data=self._datasource.getWholeRowData(self._tablename, |
data=self._datasource.getWholeRowData(self._tablename, |
119 |
self._rownames+[self._oidrow]) |
self._rownames+[self._oidrow]) |
120 |
if data: |
if data: |
121 |
for record in data: |
for record in data: |
|
|
|
|
OID=record[self._oidrow] |
|
|
if not objects.has_key(OID): |
|
|
# build new object |
|
|
objects[OID] = self._objclass(OID,self._OID) |
|
|
# save object into cache |
|
|
registerObject(objects[OID]) |
|
|
# print "Create object with OID %s" % OID |
|
|
|
|
|
populate = getattr(objects[OID],self._populatefunction) |
|
|
params=[] |
|
|
for i in self._rownames: |
|
|
params.append(record[i]) |
|
|
populate(*params) |
|
122 |
|
|
123 |
|
OID=record[self._oidrow] |
124 |
|
|
125 |
|
# just build object which are not already cached |
126 |
|
if not objInCache.has_key(OID): |
127 |
|
|
128 |
|
if not objects.has_key(OID): |
129 |
|
# build new object |
130 |
|
objects[OID] = self._objclass(OID,self._OID) |
131 |
|
# save object into cache |
132 |
|
registerObject(objects[OID]) |
133 |
|
# print "Create object with OID %s" % OID |
134 |
|
|
135 |
|
populate = getattr(objects[OID],self._populatefunction) |
136 |
|
params=[] |
137 |
|
for i in self._rownames: |
138 |
|
params.append(record[i]) |
139 |
|
populate(*params) |
140 |
|
|
141 |
|
# merge objects and objInCache |
142 |
|
for i in objInCache.keys(): |
143 |
|
objects[i]=objInCache[i] |
144 |
return objects |
return objects |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
def newChild(self): |
def newChild(self): |
149 |
pass |
o = self._objclass(OID,self._OID) |
150 |
|
# save object into cache |
151 |
|
registerObject(o) |
152 |
|
return o |
153 |
|
|
154 |
def _saveChild(self, c): |
def _saveChild(self, c): |
155 |
pass |
pass |
244 |
pass |
pass |
245 |
|
|
246 |
def getChildByOID(self,OID): |
def getChildByOID(self,OID): |
247 |
## not implemented yet |
if isObjectinCache(OID): |
248 |
pass |
return getObject(OID) |
249 |
|
|
250 |
|
data=self._datasource.getIndexedRowData(OID,self._tablename, |
251 |
|
self._oidrow,self._rownames) |
252 |
|
if data and len(data)>0: |
253 |
|
# build new object |
254 |
|
o = self._objclass(OID,self._OID) |
255 |
|
populate = getattr(o,self._populatefunction) |
256 |
|
for record in data: |
257 |
|
params=[] |
258 |
|
for i in self._rownames: |
259 |
|
params.append(record[i]) |
260 |
|
populate(*params) |
261 |
|
|
262 |
|
# save object into cache |
263 |
|
registerObject(o) |
264 |
|
|
265 |
|
# return new object |
266 |
|
return o |
267 |
|
else: |
268 |
|
return None |
269 |
|
|
270 |
def getAllInstances(self): |
def getAllInstances(self): |
271 |
|
|
272 |
# list has to check for any new still uncommited instances too |
# list has to check for any new still uncommited instances too |
273 |
|
|
274 |
try: |
try: |
275 |
list = geasList.geasList(self,self._classAttribs["_tablename"]) |
list = geasList.geasList(self,self._classAttribs["_tablename"]) |
276 |
except KeyError: |
except KeyError: |