modeling-cvs Mailing List for Object-Relational Bridge for python (Page 20)
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-24 12:07:31
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv29656/tests
Modified Files:
test_EditingContext_Global.py
Log Message:
Fixed bug #776592: was impossible to add raw '*' and '?' characters in
a LIKE statement
Index: test_EditingContext_Global.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** test_EditingContext_Global.py 24 Jul 2003 11:30:52 -0000 1.32
--- test_EditingContext_Global.py 24 Jul 2003 12:07:25 -0000 1.33
***************
*** 1077,1080 ****
--- 1077,1103 ----
## check: modify / delete / saveChanges / insert
+ def test_23_fetch_star_and_interrogation_mark_chars(self):
+ "[EditingContext] fetch real '?' and '*'"
+ ec=EditingContext()
+ b1=Book(); b1.setTitle('abc?d')
+ b2=Book(); b2.setTitle('abcXd')
+ b3=Book(); b3.setTitle('abc*d')
+ ec.insert(b1); ec.insert(b2); ec.insert(b3)
+ ec.saveChanges()
+
+ res=ec.fetch('Book', 'title like "abc?d"')
+ self.failIf(len(res)!=3)
+
+ res=ec.fetch('Book', 'title like "abc*d"')
+ self.failIf(len(res)!=3)
+
+ res=ec.fetch('Book', 'title like "abc\?d"')
+ self.failIf(len(res)!=1)
+ self.failIf(res[0].getTitle()!='abc?d')
+
+ res=ec.fetch('Book', 'title like "abc\*d"')
+ self.failIf(len(res)!=1)
+ self.failIf(res[0].getTitle()!='abc*d')
+
def test_999_customSQLQuery(self):
"[EditingContext] custom SQL Query"
|
|
From: <sbi...@us...> - 2003-07-24 12:07:31
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv29656/doc/UserGuide
Modified Files:
ManipulatingGraphOfObjects.tex
Log Message:
Fixed bug #776592: was impossible to add raw '*' and '?' characters in
a LIKE statement
Index: ManipulatingGraphOfObjects.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/ManipulatingGraphOfObjects.tex,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** ManipulatingGraphOfObjects.tex 17 Jul 2003 13:41:12 -0000 1.15
--- ManipulatingGraphOfObjects.tex 24 Jul 2003 12:07:25 -0000 1.16
***************
*** 230,233 ****
--- 230,243 ----
\end{verbatim}
+
+ Last, if you want to add raw \code{'*'} and \code{'?'} characters in a like
+ pattern, escape them. For example, this fetchs all books whose title ends with
+ \code{'here?'}:
+
+ \begin{verbatim}
+ objects=ec.fetch('Book', qualifier='title like "*here\?"')
+ \end{verbatim}
+
+
\subsection{Equality, comparisons, {\tt in} and {\tt not in}\label{ec-fetch-operators}}
When building your qualifiers, you can use the following operators:
|
|
From: <sbi...@us...> - 2003-07-24 12:07:29
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer
In directory sc8-pr-cvs1:/tmp/cvs-serv29656/DatabaseAdaptors/PostgresqlAdaptorLayer
Modified Files:
PostgresqlSQLExpression.py
Log Message:
Fixed bug #776592: was impossible to add raw '*' and '?' characters in
a LIKE statement
Index: PostgresqlSQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer/PostgresqlSQLExpression.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PostgresqlSQLExpression.py 12 Jun 2003 11:40:31 -0000 1.4
--- PostgresqlSQLExpression.py 24 Jul 2003 12:07:25 -0000 1.5
***************
*** 38,41 ****
--- 38,53 ----
import re
+ esc_question_tmp_replct='MDL_ESCAPED_QUESTION_MARK_MDL'
+ esc_star_tmp_replct='MDL_ESCAPED_STAR_MDL'
+
+ star=re.compile('\*')
+ escaped_star=re.compile(r'\\\*')
+ question_mark=re.compile('\?')
+ escaped_question_mark=re.compile(r'\\\?')
+ percent=re.compile('%')
+ underscore=re.compile('_')
+ anti_escaped_star=re.compile(esc_star_tmp_replct)
+ anti_esc_question_mark=re.compile(esc_question_tmp_replct)
+
class PostgresqlSQLExpression(SQLExpression):
"""
***************
*** 85,97 ****
'\%': postgresql interprets backslashes in strings
"""
- star=re.compile('\*')
- question_mark=re.compile('\?')
- percent=re.compile('%')
- underscore=re.compile('_')
-
pattern=percent.sub('\\\\\\\\%', pattern)
pattern=underscore.sub('\_', pattern)
pattern=question_mark.sub('_', pattern)
pattern=star.sub('%', pattern)
return pattern
--- 97,108 ----
'\%': postgresql interprets backslashes in strings
"""
pattern=percent.sub('\\\\\\\\%', pattern)
pattern=underscore.sub('\_', pattern)
+ pattern=escaped_question_mark.sub(esc_question_tmp_replct, pattern)
pattern=question_mark.sub('_', pattern)
+ pattern=escaped_star.sub(esc_star_tmp_replct, pattern)
pattern=star.sub('%', pattern)
+ pattern=anti_escaped_star.sub('*', pattern)
+ pattern=anti_esc_question_mark.sub('?', pattern)
return pattern
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv25038/tests
Modified Files:
test_EditingContext_Global.py
test_EditingContext_Global_Inheritance.py
test_EditingContext_ParentChild.py
test_EntityClassDescription.py run.py
Log Message:
Adapted tests to the new caching mechanism for models and class description
Index: test_EditingContext_Global.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** test_EditingContext_Global.py 23 Jul 2003 14:10:13 -0000 1.31
--- test_EditingContext_Global.py 24 Jul 2003 11:30:52 -0000 1.32
***************
*** 38,41 ****
--- 38,42 ----
import utils
if __name__ == "__main__":
+ utils.disable_model_cache()
utils.fixpath()
***************
*** 905,909 ****
def test_17b_insertedObject_and_FK_as_classProperty(self):
"[EC] Checks that a FK/class prop. gets its value after saving changes"
- return
ec=EditingContext()
w=Writer()
--- 906,909 ----
***************
*** 1253,1256 ****
--- 1253,1258 ----
if database_cfg=='MySQL.cfg':
author_books_model.entityNamed('Writer').attributeNamed('birthday').setExternalType('DATETIME')
+
+ utils.enable_model_cache_and_compute()
if reinitDB_flag: reinitDB(); return
Index: test_EditingContext_Global_Inheritance.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global_Inheritance.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** test_EditingContext_Global_Inheritance.py 16 Jul 2003 19:16:00 -0000 1.15
--- test_EditingContext_Global_Inheritance.py 24 Jul 2003 11:30:52 -0000 1.16
***************
*** 38,41 ****
--- 38,42 ----
import utils
if __name__ == "__main__":
+ utils.disable_model_cache()
utils.fixpath()
***************
*** 535,538 ****
--- 536,541 ----
model=ModelSet.defaultModelSet().modelNamed('StoreEmployees')
Model.updateModelWithCFG(model, database_cfg)
+
+ utils.enable_model_cache_and_compute()
if reinitDB_flag: reinitDB(); return
Index: test_EditingContext_ParentChild.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_ParentChild.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_EditingContext_ParentChild.py 17 Jul 2003 15:16:28 -0000 1.11
--- test_EditingContext_ParentChild.py 24 Jul 2003 11:30:52 -0000 1.12
***************
*** 16,19 ****
--- 16,20 ----
import utils
if __name__ == "__main__":
+ utils.disable_model_cache()
utils.fixpath()
***************
*** 655,658 ****
--- 656,661 ----
author_books_model.entityNamed('Writer').attributeNamed('birthday').setExternalType('DATETIME')
+ utils.enable_model_cache_and_compute()
+
if reinitDB_flag:
from test_EditingContext_Global import reinitDB
Index: test_EntityClassDescription.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EntityClassDescription.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_EntityClassDescription.py 2 Mar 2003 18:53:54 -0000 1.3
--- test_EntityClassDescription.py 24 Jul 2003 11:30:52 -0000 1.4
***************
*** 36,39 ****
--- 36,40 ----
if __name__ == "__main__":
import utils, sys
+ utils.disable_model_cache()
utils.fixpath()
Index: run.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/run.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** run.py 23 Jul 2003 12:19:10 -0000 1.6
--- run.py 24 Jul 2003 11:30:52 -0000 1.7
***************
*** 27,34 ****
"""Run all tests."""
__version__='$Revision$'[11:-2]
! import os, sys, getopt
import utils
import unittest
# Modeling Layer
import test_Model
--- 27,37 ----
"""Run all tests."""
__version__='$Revision$'[11:-2]
! import sys, getopt
import utils
import unittest
+ if __name__ == "__main__":
+ utils.disable_model_cache() # test_EntityClassDescription requires it
+
# Modeling Layer
import test_Model
|
|
From: <sbi...@us...> - 2003-07-24 11:14:08
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv22715/tests
Modified Files:
utils.py
Log Message:
added disable_model_cache/enable_model_cache_and_compute
Index: utils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/utils.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** utils.py 7 May 2003 11:27:10 -0000 1.7
--- utils.py 24 Jul 2003 11:14:04 -0000 1.8
***************
*** 67,68 ****
--- 67,82 ----
% (len(result.errors), len(result.failures)))
return newerrs
+
+ def disable_model_cache():
+ import os
+ try:
+ del os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE']
+ except:
+ pass
+
+ def enable_model_cache_and_compute():
+ os.environ['MDL_ENABLE_SIMPLE_METHOD_CACHE']='yes'
+ from Modeling.ModelSet import defaultModelSet
+ for m in defaultModelSet().models(): # re-enable caching
+ m.cacheSimpleMethods()
+
|
|
From: <sbi...@us...> - 2003-07-24 11:13:31
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv22581
Modified Files:
Relationship.py
Log Message:
Fixed methods in FlattenedRelationship that were copy-pasted from SipleRelationship but were inappropriate
Index: Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Relationship.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Relationship.py 23 Jul 2003 12:17:41 -0000 1.11
--- Relationship.py 24 Jul 2003 11:13:27 -0000 1.12
***************
*** 686,689 ****
--- 686,691 ----
def __eq__(self, aRelationship):
"Tests whether both relationship are equal"
+ if aRelationship.isFlattened():
+ return 0
try:
# _TBD define __eq__ for Entity
***************
*** 841,850 ****
def checkRelationshipValidity(self):
"""
Checks the relationship validity. This includes the following tests:
- cardinality > 0
! - len(joins) > 0
- name
- source and destinationEntity are not None
- - joins' sources are identical (idem for destinations)
Raises the relation is invalid.
"""
--- 843,852 ----
def checkRelationshipValidity(self):
"""
+ Not Implemented
Checks the relationship validity. This includes the following tests:
- cardinality > 0
! - definition is set
- name
- source and destinationEntity are not None
Raises the relation is invalid.
"""
***************
*** 885,896 ****
def destinationAttributes(self):
"""
! Simply returns the list of joins' destination attributes
"""
! return ()
def destinationEntity(self):
"""
! Returns the destination entity, or 'None' if the relationship has no joins
! yet
"""
components=self.componentRelationships()
--- 887,899 ----
def destinationAttributes(self):
"""
! Unimplemented
"""
! raise NotImplementedError
! #return ()
def destinationEntity(self):
"""
! Returns the destination entity, or 'None' if the relationship has no
! definition yet
"""
components=self.componentRelationships()
***************
*** 950,958 ****
def isSimple(self):
"""
! Indicates whether the relation holds one join.
! Note that this method return also 'true' when the relationship
! is invalid (i.e. it holds no joins)
"""
! return not (self._joins and len(self._joins)>1)
def isToMany(self):
--- 953,959 ----
def isSimple(self):
"""
! Unappropriate
"""
! self.raiseUnappropriate()
def isToMany(self):
***************
*** 971,986 ****
def joins(self):
! "Return the whole set of joins registered in this relationship"
! return ()
def ownsDestination(self): # strict equival. toUML aggregate ?
"""
! Returns true if the relationship owns the destinationEntity.
! See also: setOwnsDestination()
! When a relationship owns its destination, the related entity object
! cannot exist without the source object. Thus, as a side-effect, this
! sets the delete rule to 'cascade'.
"""
! return self._ownsDestination
def propagatesPrimaryKey(self):
--- 972,983 ----
def joins(self):
! "Unappropriate for flattened relationship"
! self.raiseUnappropriate()
def ownsDestination(self): # strict equival. toUML aggregate ?
"""
! Unappropriate
"""
! self.raiseUnappropriate()
def propagatesPrimaryKey(self):
***************
*** 1043,1049 ****
def sourceAttributes(self):
"""
! Simply returns the list of joins' source attributes
"""
! return map(lambda o:o.sourceAttribute(), self._joins)
def validateRelationship(self):
--- 1040,1046 ----
def sourceAttributes(self):
"""
! Unimplemented
"""
! raise NotImplementedError
def validateRelationship(self):
***************
*** 1116,1119 ****
--- 1113,1118 ----
def __eq__(self, aRelationship):
"Tests whether both relationship are equal"
+ if not aRelationship.isFlattened():
+ return 0
try:
# _TBD define __eq__ for Entity
***************
*** 1132,1139 ****
self.ownsDestination()!=aRelationship.ownsDestination():
return 0
- # Test joins set!!
- if len(self._joins)!=len(aRelationship.joins()): return 0
- for aJoin in aRelationship.joins():
- if aJoin not in self._joins: return 0
except:
return 0
--- 1131,1134 ----
|
|
From: <sbi...@us...> - 2003-07-24 11:11:36
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv22303
Modified Files:
ClassDescription.py
Log Message:
Changed docstring: MDL_ENABLE_SIMPLE_METHOD_CACHE should be set to enable caching of models (see Modeling.utils)
Index: ClassDescription.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ClassDescription.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** ClassDescription.py 23 Jul 2003 21:09:27 -0000 1.12
--- ClassDescription.py 24 Jul 2003 11:11:34 -0000 1.13
***************
*** 129,134 ****
Assigns the supplied classDescription to 'name'.
! The supplied ClassDescription's simple methods are cached, unless
! MDL_DISABLE_SIMPLE_METHOD_CACHE is set to any non-empty string. See
utils.cache_simple_methods() for details.
"""
--- 129,134 ----
Assigns the supplied classDescription to 'name'.
! The supplied ClassDescription's simple methods are not cached, unless
! MDL_ENABLE_SIMPLE_METHOD_CACHE is set to any non-empty string. See
utils.cache_simple_methods() for details.
"""
|
|
From: <sbi...@us...> - 2003-07-24 11:10:55
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv22190
Modified Files:
Model.py
Log Message:
Changed docstring: MDL_ENABLE_SIMPLE_METHOD_CACHE should be set to enable caching of models (see utils) + fixed: caching should not iterate on joins when a relationship is flattened + removed isaValidEntityName()
Index: Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Model.py 23 Jul 2003 21:09:26 -0000 1.9
--- Model.py 24 Jul 2003 11:10:53 -0000 1.10
***************
*** 272,278 ****
and caches the result of methods taking only one argument ('self').
! This can be disabled by setting the environment variable
! MDL_DISABLE_SIMPLE_METHOD_CACHE to any non-empty string; you want to
! disable it when you manipulate models at runtime, for example in a model
designer.
--- 272,278 ----
and caches the result of methods taking only one argument ('self').
! This needs to be enabled by setting the environment variable
! MDL_ENABLE_SIMPLE_METHOD_CACHE to any non-empty string; you want to leave
! it disabled when you manipulate models at runtime, for example in a model
designer.
***************
*** 284,289 ****
cache_simple_methods(a)
for r in e.relationships():
! for j in r.joins():
! cache_simple_methods(j)
cache_simple_methods(r)
cache_simple_methods(e)
--- 284,290 ----
cache_simple_methods(a)
for r in e.relationships():
! if not r.isFlattened():
! for j in r.joins():
! cache_simple_methods(j)
cache_simple_methods(r)
cache_simple_methods(e)
***************
*** 345,357 ****
return map(lambda o: o.name(), self.entities())
! def isaValidEntityName(self):
! """
! **Unimplemented** for the moment being (raise NotImplementedError)
! Returns 'true' if modelSet() is 'None', or if modelSet() does not
! hold another model where an entity is already registered with the
! same name.
! """
! # _TBD: bound to check + called by ModelSet when a Model is added
! raise NotImplementedError
def isEntityNameDeclaredInNamespace(self, aName):
--- 346,358 ----
return map(lambda o: o.name(), self.entities())
! #def isaValidEntityName(self):
! # """
! # **Unimplemented** for the moment being (raise NotImplementedError)
! # Returns 'true' if modelSet() is 'None', or if modelSet() does not
! # hold another model where an entity is already registered with the
! # same name.
! # """
! # # _TBD: bound to check + called by ModelSet when a Model is added
! # raise NotImplementedError
def isEntityNameDeclaredInNamespace(self, aName):
|
|
From: <sbi...@us...> - 2003-07-24 11:09:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv21647
Modified Files:
utils.py
Log Message:
Changed: MDL_ENABLE_SIMPLE_METHOD_CACHE should be set to enable caching of models and class descriptions. This prevents existing code to be broken when no action is taken --that was not the case when one had to explicitely set MDL_DISABLE_SIMPLE_METHOD_CACHE to disable it
Index: utils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/utils.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** utils.py 23 Jul 2003 20:58:41 -0000 1.14
--- utils.py 24 Jul 2003 11:09:08 -0000 1.15
***************
*** 195,199 ****
"""
import os
! if os.environ.get('MDL_DISABLE_SIMPLE_METHOD_CACHE', None):
return
from new import instancemethod
--- 195,199 ----
"""
import os
! if not os.environ.get('MDL_ENABLE_SIMPLE_METHOD_CACHE', None):
return
from new import instancemethod
***************
*** 201,206 ****
try:
res=m(anInstance)
! except (NotImplementedError, 'Unimplemented','Nonsense'):
! pass
l=lambda self, res=res: res
cached_m=instancemethod(l, anInstance, anInstance.__class__)
--- 201,206 ----
try:
res=m(anInstance)
! except (NotImplementedError, 'Unimplemented', "Nonsense"):
! continue
l=lambda self, res=res: res
cached_m=instancemethod(l, anInstance, anInstance.__class__)
|
|
From: <sbi...@us...> - 2003-07-23 21:09:30
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv29304
Modified Files:
CHANGES ModelSet.py Model.py ClassDescription.py
Log Message:
Simple methods for models, entities, attributes, relationships and
ClassDescriptions are now automatically cached. This speeds up operations
where model introspection is needed (when saving changes, when using
RelationshipManipulation interface, etc.)
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.131
retrieving revision 1.132
diff -C2 -d -r1.131 -r1.132
*** CHANGES 23 Jul 2003 14:50:50 -0000 1.131
--- CHANGES 23 Jul 2003 21:09:25 -0000 1.132
***************
*** 8,13 ****
--------------------------------------------------------
* Module RelationshipManipulation has been optimized and is now about 1.2x
! faster.
* Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented'
--- 8,19 ----
--------------------------------------------------------
+ * Simple methods for models, entities, attributes, relationships and
+ ClassDescriptions are now automatically cached. This speeds up operations
+ where model introspection is needed (when saving changes, when using
+ RelationshipManipulation interface, etc.)
+
* Module RelationshipManipulation has been optimized and is now about 1.2x
! faster (2x faster with caching of models and class descriptions, see
! above)
* Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented'
***************
*** 39,43 ****
[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.
--- 45,49 ----
[Merged branch brch-0_9pre7-1-PyModel]
! Note: PyModels are not officially announced w/ this release, because there's
no documentation yet. See mailing-list archives for details, or go
there and ask.
Index: ModelSet.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ModelSet.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ModelSet.py 7 Jul 2003 14:57:13 -0000 1.9
--- ModelSet.py 23 Jul 2003 21:09:26 -0000 1.10
***************
*** 159,163 ****
from Model import updateModelWithCFG
updateModelWithCFG(aModel, cfg_path)
!
# XML Import/Export facilities
def addModelFromXML(self, xmlSource):
--- 159,165 ----
from Model import updateModelWithCFG
updateModelWithCFG(aModel, cfg_path)
!
! aModel.cacheSimpleMethods()
!
# XML Import/Export facilities
def addModelFromXML(self, xmlSource):
Index: Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Model.py 23 Jul 2003 12:17:41 -0000 1.8
--- Model.py 23 Jul 2003 21:09:26 -0000 1.9
***************
*** 267,270 ****
--- 267,293 ----
+ def cacheSimpleMethods(self):
+ """
+ Iterates on entities, entities' attributes and relationships, and self,
+ and caches the result of methods taking only one argument ('self').
+
+ This can be disabled by setting the environment variable
+ MDL_DISABLE_SIMPLE_METHOD_CACHE to any non-empty string; you want to
+ disable it when you manipulate models at runtime, for example in a model
+ designer.
+
+ See: Modeling.utils.cache_simple_methods
+ """
+ from utils import cache_simple_methods
+ for e in self.entities():
+ for a in e.attributes():
+ cache_simple_methods(a)
+ for r in e.relationships():
+ for j in r.joins():
+ cache_simple_methods(j)
+ cache_simple_methods(r)
+ cache_simple_methods(e)
+ cache_simple_methods(self, ['cacheSimpleMethods'])
+
def adaptorName(self):
"Returns the DB adaptor name. It may be None."
Index: ClassDescription.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/ClassDescription.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** ClassDescription.py 16 Jul 2003 18:41:37 -0000 1.11
--- ClassDescription.py 23 Jul 2003 21:09:27 -0000 1.12
***************
*** 47,51 ****
from logging import info, warn
from delegation import DelegateWrapper
! from utils import staticmethod
# interfaces
--- 47,51 ----
from logging import info, warn
from delegation import DelegateWrapper
! from utils import staticmethod, cache_simple_methods
# interfaces
***************
*** 126,132 ****
def registerClassDescription(aClassDescription, name):
! "Assigns the supplied classDescription to 'name'"
lock()
try:
__classDescriptionCache__[name]=aClassDescription
finally:
--- 126,139 ----
def registerClassDescription(aClassDescription, name):
! """
! Assigns the supplied classDescription to 'name'.
!
! The supplied ClassDescription's simple methods are cached, unless
! MDL_DISABLE_SIMPLE_METHOD_CACHE is set to any non-empty string. See
! utils.cache_simple_methods() for details.
! """
lock()
try:
+ cache_simple_methods(aClassDescription, ['rootClassDescription'])
__classDescriptionCache__[name]=aClassDescription
finally:
|
|
From: <sbi...@us...> - 2003-07-23 20:58:44
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv26778
Modified Files:
utils.py
Log Message:
Added test on env. variable MDL_DISABLE_SIMPLE_METHOD_CACHE for cache_simple_methods()
Index: utils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/utils.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** utils.py 23 Jul 2003 15:44:29 -0000 1.13
--- utils.py 23 Jul 2003 20:58:41 -0000 1.14
***************
*** 194,197 ****
--- 194,200 ----
See also: methods_to_cache()
"""
+ import os
+ if os.environ.get('MDL_DISABLE_SIMPLE_METHOD_CACHE', None):
+ return
from new import instancemethod
for m in methods_to_cache(anInstance.__class__, exclude):
|
|
From: <sbi...@us...> - 2003-07-23 15:44:32
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv19299
Modified Files:
utils.py
Log Message:
Added cache_simple_methods() and methods_to_cache() for use in the future caching mechanism in ModelSet and ClassDescription
Index: utils.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/utils.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** utils.py 7 Jul 2003 14:24:20 -0000 1.12
--- utils.py 23 Jul 2003 15:44:29 -0000 1.13
***************
*** 50,54 ****
def capitalizeFirstLetter(aName):
"Return the same string with the first letter capitalized"
! return string.capitalize(aName[0])+aName[1:]
def lower(aString):
--- 50,54 ----
def capitalizeFirstLetter(aName):
"Return the same string with the first letter capitalized"
! return aName[0].upper()+aName[1:]
def lower(aString):
***************
*** 178,179 ****
--- 178,228 ----
import warnings
warnings.warn(msg, DeprecationWarning, 3)
+
+ def cache_simple_methods(anInstance, exclude=None):
+ """
+ Takes an instance object and caches the result for all simple methods,
+ i.e. methods that takes no arguments except 'self'. The caching is made by
+ substituting the method with a lambda returning the value the original
+ method returned.
+
+ Parameters:
+
+ anInstance -- the instance to examine
+
+ exclude -- a sequence of methods' names not to cache
+
+ See also: methods_to_cache()
+ """
+ from new import instancemethod
+ for m in methods_to_cache(anInstance.__class__, exclude):
+ try:
+ res=m(anInstance)
+ except (NotImplementedError, 'Unimplemented','Nonsense'):
+ pass
+ l=lambda self, res=res: res
+ cached_m=instancemethod(l, anInstance, anInstance.__class__)
+ setattr(anInstance, m.__name__, cached_m)
+
+ def methods_to_cache(aClass, exclude=None):
+ """
+ Searches and returns within 'aClass' the methods that accepts no arguments
+ except 'self'.
+
+ Parameters:
+
+ aClass -- the class to examine
+
+ exclude -- a sequence of methods' names to exclude from the result set
+
+ """
+ if exclude is None:
+ exclude=[]
+ import inspect
+ isfunction=inspect.isfunction
+ classDict=aClass.__dict__
+ methods=[(func, inspect.getargspec(func))
+ for func in classDict.values()
+ if isfunction(func) and func.__name__!='__init__']
+ methods=[m[0] for m in methods if len(m[1][0])==1]
+ methods=[m for m in methods if m.__name__ not in exclude]
+ return methods
|
|
From: <sbi...@us...> - 2003-07-23 14:50:53
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv10135
Modified Files:
RelationshipManipulation.py CHANGES
Log Message:
module has been optimized and is now about 1.2x faster
Index: RelationshipManipulation.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/RelationshipManipulation.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RelationshipManipulation.py 10 Jan 2003 10:45:44 -0000 1.3
--- RelationshipManipulation.py 23 Jul 2003 14:50:50 -0000 1.4
***************
*** 24,28 ****
"""
! RelationshipManipulation default implementation
This modules consists of two parts:
--- 24,29 ----
"""
! Allows the generic manipulation of objects in relation by inspecting the
! underlying model and taking appropriate actions.
This modules consists of two parts:
***************
*** 62,72 ****
##
if aKey in toManys:
! self.addObjectToPropertyWithKey(anObject, aKey)
else:
# toOne relationship: is it already set?
_selfRelObj=self.valueForKey(aKey)
if _selfRelObj: # Yes: now remove it
! self.removeObjectFromBothSidesOfRelationshipWithKey(_selfRelObj, aKey)
! self.addObjectToPropertyWithKey(anObject, aKey)
## Second step: update the other side
--- 63,74 ----
##
if aKey in toManys:
! _addObjectToPropertyWithKey(self, anObject, aKey, toOnes, toManys)
else:
# toOne relationship: is it already set?
_selfRelObj=self.valueForKey(aKey)
if _selfRelObj: # Yes: now remove it
! _removeObjectFromBothSidesOfRelationshipWithKey(self, _selfRelObj, aKey,
! toOnes, toManys)
! _addObjectToPropertyWithKey(self, anObject, aKey, toOnes, toManys)
## Second step: update the other side
***************
*** 75,82 ****
if _backRelKey is None: return
destClassDesc=self.classDescription().\
classDescriptionForDestinationKey(aKey)
if _backRelKey in destClassDesc.toManyRelationshipKeys():
! anObject.addObjectToPropertyWithKey(self, _backRelKey)
else:
# toOne relationship: is it already set?
--- 77,87 ----
if _backRelKey is None: return
+ otoOnes = anObject.classDescription().toOneRelationshipKeys()
+ otoManys = anObject.classDescription().toManyRelationshipKeys()
+
destClassDesc=self.classDescription().\
classDescriptionForDestinationKey(aKey)
if _backRelKey in destClassDesc.toManyRelationshipKeys():
! _addObjectToPropertyWithKey(anObject, self, _backRelKey, otoOnes, otoManys)
else:
# toOne relationship: is it already set?
***************
*** 85,90 ****
if _backRelObj and _backRelObj!=self:
# Yes: now remove it
! anObject.removeObjectFromBothSidesOfRelationshipWithKey(_backRelObj, _backRelKey)
! anObject.addObjectToPropertyWithKey(self, _backRelKey)
def addObjectToPropertyWithKey(self, anObject, aKey):
--- 90,95 ----
if _backRelObj and _backRelObj!=self:
# Yes: now remove it
! _removeObjectFromBothSidesOfRelationshipWithKey(anObject, _backRelObj, _backRelKey, otoOnes, otoManys)
! _addObjectToPropertyWithKey(anObject, self, _backRelKey, otoOnes, otoManys)
def addObjectToPropertyWithKey(self, anObject, aKey):
***************
*** 92,95 ****
--- 97,130 ----
toOnes = self.classDescription().toOneRelationshipKeys()
toManys = self.classDescription().toManyRelationshipKeys()
+ return _addObjectToPropertyWithKey(self, anObject, aKey, toOnes, toManys)
+
+ def removeObjectFromBothSidesOfRelationshipWithKey(self, anObject, aKey):
+ "See interfaces.RelationshipManipulating"
+ toOnes = self.classDescription().toOneRelationshipKeys()
+ toManys = self.classDescription().toManyRelationshipKeys()
+ return _removeObjectFromBothSidesOfRelationshipWithKey(self, anObject, aKey,
+ toOnes, toManys)
+
+ def removeObjectFromPropertyWithKey(self, anObject, aKey):
+ "See interfaces.RelationshipManipulating"
+ toOnes = self.classDescription().toOneRelationshipKeys()
+ toManys = self.classDescription().toManyRelationshipKeys()
+ return _removeObjectFromPropertyWithKey(self,anObject,aKey,toOnes,toManys)
+
+ def _addObjectToPropertyWithKey(self, anObject, aKey, toOnes, toManys):
+ """
+ Private method used by the methods in this module to avoid the
+ re-computation of to-one and to-many relationships when it is not necessary.
+
+ Parameters are the same as for addObjectToPropertyWithKey, with the
+ additional parameters:
+
+ toOnes -- should equal to
+ self.classDescription().toOneRelationshipKeys()
+
+ toManys -- should equal to
+ self.classDescription().toManyRelationshipKeys()
+
+ """
if aKey not in toOnes+toManys:
raise ValueError, "Key %s is not a relationship's key"%aKey
***************
*** 110,115 ****
self.takeValueForKey(tuple(values), aKey)
! def removeObjectFromBothSidesOfRelationshipWithKey(self, anObject, aKey):
! "See interfaces.RelationshipManipulating"
if anObject is None:
warn('removeObjectFromBothSidesOfRelationshipWithKey', \
--- 145,164 ----
self.takeValueForKey(tuple(values), aKey)
! def _removeObjectFromBothSidesOfRelationshipWithKey(self, anObject, aKey,
! toOnes, toManys):
! """
! Private method used by the methods in this module to avoid the
! re-computation of to-one and to-many relationships when it is not necessary.
!
! Parameters are the same as for
! removeObjectFromBothSidesOfRelationshipWithKey, with the additional
! parameters:
!
! toOnes -- should equal to self.classDescription().toOneRelationshipKeys()
!
! toManys -- should equal to
! self.classDescription().toManyRelationshipKeys()
!
! """
if anObject is None:
warn('removeObjectFromBothSidesOfRelationshipWithKey', \
***************
*** 117,122 ****
return
- toOnes = self.classDescription().toOneRelationshipKeys()
- toManys = self.classDescription().toManyRelationshipKeys()
if aKey not in toOnes+toManys:
raise ValueError, "Key %s is not a relationship"%aKey
--- 166,169 ----
***************
*** 125,129 ****
##
if aKey in toManys:
! self.removeObjectFromPropertyWithKey(anObject, aKey)
else:
# toOne: check this is the one!
--- 172,176 ----
##
if aKey in toManys:
! _removeObjectFromPropertyWithKey(self,anObject, aKey, toOnes, toManys)
else:
# toOne: check this is the one!
***************
*** 131,135 ****
raise ValueError, 'anObject %s is not set for key %s'%(repr(anObject),
aKey)
! self.addObjectToPropertyWithKey(None, aKey)
## Second step: update the other side
--- 178,182 ----
raise ValueError, 'anObject %s is not set for key %s'%(repr(anObject),
aKey)
! _addObjectToPropertyWithKey(self,None, aKey, toOnes,toManys)
## Second step: update the other side
***************
*** 150,157 ****
anObject.addObjectToPropertyWithKey(None, _backRelKey)
! def removeObjectFromPropertyWithKey(self, anObject, aKey):
! "See interfaces.RelationshipManipulating"
! toOnes = self.classDescription().toOneRelationshipKeys()
! toManys = self.classDescription().toManyRelationshipKeys()
if aKey not in toOnes+toManys:
raise ValueError, "Key %s is not a relationship's key"%aKey
--- 197,214 ----
anObject.addObjectToPropertyWithKey(None, _backRelKey)
! def _removeObjectFromPropertyWithKey(self, anObject, aKey, toOnes, toManys):
! """
! Private method used by the methods in this module to avoid the
! re-computation of to-one and to-many relationships when it is not necessary.
!
! Parameters are the same as for removeObjectFromPropertyWithKey(), with the
! additional parameters:
!
! toOnes -- should equal to self.classDescription().toOneRelationshipKeys()
!
! toManys -- should equal to
! self.classDescription().toManyRelationshipKeys()
!
! """
if aKey not in toOnes+toManys:
raise ValueError, "Key %s is not a relationship's key"%aKey
***************
*** 177,181 ****
values.remove(anObject)
self.takeValueForKey(tuple(values), aKey)
-
class RelationshipManipulation:
--- 234,237 ----
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.130
retrieving revision 1.131
diff -C2 -d -r1.130 -r1.131
*** CHANGES 23 Jul 2003 12:17:41 -0000 1.130
--- CHANGES 23 Jul 2003 14:50:50 -0000 1.131
***************
*** 8,11 ****
--- 8,14 ----
--------------------------------------------------------
+ * Module RelationshipManipulation has been optimized and is now about 1.2x
+ faster.
+
* Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented'
exception with NotImplementedError
|
|
From: <sbi...@us...> - 2003-07-23 14:12:59
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks
In directory sc8-pr-cvs1:/tmp/cvs-serv3664/tests/testPackages/AuthorBooks
Modified Files:
model_AuthorBooks.xml Book.py
Log Message:
made Book.FK_Writer_Id a class property to support test for bug #775082
Index: model_AuthorBooks.xml
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks/model_AuthorBooks.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** model_AuthorBooks.xml 7 May 2003 11:27:10 -0000 1.6
--- model_AuthorBooks.xml 23 Jul 2003 14:12:56 -0000 1.7
***************
*** 27,31 ****
<attribute isClassProperty='1' columnName='title' name='title' isRequired='1' precision='0' defaultValue='None' externalType='VARCHAR' width='40' scale='0' type='string' displayLabel='Title'/>
<attribute isClassProperty='1' columnName='id' name='id' isRequired='1' precision='0' defaultValue='0' externalType='INT' width='0' scale='0' type='int' displayLabel=''/>
! <attribute isClassProperty='0' columnName='FK_WRITER_ID' name='FK_Writer_Id' isRequired='0' precision='0' defaultValue='None' externalType='INTEGER' width='0' scale='0' type='string' displayLabel=''/>
<attribute isClassProperty='1' columnName='PRICE' name='price' isRequired='0' precision='10' defaultValue='None' externalType='NUMERIC' width='0' scale='2' type='float' displayLabel=''/>
<relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='1' multiplicityLowerBound='0' destinationEntity='Writer' name='author' displayLabel='' joinSemantic='0'>
--- 27,31 ----
<attribute isClassProperty='1' columnName='title' name='title' isRequired='1' precision='0' defaultValue='None' externalType='VARCHAR' width='40' scale='0' type='string' displayLabel='Title'/>
<attribute isClassProperty='1' columnName='id' name='id' isRequired='1' precision='0' defaultValue='0' externalType='INT' width='0' scale='0' type='int' displayLabel=''/>
! <attribute isClassProperty='1' columnName='FK_WRITER_ID' name='FK_Writer_Id' isRequired='0' precision='0' defaultValue='None' externalType='INTEGER' width='0' scale='0' type='int' displayLabel=''/>
<attribute isClassProperty='1' columnName='PRICE' name='price' isRequired='0' precision='10' defaultValue='None' externalType='NUMERIC' width='0' scale='2' type='float' displayLabel=''/>
<relation deleteRule='0' isClassProperty='1' multiplicityUpperBound='1' multiplicityLowerBound='0' destinationEntity='Writer' name='author' displayLabel='' joinSemantic='0'>
Index: Book.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/testPackages/AuthorBooks/Book.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Book.py 27 Mar 2003 11:47:57 -0000 1.4
--- Book.py 23 Jul 2003 14:12:56 -0000 1.5
***************
*** 20,24 ****
self._price=None
self._author=None
!
def entityName(self):
"Used by the framework to link this object to its entity"
--- 20,25 ----
self._price=None
self._author=None
! self._FK_Writer_Id=None
!
def entityName(self):
"Used by the framework to link this object to its entity"
***************
*** 34,37 ****
--- 35,43 ----
return self._id
+ def getFK_Writer_Id(self):
+ "Return the Writer / firstName attribute value"
+ self.willRead()
+ return self._FK_Writer_Id
+
def getTitle(self):
"Return the Book / title attribute value"
***************
*** 62,66 ****
self.willChange()
self._price = price
!
def validatePrice(self, value):
"Edit this to enforce custom business logic"
--- 68,72 ----
self.willChange()
self._price = price
!
def validatePrice(self, value):
"Edit this to enforce custom business logic"
|
|
From: <sbi...@us...> - 2003-07-23 14:10:19
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv3176/tests
Modified Files:
test_EditingContext_Global.py
Log Message:
Added test for bug #775082
Index: test_EditingContext_Global.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_EditingContext_Global.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** test_EditingContext_Global.py 18 Jul 2003 14:30:46 -0000 1.30
--- test_EditingContext_Global.py 23 Jul 2003 14:10:13 -0000 1.31
***************
*** 52,56 ****
from testPackages.AuthorBooks.Book import Book
-
class Writer_test07(Writer):
refusesValidateForDelete=0
--- 52,55 ----
***************
*** 903,906 ****
--- 902,924 ----
gid=ec.globalIDForObject(b)
self.failUnless(b.getId() == gid.keyValues()['id'])
+
+ def test_17b_insertedObject_and_FK_as_classProperty(self):
+ "[EC] Checks that a FK/class prop. gets its value after saving changes"
+ return
+ ec=EditingContext()
+ w=Writer()
+ w.setLastName('test author')
+ ec.insertObject(w)
+ ec.saveChanges()
+
+ b=Book()
+ ec.insertObject(b)
+ b.setTitle('dummy title')
+ b.setAuthor(w)
+ w.addToBooks(b)
+ self.failIf(b.getFK_Writer_Id())
+ ec.saveChanges()
+ gid=ec.globalIDForObject(w)
+ self.assertEqual(b.getFK_Writer_Id(), gid.keyValues()['id'])
def test_18_percent_in_qualifiers_should_be_correctly_escaped(self):
|
|
From: <sbi...@us...> - 2003-07-23 12:53:11
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv23569
Modified Files:
Join.py
Log Message:
Fixed typo
Index: Join.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Join.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Join.py 23 Jul 2003 12:17:41 -0000 1.4
--- Join.py 23 Jul 2003 12:53:08 -0000 1.5
***************
*** 112,116 ****
"""
# Just a reminder
! raise NotImplementedError, 'Calling it on a join is a nonsense
def getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1'):
--- 112,116 ----
"""
# Just a reminder
! raise NotImplementedError, 'Calling it on a join is a nonsense'
def getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1'):
|
|
From: <sbi...@us...> - 2003-07-23 12:19:13
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv19150/tests
Modified Files:
run.py
Log Message:
Added tests for PyModels in global test suite
Index: run.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/run.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** run.py 14 Mar 2003 11:40:13 -0000 1.5
--- run.py 23 Jul 2003 12:19:10 -0000 1.6
***************
*** 37,40 ****
--- 37,41 ----
import test_Relationship
import test_ImportExport
+ import test_PyModel
# Control Layer
import test_GlobalID # before EditingContext
***************
*** 86,89 ****
--- 87,91 ----
suite.addTest(test_Relationship.test_suite())
suite.addTest(test_ImportExport.test_suite())
+ suite.addTest(test_PyModel.test_suite())
suite.addTest(test_GlobalID.test_suite())
suite.addTest(test_KeyValueCoding.test_suite())
|
|
From: <sbi...@us...> - 2003-07-23 12:17:44
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv18890
Modified Files:
CHANGES Model.py Entity.py Attribute.py Relationship.py
Join.py
Log Message:
Replaced 'Unimplemented' exception with NotImplementedError
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.129
retrieving revision 1.130
diff -C2 -d -r1.129 -r1.130
*** CHANGES 21 Jul 2003 14:28:17 -0000 1.129
--- CHANGES 23 Jul 2003 12:17:41 -0000 1.130
***************
*** 8,11 ****
--- 8,14 ----
--------------------------------------------------------
+ * Model, Entity, Attribute, Relationship, Join: replaced 'Unimplemented'
+ exception with NotImplementedError
+
* Added documentation: handling custom types for attributes (2003/07/21)
Index: Model.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Model.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Model.py 8 Jul 2003 17:32:22 -0000 1.7
--- Model.py 23 Jul 2003 12:17:41 -0000 1.8
***************
*** 324,328 ****
def isaValidEntityName(self):
"""
! **Unimplemented** for the moment being (raise 'Unimplemented')
Returns 'true' if modelSet() is 'None', or if modelSet() does not
hold another model where an entity is already registered with the
--- 324,328 ----
def isaValidEntityName(self):
"""
! **Unimplemented** for the moment being (raise NotImplementedError)
Returns 'true' if modelSet() is 'None', or if modelSet() does not
hold another model where an entity is already registered with the
***************
*** 330,334 ****
"""
# _TBD: bound to check + called by ModelSet when a Model is added
! raise 'Unimplemented'
def isEntityNameDeclaredInNamespace(self, aName):
--- 330,334 ----
"""
# _TBD: bound to check + called by ModelSet when a Model is added
! raise NotImplementedError
def isEntityNameDeclaredInNamespace(self, aName):
***************
*** 385,389 ****
"""
# _TBD: Note: same for attributes when flattened (derived? no) will be taken into account
! raise 'Unimplemented'
def setAdaptorName(self, adaptorName):
--- 385,389 ----
"""
# _TBD: Note: same for attributes when flattened (derived? no) will be taken into account
! raise NotImplementedError
def setAdaptorName(self, adaptorName):
***************
*** 424,428 ****
def validateObject(self, aModel):
"Checks whether the supplied object is valid"
! raise 'Unimplemented'
# XML functionalities
--- 424,428 ----
def validateObject(self, aModel):
"Checks whether the supplied object is valid"
! raise NotImplementedError
# XML functionalities
***************
*** 476,480 ****
node=parentNode
else:
! raise 'Unimplemented'
exportAttrDict=self.xmlAttributesDict()
for attr in exportAttrDict.keys():
--- 476,480 ----
node=parentNode
else:
! raise NotImplementedError
exportAttrDict=self.xmlAttributesDict()
for attr in exportAttrDict.keys():
Index: Entity.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Entity.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Entity.py 7 Jul 2003 14:57:13 -0000 1.14
--- Entity.py 23 Jul 2003 12:17:41 -0000 1.15
***************
*** 910,915 ****
raise ValueError, "Parameter 'PKs' must be a sequence"
#if len(PKs)>1:
! # raise 'Unimplemented', 'Sorry, we only support singletons as PKs for '\
! # 'the moment being'
_ok=1
_PKs=[]
--- 910,915 ----
raise ValueError, "Parameter 'PKs' must be a sequence"
#if len(PKs)>1:
! # raise NotImplementedError,'Sorry, we only support singletons as PKs '\
! # 'for the moment being'
_ok=1
_PKs=[]
***************
*** 964,972 ****
Sets the restricting qualifier.
! Not implemented yet, this method unconditionally raises.
See also: restrictingQualifier()
"""
! raise 'Unimplemented', 'Unimplemented yet'
def setTypeName(self, aName):
--- 964,973 ----
Sets the restricting qualifier.
! Not implemented yet, this method unconditionally raises
! NotImplementedError.
See also: restrictingQualifier()
"""
! raise NotImplementedError, 'Unimplemented yet'
def setTypeName(self, aName):
Index: Attribute.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Attribute.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Attribute.py 23 Jul 2003 11:22:23 -0000 1.16
--- Attribute.py 23 Jul 2003 12:17:41 -0000 1.17
***************
*** 594,598 ****
elif self._isFlattened:
return self.flattenedPropertySet()
! raise 'Unimplemented', 'All cases are not properly covered!'
##
--- 594,598 ----
elif self._isFlattened:
return self.flattenedPropertySet()
! raise NotImplementedError, 'All cases are not properly covered!'
##
***************
*** 679,683 ****
- etc. TBD
"""
! raise 'Unimplemented'
##
--- 679,683 ----
- etc. TBD
"""
! raise NotImplementedError
##
Index: Relationship.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Relationship.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Relationship.py 7 Jul 2003 14:57:13 -0000 1.10
--- Relationship.py 23 Jul 2003 12:17:41 -0000 1.11
***************
*** 608,612 ****
-
"""
! raise 'Unimplemented'
def validateValue(self, value, object=None):
--- 608,612 ----
-
"""
! raise NotImplementedError
def validateValue(self, value, object=None):
***************
*** 1052,1056 ****
-
"""
! raise 'Unimplemented'
def validateValue(self, value, object=None):
--- 1052,1056 ----
-
"""
! raise NotImplementedError
def validateValue(self, value, object=None):
Index: Join.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Join.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Join.py 14 Mar 2003 11:40:09 -0000 1.3
--- Join.py 23 Jul 2003 12:17:41 -0000 1.4
***************
*** 109,115 ****
"""
Cannot be called: initialization from XML is made by relationships.
! Raises 'Nonsense'.
"""
! raise 'Nonsense' # Just a reminder
def getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1'):
--- 109,116 ----
"""
Cannot be called: initialization from XML is made by relationships.
! Raises NotImplementedError.
"""
! # Just a reminder
! raise NotImplementedError, 'Calling it on a join is a nonsense
def getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1'):
|
|
From: <sbi...@us...> - 2003-07-23 11:24:01
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv9847/tests
Modified Files:
test_PyModel.py
Log Message:
misc. check
Index: test_PyModel.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_PyModel.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_PyModel.py 7 Jul 2003 14:57:14 -0000 1.2
--- test_PyModel.py 23 Jul 2003 11:23:58 -0000 1.3
***************
*** 344,348 ****
),
]
! #self.model.build()
#self.check_model(self.model)
#self.check_inverse_rels(self.model)
--- 344,348 ----
),
]
! self.assertRaises(ValueError, self.model.build)
#self.check_model(self.model)
#self.check_inverse_rels(self.model)
|
|
From: <sbi...@us...> - 2003-07-23 11:23:21
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv9773
Modified Files:
EntityClassDescription.py
Log Message:
Fixed adaptorName()
Index: EntityClassDescription.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/EntityClassDescription.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** EntityClassDescription.py 18 Jul 2003 13:50:34 -0000 1.14
--- EntityClassDescription.py 23 Jul 2003 11:23:12 -0000 1.15
***************
*** 90,94 ****
persistent the corresponding instances
"""
! return self._entity.adaptorName()
def allAttributesKeys(self):
--- 90,94 ----
persistent the corresponding instances
"""
! return self._entity.model().adaptorName()
def allAttributesKeys(self):
|
|
From: <sbi...@us...> - 2003-07-23 11:22:28
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv9646
Modified Files:
Attribute.py
Log Message:
Fixed readFormat() (was calling a inexistant method!)
Index: Attribute.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Attribute.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Attribute.py 7 Jul 2003 14:57:13 -0000 1.15
--- Attribute.py 23 Jul 2003 11:22:23 -0000 1.16
***************
*** 275,281 ****
def readFormat(self):
"""
! Simply returns the attribute's externalName()
"""
! return self.externalName()
def relationshipPath(self):
--- 275,281 ----
def readFormat(self):
"""
! Simply returns the attribute's columnName()
"""
! return self.columnName()
def relationshipPath(self):
|
|
From: <sbi...@us...> - 2003-07-21 14:28:22
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv22947
Modified Files:
CHANGES
Log Message:
Added documentation: handling custom types for attributes
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v
retrieving revision 1.128
retrieving revision 1.129
diff -C2 -d -r1.128 -r1.129
*** CHANGES 18 Jul 2003 15:01:13 -0000 1.128
--- CHANGES 21 Jul 2003 14:28:17 -0000 1.129
***************
*** 8,11 ****
--- 8,13 ----
--------------------------------------------------------
+ * Added documentation: handling custom types for attributes (2003/07/21)
+
0.9-pre-10 (2003/07/18)
-----------------------
|
|
From: <sbi...@us...> - 2003-07-21 14:28:22
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv22947/doc/UserGuide
Modified Files:
CustomObject.tex
Log Message:
Added documentation: handling custom types for attributes
Index: CustomObject.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/CustomObject.tex,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CustomObject.tex 4 Jul 2003 17:06:52 -0000 1.5
--- CustomObject.tex 21 Jul 2003 14:28:17 -0000 1.6
***************
*** 115,119 ****
and works on the same principles.
! \section{Accessing the objects' properties\label{customobject-object-properties}}
(quick notes, needs to be further documented)
--- 115,119 ----
and works on the same principles.
! \section{Accessing the objects' properties\label{customobject-key-value-coding}}
(quick notes, needs to be further documented)
***************
*** 227,231 ****
>>> #
... # Now we will manipulate 'objs' without explicitly referring
! ... # to its method
...
>>> for o in objs:
--- 227,231 ----
>>> #
... # Now we will manipulate 'objs' without explicitly referring
! ... # to its methods
...
>>> for o in objs:
***************
*** 273,275 ****
Object <Book.Book instance at 0x84a38b4>
["T'assieds pas sur le compte-gouttes", 4, None]
! \end{verbatim}
\ No newline at end of file
--- 273,393 ----
Object <Book.Book instance at 0x84a38b4>
["T'assieds pas sur le compte-gouttes", 4, None]
! \end{verbatim}
!
! \chapter{Handling custom types for attributes\label{attribute-custom-type}}
!
! The framework handles automatically a subset of built-in python types:
! \code{int}, \code{string}, \code{float} and date types
! (e.g. \code{mx.DateTime}
! %, \code{DCOracle2.OracleDate if you use Oracle
! ). We'll see here how you can make the framework automatically assign to
! attributes' values real objects.
!
! \section{Example: using FixedPoint for a price attribute\label{attribute-custom-type-example}}
!
! Sometimes you need more than this. Let's take the test package
! \module{AuthorBooks}, and suppose we want to use
! \module{FixedPoint}\footnote{\code{FixedPoint} package can be found on
! \ulink{sourceforge}{http://fixedpoint.sourceforge.net/html/lib/module-FixedPoint.html}}.
!
! \begin{itemize}
!
! \item change the model so that price is a \code{string}/\code{VARCHAR} (was: a
! \code{float}/\code{NUMERIC(10,2)}): we will store the \class{FixedPoint}
! object as a string, not as a float, because of the inherent imprecision
! which goes any (binary) representation of float\footnote{try to type
! '\code{0.7}' in a python interpreter:\\
! \code{>{}>{}> 0.7}\\
! \code{0.69999999999999996}}
!
! \item add \method{_setPrice()} and \method{_getPrice()} to
! \class{AuthorBooks.Book}:
!
! \begin{verbatim}
!
! PRECISION=2
! def _setPrice(self, value):
! if value is None:
! self._price=None
! else:
! self._price = FixedPoint(value, PRECISION)
!
! def _getPrice(self):
! if self._price:
! return None
! else:
! return str(self._price)
!
! \end{verbatim}
!
! \end{itemize}
!
! Now let's test this: (remember to change the DB schema so that table BOOK's
! attribute \code{price} is a \code{VARCHAR})
!
! \begin{verbatim}
! >>> from fixedpoint import FixedPoint
! >>> from AuthorBooks.Book import Book
! >>> from Modeling.EditingContext import EditingContext
! >>> ec=EditingContext()
! >>> book=Book()
! >>> book.setTitle('Test FixedPoint')
! >>> book.setPrice(FixedPoint("3.341"))
! >>> book.getTitle(), book.getPrice()
! ('Test FixedPoint', FixedPoint('3.34', 2)) # precision=2
! >>> ec.insert(book)
! >>> ec.saveChanges()
! >>> book.getTitle(), book.getPrice()
! ('Test FixedPoint', FixedPoint('3.34', 2))
! \end{verbatim}
!
! Here you can check in you db that it was stored as a \code{varchar}, as
! expected. Start a new python and test the fetch:
!
! \begin{verbatim}
! >>> from fixedpoint import FixedPoint
! >>> from Modeling.EditingContext import EditingContext
! >>> ec=EditingContext()
! >>> books=ec.fetch('Book')
! >>> books[0].getTitle(), books[0].getPrice()
! ('Test FixedPoint', FixedPoint('3.34', 2))
! \end{verbatim}
!
! As you can see, \class{FixedPoint} is now correctly and automatically
! handled by the framework.
!
!
!
! This technique can be used for any custom type you want to use. The next
! section gives some details on how this works.
!
! \section{Behind the scenes\label{attribute-custom-type-behind-the-scenes}}
!
! We have seen how to map any attribute's value to an instance of given
! class. Here again, this is the \module{KeyValueCoding} in action, as described
! in section~\ref{customobject-key-value-coding}.
!
! The framework {\em always} accesses the attributes' values with the so-called
! "private" methods (\method{storedValueForKey()},
! \method{takeStoredValueForKey()}). We already know that they will try to use
! private setters/getters --such as \method{_setPrice()} and
! \method{_getPrice()}-- before the public ones --being
! \method{getPrice()} and \method{setPrice()}).
!
! So, what happens here is:
! \begin{enumerate}
!
! \item when the framework is about to save the data, it collects the
! attributes' value using \method{storedValueForKey}. This one finds
! \method{_getprice()}, which gently returns the corresponding string,
!
! Note: the same happens for validation before saving: type checking also
! calls \method{_getPrice()} and gets a string, so everything's ok.
!
! \item when the framework fetches the data, it uses
! \method{takeStoredValueForKey()} to initialize attributes' values; for
! the attribute \code{price}, this method finds and calls
! \method{_setPrice()} which turns the string back to
! \class{FixedPoint}.
!
! \end{enumerate}
|
|
From: <sbi...@us...> - 2003-07-21 08:54:48
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1:/tmp/cvs-serv5103 Modified Files: vertoo.data Log Message: Release 0.9pre10 Index: vertoo.data =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/vertoo.data,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vertoo.data 4 Jul 2003 17:29:29 -0000 1.2 --- vertoo.data 21 Jul 2003 08:54:44 -0000 1.3 *************** *** 1 **** ! Modeling = major:0; minor:9; pre:9; release:x; date:Jun 04, 2003; \ No newline at end of file --- 1 ---- ! Modeling = major:0; minor:9; pre:10; release:x; date:Jun 18, 2003; \ No newline at end of file |
|
From: <sbi...@us...> - 2003-07-18 15:18:13
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv29328
Modified Files:
DEPENDENCIES
Log Message:
Release 0.9-pre-10
Index: DEPENDENCIES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/DEPENDENCIES,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** DEPENDENCIES 4 Jul 2003 17:41:51 -0000 1.11
--- DEPENDENCIES 18 Jul 2003 15:18:09 -0000 1.12
***************
*** 26,30 ****
(postgresql servers v7.2 and 7.3 are supported)
! - psycopg v1.1.5.1 -- http://initd.org/software/psycopg
- Or pgdb v3.3 (debian module python2.1-pygresql v7.2.1-2 )
--- 26,30 ----
(postgresql servers v7.2 and 7.3 are supported)
! - psycopg v1.1.6 -- http://initd.org/software/psycopg
- Or pgdb v3.3 (debian module python2.1-pygresql v7.2.1-2 )
|