[Modeling-cvs] ProjectModeling/Modeling EditingContext.py,1.20,1.21 CHANGES,1.75,1.76
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-03-12 15:45:59
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv24823
Modified Files:
EditingContext.py CHANGES
Log Message:
Fixed EditingContext.objectsWithFetchSpecification(): when a nested EC
asks for objects, the result set now correctly includes objects that
are inserted in its parent (or grand-parent, etc.) and objects that
are marked as deleted in the parent are excluded.
See also: tests.test_EditingContext_ParentChild,
test_10_child_gets_newly_inserted_objects() and
test_11_child_doesnt_get_deleted_objects()
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** EditingContext.py 12 Mar 2003 11:06:09 -0000 1.20
--- EditingContext.py 12 Mar 2003 15:45:54 -0000 1.21
***************
*** 1135,1140 ****
insertObject()) but that are not saved yet.
! Last, objects that are marked as deleted (cf. deleteObject()) in the
EditingContext are not returned.
If parameter 'anEditingContext' is omitted or 'None', it defaults to
--- 1135,1145 ----
insertObject()) but that are not saved yet.
! Objects that are marked as deleted (cf. deleteObject()) in the
EditingContext are not returned.
+
+ When a nested EditingContext fetches objects, the result set will contain
+ the objects that are inserted in the parent (or the parent's parent,
+ etc.), and objects which are marked as deleted in parent will not be part
+ of the result set.
If parameter 'anEditingContext' is omitted or 'None', it defaults to
***************
*** 1150,1157 ****
fs=aFetchSpecification
ec=anEditingContext
objects=self.parentObjectStore().objectsWithFetchSpecification(fs, ec)
! if anEditingContext is self:
entitiesNames=[fs.entityName()]
if fs.isDeep():
--- 1155,1163 ----
fs=aFetchSpecification
ec=anEditingContext
+ # +--> From this point we use 'ec' instead of 'anEditingContext'
objects=self.parentObjectStore().objectsWithFetchSpecification(fs, ec)
! if ec is self or ec.isaChildOf(self):
entitiesNames=[fs.entityName()]
if fs.isDeep():
***************
*** 1163,1175 ****
for entityName in entitiesNames:
# do not include deleted objects in the returned set of objects
! ec_deletedObjects = ec.allDeletedObjects()
! ec_insertedObjects = ec.allInsertedObjects()
! for object in objects:
! if object in ec_deletedObjects:
! objects.remove(object)
# now append inserted objects
objs=[o for o in ec_insertedObjects if o.entityName()==entityName]
if fs.qualifier():
objs=filteredArrayWithQualifier(objs,fs.qualifier())
objects.extend(objs)
--- 1169,1207 ----
for entityName in entitiesNames:
# do not include deleted objects in the returned set of objects
! ec_insertedObjects = self.allInsertedObjects()
!
! if ec.isaChildOf(self):
!
! # If we're returning objects for a child's use, we remove the one
! # that are marked for deletion in the parent (self) However, the
! # deleted objects in self and the ones in the child-ec are distinct,
! # but the GlobalIDs are the same and this is what we do here:
! # compare the gIDs and remove the apropriate objects from the result
! # set
! ec_deletedGids=self._deletedObjects+self._pendingDeletedObjects
! objects=[o for o in objects
! if ec.globalIDForObject(o) not in ec_deletedGids]
!
! else:
! # We work for self, so we just remove the ones that are already
! # marked as deleted
! ec_deletedObjects = self.allDeletedObjects()
! objects=[o for o in objects if o not in ec_deletedObjects]
!
# now append inserted objects
objs=[o for o in ec_insertedObjects if o.entityName()==entityName]
if fs.qualifier():
objs=filteredArrayWithQualifier(objs,fs.qualifier())
+
+ # If we are returning objects for a child's use it is NOT POSSIBLE to
+ # return our (self's) objects, instead, we return a fault for the
+ # given object.
+ # Note that faultForGlobalID() is responsible for cloning inserted
+ # objects when they are requested by the nested EditingContext
+ if ec.isaChildOf(self):
+ fault_objs=[ec.faultForGlobalID(self.globalIDForObject(o), ec)
+ for o in objs]
+ objs=fault_objs
+
objects.extend(objs)
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.75
retrieving revision 1.76
diff -C2 -d -r1.75 -r1.76
*** CHANGES 10 Mar 2003 16:36:08 -0000 1.75
--- CHANGES 12 Mar 2003 15:45:55 -0000 1.76
***************
*** 8,18 ****
--------------------------------------------------------
! * EditingContext.saveChangesInEditingContext(): now locks 'self' before
! proceeding, so that two nested \class{EditingContext} which have the same
! parent and are managed by two different threads can concurrently save
! their changes to their parent without explictly locking it.
! (this is logical since a EC is supposed to perform any of its
! operations safely in a multi-threaded environment --given that it's
! not shared between threads, obviously)
* Added Modeling.utilities.EditingContextSessioning
--- 8,29 ----
--------------------------------------------------------
! * EditingContext
!
! + saveChangesInEditingContext(): now locks 'self' before proceeding, so
! that two nested \class{EditingContext} which have the same parent and
! are managed by two different threads can concurrently save their changes
! to their parent without explictly locking it. (this is logical since a
! EC is supposed to perform any of its operations safely in a
! multi-threaded environment --given that it's not shared between threads,
! obviously)
!
! + Fixed objectsWithFetchSpecification(): when a nested EC asks for
! objects, the result set now correctly includes objects that are inserted
! in its parent (or grand-parent, etc.) and objects that are marked as
! deleted in the parent are excluded.
!
! See also: tests.test_EditingContext_ParentChild,
! test_10_child_gets_newly_inserted_objects() and
! test_11_child_doesnt_get_deleted_objects()
* Added Modeling.utilities.EditingContextSessioning
|