[Modeling-cvs] ProjectModeling/Modeling CHANGES,1.115,1.116 CustomObject.py,1.13,1.14 EditingContext
Status: Abandoned
Brought to you by:
sbigaret
|
From: <sbi...@us...> - 2003-07-03 23:03:41
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv17906/Modeling
Modified Files:
CHANGES CustomObject.py EditingContext.py KeyValueCoding.py
utils.py
Log Message:
API change (see mailing-list archives): Added EditingContext.insert(),
delete(), fetch(), fetchCOunt(), autoInsertion(), setAutoInsertion(). Added
CustomObject.globalID(). Added KeyValueCoding.valuesForKeys().
Deprecated methods KeyValueCoding.setValueForKey(), setValueForKeyPath(),
setStoredValueForKey() (will be removed in v0.9.1)
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.115
retrieving revision 1.116
diff -C2 -d -r1.115 -r1.116
*** CHANGES 28 Jun 2003 15:49:15 -0000 1.115
--- CHANGES 3 Jul 2003 23:03:38 -0000 1.116
***************
*** 8,11 ****
--- 8,19 ----
--------------------------------------------------------
+ * API change (see mailing-list archives): Added EditingContext.insert(),
+ delete(), fetch(), fetchCOunt(), autoInsertion(),
+ setAutoInsertion(). Added CustomObject.globalID(). Added
+ KeyValueCoding.valuesForKeys().
+
+ Deprecated methods KeyValueCoding.setValueForKey(), setValueForKeyPath(),
+ setStoredValueForKey() (will be removed in v0.9.1)
+
* documentation: added Project's status page
Index: CustomObject.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CustomObject.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** CustomObject.py 14 Mar 2003 11:40:01 -0000 1.13
--- CustomObject.py 3 Jul 2003 23:03:38 -0000 1.14
***************
*** 160,163 ****
--- 160,169 ----
return self.__editingContext()
+ def globalID(self):
+ """Returns the object's globalID, or None if the object is not registered
+ within an EditingContext"""
+ ec=self.editingContext()
+ return ec and ec.globalIDForObject(self) or None
+
def inverseForRelationshipKey(self, aKey):
"""
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** EditingContext.py 27 Mar 2003 13:39:16 -0000 1.23
--- EditingContext.py 3 Jul 2003 23:03:38 -0000 1.24
***************
*** 638,642 ****
"""
return self._propagatesInsertionForRelatedObjects
!
def setPropagatesInsertionForRelatedObjects(self, bool):
"""
--- 638,643 ----
"""
return self._propagatesInsertionForRelatedObjects
! autoInsertion=propagatesInsertionForRelatedObjects
!
def setPropagatesInsertionForRelatedObjects(self, bool):
"""
***************
*** 660,664 ****
object.propagateInsertionWithEditingContext(self)
self._propagatesInsertionForRelatedObjects=not not bool
!
def saveChanges(self):
"""
--- 661,666 ----
object.propagateInsertionWithEditingContext(self)
self._propagatesInsertionForRelatedObjects=not not bool
! setAutoInsertion=setPropagatesInsertionForRelatedObjects
!
def saveChanges(self):
"""
***************
*** 739,742 ****
--- 741,747 ----
Parameter 'anObject' should already be registered within the
'EditingContext' ; if not, ObjectNotRegisteredError is raised.
+
+ Both methods deleteObject() and delete() are completely equivalent.
+
"""
gID=self.globalIDForObject(anObject)
***************
*** 774,778 ****
gID not in self._pendingDeletedObjects: # ignore
self._pendingDeletedObjects.append(gID)
!
def forgetObject(self, anObject):
"""
--- 779,785 ----
gID not in self._pendingDeletedObjects: # ignore
self._pendingDeletedObjects.append(gID)
!
! delete=deleteObject
!
def forgetObject(self, anObject):
"""
***************
*** 828,831 ****
--- 835,841 ----
or start 'python' with argument '-W error::RuntimeWarning::0'.
(see the documentation for standard module warnings for further details)
+
+ Both methods insertObject() and insert() are completely equivalent.
+
"""
gID=self._uniquingTable.globalIDForObject(anObject)
***************
*** 847,850 ****
--- 857,862 ----
self._pendingInsertedObjects.append(gID)
+ insert=insertObject
+
def insertObjectWithGlobalID(self, anObject, aTemporaryGlobalID):
"""
***************
*** 919,924 ****
object.clearProperties()
except:
! import StringIO, traceback
! exc=StringIO.StringIO()
traceback.print_exc(file=exc)
trace(exc.getvalue())
--- 931,936 ----
object.clearProperties()
except:
! import cStringIO, traceback
! exc=cStringIO.StringIO()
traceback.print_exc(file=exc)
trace(exc.getvalue())
***************
*** 1096,1102 ****
anEditingContext=None):
"""
- Forwards the message to the parentObjectStore(), usually an
- ObjectStoreCoordinator.
-
Returns the approximate number of objects that would be returned by
objectsWithFetchSpecification() if called with the very same parameters.
--- 1108,1111 ----
***************
*** 1108,1111 ****
--- 1117,1123 ----
return them --see its documentation as well).
+ Forwards the message to the parentObjectStore(), usually an
+ ObjectStoreCoordinator.
+
Parameters:
***************
*** 1122,1125 ****
--- 1134,1181 ----
return self.parentObjectStore().objectsCountWithFetchSpecification(aFetchSpecification, anEditingContext)
+ def fetchCount(self, entityName,
+ qualifier=None, # either a Qualifier instance or a string
+ #orderBy=None, # either a SortOrdering or a string
+ isDeep=0, # should subentities be fetched as well?
+ #refresh=0, # unsupported yet
+ #lock=0, # unsupported yet
+ #limit=None, # \
+ #page=None, # > slice parameters, not in core yet
+ #offset=None, # / (page/offset: mutually exclusive)
+ ):
+ """
+ Returns the approximate number of objects that would be returned by
+ fetch() if called with the very same parameters.
+
+ About ``approximate'': the number returned is in fact the upper bound ; as
+ the objects are not actually fetched against the database, it is not
+ possible to determine whether some have already been deleted within
+ anEditingContext (in which case objectsWithFetchSpecification() would not
+ return them --see its documentation as well).
+
+ Returns the objects identified by the following parameters:
+
+ entityName -- the corresponding entity's name (see also isDeep, below)
+
+ qualifier -- a string qualifying the objects to be fetched (a instance
+ of Qualifier can also be supplied)
+
+ isDeep -- shall the fetch be made against the entity and its
+ sub-entities?
+
+ """
+
+ if type(qualifier)==type(''):
+ from Qualifier import qualifierWithQualifierFormat
+ qualifier=qualifierWithQualifierFormat(qualifier)
+ #if type(orderBy)==type(''):
+ # from SortOrdering import sortOrderingsWithString
+ # orderBy=sortOrderingsWithString(orderBy)
+ from Modeling.FetchSpecification import FetchSpecification
+ fs=FetchSpecification(entityName, qualifier=qualifier, deepFlag=isDeep)
+ #fs.setLocksObject(lock)
+ #fs.setRefreshesRefetchedObjects(refresh)
+ return self.objectsCountWithFetchSpecification(fs)
+
def objectsWithFetchSpecification(self, aFetchSpecification,
anEditingContext=None):
***************
*** 1210,1213 ****
--- 1266,1304 ----
return objects
+
+ def fetch(self, entityName,
+ qualifier=None, # either a Qualifier instance or a string
+ #orderBy=None, # either a SortOrdering or a string
+ isDeep=0, # should subentities be fetched as well?
+ #refresh=0, # unsupported yet
+ #lock=0, # unsupported yet
+ #limit=None, # \
+ #page=None, # > slice parameters, not in core yet
+ #offset=None, # / (page/offset: mutually exclusive)
+ ):
+ """
+ Returns the objects identified by the following parameters:
+
+ entityName -- the corresponding entity's name (see also isDeep, below)
+
+ qualifier -- a string qualifying the objects to be fetched (a instance
+ of Qualifier can also be supplied)
+
+ isDeep -- shall the fetch be made against the entity and its
+ sub-entities?
+
+ """
+
+ if type(qualifier)==type(''):
+ from Qualifier import qualifierWithQualifierFormat
+ qualifier=qualifierWithQualifierFormat(qualifier)
+ #if type(orderBy)==type(''):
+ # from SortOrdering import sortOrderingsWithString
+ # orderBy=sortOrderingsWithString(orderBy)
+ from Modeling.FetchSpecification import FetchSpecification
+ fs=FetchSpecification(entityName, qualifier=qualifier, deepFlag=isDeep)
+ #fs.setLocksObject(lock)
+ #fs.setRefreshesRefetchedObjects(refresh)
+ return self.objectsWithFetchSpecification(fs)
def ownsObject(self, anObject):
Index: KeyValueCoding.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/KeyValueCoding.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** KeyValueCoding.py 26 Jan 2003 17:41:18 -0000 1.5
--- KeyValueCoding.py 3 Jul 2003 23:03:38 -0000 1.6
***************
*** 41,44 ****
--- 41,45 ----
except: pass
+ from utils import deprecated
import string
***************
*** 126,138 ****
return takeValueForKeyPath(self, value, key)
- # aliases
- def setValueForKey(self, value, key):
- "See interfaces.KeyValueCoding for details"
- self.takeValueForKey(value, key)
-
- def setValueForKeyPath(self, value, keypath):
- "See interfaces.KeyValueCoding for details"
- self.takeValueForKeyPath(value, keypath)
-
## 2. So-called 'private' access methods
def storedValueForKey(self, key):
--- 127,130 ----
***************
*** 174,181 ****
self.handleTakeStoredValueForUnboundKey(value, key)
- def setStoredValueForKey(self, value, key):
- "An alias for 'takeStoredValueForKey()'"
- self.takeStoredValueForKey(self, value, key)
-
## 3. Error handling
def handleQueryWithUnboundKey(self, key):
--- 166,169 ----
***************
*** 209,213 ****
--- 197,224 ----
for key in dictionary.keys():
self.takeValueForKey(dictionary[key], key)
+
+ def valuesForKeys(self, keys):
+ "See interfaces.KeyValueCoding for details"
+ res=[]
+ for key in keys:
+ res.append(self.valueForKey(key))
+ return res
+ # DEPRECATED aliases
+ def setValueForKey(self, value, key):
+ "DEPRECATED -- alias for takeValueForKey()"
+ deprecated('setValueForKey', 'takeValueForKey', '0.9.1')
+ self.takeValueForKey(value, key)
+
+ def setValueForKeyPath(self, value, keypath):
+ "DEPRECATED -- alias for takeValueForKeyPath()"
+ deprecated('setValueForKeyPath', 'takeValueForKeyPath', '0.9.1')
+ self.takeValueForKeyPath(value, keypath)
+
+ def setStoredValueForKey(self, value, key):
+ "DEPRECATED -- alias for 'takeStoredValueForKey()'"
+ deprecated('setStoredValueForKey', 'takeStoredValueForKey', '0.9.1')
+ self.takeStoredValueForKey(self, value, key)
+
try:
verify_class_implementation(KeyValueCodingInterface, KeyValueCoding)
Index: utils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/utils.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** utils.py 14 Mar 2003 11:40:10 -0000 1.10
--- utils.py 3 Jul 2003 23:03:38 -0000 1.11
***************
*** 170,171 ****
--- 170,179 ----
except TypeError: pass
+ def deprecated(methodName, replacement=None,removed_in_version=None):
+ msg="Method %s is deprecated."
+ if replacement:
+ msg+=" Please use %s instead."
+ if removed_in_version:
+ msg+="\nThis method will be removed for version %s"%removed_in_version
+ import warnings
+ warnings.warn(msg, DeprecationWarning, 2)
|