modeling-cvs Mailing List for Object-Relational Bridge for python (Page 21)
Status: Abandoned
Brought to you by:
sbigaret
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
(54) |
Apr
(29) |
May
(94) |
Jun
(47) |
Jul
(156) |
Aug
(132) |
Sep
(40) |
Oct
(6) |
Nov
(18) |
Dec
(24) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(18) |
Feb
(59) |
Mar
(7) |
Apr
|
May
(8) |
Jun
(2) |
Jul
(12) |
Aug
(15) |
Sep
(12) |
Oct
(6) |
Nov
(25) |
Dec
(1) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
(27) |
Mar
|
Apr
(16) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sbi...@us...> - 2003-07-18 15:13:57
|
Update of /cvsroot/modeling/ZModeling In directory sc8-pr-cvs1:/tmp/cvs-serv28624 Modified Files: CHANGES Log Message: Release 0.9-pre-10 Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ZModeling/CHANGES,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CHANGES 4 Jul 2003 17:29:29 -0000 1.20 --- CHANGES 18 Jul 2003 15:13:54 -0000 1.21 *************** *** 1,5 **** -*- text -*- ! Current release is: 0.9-pre-9 0.9-pre-9 (2003/07/04) --- 1,13 ---- -*- text -*- ! Current release is: 0.9-pre-10 ! ! 0.9-pre-10 (2003/07/18) ! ----------------------- ! ! * ZModelizationTool: The core changed ClassDescription's delete rules: ! constants DELETE_CASCADE, DELETE_DENY, DELETE_NULLIFY and ! DELETE_NOACTION are now strings (were: integers) ! 2 dtmls updated. Full backward compatibility. 0.9-pre-9 (2003/07/04) |
|
From: <sbi...@us...> - 2003-07-18 15:01:16
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage
In directory sc8-pr-cvs1:/tmp/cvs-serv26462/Modeling/doc/HomePage
Modified Files:
main.tex downloads.tex
Log Message:
Release 0.9-pre-10
Index: main.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/main.tex,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** main.tex 4 Jul 2003 17:43:47 -0000 1.18
--- main.tex 18 Jul 2003 15:01:13 -0000 1.19
***************
*** 7,11 ****
% Increment the release number whenever significant changes are made.
% The author and/or editor can define 'significant' however they like.
! %\release{0.9-pre-9}
% At minimum, give your name and an email address. You can include a
--- 7,11 ----
% Increment the release number whenever significant changes are made.
% The author and/or editor can define 'significant' however they like.
! %\release{0.9-pre-10}
% At minimum, give your name and an email address. You can include a
***************
*** 13,17 ****
\author{S\'ebastien Bigaret}
\email{sbi...@us...}
! \date{Jun 04, 2003}
%\date{\today}
--- 13,17 ----
\author{S\'ebastien Bigaret}
\email{sbi...@us...}
! \date{Jun 18, 2003}
%\date{\today}
Index: downloads.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/downloads.tex,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** downloads.tex 17 Jul 2003 10:05:20 -0000 1.11
--- downloads.tex 18 Jul 2003 15:01:13 -0000 1.12
***************
*** 10,14 ****
\begin{enumerate}
! \item[\bf Current version: 0.9-pre-9]
Download it here:\begin{rawhtml}<a
--- 10,14 ----
\begin{enumerate}
! \item[\bf Current version: 0.9-pre-10]
Download it here:\begin{rawhtml}<a
|
|
From: <sbi...@us...> - 2003-07-18 15:01:16
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv26462/Modeling/doc
Modified Files:
UserGuide.tex Tutorial.tex
Log Message:
Release 0.9-pre-10
Index: UserGuide.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide.tex,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** UserGuide.tex 4 Jul 2003 17:29:29 -0000 1.23
--- UserGuide.tex 18 Jul 2003 15:01:13 -0000 1.24
***************
*** 12,18 ****
% the rest is at your discretion.
\authoraddress{Email: \email{sbi...@us...}}
! \date{Jun 04, 2003}
%\date{\today}
! \release{0.9-pre-9}
%\setreleaseinfo{pre-8}
\setshortversion{0.9}
--- 12,18 ----
% the rest is at your discretion.
\authoraddress{Email: \email{sbi...@us...}}
! \date{Jun 18, 2003}
%\date{\today}
! \release{0.9-pre-10}
%\setreleaseinfo{pre-8}
\setshortversion{0.9}
Index: Tutorial.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/Tutorial.tex,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Tutorial.tex 4 Jul 2003 17:29:29 -0000 1.5
--- Tutorial.tex 18 Jul 2003 15:01:13 -0000 1.6
***************
*** 14,18 ****
\date{February 10, 2003}
%\date{\today}
! \release{0.9-pre-9}
%\setreleaseinfo{5}
\setshortversion{0.9}
--- 14,18 ----
\date{February 10, 2003}
%\date{\today}
! \release{0.9-pre-10}
%\setreleaseinfo{5}
\setshortversion{0.9}
|
|
From: <sbi...@us...> - 2003-07-18 15:01:15
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv26462/Modeling
Modified Files:
CHANGES
Log Message:
Release 0.9-pre-10
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** CHANGES 18 Jul 2003 14:30:45 -0000 1.127
--- CHANGES 18 Jul 2003 15:01:13 -0000 1.128
***************
*** 3,11 ****
Module Modeling
---------------
! Current release is: 0.9-pre-9 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
* Fixed bug #772997: deleted then re-insert objects not correctly handled.
--- 3,14 ----
Module Modeling
---------------
! Current release is: 0.9-pre-10 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
+ 0.9-pre-10 (2003/07/18)
+ -----------------------
+
* Fixed bug #772997: deleted then re-insert objects not correctly handled.
***************
*** 27,30 ****
--- 30,37 ----
[Merged branch brch-0_9pre7-1-PyModel]
+
+ Note: PyModel are not officially announced w/ this release, because there's
+ no documentation yet. See mailing-list archives for details, or go
+ there and ask.
* Fixed: adaptorModel() could raise instead of returning None when model's
|
|
From: <sbi...@us...> - 2003-07-18 15:01:15
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv26462
Modified Files:
setup.py
Log Message:
Release 0.9-pre-10
Index: setup.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/setup.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** setup.py 4 Jul 2003 17:29:29 -0000 1.26
--- setup.py 18 Jul 2003 15:01:12 -0000 1.27
***************
*** 46,50 ****
setup(name="ModelingCore",
! version="0.9-pre-9",
licence ="GNU General Public License",
description=short_description,
--- 46,50 ----
setup(name="ModelingCore",
! version="0.9-pre-10",
licence ="GNU General Public License",
description=short_description,
|
|
From: <sbi...@us...> - 2003-07-18 14:56:56
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage
In directory sc8-pr-cvs1:/tmp/cvs-serv25755/doc/HomePage
Modified Files:
contributors.tex
Log Message:
Added credits for SICEm, which invests some time on supporting open-source projects, including this framework
Index: contributors.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/contributors.tex,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** contributors.tex 8 Jul 2003 10:09:55 -0000 1.3
--- contributors.tex 18 Jul 2003 14:56:25 -0000 1.4
***************
*** 14,18 ****
\begin{itemize}
\item Yannick Gingras from \begin{rawhtml}<a href="http://www.savoirfairelinux.com/">Savoir-faire Linux</A>\end{rawhtml}
! \item Ernesto Revilla
\item Mario Ruggier
\end{itemize}
--- 14,18 ----
\begin{itemize}
\item Yannick Gingras from \begin{rawhtml}<a href="http://www.savoirfairelinux.com/">Savoir-faire Linux</A>\end{rawhtml}
! \item Ernesto Revilla from \begin{rawhtml}<a href="http://www.sicem.biz/">SICEm</A>\end{rawhtml}
\item Mario Ruggier
\end{itemize}
|
|
From: <sbi...@us...> - 2003-07-18 14:30:49
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv21897/tests
Modified Files:
test_EditingContext_Global.py
Log Message:
Fixed bug #772997: deleted then re-insert objects not correctly handled.
Index: test_EditingContext_Global.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** test_EditingContext_Global.py 16 Jul 2003 19:05:37 -0000 1.29
--- test_EditingContext_Global.py 18 Jul 2003 14:30:46 -0000 1.30
***************
*** 990,995 ****
self.assertEqual(fdard.snapshot_raw()['lastName'], fdard_name)
def test_999_customSQLQuery(self):
! "[EditingContext] customSQLQuery"
fs=FetchSpecification(entityName='Writer')
#dbContext=EditingContext().rootObjectStore().objectStoreForFetchSpecification(fs)
--- 990,1064 ----
self.assertEqual(fdard.snapshot_raw()['lastName'], fdard_name)
+ def test_22_cancel_delete(self):
+ "[EditingContext] cancel a delete on an object"
+ ## check: delete / insert
+ ec=EditingContext()
+ rabelais=ec.fetch('Writer', 'lastName == "Rabelais"')[0]
+ ec.deleteObject(rabelais)
+ self.failUnless(rabelais in ec.allDeletedObjects())
+ self.failIf(rabelais in ec.deletedObjects()) # unprocessed
+ ec.insertObject(rabelais) # cancel the deletion
+ self.failIf(len(ec.fetch('Writer', 'lastName == "Rabelais"'))!=1)
+ self.failIf(rabelais in ec.allDeletedObjects())
+ self.failIf(rabelais in ec.allInsertedObjects())
+
+ ## check: delete / processRecentChanges / insert
+ ec=EditingContext()
+ rabelais=ec.fetch('Writer', 'lastName == "Rabelais"')[0]
+ ec.deleteObject(rabelais)
+ self.failUnless(rabelais in ec.allDeletedObjects())
+ ec.processRecentChanges()
+ self.failUnless(rabelais in ec.deletedObjects())
+ ec.insertObject(rabelais) # cancel the deletion
+ self.failIf(rabelais in ec.allDeletedObjects())
+ self.failIf(rabelais in ec.allInsertedObjects())
+
+ ## check: delete / saveChanges / insert
+ ec=EditingContext()
+ new=Writer(); new.setLastName('test_22')
+ ec.insert(new)
+ ec.saveChanges()
+
+ ec=EditingContext()
+ new=ec.fetch('Writer', 'lastName == "test_22"')[0]
+ new_gid=new.globalID()
+ ec.deleteObject(new)
+ self.failUnless(new in ec.allDeletedObjects())
+ self.failIf(new in ec.deletedObjects())
+ ec.saveChanges()
+ ec.insertObject(new) # cancel the deletion? No, insertion of a new object
+ self.failIf(new in ec.allDeletedObjects())
+ self.failUnless(new in ec.allInsertedObjects())
+ self.failIf(new.globalID()==new_gid)
+ self.failIf(not new.globalID().isTemporary())
+
+ ## check: modify / delete / processRecentChanges / insert -> in modify?
+ ec=EditingContext()
+ new=Writer(); new.setLastName('test_22')
+ ec.insert(new)
+ ec.saveChanges()
+
+ ec=EditingContext()
+ new=ec.fetch('Writer', 'lastName == "test_22"')[0]
+ new_gid=new.globalID()
+ new.setLastName('test_22 alternate value')
+ self.failUnless(new in ec.allUpdatedObjects())
+ ec.deleteObject(new)
+ self.failUnless(new in ec.allDeletedObjects())
+ self.failIf(new in ec.deletedObjects())
+ self.failIf(new in ec.allUpdatedObjects())
+ ec.processRecentChanges()
+ self.failUnless(new in ec.deletedObjects())
+ self.failIf(new in ec.allUpdatedObjects())
+ ec.insertObject(new) # cancel the deletion
+ self.failIf(new in ec.allDeletedObjects())
+ self.failUnless(new in ec.allUpdatedObjects())
+ self.failUnless(new.globalID()==new_gid)
+
+
+ ## check: modify / delete / saveChanges / insert
+
def test_999_customSQLQuery(self):
! "[EditingContext] custom SQL Query"
fs=FetchSpecification(entityName='Writer')
#dbContext=EditingContext().rootObjectStore().objectStoreForFetchSpecification(fs)
|
|
From: <sbi...@us...> - 2003-07-18 14:30:49
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv21897
Modified Files:
TODO CHANGES EditingContext.py
Log Message:
Fixed bug #772997: deleted then re-insert objects not correctly handled.
Index: TODO
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/TODO,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** TODO 28 Jun 2003 15:45:26 -0000 1.13
--- TODO 18 Jul 2003 14:30:45 -0000 1.14
***************
*** 160,163 ****
--- 160,167 ----
memory footprint low.
+ EditingContext.insertObject(): cf. comment when reinserting a previously
+ deleted object: if we had our own snapshoting in EC we could decide
+ whether an re-inserted object should be marked as updated or not.
+
* CustomObject & observability: the implementation requires that willRead()
and willChange() are called, when appropriate. This should be
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.126
retrieving revision 1.127
diff -C2 -d -r1.126 -r1.127
*** CHANGES 18 Jul 2003 13:37:26 -0000 1.126
--- CHANGES 18 Jul 2003 14:30:45 -0000 1.127
***************
*** 8,11 ****
--- 8,13 ----
--------------------------------------------------------
+ * Fixed bug #772997: deleted then re-insert objects not correctly handled.
+
* Added the ability to fetch raw rows (dictionaries instead of fully
intialized objects) --see FetchSpecification.setFetchesRawRows() and
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** EditingContext.py 18 Jul 2003 13:43:39 -0000 1.29
--- EditingContext.py 18 Jul 2003 14:30:45 -0000 1.30
***************
*** 906,912 ****
else:
raise ValueError, 'Object already registered'
! if gID in self._pendingDeletedObjects:
! self._pendingDeletedObjects.remove(gID)
! self._pendingInsertedObjects.append(gID)
insert=insertObject
--- 906,918 ----
else:
raise ValueError, 'Object already registered'
! else: # cancel the deletion
! if gID in self._pendingDeletedObjects:
! self._pendingDeletedObjects.remove(gID)
! if gID in self._deletedObjects:
! self._deletedObjects.remove(gID)
! # Mark it as updated, because we here have no way to know whether
! # it was updated or not before it was deleted, or even between its
! # deletion and the cancellation of its deletion!
! self._pendingUpdatedObjects.append(gID)
insert=insertObject
|
|
From: <sbi...@us...> - 2003-07-18 13:50:38
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv16071
Modified Files:
EntityClassDescription.py
Log Message:
Fixed a variable name, badly chosen
Index: EntityClassDescription.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EntityClassDescription.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** EntityClassDescription.py 16 Jul 2003 18:41:37 -0000 1.13
--- EntityClassDescription.py 18 Jul 2003 13:50:34 -0000 1.14
***************
*** 214,220 ****
See also: toOneRelationshipKeys(), allToOneRelationshipKeys()
"""
! toManyRels=filter(lambda rel: rel.isToOne(), self._entity.relationships())
res=[]
! for rel in toManyRels:
res.extend([a.name() for a in rel.sourceAttributes()])
return res
--- 214,220 ----
See also: toOneRelationshipKeys(), allToOneRelationshipKeys()
"""
! toOneRels=filter(lambda rel: rel.isToOne(), self._entity.relationships())
res=[]
! for rel in toOneRels:
res.extend([a.name() for a in rel.sourceAttributes()])
return res
|
|
From: <sbi...@us...> - 2003-07-18 13:43:43
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv14941
Modified Files:
EditingContext.py
Log Message:
Slight perf. enhancement in insertObject(): most of the time deleted objects are pending, because most of the time processRecentChanges() is not run indepently from saveChanges()
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** EditingContext.py 18 Jul 2003 11:32:52 -0000 1.28
--- EditingContext.py 18 Jul 2003 13:43:39 -0000 1.29
***************
*** 898,903 ****
else:
# Already registered: only deleted objects are allowed to re-insert
! if not gID in self._deletedObjects and \
! not gID in self._pendingDeletedObjects:
if self.propagatesInsertionForRelatedObjects():
import warnings
--- 898,903 ----
else:
# Already registered: only deleted objects are allowed to re-insert
! if not gID in self._pendingDeletedObjects and \
! not gID in self._deletedObjects:
if self.propagatesInsertionForRelatedObjects():
import warnings
|
|
From: <sbi...@us...> - 2003-07-18 13:37:30
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv13952
Modified Files:
CHANGES
Log Message:
misc.
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** CHANGES 16 Jul 2003 19:16:00 -0000 1.125
--- CHANGES 18 Jul 2003 13:37:26 -0000 1.126
***************
*** 12,15 ****
--- 12,16 ----
EditingContext.fetch() 's parameter 'rawRows'. Also added the possibility
to turn these rows into real objects --see EditingContext.faultForRawRow()
+ Documentation updated.
* Added CustomObject.snapshot_raw(), support for the future ability to fetch
|
|
From: <sbi...@us...> - 2003-07-18 13:37:07
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv13683
Modified Files:
DatabaseChannel.py
Log Message:
Reverted the "enhancement" made in the previous version: while enhancing perfs
when no obejcts were modified, it was dramatically (I mean that) slow when a
lot of objects were modified.
Index: DatabaseChannel.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseChannel.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** DatabaseChannel.py 18 Jul 2003 11:44:46 -0000 1.15
--- DatabaseChannel.py 18 Jul 2003 13:37:03 -0000 1.16
***************
*** 153,185 ****
if self.fetchesRawRows():
ec=self._editingContext
! ## Implementation note:
! # we formerly had the straighforward code:
! # object=ec.objectForGlobalID(globalID)
! # if object is not None:
! # return object.snapshot_raw()
! #
! # This works, but the more objects were already loaded within the
! # EditingContext, the slower it was. So we changed it to this version,
! # which does not have this drawback. However, obviously, the more
! # updated objects we have in the EditingContext, the slower it will be.
! # This CANNOT be changed: if an object is modified, its current state
! # should be reflected in the result set.
! if globalID in ec.allUpdatedGlobalIDs():
! return ec.objectForGlobalID(globalID).snapshot_raw()
! else:
! # Check the database cache: if it's already cached, use the cached
! # snapshot instead of the row coming from the db. If we do not do
! # this and the row has been changed independently from the framework,
! # then we'll get the raw snapshot and the corresponding object not
! # exposing the same values --and we do not want that, this is not
! # our problem here, rather, this would be handled w/ optimistic
! # locking.
! database=self.databaseContext().database()
! registeredSnapshot=database.snapshotForGlobalID(globalID)
! if registeredSnapshot:
! return registeredSnapshot
else:
! return dict
!
# Get snapshot
#snapshot=self._currentEntity.snapshotForRow(dict)
--- 153,170 ----
if self.fetchesRawRows():
ec=self._editingContext
! object=ec.objectForGlobalID(globalID)
! if object is not None:
! if not object.isFault():
! return object.snapshot_raw()
else:
! database=self.databaseContext().database()
! registeredSnapshot=database.snapshotForGlobalID(globalID)
! if registeredSnapshot:
! return registeredSnapshot
! else:
! return dict
! else:
! return dict
!
# Get snapshot
#snapshot=self._currentEntity.snapshotForRow(dict)
|
|
From: <sbi...@us...> - 2003-07-18 11:44:49
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv28258
Modified Files:
DatabaseChannel.py
Log Message:
Quicker implementation of fetchObject() w/ raw rows: runs at the same speed (or almost) when the ec has no objects, and when the EC already has the objects and these objects are NOT modified
Index: DatabaseChannel.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseChannel.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** DatabaseChannel.py 16 Jul 2003 19:16:00 -0000 1.14
--- DatabaseChannel.py 18 Jul 2003 11:44:46 -0000 1.15
***************
*** 153,161 ****
if self.fetchesRawRows():
ec=self._editingContext
! object=ec.objectForGlobalID(globalID)
! if object is not None:
! return object.snapshot_raw()
else:
! return dict
# Get snapshot
--- 153,184 ----
if self.fetchesRawRows():
ec=self._editingContext
! ## Implementation note:
! # we formerly had the straighforward code:
! # object=ec.objectForGlobalID(globalID)
! # if object is not None:
! # return object.snapshot_raw()
! #
! # This works, but the more objects were already loaded within the
! # EditingContext, the slower it was. So we changed it to this version,
! # which does not have this drawback. However, obviously, the more
! # updated objects we have in the EditingContext, the slower it will be.
! # This CANNOT be changed: if an object is modified, its current state
! # should be reflected in the result set.
! if globalID in ec.allUpdatedGlobalIDs():
! return ec.objectForGlobalID(globalID).snapshot_raw()
else:
! # Check the database cache: if it's already cached, use the cached
! # snapshot instead of the row coming from the db. If we do not do
! # this and the row has been changed independently from the framework,
! # then we'll get the raw snapshot and the corresponding object not
! # exposing the same values --and we do not want that, this is not
! # our problem here, rather, this would be handled w/ optimistic
! # locking.
! database=self.databaseContext().database()
! registeredSnapshot=database.snapshotForGlobalID(globalID)
! if registeredSnapshot:
! return registeredSnapshot
! else:
! return dict
# Get snapshot
|
|
From: <sbi...@us...> - 2003-07-18 11:32:55
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv26540
Modified Files:
EditingContext.py
Log Message:
Added allInsertedGlobalIDs(), allUpdatedGlobalIDs() and allDeletedGlobalIDs()
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** EditingContext.py 17 Jul 2003 15:16:28 -0000 1.27
--- EditingContext.py 18 Jul 2003 11:32:52 -0000 1.28
***************
*** 363,366 ****
--- 363,380 ----
# Changes within the editing context
+ def allDeletedGlobalIDs(self):
+ """
+ Returns a sequence made of GlobalIDs of objects that have been deleted
+ into the EditingContext and that have not been made persistent yet.
+
+ The GlobalIDs returned are those identifying objects who were marked as
+ deleted within the EditingContext, while deletedGlobalIDs() only returns
+ the GlobalIDs for objects that were marked as deleted before the last
+ invocation of processRecentChanges() (or saveChanges()).
+
+ See also: deletedGlobalIDs(), allDeletedObjects()
+ """
+ return tuple(self._deletedObjects+self._pendingDeletedObjects)
+
def deletedGlobalIDs(self):
"""
***************
*** 368,371 ****
--- 382,390 ----
graph of objects managed by the EditingContext.
+ The GlobalIDs returned are those indentifying objects who were marked as
+ deleted before the last invocation of processRecentChanges() (or
+ saveChanges()). If you want to get all deleted GlobalIDs, see
+ allDeletedGlobalIDs().
+
See also: deletedObjects()
"""
***************
*** 400,403 ****
--- 419,436 ----
return map(self.objectForGlobalID, self._deletedObjects)
+ def allInsertedGlobalIDs(self):
+ """
+ Returns a sequence made of GlobalIDs of objects that have been inserted
+ into the EditingContext and that have not been made persistent yet.
+
+ The GlobalIDs returned are those identifying objects who were marked as
+ inserted within the EditingContext, while insertedGlobalIDs() only returns
+ the GlobalIDs for objects that were marked as inserted before the last
+ invocation of processRecentChanges() (or saveChanges()).
+
+ See also: insertedObjects(), allInsertedObjects()
+ """
+ return tuple(self._insertedObjects+self._pendingInsertedObjects)
+
def insertedGlobalIDs(self):
"""
***************
*** 406,412 ****
into the EditingContext and that have not been made persistent yet.
! The objects returned are those who were marked as inserted before the last
! invocation of processRecentChanges() (or saveChanges()). If you want to
! get all inserted objects, see allInsertedObjects().
See also: insertedObjects()
--- 439,446 ----
into the EditingContext and that have not been made persistent yet.
! The GlobalIDs returned are those indentifying objects who were marked as
! inserted before the last invocation of processRecentChanges() (or
! saveChanges()). If you want to get all inserted GlobalIDs, see
! allInsertedGlobalIDs().
See also: insertedObjects()
***************
*** 442,445 ****
--- 476,493 ----
return map(self.objectForGlobalID, self._insertedObjects)
+ def allUpdatedGlobalIDs(self):
+ """
+ Returns a sequence made of GlobalIDs of objects that have been updated
+ into the EditingContext and that have not been made persistent yet.
+
+ The GlobalIDs returned are those identifying objects who were marked as
+ updated within the EditingContext, while updatedGlobalIDs() only returns
+ the GlobalIDs for objects that were marked as updated before the last
+ invocation of processRecentChanges() (or saveChanges()).
+
+ See also: updatedObjects(), allUpdatedObjects()
+ """
+ return tuple(self._updatedObjects+self._pendingUpdatedObjects)
+
def updatedGlobalIDs(self):
"""
***************
*** 447,451 ****
the last saveChanges(), or since the EditingContext was created.
! See also: updatedObjects()
"""
return tuple(self._updatedObjects)
--- 495,504 ----
the last saveChanges(), or since the EditingContext was created.
! The GlobalIDs returned are those indentifying objects who were marked as
! updated before the last invocation of processRecentChanges() (or
! saveChanges()). If you want to get all updated GlobalIDs, see
! allUpdatedGlobalIDs().
!
! See also: allUpdatedGlobalIDs(), updatedObjects()
"""
return tuple(self._updatedObjects)
***************
*** 856,860 ****
self._pendingDeletedObjects.remove(gID)
self._pendingInsertedObjects.append(gID)
!
insert=insertObject
--- 909,913 ----
self._pendingDeletedObjects.remove(gID)
self._pendingInsertedObjects.append(gID)
!
insert=insertObject
***************
*** 1252,1256 ****
if not self_obj.isFault():
objects[objects.index(o)]=self_obj.snapshot_raw()
!
if ec is self or ec.isaChildOf(self):
entitiesNames=[fs.entityName()]
--- 1305,1309 ----
if not self_obj.isFault():
objects[objects.index(o)]=self_obj.snapshot_raw()
!
if ec is self or ec.isaChildOf(self):
entitiesNames=[fs.entityName()]
|
|
From: <sbi...@us...> - 2003-07-18 10:37:44
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv18071
Modified Files:
ObjectStoreCoordinator.py
Log Message:
enabled warning for exception before swallowing it
Index: ObjectStoreCoordinator.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ObjectStoreCoordinator.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ObjectStoreCoordinator.py 16 Jul 2003 19:16:00 -0000 1.10
--- ObjectStoreCoordinator.py 18 Jul 2003 10:37:41 -0000 1.11
***************
*** 548,556 ****
except:
warn("Got an exception: rollback changes")
! #if 1: # __TBD if DEBUG (somehow)
! # exc=StringIO.StringIO()
! # traceback.print_exc(file=exc)
! # debug(exc.getvalue())
! # del exc
exctype, value = sys.exc_info()[:2]
--- 548,556 ----
except:
warn("Got an exception: rollback changes")
! if 1: # __TBD if DEBUG (somehow)
! exc=StringIO.StringIO()
! traceback.print_exc(file=exc)
! warn(exc.getvalue())
! del exc
exctype, value = sys.exc_info()[:2]
|
|
From: <sbi...@us...> - 2003-07-18 10:33:55
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv17555
Modified Files:
logging.py
Log Message:
Fixed: now logging accepts unicode messages
Index: logging.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/logging.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** logging.py 20 Feb 2003 11:48:58 -0000 1.5
--- logging.py 18 Jul 2003 10:33:52 -0000 1.6
***************
*** 54,57 ****
--- 54,59 ----
def log_stderr(msg):
+ if type(msg) is type(u''):
+ msg=msg.encode('utf-8')
sys.stderr.write('%s\n'%msg)
no_log=lambda msg, severity=0: None
|
|
From: <sbi...@us...> - 2003-07-17 15:16:31
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv23036
Modified Files:
EditingContext.py
Log Message:
Fixed: buggy test_12a_fetchesRawRows() in test_EC_parentChild did not detect that fetching raw rows were not reflecting the changes in the parent
Index: EditingContext.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EditingContext.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** EditingContext.py 16 Jul 2003 19:16:00 -0000 1.26
--- EditingContext.py 17 Jul 2003 15:16:28 -0000 1.27
***************
*** 1243,1246 ****
--- 1243,1256 ----
objects=self.parentObjectStore().objectsWithFetchSpecification(fs, ec)
+ if ec.isaChildOf(self) and fs.fetchesRawRows():
+ # filter the returned raw rows: we'd better replace the modified objects
+ # with our own version
+ fs_entityName=fs.entityName()
+ copy_objects=list(objects)
+ for o in copy_objects:
+ self_obj=self.faultForRawRow(o, fs_entityName)
+ if not self_obj.isFault():
+ objects[objects.index(o)]=self_obj.snapshot_raw()
+
if ec is self or ec.isaChildOf(self):
entitiesNames=[fs.entityName()]
|
|
From: <sbi...@us...> - 2003-07-17 15:16:31
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv23036/tests
Modified Files:
test_EditingContext_ParentChild.py
Log Message:
Fixed: buggy test_12a_fetchesRawRows() in test_EC_parentChild did not detect that fetching raw rows were not reflecting the changes in the parent
Index: test_EditingContext_ParentChild.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_ParentChild.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_EditingContext_ParentChild.py 16 Jul 2003 19:16:00 -0000 1.10
--- test_EditingContext_ParentChild.py 17 Jul 2003 15:16:28 -0000 1.11
***************
*** 491,501 ****
# modified objects in parent
! pjohn=ec.fetch('Executive', 'lastName == "Cleese"')[0]
! pjohn_gid=john.globalID()
john_name=pjohn.getLastName()
alternate_john_name=john_name+' -- testing'
pjohn.setLastName(alternate_john_name)
! pjohn=ec.fetch('Executive', isDeep=1, rawRows=1)[0]
! self.assertEqual(john['lastName'], alternate_john_name)
def test_12b_fetchesRawRows(self):
--- 491,501 ----
# modified objects in parent
! pjohn=parent_ec.fetch('Executive', 'lastName == "Cleese"')[0]
! pjohn_gid=pjohn.globalID()
john_name=pjohn.getLastName()
alternate_john_name=john_name+' -- testing'
pjohn.setLastName(alternate_john_name)
! cjohn=child_ec.fetch('Executive', isDeep=1, rawRows=1)[0]
! self.assertEqual(cjohn['lastName'], alternate_john_name)
def test_12b_fetchesRawRows(self):
|
|
From: <sbi...@us...> - 2003-07-17 13:49:38
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv7657/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Re-introduced documentation for PyModel, by Mario
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** DefiningaModel.tex 4 Jul 2003 17:05:14 -0000 1.11
--- DefiningaModel.tex 17 Jul 2003 13:49:32 -0000 1.12
***************
*** 16,21 ****
The next section reviews the main concepts of Entity-Relationship Modeling,
with the rest of the chapter dedicated to how such models map onto
! %the python description, or PyModel, and
! the XML description.
Some included tools may help you with the design and management of
--- 16,20 ----
The next section reviews the main concepts of Entity-Relationship Modeling,
with the rest of the chapter dedicated to how such models map onto
! the python description, or PyModel, and the XML description.
Some included tools may help you with the design and management of
***************
*** 23,28 ****
command-line scripts. Thus, the easiest way to define a model would be to use the
ZModelizationTool inside a Zope instance. However, you do not {\em need} a
! Zope instance to design models, as %both PyModels and
! XML models may be
designed in your favorite editor.
Both tools includes some validation logic, so that
--- 22,26 ----
command-line scripts. Thus, the easiest way to define a model would be to use the
ZModelizationTool inside a Zope instance. However, you do not {\em need} a
! Zope instance to design models, as both PyModels and XML models may be
designed in your favorite editor.
Both tools includes some validation logic, so that
***************
*** 105,182 ****
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! %\section{PyModels}
! %
! %A PyModel is a python module that defines a variable \var{model}
! %that is of type \var{Model}. Objects of type \var{Model} collect
! %all information about their entities, as a list of objects of
! %type \var{Entity}. Similarly, entities collect objects defining
! %attributes and relationships. A \var{model} instance may also
! %define bi-directional relationships as associations. The python
! %classes for each of these is described below. To reduce boilerplate
! %code, PyModels allow defaults to be specified for all values.
! %Furthermore, sub-types for frequently used constructs are provided,
! %and others may of course be defined as necessary.
! %
! %\subsection{A sample PyModel}
! %
! %Before dealing with all teh details, here is an overview of
! %a PyModel. Note the the \var{id} default property for entities,
! %as well as the predefined \var{Attribute} sub-types,
! %\var{APrimaryKey} and \var{AString}.
! %
! %\begin{verbatim}
! %from Modeling.PyModel import *
! %
! %Entity.defaults['properties'] = [
! % APrimaryKey('id', isClassProperty=0, isRequired=1, doc='Primary key!')
! %]
! %AString.defaults['width'] = 30
! %
! %model = Model('StoreEmployees',adaptorName='Postgresql',
! % connDict={'database': 'STORE_EMPLOYEES'} )
! %
! %model.entities = [
! % Entity('Employee',
! % properties = [
! % AString('corporateName', isRequired=1),
! % ]
! % ),
! % Entity('SalesClerk', parent='Employee',
! % properties = [ ... ]
! % ),
! % Entity('Mark',
! % properties = [ ... ]
! % )
! % Entity('Store',
! % properties = [ ... ]
! % )
! %]
! %model.associations = [
! % Association('Employee', 'Store'),
! % Association('Mark', 'Employee'),
! %]
! %\end{verbatim}
! %
! %\subsection{PyModel types in detail}
! %
! %\subsubsection{Model}
! %
! %tbd.
! %
! %\subsubsection{Entity}
! %
! %tbd.
! %
! %\subsubsection{Attribute}
! %
! % AInteger, AString, AFloat, ADateTime, APrimaryKey, AForeignKey
! %
! %\subsubsection{Relationship}
! %
! % RToOne, RToMany
! %
! %\subsubsection{Association}
! %
! %tbd.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 103,180 ----
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! \section{PyModels}
!
! A PyModel is a python module that defines a variable \var{model}
! that is of type \var{Model}. Objects of type \var{Model} collect
! all information about their entities, as a list of objects of
! type \var{Entity}. Similarly, entities collect objects defining
! attributes and relationships. A \var{model} instance may also
! define bi-directional relationships as associations. The python
! classes for each of these is described below. To reduce boilerplate
! code, PyModels allow defaults to be specified for all values.
! Furthermore, sub-types for frequently used constructs are provided,
! and others may of course be defined as necessary.
!
! \subsection{A sample PyModel}
!
! Before dealing with all the details, here is an overview of
! a PyModel. Note the the \var{id} default property for entities,
! as well as the predefined \var{Attribute} sub-types,
! \var{APrimaryKey} and \var{AString}.
!
! \begin{verbatim}
! from Modeling.PyModel import *
!
! Entity.defaults['properties'] = [
! APrimaryKey('id', isClassProperty=0, isRequired=1, doc='Primary key!')
! ]
! AString.defaults['width'] = 30
!
! model = Model('StoreEmployees',adaptorName='Postgresql',
! connDict={'database': 'STORE_EMPLOYEES'} )
!
! model.entities = [
! Entity('Employee',
! properties = [
! AString('corporateName', isRequired=1),
! ]
! ),
! Entity('SalesClerk', parent='Employee',
! properties = [ ... ]
! ),
! Entity('Mark',
! properties = [ ... ]
! )
! Entity('Store',
! properties = [ ... ]
! )
! ]
! model.associations = [
! Association('Employee', 'Store'),
! Association('Mark', 'Employee'),
! ]
! \end{verbatim}
!
! \subsection{PyModel types in detail}
!
! \subsubsection{Model}
!
! tbd.
!
! \subsubsection{Entity}
!
! tbd.
!
! \subsubsection{Attribute}
!
! AInteger, AString, AFloat, ADateTime, APrimaryKey, AForeignKey
!
! \subsubsection{Relationship}
!
! RToOne, RToMany
!
! \subsubsection{Association}
!
! tbd.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***************
*** 411,417 ****
\code{string}, \code{'int'}\footnote{Note that python types \code{int}
and \code{long int} are treated the same way. This is due to different
! DB-adaptors having different behaviours --I also noticed that
! \module{pgdb} can have a ''non-deterministic'' behaviour: sometimes it
! returns \code{int}, sometimes \code{long int}, for the same db-field
and the same value (e.g. 42); anyway it sounds reasonable to consider
\code{int} and \code{long int} as equivalent within the framework's
--- 409,415 ----
\code{string}, \code{'int'}\footnote{Note that python types \code{int}
and \code{long int} are treated the same way. This is due to different
! DB-adaptors having different behaviours --some can also
! have a ''non-deterministic'' behaviour: sometimes
! returning \code{int}, sometimes \code{long int}, for the same db-field
and the same value (e.g. 42); anyway it sounds reasonable to consider
\code{int} and \code{long int} as equivalent within the framework's
|
|
From: <sbi...@us...> - 2003-07-17 13:41:18
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv6273/doc/UserGuide
Modified Files:
ManipulatingGraphOfObjects.tex
Log Message:
Documented the influence of changes in a graph of objects/EC when fetching
Index: ManipulatingGraphOfObjects.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/ManipulatingGraphOfObjects.tex,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** ManipulatingGraphOfObjects.tex 17 Jul 2003 12:39:40 -0000 1.14
--- ManipulatingGraphOfObjects.tex 17 Jul 2003 13:41:12 -0000 1.15
***************
*** 409,415 ****
\end{itemize}
! \subsection{The influence of an EditingContext on fetchs\label{ec-fetch-inserted-deleted-objects}}
- TBD
\subsection{Fetching raw rows\label{ec-fetch-raw-rows}}
--- 409,487 ----
\end{itemize}
! \subsection{The influence of an EditingContext on fetchs\label{ec-fetch-reflect-changes}}
!
! Each \class{EditingContext} holds a different graph of objects, isolated from
! the other, where modifications, insertions and deletions can be made
! independently until they are saved in the database.
!
! The state of a given \class{EditingContext} naturally have an impact on the
! objects you fetched. When nothing has been changed, you obviously get the
! objects as they are stored in the database. However, whenever you insert,
! modify or delete object, the result set of a fetch changes:
!
! \begin{verbatim}
! >>> from AuthorBooks.Book import Book
! >>> ec=EditingContext()
! >>> books=ec.fetch('Book')
! >>> pprint.pprint([b.getTitle() for b in books])
! ['Gargantua',
! 'Bouge ton pied que je voie la mer',
! 'Le coup du pere Francois',
! "T'assieds pas sur le compte-gouttes"]
! >>> new_book=Book()
! >>> new_book.setTitle('The Great Book')
! >>> ec.insert(new_book)
! >>> books=ec.fetch('Book')
! >>> pprint.pprint([b.getTitle() for b in books])
! ['Gargantua',
! 'Bouge ton pied que je voie la mer',
! 'Le coup du pere Francois',
! "T'assieds pas sur le compte-gouttes",
! 'The Great Book']
! \end{verbatim}
!
! As exposed above, newly inserted objects automatically appear in the result
! set when applicable. Of course, you can still benefit from standard fetch
! techniques, such as qualifiers:
! \begin{verbatim}
! >>> books=ec.fetch('Book', 'title like "*G*"')
! >>> [b.getTitle() for b in books]
! ['Gargantua', 'The Great Book']
! \end{verbatim}
!
! You get the expected result, even if the inserted book is {\em not} saved in
! the database yet.
!
! If you modify your objects, these modifications will always be visible in your
! result set; continuing on the same example:
!
! \begin{verbatim}
! >>> gargantua=ec.fetch('Book', 'title == "Gargantua"')[0]
! >>> gargantua.setTitle('Gargantua et Pantagruel')
! >>> books=ec.fetch('Book', 'title like "*G*"')
! >>> [b.getTitle() for b in books]
! ['Gargantua et Pantagruel', 'The Great Book']
! \end{verbatim}
!
! Your changes to objects are not persistent yet in the database, still, they
! appear as expected in the result set.
!
! Last, the same principles apply to deleted object:
!
! \begin{verbatim}
! >>> gargantua=ec.fetch('Book', 'title == "Gargantua"')[0]
! >>> pprint.pprint([b.getTitle() for b in ec.fetch('Book')])
! ['Bouge ton pied que je voie la mer',
! 'Le coup du pere Francois',
! "T'assieds pas sur le compte-gouttes",
! 'The Great Book']
! >>> [b.getTitle() for b in ec.fetch('Book', 'title like "*G*"')]
! ['The Great Book']
! \end{verbatim}
!
! Objects marked as deleted do not appear in the result set, even if the object
! still exists in the database (it will only be deleted when the
! \class{EditingContext} receives the \method{saveChanges()} message, see~\ref{ec-save-changes}).
\subsection{Fetching raw rows\label{ec-fetch-raw-rows}}
***************
*** 477,481 ****
The very same rule applies to raw fetch as to ``normal'' fetch, in particular,
! everything we saw in the section~\ref{ec-fetch-inserted-deleted-objects} is
still valid. If your \class{EditingContext} contains some newly inserted
objects, you'll them appear; and deleted objects won't appear. For example:
--- 549,553 ----
The very same rule applies to raw fetch as to ``normal'' fetch, in particular,
! everything we saw in the section~\ref{ec-fetch-reflect-changes} is
still valid. If your \class{EditingContext} contains some newly inserted
objects, you'll them appear; and deleted objects won't appear. For example:
***************
*** 592,595 ****
--- 664,672 ----
just specify the root entity, and the object of the right class will be
automatically returned.
+
+ %\subsubsection{Turning objects to raw rows\label{ec-fetch-turn-object-to-raw-row}}
+ %
+ %For the sake of completeness: CustomObject.snapshot() and
+ %CustomObject.snapshot_raw()
\section{Saving Changes\label{ec-save-changes}}
|
|
From: <sbi...@us...> - 2003-07-17 12:39:43
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv28239/doc/UserGuide
Modified Files:
ManipulatingGraphOfObjects.tex
Log Message:
Documentation for fetching raw rows part 2
Index: ManipulatingGraphOfObjects.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/ManipulatingGraphOfObjects.tex,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ManipulatingGraphOfObjects.tex 16 Jul 2003 23:32:17 -0000 1.13
--- ManipulatingGraphOfObjects.tex 17 Jul 2003 12:39:40 -0000 1.14
***************
*** 20,24 ****
An other feature assumed by \class{EditingContext}s is that they make sure
! that an given object has a single instance within them. So, if you fetch a
particular object, then later access the same object e.g. by traversing some
relationships, you are sure that the two are the same object (exactly the
--- 20,24 ----
An other feature assumed by \class{EditingContext}s is that they make sure
! that a given object has a single instance within them. So, if you fetch a
particular object, then later access the same object e.g. by traversing some
relationships, you are sure that the two are the same object (exactly the
***************
*** 45,49 ****
A A'
\end{verbatim}
! with \class{A} and \class{A'} having the same values.
--- 45,50 ----
A A'
\end{verbatim}
! with objects \class{A} and \class{A'} ultimately referring to the very same
! row in the database.
***************
*** 429,432 ****
--- 430,443 ----
it (e.g. for modification).
+ \begin{notice}
+ Of course, when fetching raw rows, you cannot benefit from most of the
+ framework's capabilities since it manipulates objects, not dictionaries; you
+ shoudl also note that the fetched data are not cached by the
+ framework. However, in some situations like the ones we saw above, it's just
+ what you want; moreover, it speeds up the fetch process, and reduces the
+ memory footprint to just what is needed.
+ \end{notice}
+
+
In this section we'll see how to do these both things: fetching raw rows and
turning a raw into a real object.
***************
*** 536,540 ****
\subsubsection{Turning rows into real objects\label{ec-fetch-turn-raw-row-to-object}}
! TBD
\section{Saving Changes\label{ec-save-changes}}
--- 547,595 ----
\subsubsection{Turning rows into real objects\label{ec-fetch-turn-raw-row-to-object}}
! Say you've presented to your user a large list of objects to choose from. Now
! the user selects one for modification or detailed inspection, probably
! including the objects in relations. There you need to get the magic on real
! objects back.
!
! This is easily done with \class{EditingContext}'s \method{faultForRawRow};
! continuing the previous example:
!
! \begin{verbatim}
! >>> raw_john=ec.fetch('Executive', 'firstName=="John"', rawRows=1)[0]
! >>> pprint.pprint(raw_john)
! {'firstName': 'John',
! 'fkStoreId': <Modeling.GlobalID.TemporaryGlobalID instance at 0x8364a0c>,
! 'id': 3,
! 'lastName': 'Cleese',
! 'officeLocation': '4XD7'}
! >>> john=ec.faultForRawRow(raw_john, 'Employee')
! >>> john
! <Executive.Executive instance at 0x8531db4>
! >>> john.getFirstName(),john.getLastName(),john.getToStore().getCorporateName()
! ('John', 'Cleese', 'We sell parrots')
! \end{verbatim}
!
! Here we converted a raw dictionary to a real object, which is automatically
! registered within the framework with all its normal capabilities, just as if
! you directly fetch()'ed it from the database.
!
! As you can see, \method{faultForRawRow()} takes a dictionary and the name of
! the entity the object belongs to, and returns the real object. Note that the
! entity's name shouldn't be exactly the right one: we asked for an
! \code{Employee}, we got an object of class/entity \code{Executive}, sub-entity
! of \code{Employee}. The only constraint on \code{entityName} is that it needs
! to belong to the same inheritance tree than the object's. This makes life
! easier when turning into objects raw rows which were fetched against a whole
! inheritance tree.
!
! For example, you may fetch raw rows for the whole hierarchy beyond entity
! 'Employee': the rows you'll get will belong to either entities 'Employee',
! 'SalesClerk' or 'Executive', but this information is not enclosed within the
! dictionaries themselves\footnote{except that, if the sub-entities have more
! attributes than their parent, you'll probably be able to guess to which entity
! a dictionary belongs to: for instance, only '\code{Executive}' objects have an
! attribute '\code{officeLocation}'.}. When turning the raws back to objects,
! just specify the root entity, and the object of the right class will be
! automatically returned.
\section{Saving Changes\label{ec-save-changes}}
|
|
From: <sbi...@us...> - 2003-07-17 10:14:55
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage
In directory sc8-pr-cvs1:/tmp/cvs-serv4700/doc/HomePage
Modified Files:
downloads.tex
Log Message:
misc. reorg.
Index: downloads.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/downloads.tex,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** downloads.tex 4 Jul 2003 17:29:29 -0000 1.10
--- downloads.tex 17 Jul 2003 10:05:20 -0000 1.11
***************
*** 22,29 ****
\item[\bf APIs]
! \begin{rawhtml}
! <a href="download/Modeling-API.tar.gz">API for the Modeling Framework</a><br>
! <a href="download/Notification-API.tar.gz">API for the Notification Framework</a>
! \end{rawhtml}
\end{enumerate}
--- 22,33 ----
\item[\bf APIs]
! You can view them online (see menu on the left), or download the tarballs for
! offline consultation:
! \begin{itemize}
! \item \begin{rawhtml}<a href="download/Modeling-API.tar.gz">API for the
! Modeling Framework</a>\end{rawhtml}
!
! \item \begin{rawhtml}<a href="download/Notification-API.tar.gz">API for the Notification Framework</a>\end{rawhtml}
! \end{itemize}
\end{enumerate}
|
|
From: <sbi...@us...> - 2003-07-16 23:32:24
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv12689/doc/UserGuide
Modified Files:
ManipulatingGraphOfObjects.tex
Log Message:
Documentation for fetching raw rows part 1 --to be continued
Index: ManipulatingGraphOfObjects.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/ManipulatingGraphOfObjects.tex,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** ManipulatingGraphOfObjects.tex 10 Jul 2003 11:57:55 -0000 1.12
--- ManipulatingGraphOfObjects.tex 16 Jul 2003 23:32:17 -0000 1.13
***************
*** 50,55 ****
To create an \class{EditingContext}, simply use the statements:
\begin{verbatim}
! from Modeling.EditingContext import EditingContext
! ec=EditingContext()
\end{verbatim}
--- 50,55 ----
To create an \class{EditingContext}, simply use the statements:
\begin{verbatim}
! >>> from Modeling.EditingContext import EditingContext
! >>> ec=EditingContext()
\end{verbatim}
***************
*** 73,78 ****
'insertObject()':
\begin{verbatim}
! newBook=Book()
! ec.insertObject(newBook)
\end{verbatim}
--- 73,78 ----
'insertObject()':
\begin{verbatim}
! >>> newBook=Book()
! >>> ec.insertObject(newBook)
\end{verbatim}
***************
*** 82,89 ****
\begin{verbatim}
! newBook=Book()
! ec.insert(newBook)
\end{verbatim}
\section{Fetching objects\label{ec-fetch-object}}
--- 82,140 ----
\begin{verbatim}
! >>> newBook=Book()
! >>> ec.insert(newBook)
\end{verbatim}
+ \section{Updating objects\label{ec-update-object}}
+
+ As explained in section \ref{basics-CustomObject},
+ the getters and setters take care of informing the
+ \class{EditingContext} of any changes made to an object. Thus, except for
+ the \method{willRead} and \method{willChange} methods in the getters and
+ setters, you do not need to take any particular other action.
+
+
+ We will see in section~\ref{ec-fetch-object} how to retrieve objects from
+ the database.
+
+ \section{Deleting an object\label{ec-delete-object}}
+
+ (We suppose here we already know how to get objects --this is covered by
+ the next section)
+
+
+ When you want an object to be deleted, you inform it with the
+ \method{deleteObject} message:
+ \begin{verbatim}
+ >>> ec.deleteObject(aBook)
+ \end{verbatim}
+
+ Alternatively, you can use the method \method{delete} ; both
+ \method{delete} and \method{deleteObject} are completely equivalent, and
+ depending on your own feeling you may prefer one or the other.
+
+ You can also discard the insertion of an object you've just added:
+
+ \begin{verbatim}
+ >>> newBook = Book()
+ >>> ec.insert(newBook)
+ [... then at some point you can change your mind]
+ >>> ec.delete(newBook)
+ \end{verbatim}
+
+ Note that, before a deleted object is about to be made persistent (i.e. when
+ its corresponding row in the database is about to be deleted), some logic
+ is triggered. For example, if this object still has some relationships but
+ these relationships are marked as \constant{CASCADE_DELETE}, the objects
+ in relations will be deleted as well (given that their own validation
+ logic allows them to be deleted, of course). Or, if it is marked as
+ \constant{DELETE_DENY}, the deletion will be denied and for that object to
+ be deleted, you will need to remove any object in relation with it.
+
+ You can refer to the next section, \ref{ec-save-changes}, and to
+ relationships' properties described in section~\ref{design-rels} for
+ further details.
+
+
\section{Fetching objects\label{ec-fetch-object}}
***************
*** 168,172 ****
You can also use the operator \code{'caseInsensitiveLike'}:
\begin{verbatim}
! object=ec.fetch('Writer', qualifier='lastName caseInsensitiveLike "hu?o"')
\end{verbatim}
will match: \code{'Hugo'}, \code{'Hulo'}, \code{'HUGO'}, \code{'hUXO'}, ...
--- 219,223 ----
You can also use the operator \code{'caseInsensitiveLike'}:
\begin{verbatim}
! objects=ec.fetch('Writer', qualifier='lastName caseInsensitiveLike "hu?o"')
\end{verbatim}
will match: \code{'Hugo'}, \code{'Hulo'}, \code{'HUGO'}, \code{'hUXO'}, ...
***************
*** 175,179 ****
\code{caseInsensitiveLike}: \code{ilike}
\begin{verbatim}
! object=ec.fetch('Writer', qualifier='lastName ilike "hu?o"')
\end{verbatim}
--- 226,230 ----
\code{caseInsensitiveLike}: \code{ilike}
\begin{verbatim}
! objects=ec.fetch('Writer', qualifier='lastName ilike "hu?o"')
\end{verbatim}
***************
*** 357,397 ****
\end{itemize}
! \section{Updating objects\label{ec-update-object}}
! As explained in section \ref{basics-CustomObject},
! the getters and setters take care of informing the
! \class{EditingContext} of any changes made to an object. Thus, except for
! the \method{willRead} and \method{willChange} methods in the getters and
! setters, you do not need to take any particular other action.
! \section{Deleting an object\label{ec-delete-object}}
- When you want an object to be deleted, you inform it with the
- \method{deleteObject} message:
\begin{verbatim}
! ec.deleteObject(aBook)
\end{verbatim}
! Alternatively, you can use the method \method{delete} ; both
! \method{delete} and \method{deleteObject} are completely equivalent, and
! depending on your own feeling you may prefer one or the other.
\begin{verbatim}
! ec.delete(newBook)
\end{verbatim}
! Note that, before a deleted object is about to be made persistent (i.e. when
! its corresponding row in the database is about to be deleted), some logic
! is triggered. For example, if this object still has some relationships but
! these relationships are marked as \constant{CASCADE_DELETE}, the objects
! in relations will be deleted as well (given that their own validation
! logic allows them to be deleted, of course). Or, if it is marked as
! \constant{DELETE_DENY}, the deletion will be denied and for that object to
! be deleted, you will need to remove any object in relation with it.
! You can refer to the next section, \ref{ec-save-changes}, and to
! relationships' properties described in section~\ref{design-rels} for
! further details.
\section{Saving Changes\label{ec-save-changes}}
--- 408,540 ----
\end{itemize}
! \subsection{The influence of an EditingContext on fetchs\label{ec-fetch-inserted-deleted-objects}}
! TBD
! \subsection{Fetching raw rows\label{ec-fetch-raw-rows}}
!
! Sometimes and for some reasons, you do not want to get a whole set of fully
! initialized objects.
!
! For example, you need to get the data for a lot of objects to do some
! processing on some of its attributes, but you don't need the objects {\em per
! se}.
!
! Or, building a GUI, you want to present a large list of items from which the
! user can e.g. choose one for, say, inspection or modification; here again, you
! do not need all the {\em objects} to build the list, and most of times you do
! not want it either since this would imply a too large memory footprint (along
! with a fetch taking too much time): all what you want is the raw data
! themselves, and the ability to turn them into real objects just when you need
! it (e.g. for modification).
!
! In this section we'll see how to do these both things: fetching raw rows and
! turning a raw into a real object.
!
! \subsubsection{Getting raw data\label{ec-fetch-get-raw-rows}}
!
! The framework offers a specific API for this:
\begin{verbatim}
! >>> from Modeling.EditingContext import EditingContext
! >>> import pprint, StoreEmployees
! >>> ec = EditingContext()
! >>> raw_employees = ec.fetch('Employee', isDeep=1, rawRows=1)
! >>> pprint.pprint(raw_employees)
! [{'firstName': 'Jeanne',
! 'fkStoreId': 1,
! 'id': 2,
! 'lastName': 'Cleese',
! 'storeArea': 'DE'},
! {'firstName': 'John Jr.',
! 'fkStoreId': 1,
! 'id': 1,
! 'lastName': 'Cleese',
! 'storeArea': 'AB'},
! {'firstName': 'John',
! 'fkStoreId': 1,
! 'id': 3,
! 'lastName': 'Cleese',
! 'officeLocation': '4XD7'}]
\end{verbatim}
! As you can see, with parameter {\bf \code{rawRows}} you get the raw dictionary
! directly from the database. No object is initialized by such a fetch. However,
! you can use every functionality we already saw for fetching (inheritance with
! parameter \code{isDeep}, qualifiers), as is.
!
!
! The very same rule applies to raw fetch as to ``normal'' fetch, in particular,
! everything we saw in the section~\ref{ec-fetch-inserted-deleted-objects} is
! still valid. If your \class{EditingContext} contains some newly inserted
! objects, you'll them appear; and deleted objects won't appear. For example:
\begin{verbatim}
! >>> from StoreEmployees.SalesClerk import SalesClerk
! >>> terry=SalesClerk()
! >>> terry.setFirstName('Terry'); terry.setLastName('Gilliam')
! >>> ec.insert(terry)
! >>> salesClerks=ec.fetch('SalesClerk', rawRows=1)
! >>> pprint.pprint(salesClerks)
! [{'firstName': 'Jeanne',
! 'fkStoreId': 1,
! 'id': 2,
! 'lastName': 'Cleese',
! 'storeArea': 'DE'},
! {'firstName': 'John Jr.',
! 'fkStoreId': 1,
! 'id': 1,
! 'lastName': 'Cleese',
! 'storeArea': 'AB'},
! {'firstName': 'Terry',
! 'fkStoreId': None,
! 'id': <Modeling.GlobalID.TemporaryGlobalID instance at 0x84fcc64>,
! 'lastName': 'Gilliam',
! 'storeArea': None}]
! >>> salesClerk.globalID()
! <Modeling.GlobalID.TemporaryGlobalID instance at 0x84fcc64>
\end{verbatim}
! You probably already noticed the particular value associated to Terry's
! '\code{id}' field. Since this object is not saved in the database yet, its
! current \code{id} (the primary key for \class{SalesClerk} objects) is not
! determined yet either. Instead, the framework returns its identifier, which is
! a \class{TemporaryGlobalID}.
! The same phenomenon appear on foreign keys when an object is related to a
! newly inserted object; continuing the previous example:
! \begin{verbatim}
! >>> pprint.pprint(ec.fetch('Executive', rawRows=1)) # No modifications yet
! [{'firstName': 'John',
! 'fkStoreId': 1,
! 'id': 3,
! 'lastName': 'Cleese',
! 'officeLocation': '4XD7'}]
! >>> from StoreEmployees.Store import Store
! >>> parrot_store=Store()
! >>> parrot_store.setCorporateName('We sell parrots')
! >>> ec.insert(parrot_store)
! >>> john=ec.fetch('Executive', 'firstName=="John"')[0]
! >>> john.getToStore().removeFromEmployees(john)
! >>> john.setToStore(parrot_store) ; parrot_store.addToEmployees(john)
! >>> pprint.pprint(ec.fetch('Executive', rawRows=1))
! [{'firstName': 'John',
! 'fkStoreId': <Modeling.GlobalID.TemporaryGlobalID instance at 0x8364a0c>,
! 'id': 3,
! 'lastName': 'Cleese',
! 'officeLocation': '4XD7'}]
! >>> parrot_store.globalID()
! <Modeling.GlobalID.TemporaryGlobalID instance at 0x8364a0c>
! \end{verbatim}
+ We see clearly here that this time, \code{fkStoreId} gets a
+ \class{TemporaryGlobalID} corresponding to \code{parrot_store}'s global
+ id. Moreover, we also remark that even if the modifications are not saved into
+ the database yet, raw fetching returns the objects as they currently are in
+ the \class{EditingContext}, just as with normal fetching.
+
+ \subsubsection{Turning rows into real objects\label{ec-fetch-turn-raw-row-to-object}}
+
+ TBD
\section{Saving Changes\label{ec-save-changes}}
|
|
From: <sbi...@us...> - 2003-07-16 19:16:03
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/interfaces
In directory sc8-pr-cvs1:/tmp/cvs-serv30582/interfaces
Modified Files:
ObjectStoreInterface.py
Log Message:
Added the ability to fetch raw rows (dictionaries instead of fully
intialized objects) --see FetchSpecification.setFetchesRawRows() and
EditingContext.fetch() 's parameter 'rawRows'. Also added the possibility
to turn these rows into real objects --see EditingContext.faultForRawRow()
Index: ObjectStoreInterface.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/interfaces/ObjectStoreInterface.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ObjectStoreInterface.py 14 Mar 2003 11:40:12 -0000 1.5
--- ObjectStoreInterface.py 16 Jul 2003 19:16:00 -0000 1.6
***************
*** 125,128 ****
--- 125,142 ----
def faultForRawRow(self, aRow, anEntityName, anEditingContext):
"""
+ Turns a row (dictionary) into a real object. Any row, such as the one
+ returned by a fetch when raw rows is actvated, can be turned into a
+ real object given that it contains the primary keys.
+
+ Parameters:
+
+ row -- a dictionary. This dictionary should have the entity's primary
+ keys in its keys (and their corresponding values)
+
+ entityName -- the name of the entity the row represents
+
+ anEditingContext -- The EditingContext in which the object should be
+ registered.
+
"""
|
|
From: <sbi...@us...> - 2003-07-16 19:16:03
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv30582/tests
Modified Files:
test_EditingContext_Global_Inheritance.py
test_EditingContext_ParentChild.py
Log Message:
Added the ability to fetch raw rows (dictionaries instead of fully
intialized objects) --see FetchSpecification.setFetchesRawRows() and
EditingContext.fetch() 's parameter 'rawRows'. Also added the possibility
to turn these rows into real objects --see EditingContext.faultForRawRow()
Index: test_EditingContext_Global_Inheritance.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** test_EditingContext_Global_Inheritance.py 15 Jul 2003 11:07:10 -0000 1.14
--- test_EditingContext_Global_Inheritance.py 16 Jul 2003 19:16:00 -0000 1.15
***************
*** 52,55 ****
--- 52,56 ----
from StoreEmployees import Employee
from StoreEmployees.SalesClerk import SalesClerk
+ from StoreEmployees.Executive import Executive
from StoreEmployees.Address import Address
***************
*** 274,277 ****
--- 275,371 ----
self.failIf(len(objs2)!=3)
+ def test_08a_fetchesRawRows(self):
+ "[EditingContext/Inheritance] fetchesRawRows / basics"
+ ec=EditingContext()
+
+ # No inheritance
+ addresses=ec.fetch('Address', rawRows=1)
+ self.failIf(len(addresses)!=3)
+ for a in addresses:
+ self.failIf(type(a) is not type({}))
+
+ # Inheritance
+ employees=ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.failIf(len(employees)!=3)
+ for e in employees:
+ self.failIf(type(e) is not type({}))
+
+ # modified objects
+ john=ec.fetch('Executive', 'lastName == "Cleese"')[0]
+ john_gid=john.globalID()
+ john_name=john.getLastName()
+ alternate_john_name=john_name+' -- testing'
+ john.setLastName(alternate_john_name)
+ john=ec.fetch('Executive', isDeep=1, rawRows=1)[0]
+ self.assertEqual(john['lastName'], alternate_john_name)
+
+ def test_08b_fetchesRawRows(self):
+ "[EditingContext/Inheritance] fetchesRawRows / inserted & deleted objects"
+ ec=EditingContext()
+
+ # Inserted objects should appear, as expected
+ nsc=SalesClerk()
+ nsc.setLastName('New SC')
+ ne=Executive()
+ ne.setLastName('New Executive')
+ ec.insert(nsc)
+ ec.insert(ne)
+ employees=ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.assertEqual(len(employees), 5)
+ rnsc=rne=None # returned nsc/ne
+ for e in employees:
+ self.assertEqual(type(e), type({}))
+
+ # deletedObjects should not appear
+ ec.delete(nsc)
+ jeanne=ec.fetch('SalesClerk', 'firstName=="Jeanne"')[0]
+ ec.deleteObject(jeanne)
+ employees=ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.assertEqual(len(employees), 3)
+ rnsc=rne=rjeanne=None # returned nsc/ne
+ for e in employees:
+ self.assertEqual(type(e), type({}))
+ if e['lastName']==nsc.getLastName(): rnsc=e
+ if e['lastName']==ne.getLastName(): rne=e
+ if e['firstName']==jeanne.getFirstName(): rjeanne=e
+ self.assertEqual(rnsc, None)
+ self.assertEqual(rjeanne, None)
+ self.assertEqual(rne, ne.snapshot_raw())
+
+ def test_09_faultForRawRow(self):
+ "[EditingContext/Inheritance] faultForRawRow"
+ ec=EditingContext()
+ employees=ec.fetch('Employee', isDeep=1, rawRows=1)
+ r_executives=[]
+ r_sales_clerks=[]
+ for e in employees:
+ if e.has_key('officeLocation'):
+ r_executives.append(e)
+ else:
+ r_sales_clerks.append(e)
+ self.failIf(len(r_executives)!=1)
+ self.failIf(len(r_sales_clerks)!=2)
+
+ r_john_c=r_executives[0]
+ john_c1=ec.faultForRawRow(r_john_c, 'Employee')
+ john_c2=ec.faultForRawRow(r_john_c, 'Executive')
+ self.failUnless(john_c1.isFault())
+ self.failUnless(john_c1==john_c2)
+ john_c3=ec.fetch('Employee', 'firstName=="John" AND lastName=="Cleese"',
+ isDeep=1)[0]
+ self.failUnless(john_c2==john_c3)
+ john_c3.getFirstName()
+ self.failIf(john_c1.isFault())
+
+ # Anything in the correct inheritance tree return the right object
+ john_c4=ec.faultForRawRow(r_john_c, 'SalesClerk')
+ self.failUnless(john_c1==john_c4)
+
+ # Check that it correctly raise when 'pk' is not present
+ self.assertRaises(ValueError,
+ ec.faultForRawRow, {'incorrect':0}, 'Employee')
+
+ ## TBD: CHECK FOR TEMPORARY/INSERTED
+
def tearDown(self):
"""
Index: test_EditingContext_ParentChild.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_ParentChild.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_EditingContext_ParentChild.py 7 Jul 2003 14:57:14 -0000 1.9
--- test_EditingContext_ParentChild.py 16 Jul 2003 19:16:00 -0000 1.10
***************
*** 470,473 ****
--- 470,587 ----
'obj.W/FetchSpec() should not have returned John Cleese')
+ def test_12a_fetchesRawRows(self):
+ "[EC:parent/child] fetchesRawRows / basics"
+ ## Basically the same test than
+ ## test_EC_Global_Inheritance.test_08a_fetchesRawRows()
+ ## except for the part on modified objects (modified in parent EC here)
+ parent_ec=EditingContext()
+ child_ec=EditingContext(parent_ec)
+
+ # No inheritance
+ addresses=child_ec.fetch('Address', rawRows=1)
+ self.failIf(len(addresses)!=3)
+ for a in addresses:
+ self.failIf(type(a) is not type({}))
+
+ # Inheritance
+ employees=child_ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.failIf(len(employees)!=3)
+ for e in employees:
+ self.failIf(type(e) is not type({}))
+
+ # modified objects in parent
+ pjohn=ec.fetch('Executive', 'lastName == "Cleese"')[0]
+ pjohn_gid=john.globalID()
+ john_name=pjohn.getLastName()
+ alternate_john_name=john_name+' -- testing'
+ pjohn.setLastName(alternate_john_name)
+ pjohn=ec.fetch('Executive', isDeep=1, rawRows=1)[0]
+ self.assertEqual(john['lastName'], alternate_john_name)
+
+ def test_12b_fetchesRawRows(self):
+ "[EC:parent/child] fetchesRawRows / inserted & deleted objects"
+ from StoreEmployees.SalesClerk import SalesClerk
+ from StoreEmployees.Executive import Executive
+
+ parent_ec=EditingContext()
+ child_ec=EditingContext(parent_ec)
+
+ # Inserted objects (either in parent or in child) should appear,
+ # as expected
+ nsc=SalesClerk()
+ nsc.setLastName('New SC')
+ ne=Executive()
+ ne.setLastName('New Executive')
+ parent_ec.insert(nsc)
+ child_ec.insert(ne)
+ employees=child_ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.assertEqual(len(employees), 5)
+ rnsc=rne=None # returned nsc/ne
+ for e in employees:
+ self.assertEqual(type(e), type({}))
+
+ parent_ec.delete(nsc) # clean-up
+
+ # deletedObjects (either in parent or in child) should not appear
+ # Note: we left: 'ne' in the parent
+ jeanne=child_ec.fetch('SalesClerk', 'firstName=="Jeanne"')[0]
+ child_ec.deleteObject(jeanne)
+ john_jr=parent_ec.fetch('SalesClerk', 'firstName=="John Jr."')[0]
+ john=parent_ec.fetch('Executive', 'firstName=="John"')[0]
+ parent_ec.deleteObject(john_jr)
+
+ employees=child_ec.fetch('Employee', isDeep=1, rawRows=1)
+ self.assertEqual(len(employees), 2)
+ rnsc=rne=rjeanne=rjohn_jr=rjohn=None # returned nsc/ne
+ for e in employees:
+ self.assertEqual(type(e), type({}))
+ if e['lastName']==nsc.getLastName(): rnsc=e
+ if e['lastName']==ne.getLastName(): rne=e
+ if e['firstName']==jeanne.getFirstName(): rjeanne=e
+ if e['firstName']==john_jr.getFirstName(): rjohn_jr=e
+ if e['firstName']==john.getFirstName(): rjohn=e
+ self.assertEqual(rnsc, None)
+ self.assertEqual(rjeanne, None)
+ self.assertEqual(rjohn_jr, None)
+ self.assertEqual(rne, ne.snapshot_raw())
+ self.assertEqual(rjohn, john.snapshot_raw())
+
+
+ def test_13_faultForRawRow(self):
+ "[EC:parent/child] faultForRawRow"
+ parent_ec=EditingContext()
+ child_ec=EditingContext(parent_ec)
+
+ employees=child_ec.fetch('Employee', isDeep=1, rawRows=1)
+ r_executives=[]
+ r_sales_clerks=[]
+ for e in employees:
+ if e.has_key('officeLocation'):
+ r_executives.append(e)
+ else:
+ r_sales_clerks.append(e)
+ self.failIf(len(r_executives)!=1)
+ self.failIf(len(r_sales_clerks)!=2)
+
+ r_john_c=r_executives[0]
+ john_c1=child_ec.faultForRawRow(r_john_c, 'Employee')
+ john_c2=child_ec.faultForRawRow(r_john_c, 'Executive')
+ self.failUnless(john_c1.isFault())
+ self.failUnless(john_c1==john_c2)
+ john_c3=child_ec.fetch('Employee',
+ 'firstName=="John" AND lastName=="Cleese"',
+ isDeep=1)[0]
+ self.failUnless(john_c2==john_c3)
+ john_c3.getFirstName()
+ self.failIf(john_c1.isFault())
+
+ # Anything in the correct inheritance tree return the right object
+ john_c4=child_ec.faultForRawRow(r_john_c, 'SalesClerk')
+ self.failUnless(john_c1==john_c4)
+
+ # Last, check that it correctly raise when 'pk' is not present
+ self.assertRaises(ValueError,
+ child_ec.faultForRawRow, {'incorrect':0}, 'Employee')
+
def tearDown(self):
"""
|