modeling-cvs Mailing List for Object-Relational Bridge for python (Page 13)
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-08-31 17:38:11
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv19441/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
misc. update
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** DefiningaModel.tex 31 Aug 2003 17:32:25 -0000 1.37
--- DefiningaModel.tex 31 Aug 2003 17:38:07 -0000 1.38
***************
*** 1855,1860 ****
\subsection{Modeling many-to-many relationships\label{design-rels-many-to-many}}
! Many-to-many relationships are not automatically handled by the framework yet,
! however they can be modeled and used as such.
We'll first examine how many-to-many relationships are mapped in relational
--- 1855,1860 ----
\subsection{Modeling many-to-many relationships\label{design-rels-many-to-many}}
! Many-to-many relationships are not \emph{automatically handled} by the
! framework yet, however they can be modeled and used with minimal efforts.
We'll first examine how many-to-many relationships are mapped in relational
***************
*** 1937,1943 ****
----+-----------+------------
1 | 1 | 1 # p1 <--> a1
! 2 | 1 | 2 # p1 <--> a2
! 3 | 2 | 1 # p2 <--> a1
! 4 | 3 | 3 # p3 <--> a3
5 | 3 | 1 # p3 <--> a1
\end{verbatim}
--- 1937,1943 ----
----+-----------+------------
1 | 1 | 1 # p1 <--> a1
! 2 | 1 | 2 # p1 <--> a2
! 3 | 2 | 1 # p2 <--> a1
! 4 | 3 | 3 # p3 <--> a3
5 | 3 | 1 # p3 <--> a1
\end{verbatim}
***************
*** 1991,1999 ****
model.associations=[
Association('PersonAddress','Person',
! relations=['person','personAddresses'],
! delete=['nullify','cascade'] ),
Association('PersonAddress','Address',
! relations=['address','personAddresses'],
! delete=['nullify','deny'] ),
]
\end{verbatim}
--- 1991,1999 ----
model.associations=[
Association('PersonAddress','Person',
! relations=['person','personAddresses'],
! delete=['nullify','cascade'] ),
Association('PersonAddress','Address',
! relations=['address','personAddresses'],
! delete=['nullify','deny'] ),
]
\end{verbatim}
|
|
From: <sbi...@us...> - 2003-08-31 17:32:29
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv18199
Modified Files:
CHANGES
Log Message:
Modeling many-to-many relationships
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** CHANGES 31 Aug 2003 15:29:12 -0000 1.13
--- CHANGES 31 Aug 2003 17:32:25 -0000 1.14
***************
*** 11,14 ****
--- 11,22 ----
-----------------------
+ * Documentation:
+
+ - documentation for models in general has been rewritten. In particular,
+ PyModels are now fully documented
+
+ - instructions for modeling and manipulating many-to-many relationships
+ have been added in the User's Guide.
+
* PyModel.Model:
|
|
From: <sbi...@us...> - 2003-08-31 17:32:29
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv18199/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Modeling many-to-many relationships
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** DefiningaModel.tex 31 Aug 2003 17:22:50 -0000 1.36
--- DefiningaModel.tex 31 Aug 2003 17:32:25 -0000 1.37
***************
*** 1999,2009 ****
--- 1999,2079 ----
\end{verbatim}
+ We just defined a new entity, \class{PersonAddress}, and two associations
+ modeling the relationships between the correlation table and the correlated
+ ones.
+ Last, we'll need to add some code in classes \class{Person} and \code{Address}
+ to directly manipulate the many-to-many relationships. Since relating an
+ object to an other one is just a matter of adding a object/a row to the
+ correlation table, the code is pretty straightforward.
+
+ In \class{Person}, you'll add the following methods:
+ \begin{verbatim}
+ # Relationship: addresses
+ def getAddresses(self):
+ return self.valueForKeyPath('personAddresses.address')
+
+ def addToAddresses(self, address):
+ if address in self.getAddresses():
+ return
+ from PersonAddress import PersonAddress
+ _pa=PersonAddress() # Create an object in the correlation table
+ self.editingContext().insert(_pa)
+ self.addToPersonAddresses(_pa)
+ _pa.setPerson(self)
+ _pa.setAddress(address)
+ address.addToPersonAddresses(_pa)
+
+ def removeFromAddresses(self, address):
+ _pa=[pa for pa in self.getPersonAddresses() if address == pa.getAddress()]
+ if not _pa:
+ raise ValueError, 'Cannot find address'
+ # Here we simply need to remove the corresponding object in the
+ # correlation table
+ _pa=_pa[0]
+ self.removeFromPersonAddresses(_pa)
+ _pa.getAddress().removeFromPersonAddresses(_pa)
+ _pa.setAddress(None)
+ _pa.setPerson(None)
+ self.editingContext().delete(_pa)
+ \end{verbatim}
+ And you'll add the equivalent methods in \class{Address}:
+ \begin{verbatim}
+ # Relationship: persons
+ def getPersons(self):
+ return self.valueForKeyPath('personAddresses.person')
+
+ def addToPersons(self, person):
+ if person in self.getPersons():
+ return
+ from PersonAddress import PersonAddress
+ _pa=PersonAddress() # Create an object in the correlation table
+ self.editingContext().insert(_pa)
+ self.addToPersonAddresses(_pa)
+ _pa.setPerson(person)
+ _pa.setAddress(self)
+ person.addToPersonAddresses(_pa)
+ def removeFromPersons(self, person):
+ _pa=[pa for pa in self.getPersonAddresses() if person == pa.getPerson()]
+ if not _pa:
+ raise ValueError, 'Cannot find person'
+ # Here we simply need to remove the corresponding object in the
+ # correlation table
+ _pa=_pa[0]
+ self.removeFromPersonAddresses(_pa)
+ _pa.getPerson().removeFromPersonAddresses(_pa)
+ _pa.setAddress(None)
+ _pa.setPerson(None)
+ self.editingContext().delete(_pa)
+ \end{verbatim}
\makeatletter
\def\verbatim@font{\normalsize\ttfamily}
\makeatother
+ Now we can normally call e.g. \method{getAddresses} or \method{addToAddresses}
+ on a \class{Person} object, passing a \class{Address} object, without caring
+ about the details anymore.
\subsection{How to model inheritance \label{design-inheritance}}
|
|
From: <sbi...@us...> - 2003-08-31 17:22:54
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv16069/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Added doc.: how to model many-to-many relationships (to be continued)
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** DefiningaModel.tex 30 Aug 2003 16:46:49 -0000 1.35
--- DefiningaModel.tex 31 Aug 2003 17:22:50 -0000 1.36
***************
*** 1853,1856 ****
--- 1853,2008 ----
+ \subsection{Modeling many-to-many relationships\label{design-rels-many-to-many}}
+
+ Many-to-many relationships are not automatically handled by the framework yet,
+ however they can be modeled and used as such.
+
+ We'll first examine how many-to-many relationships are mapped in relational
+ database schema. Then we will give a short example demonstrating how to do
+ this, including the code that you'll have to insert in your classes to handle
+ them.
+
+ We will use the following model as an example:
+ \begin{verbatim}
+ +--------+ 0,* 0,* +---------+
+ | Person |<-persons------addresses-->| Address |
+ |--------| |---------|
+ | name | | street |
+ +--------+ | town |
+ +---------+
+ \end{verbatim}
+
+ \subsubsection{General principle: the correlation table\label{design-rels-many-to-many-principle}}
+
+ Modeling many-to-many relationships in a relational database schema usually
+ involves designing a \emph{correlation table}, a table which holds the
+ informations about the objects in the two tables, \class{Person} and
+ \class{Address}. Each line in the correlation table is basically a tuple of
+ two elements, one from \class{Address} and one from \class{Person}, so that we
+ can tell that if \code{person_1} and \code{address_2} appear in a single row
+ of the correlation table, we know that those two objects are related to each
+ other.
+
+ Now let's integrate the correlation table into our model:
+ \begin{verbatim}
+ +--------+ 0,1 0,* +----------+ 0,* 0,1 +---------+
+ | Person |<-person---pAs->>| PersAddr |<<-pAs------address-->| Address |
+ |--------| |----------| |---------|
+ | name | | FKperson | | street |
+ +--------+ | FKaddress| | town |
+ +----------+ +---------+
+ \end{verbatim}
+
+ where:
+ \begin{itemize}
+
+ \item \class{PersAddr} is the abbreviation for PersonAddress (the correlation
+ table is usually named after the names of the two tables it correlates)
+
+ \item relationships named \code{personAddresses} are abbreviated with
+ \code{pAs}
+
+ \end{itemize}
+
+ To fully understand what's going on here, let's look at the tables themselves.
+ Suppose tables \class{Address} and \class{Person} have 3 rows each:
+ \begin{verbatim}
+ SELECT * FROM Person;
+ id | name
+ --- +------
+ 1 | p1
+ 2 | p2
+ 3 | p3
+
+ SELECT * FROM Address;
+ id | street | town
+ ----+-----------+------
+ 1 | street a1 |
+ 2 | street a2 |
+ 3 | street a3 |
+ \end{verbatim}
+
+ Then, for the following situation:
+ \begin{itemize}
+ \item \code{p1}'s addresses are \code{[a1, a2]}
+ \item \code{p2}'s addresses are \code{[a1]}
+ \item \code{p3}'s addresses are \code{[a1, a3]}
+ \end{itemize}
+
+ The correlation table looks like:
+
+ \begin{verbatim}
+ SELECT * FROM Person_Address;
+ id | fk_person | fk_address
+ ----+-----------+------------
+ 1 | 1 | 1 # p1 <--> a1
+ 2 | 1 | 2 # p1 <--> a2
+ 3 | 2 | 1 # p2 <--> a1
+ 4 | 3 | 3 # p3 <--> a3
+ 5 | 3 | 1 # p3 <--> a1
+ \end{verbatim}
+
+ \subsubsection{A short example\label{design-rels-many-to-many-principles}}
+
+ Now that we now how many-to-many relationships are handled, we know what we
+ should do:
+
+ \begin{enumerate}
+
+ \item define the correlation table as an entity in the model,
+
+ \item connect the two tables to the correlation table and back,
+
+ \item because we do not want to directly manipulate objects coming from the
+ correlation table, we will write some code so that we can directly
+ access persons from a given address, and addresses from a given person;
+
+ \end{enumerate}
+
+ We've seen in the previous how the model looks like with the correlation
+ table. Here is the full PyModel:
+
+ \makeatletter
+ \def\verbatim@font{\footnotesize\ttfamily}
+ \makeatother
+ \begin{verbatim}
+ from Modeling.PyModel import *
+
+ # defaults
+ AString.defaults['width'] = 40
+ Entity.defaults['properties'] = [
+ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK')
+ ]
+
+ ##
+ _connDict = {'database': 'MM1', 'user': 'postgres', 'host': 'localhost',
+ 'password': ''}
+ model = Model('MM1',adaptorName='Postgresql',connDict=_connDict)
+ model.version='0.1'
+ model.entities = [
+ Entity('Person',
+ properties=[ AString('name',isRequired=1) ] ),
+ Entity('Address',
+ properties=[ AString('street', isRequired=1),
+ AString('town') ] ),
+ Entity('PersonAddress'),
+ ]
+ #---
+ model.associations=[
+ Association('PersonAddress','Person',
+ relations=['person','personAddresses'],
+ delete=['nullify','cascade'] ),
+ Association('PersonAddress','Address',
+ relations=['address','personAddresses'],
+ delete=['nullify','deny'] ),
+ ]
+ \end{verbatim}
+
+
+
+
+ \makeatletter
+ \def\verbatim@font{\normalsize\ttfamily}
+ \makeatother
|
|
From: <sbi...@us...> - 2003-08-31 15:44:09
|
Update of /cvsroot/modeling/ProjectModeling In directory sc8-pr-cvs1:/tmp/cvs-serv30109 Modified Files: INSTALL Log Message: Added Oracle Index: INSTALL =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/INSTALL,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** INSTALL 10 Aug 2003 21:16:14 -0000 1.8 --- INSTALL 31 Aug 2003 15:44:06 -0000 1.9 *************** *** 115,118 **** --- 115,128 ---- Installation: standard distutils. + Oracle + ------ + + The only supported python db-adaptor is DCOracle2, currently v1.3beta. + + You'll find it at: http://www.zope.org/Members/matt/dco2 + + Installation: see the INSTALL file distributed with DCOracle2. + + Postgresql ---------- |
|
From: <sbi...@us...> - 2003-08-31 15:38:14
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage
In directory sc8-pr-cvs1:/tmp/cvs-serv29423/Modeling/doc/HomePage
Modified Files:
main.tex
Log Message:
Oracle supported
Index: main.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/main.tex,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** main.tex 31 Aug 2003 15:29:14 -0000 1.25
--- main.tex 31 Aug 2003 15:38:10 -0000 1.26
***************
*** 100,103 ****
--- 100,120 ----
\begin{description}
+ \item[\begin{rawhtml}<a href="http://www.mysql.com/">MySQL</a>\end{rawhtml}]
+ tested with v3.23.52 and v4.0.13
+
+ Supported python adaptor:
+ \begin{rawhtml}
+ <a href="http://sourceforge.net/projects/mysql-python">MySQL</a>
+ \end{rawhtml}
+
+ \item[\begin{rawhtml}<a href="http://www.oracle.com/">Oracle</a>\end{rawhtml}]
+ tested with Oracle 8i (linux/8.1.7.0.1) and Oracle 9i (9.2.0.1.0/linux)
+
+ Supported python adaptor:
+ \begin{rawhtml}
+ <a href="http://www.zope.org/Members/matt/dco2">DCOracle2</a>
+ \end{rawhtml}
+
+
\item[\begin{rawhtml}<a href="http://www.postgresql.org/">Postgresql</a>\end{rawhtml}] versions 7.2 and 7.3 (see \begin{rawhtml}
<a href="http://modeling.sourceforge.net/UserGuide/env-vars-postgresql.html">Postgresql specificities</a>\end{rawhtml} in the User's Guide if you're using v7.3).
***************
*** 113,124 ****
\begin{rawhtml}
<a href="http://pypgsql.sourceforge.net">PyPgSQL</a>
- \end{rawhtml}
-
- \item[\begin{rawhtml}<a href="http://www.mysql.com/">MySQL</a>\end{rawhtml}]
- tested with v3.23.52 and v4.0.13
-
- Supported python adaptor:
- \begin{rawhtml}
- <a href="http://sourceforge.net/projects/mysql-python">MySQL</a>
\end{rawhtml}
--- 130,133 ----
|
|
From: <sbi...@us...> - 2003-08-31 15:29:17
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage
In directory sc8-pr-cvs1:/tmp/cvs-serv27936/Modeling/doc/HomePage
Modified Files:
downloads.tex main.tex
Log Message:
Release 0.9pre14
Index: downloads.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/downloads.tex,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** downloads.tex 10 Aug 2003 21:14:49 -0000 1.15
--- downloads.tex 31 Aug 2003 15:29:13 -0000 1.16
***************
*** 10,14 ****
\begin{enumerate}
! \item[\bf Current version: 0.9-pre-13]
Download it here:\begin{rawhtml}<a
--- 10,14 ----
\begin{enumerate}
! \item[\bf Current version: 0.9-pre-14]
Download it here:\begin{rawhtml}<a
Index: main.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/HomePage/main.tex,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** main.tex 10 Aug 2003 21:14:49 -0000 1.24
--- main.tex 31 Aug 2003 15:29:14 -0000 1.25
***************
*** 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-13}
% 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-14}
% At minimum, give your name and an email address. You can include a
***************
*** 13,17 ****
\author{S\'ebastien Bigaret}
\email{sbi...@us...}
! \date{Aug 10, 2003}
%\date{\today}
--- 13,17 ----
\author{S\'ebastien Bigaret}
\email{sbi...@us...}
! \date{Aug 31, 2003}
%\date{\today}
|
|
From: <sbi...@us...> - 2003-08-31 15:29:16
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv27936/Modeling/doc
Modified Files:
Tutorial.tex UserGuide.tex
Log Message:
Release 0.9pre14
Index: Tutorial.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/Tutorial.tex,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Tutorial.tex 10 Aug 2003 21:14:49 -0000 1.9
--- Tutorial.tex 31 Aug 2003 15:29:12 -0000 1.10
***************
*** 14,18 ****
\date{February 10, 2003}
%\date{\today}
! \release{0.9-pre-13}
%\setreleaseinfo{5}
\setshortversion{0.9}
--- 14,18 ----
\date{February 10, 2003}
%\date{\today}
! \release{0.9-pre-14}
%\setreleaseinfo{5}
\setshortversion{0.9}
Index: UserGuide.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide.tex,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** UserGuide.tex 10 Aug 2003 21:14:49 -0000 1.28
--- UserGuide.tex 31 Aug 2003 15:29:13 -0000 1.29
***************
*** 12,18 ****
% the rest is at your discretion.
\authoraddress{Email: \email{sbi...@us...}}
! \date{Aug 10, 2003}
%\date{\today}
! \release{0.9-pre-13}
%\setreleaseinfo{pre-8}
\setshortversion{0.9}
--- 12,18 ----
% the rest is at your discretion.
\authoraddress{Email: \email{sbi...@us...}}
! \date{Aug 31, 2003}
%\date{\today}
! \release{0.9-pre-14}
%\setreleaseinfo{pre-8}
\setshortversion{0.9}
|
|
From: <sbi...@us...> - 2003-08-31 15:29:16
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv27936
Modified Files:
CHANGES setup.py vertoo.data
Log Message:
Release 0.9pre14
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** CHANGES 30 Aug 2003 12:55:05 -0000 1.12
--- CHANGES 31 Aug 2003 15:29:12 -0000 1.13
***************
*** 3,11 ****
Module Modeling
---------------
! Current release is: 0.9-pre-13 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
* PyModel.Model:
--- 3,14 ----
Module Modeling
---------------
! Current release is: 0.9-pre-14 / See also: TODO, INSTALL and doc/
* ** Distributed under the GNU General Public License **
--------------------------------------------------------
+ 0.9-pre-14 (2003/08/31)
+ -----------------------
+
* PyModel.Model:
***************
*** 24,29 ****
statement.
! * Added OracleAdaptorLayer (do not use now, there are still commits)
! Test units updated.
0.9-pre-13 (2003/08/10)
--- 27,32 ----
statement.
! * Full support for Oracle database: added OracleAdaptorLayer (do not use
! now, there are still commits). Test units updated.
0.9-pre-13 (2003/08/10)
Index: setup.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/setup.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** setup.py 23 Aug 2003 15:01:12 -0000 1.32
--- setup.py 31 Aug 2003 15:29:12 -0000 1.33
***************
*** 46,50 ****
setup(name="ModelingCore",
! version="0.9-pre-13",
licence ="GNU General Public License",
description=short_description,
--- 46,50 ----
setup(name="ModelingCore",
! version="0.9-pre-14",
licence ="GNU General Public License",
description=short_description,
Index: vertoo.data
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/vertoo.data,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** vertoo.data 10 Aug 2003 21:16:37 -0000 1.7
--- vertoo.data 31 Aug 2003 15:29:12 -0000 1.8
***************
*** 1,2 ****
! mdl-code = major:0; minor:9; pre:13; release:x; date:Aug 10, 2003;
! mdl_doc = major:0; minor:9; pre:13; release:x; date:Aug 10, 2003;
\ No newline at end of file
--- 1,2 ----
! mdl-code = major:0; minor:9; pre:14; release:x; date:Aug 31, 2003;
! mdl_doc = major:0; minor:9; pre:14; release:x; date:Aug 31, 2003;
\ No newline at end of file
|
|
From: <sbi...@us...> - 2003-08-31 15:27:01
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv27501
Modified Files:
vertoo.config
Log Message:
Changed: new vertoo.config format
Index: vertoo.config
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/vertoo.config,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** vertoo.config 10 Aug 2003 21:15:41 -0000 1.3
--- vertoo.config 31 Aug 2003 15:26:56 -0000 1.4
***************
*** 2,69 ****
#versionFormatInfo = VersionFormatInfo(BasicVersionPart)
! registry.registerScheme('normal', '%major.%minor')
! registry.registerScheme('full', '%major.%minor%[pre?-pre-%pre:]%[release?.%release:]')
! #registry.registerScheme('pre', '%major.%minor%[pre?-pre-%pre:]')
! registry.registerScheme('short_pre', '%major.%minor')
! registry.registerScheme('date', '%date')
! #registry.registerScheme('full', '%major.%minor%[release?.%release:]')
! # %@. expands to module name
! scmTool = ScmToolInfo(
! tool="cvs",
! commitmsg="Update version to @+",
! tagfmt="Prj-@full",
! )
! MDL_code = ModuleInfo('mdl-code', [
! FileInfo("setup.py",
! [ AnchorInfo('simple', 1,
! arguments(pattern="version=%Q", format='@full')),
! ]),
! #FileInfo("CHANGES",
! # [ AnchorInfo('simple', 1,
! # arguments(pattern="is: %v", format='@full')),
! # ]),
! #FileInfo([ "Modeling/doc/UserGuide.tex",
! # "Modeling/doc/HomePage/main.tex",
! # "Modeling/doc/Tutorial.tex" ],
! # [ AnchorInfo('simple', 1,
! # arguments(pattern=r"\release{%v}", format='@full')),
! # AnchorInfo('simple', 1,
! # arguments(pattern=r"\setshortversion{%v}", format='@short_pre')),
! # AnchorInfo('simple', 1,
! # arguments(pattern=r"\date{%v}", format='@date')),
! # ]),
! #FileInfo("Modeling/doc/HomePage/downloads.tex",
! # [ AnchorInfo('simple', 1,
! # arguments(pattern="Current version: %v", format='@full')),
! # ]),
! ])
! MDL_doc = ModuleInfo('mdl_doc', [
! #FileInfo("setup.py",
! # [ AnchorInfo('simple', 1,
! # arguments(pattern="version=%Q", format='@full')),
! # ]),
! FileInfo("CHANGES",
! [ AnchorInfo('simple', 1,
! arguments(pattern="is: %v", format='@full')),
! ]),
! FileInfo([ "Modeling/doc/UserGuide.tex",
! "Modeling/doc/HomePage/main.tex",
! "Modeling/doc/Tutorial.tex" ],
! [ AnchorInfo('simple', 1,
! arguments(pattern=r"\release{%v}", format='@full')),
! AnchorInfo('simple', 1,
! arguments(pattern=r"\setshortversion{%v}", format='@short_pre')),
! AnchorInfo('simple', 1,
! arguments(pattern=r"\date{%v}", format='@date')),
! ]),
! FileInfo("Modeling/doc/HomePage/downloads.tex",
! [ AnchorInfo('simple', 1,
! arguments(pattern="Current version: %v", format='@full')),
! ]),
! ])
! modules = [MDL_code, MDL_doc]
# vim:set ft=python fdm=manual:
--- 2,57 ----
#versionFormatInfo = VersionFormatInfo(BasicVersionPart)
! addScheme('normal', '%major.%minor')
! addScheme('full', '%major.%minor%[pre?-pre-%pre:]%[release?.%release:]')
! addScheme('short_pre', '%major.%minor')
! addScheme('date', '%date')
! # # %@. expands to module name
! # scmTool = ScmToolInfo(
! # tool="cvs",
! # commitmsg="Update version to @+",
! # tagfmt="Prj-@full",
! # )
! mdl_code=addModule('mdl-code')
! #mdl_code.setVersionFormat('@public', 'major.minor')
! mdl_code.addAnchor("setup.py",
! arguments(pattern="version=%Q", format='@full'))
! mdl_doc=addModule('mdl_doc')
! ## CHANGES
! mdl_doc.addAnchor("CHANGES",
! arguments(pattern="is: %v", format='@full'))
! ## UserGuide
! mdl_doc.addAnchor("Modeling/doc/UserGuide.tex",
! arguments(pattern=r"\release{%v}", format='@full'))
! mdl_doc.addAnchor("Modeling/doc/UserGuide.tex",
! arguments(pattern=r"\setshortversion{%v}",
! format='@short_pre'))
! mdl_doc.addAnchor("Modeling/doc/UserGuide.tex",
! arguments(pattern=r"\date{%v}", format='@date'))
! ## main.tex
! mdl_doc.addAnchor("Modeling/doc/HomePage/main.tex",
! arguments(pattern=r"\release{%v}", format='@full'))
! mdl_doc.addAnchor("Modeling/doc/HomePage/main.tex",
! arguments(pattern=r"\setshortversion{%v}",
! format='@short_pre'))
! mdl_doc.addAnchor("Modeling/doc/HomePage/main.tex",
! arguments(pattern=r"\date{%v}", format='@date'))
! ## Tutorial.tex
! mdl_doc.addAnchor("Modeling/doc/Tutorial.tex",
! arguments(pattern=r"\release{%v}", format='@full'))
! mdl_doc.addAnchor("Modeling/doc/Tutorial.tex",
! arguments(pattern=r"\setshortversion{%v}",
! format='@short_pre'))
! mdl_doc.addAnchor("Modeling/doc/Tutorial.tex",
! arguments(pattern=r"\date{%v}", format='@date'))
!
! ## downloads.tex
! mdl_doc.addAnchor("Modeling/doc/HomePage/downloads.tex",
! arguments(pattern="Current version: %v", format='@full'))
!
!
! #modules = [MDL_code, MDL_doc]
# vim:set ft=python fdm=manual:
|
|
From: <sbi...@us...> - 2003-08-31 15:02:54
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/OracleAdaptorLayer
In directory sc8-pr-cvs1:/tmp/cvs-serv23418/DatabaseAdaptors/OracleAdaptorLayer
Modified Files:
OracleSQLExpression.py
Log Message:
Fixed: Oracle needs ESCAPE with LIKE
Index: OracleSQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/OracleAdaptorLayer/OracleSQLExpression.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** OracleSQLExpression.py 19 Aug 2003 22:01:18 -0000 1.1
--- OracleSQLExpression.py 31 Aug 2003 15:02:51 -0000 1.2
***************
*** 34,38 ****
__version__='$Revision$'[11:-2]
! from Modeling.SQLExpression import SQLExpression,DateType,CharacterType,NumericType
from oracle_utils import oracle_server_version
import string
--- 34,40 ----
__version__='$Revision$'[11:-2]
! from Modeling.SQLExpression import SQLExpression
! from Modeling.SQLExpression import DateType,CharacterType,NumericType
! from Modeling.Qualifier import QualifierOperatorLike
from oracle_utils import oracle_server_version
import string
***************
*** 135,138 ****
--- 137,166 ----
return attribute.externalType()
+
+ def sqlStringForCaseInsensitiveLike(self, keyString, valueString):
+ """
+ Overrides the default implementation and appends the string:
+
+ ESCAPE '\'
+
+ to LIKE expression, so that Oracle can match as expected.
+ """
+ ret=SQLExpression.sqlStringForCaseInsensitiveLike(self, keyString,
+ valueString)
+ return ret+" ESCAPE '\\'"
+
+ def sqlStringForKeyValueQualifier(self, aQualifier):
+ """
+ Overrides the default implementation and appends the string:
+
+ ESCAPE '\'
+
+ to LIKE expression (and only to LIKE expressions), so that Oracle can
+ match as expected.
+ """
+ ret=SQLExpression.sqlStringForKeyValueQualifier(self, aQualifier)
+ if aQualifier.operator() is QualifierOperatorLike:
+ ret+=" ESCAPE '\\'"
+ return ret
def valueTypeForExternalTypeMapping(self):
|
|
From: <sbi...@us...> - 2003-08-31 13:58:25
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer
In directory sc8-pr-cvs1:/tmp/cvs-serv14361/DatabaseAdaptors/PostgresqlAdaptorLayer
Modified Files:
PostgresqlSQLExpression.py
Log Message:
Fixed: incorrect sqlEscapeChar
Index: PostgresqlSQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer/PostgresqlSQLExpression.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PostgresqlSQLExpression.py 9 Aug 2003 15:10:11 -0000 1.7
--- PostgresqlSQLExpression.py 31 Aug 2003 13:58:22 -0000 1.8
***************
*** 111,114 ****
--- 111,121 ----
self._statement=self._statement+' AS DISTINCT_ROWS'
+ def sqlEscapeChar(self):
+ """
+ Postgresql interprets strings, hence the escape char is a double
+ backslash
+ """
+ return '\\\\'
+
def sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar):
"""
|
|
From: <sbi...@us...> - 2003-08-31 13:54:25
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv13824
Modified Files:
SQLExpression.py
Log Message:
misc. \\% == \%
Index: SQLExpression.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/SQLExpression.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** SQLExpression.py 20 Aug 2003 19:58:04 -0000 1.22
--- SQLExpression.py 31 Aug 2003 13:54:20 -0000 1.23
***************
*** 76,80 ****
anti_escaped_star=re.compile(esc_star_tmp_replct)
anti_esc_question_mark=re.compile(esc_question_tmp_replct)
!
class InvalidSQLTypeError(ValueError):
"""
--- 76,80 ----
anti_escaped_star=re.compile(esc_star_tmp_replct)
anti_esc_question_mark=re.compile(esc_question_tmp_replct)
!
class InvalidSQLTypeError(ValueError):
"""
***************
*** 87,91 ****
"""
"""
!
class Internals:
"""
--- 87,91 ----
"""
"""
!
class Internals:
"""
***************
*** 935,939 ****
'?' becomes '_'.
"""
! pattern=percent.sub('\\%', pattern)
pattern=underscore.sub('\_', pattern)
pattern=escaped_question_mark.sub(esc_question_tmp_replct, pattern)
--- 935,939 ----
'?' becomes '_'.
"""
! pattern=percent.sub('\%', pattern)
pattern=underscore.sub('\_', pattern)
pattern=escaped_question_mark.sub(esc_question_tmp_replct, pattern)
|
|
From: <sbi...@us...> - 2003-08-30 17:22:59
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv14024/ProjectModeling/Modeling
Modified Files:
Attribute.py
Log Message:
date types: mxDateTime and/or DCOracle2's Date
Index: Attribute.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/Attribute.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Attribute.py 23 Jul 2003 12:17:41 -0000 1.17
--- Attribute.py 30 Aug 2003 17:22:56 -0000 1.18
***************
*** 72,82 ****
FieldIndex,
KeywordIndex)
def availableTypes():
#return ('string'(py2.1)/'str'(py2.2), 'int', 'float', 'tuple')
! return tuple([t.__name__ for t in (types.StringType,
! types.IntType,
! types.FloatType,
! #types.TupleType,
! DateTime)])
try:
--- 72,97 ----
FieldIndex,
KeywordIndex)
+
+
+ def date_types():
+ "Returns the set of valid date types"
+ avail_types=[ type(DateTime(0)) ]
+ try:
+ import DCOracle2
+ avail_types.append(type(DCOracle2.Date(0,0,0)))
+ except ImportError:
+ pass
+ return avail_types
+
+
def availableTypes():
#return ('string'(py2.1)/'str'(py2.2), 'int', 'float', 'tuple')
! avail_types=[ types.StringType,
! types.IntType,
! types.FloatType,
! #types.TupleType,
! ]
! avail_types.extend(date_types())
! return tuple([t.__name__ for t in avail_types])
try:
***************
*** 497,505 ****
if type(value)==types.LongType:
if self.type()!=types.IntType.__name__:
! #print 'int!=',self.type()
_error.addErrorForKey(Validation.TYPE_MISMATCH, self.name())
elif type(value).__name__!=self.type():
_error.addErrorForKey(Validation.TYPE_MISMATCH, self.name())
- #print self.name(),': type(value).__name__: ',type(value).__name__, '!= self.type():',self.type()
# String should not exceed width
--- 512,523 ----
if type(value)==types.LongType:
if self.type()!=types.IntType.__name__:
! _error.addErrorForKey(Validation.TYPE_MISMATCH, self.name())
!
! elif type(value) in date_types():
! if self.type() not in [t.__name__ for t in date_types()]:
_error.addErrorForKey(Validation.TYPE_MISMATCH, self.name())
+
elif type(value).__name__!=self.type():
_error.addErrorForKey(Validation.TYPE_MISMATCH, self.name())
# String should not exceed width
|
|
From: <sbi...@us...> - 2003-08-30 17:01:52
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/SQLiteAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv11262/DatabaseAdaptors/SQLiteAdaptorLayer Modified Files: SQLiteSQLExpression.py Log Message: Fixed: missing import Index: SQLiteSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/SQLiteAdaptorLayer/SQLiteSQLExpression.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SQLiteSQLExpression.py 24 Aug 2003 14:13:08 -0000 1.3 --- SQLiteSQLExpression.py 30 Aug 2003 17:01:48 -0000 1.4 *************** *** 45,49 **** __version__='$Revision$'[11:-2] ! from Modeling.SQLExpression import SQLExpression, DateType, CharacterType from Modeling.logging import trace import string --- 45,50 ---- __version__='$Revision$'[11:-2] ! from Modeling.SQLExpression import SQLExpression ! from Modeling.SQLExpression import DateType, CharacterType, NumericType from Modeling.logging import trace import string |
|
From: <sbi...@us...> - 2003-08-30 16:46:52
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv8682/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
misc. fixed path for model doc.
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** DefiningaModel.tex 30 Aug 2003 16:42:44 -0000 1.34
--- DefiningaModel.tex 30 Aug 2003 16:46:49 -0000 1.35
***************
*** 1400,1404 ****
\end{verbatim}
! (extracted from \file{testPackages/AuthorBooks/pymodel_AuthorBooks.py},
corresponding to the model defined in~\ref{model-author-books})
--- 1400,1405 ----
\end{verbatim}
! (extracted from
! \file{Modeling/tests/testPackages/AuthorBooks/pymodel_AuthorBooks.py},
corresponding to the model defined in~\ref{model-author-books})
|
|
From: <sbi...@us...> - 2003-08-30 16:42:48
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv7967/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
PyModel doc: added doc. for Association
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** DefiningaModel.tex 30 Aug 2003 16:16:53 -0000 1.33
--- DefiningaModel.tex 30 Aug 2003 16:42:44 -0000 1.34
***************
*** 880,883 ****
--- 880,885 ----
\end{itemize}
+ We now examines those subclasses and their defaults.
+
%%
\subsubsection{ADateTime\label{pymodel-attribute-props-datetime}}
***************
*** 1002,1005 ****
--- 1004,1011 ----
to~\ref{attributes-props}.
\end{notice}
+ \begin{notice}[warning]
+ If you want to make your primary keys class properties, please be sure to read
+ the dedicated ''FAQ'' entry (\ref{design-faq}).
+ \end{notice}
Every entity must define a primary key. However, most of the times, you do not
***************
*** 1036,1041 ****
\end{notice}
! If you want to make your foreign keys class properties, please be sure to read
! the dedicated ''FAQ'' entry (\ref{design-faq}).
%%
--- 1042,1049 ----
\end{notice}
! \begin{notice}[warning]
! Foreign keys should not be marked as class properties. For a full discussion
! on this topic, please refer to the dedicated ''FAQ'' entry (\ref{design-faq}).
! \end{notice}
%%
***************
*** 1313,1316 ****
--- 1321,1370 ----
\subsection{Association\label{pymodel-association-props}}
+ \class{Association}s are a pratical shortvut for defining a relationship and
+ its inverse in a single python statement.
+
+ Suppose that we want to design the two relationships already discussed above
+ between entities \code{Employee} and \code{Store}:
+ \begin{verbatim}
+ Employee <<-toEmployees------toStore-> Store
+ \end{verbatim}
+
+ We could define the appropriate \class{RToOne} and \class{RToMany} objects in
+ their respective entities. Now we can also define them like this:
+
+ \begin{verbatim}
+ model.entities = [ Entity('Employee'), Entity('Store') ]
+ model.associations = [
+ Association('Employee', 'Store'),
+ ]
+ \end{verbatim}
+ (We've only left in the example the necessary declarations for demonstration
+ --the full pymodel is exposed in~\ref{pymodel-sample}).
+
+ This automatically creates the two relationships, along with the necessay
+ foreign key.\\
+
+ {\bf \sc Important}: \class{Association} objects \emph{always} define a to-one
+ association from the first entity to the second entity, and an inverse
+ to-many relationship from the second entity to the first one.
+
+ Here is an equivalent declaration, where some of the defaults are explictly
+ exposed:
+
+ \begin{verbatim}
+ Association('Employee', 'Store',
+ relations=['toStore', 'toEmployees'],
+ multiplicity=[ [0, 1], [0, None] ],
+ delete=['nullify', 'deny'])
+ \end{verbatim}
+
+ Here again and as a general rule, we suggest that you provide at least the
+ names and the multiplicity of both relationships, so that it is clear which
+ one is the to-one/to-many relationship.
+
+
+ Now here are the defaults that \class{Association} uses. As you see, it uses
+ the same defaults then \class{RToOne} and \class{RToMany}:
+
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
\lineiv{src}{\code{string}}{\emph{no default}}{The source entity's name. This
***************
*** 1318,1336 ****
\lineiv{dst}{\code{string}}{\emph{no default}}{The destination entity's
name. This parameter is mandatory when creating a \class{Association}}
! \lineiv{multiplicity}{sequence}{\code{[ [0,1], [0,None] ]}}{}
! \lineiv{relations}{sequence}{~}{~}
! \lineiv{keys}{\code{sequence}}{\code{[None, None]}}{~}
\lineiv{delete}{sequence}{\code{[ RToOne.defaults['delete'],
! RToMany.defaults['delete'] ]}}{~}
\lineiv{isClassProperty}{sequence}{\code{[ RToOne.defaults['isClassProperty'],
! RToMany.defaults['isClassProperty'] ]}}{~}
\lineiv{joinSemantic}{sequence}{\code{[ RToOne.defaults['joinSemantic'],
! RToMany.defaults['joinSemantic'] ]}}{~}
\lineiv{displayLabel}{sequence}{\code{[ RToOne.defaults['displayLabel'],
! RToMany.defaults['displayLabel'] ]}}{~}
\lineiv{doc}{sequence}{\code{[ RToOne.defaults['doc'],
! RToMany.defaults['doc'] ]}}{~}
\end{longtableiv}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 1372,1405 ----
\lineiv{dst}{\code{string}}{\emph{no default}}{The destination entity's
name. This parameter is mandatory when creating a \class{Association}}
! \lineiv{multiplicity}{sequence}{\code{[ [0,1], [0,None] ]}}{The multiplicity
! for each rel.}
! \lineiv{relations}{sequence}{\code{['to<Dst>', 'to<Src>s']}}{The names for the relationships}
! \lineiv{keys}{\code{sequence}}{\code{[None, None]}}{The two attributes'names
! that both relationships refer to as source/destination attributes}
\lineiv{delete}{sequence}{\code{[ RToOne.defaults['delete'],
! RToMany.defaults['delete'] ]}}{the delete rule for each rel.}
\lineiv{isClassProperty}{sequence}{\code{[ RToOne.defaults['isClassProperty'],
! RToMany.defaults['isClassProperty'] ]}}{Whether each rel. is a class property}
\lineiv{joinSemantic}{sequence}{\code{[ RToOne.defaults['joinSemantic'],
! RToMany.defaults['joinSemantic'] ]}}{The join semantic for each rel.}
\lineiv{displayLabel}{sequence}{\code{[ RToOne.defaults['displayLabel'],
! RToMany.defaults['displayLabel'] ]}}{the \code{displayLabel} for each rel.}
\lineiv{doc}{sequence}{\code{[ RToOne.defaults['doc'],
! RToMany.defaults['doc'] ]}}{A comment assigned to each rel.}
\end{longtableiv}
+ Last, an \class{Association} can be used to define a directional association
+ (where only one of the two relationships is defined), by setting one of the
+ \code{relations} to \code{None}, such as in:
+
+ \begin{verbatim}
+ Association('Writer', 'Writer',
+ relations=['pygmalion', None],
+ delete=['nullify', None],
+ keys=['FK_Writer_id', 'id']),
+ \end{verbatim}
+
+ (extracted from \file{testPackages/AuthorBooks/pymodel_AuthorBooks.py},
+ corresponding to the model defined in~\ref{model-author-books})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
From: <sbi...@us...> - 2003-08-30 16:16:56
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv3664/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
PyModel doc: added doc. for RToOne/RToMany being inverse to each other
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** DefiningaModel.tex 30 Aug 2003 15:13:00 -0000 1.32
--- DefiningaModel.tex 30 Aug 2003 16:16:53 -0000 1.33
***************
*** 871,874 ****
--- 871,882 ----
\end{notice}
+ Every attribute can be declared as a plain \class{Attribute} object. However,
+ the framework provides convenience subclasses for standard attributes:
+ \begin{itemize}
+ \item \class{ADateTime} for mapping dates,
+ \item \class{AFloat} for mapping floating-point numbers,
+ \item \class{AInteger} for mapping integers,
+ \item and \class{AString} for mapping strings.
+ \end{itemize}
%%
***************
*** 975,979 ****
\subsubsection{APrimaryKey\label{pymodel-attribute-props-primary-key}}
! The component \class{AFloat} redefines the following defaults:
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
--- 983,987 ----
\subsubsection{APrimaryKey\label{pymodel-attribute-props-primary-key}}
! The component \class{APrimaryKey} redefines the following defaults:
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
***************
*** 995,998 ****
--- 1003,1018 ----
\end{notice}
+ Every entity must define a primary key. However, most of the times, you do not
+ want to explicitly declare a primary key in each of your entities, since
+ they'll basically be the same. In this case, you'll simply add a primary key
+ to the \class{Entity}'s defaults:
+ \begin{verbatim}
+ Entity.defaults['properties'] = [
+ APrimaryKey('id', isClassProperty=0, isRequired=1, doc='PK')
+ ]
+ \end{verbatim}
+ Every declared entity will then automatically get its own primary key --a
+ clone of the default one.
+
%%
\subsubsection{AForeignKey\label{pymodel-attribute-props-foreign-key}}
***************
*** 1065,1069 ****
\lineiv{displayLabel}{\code{string}}{\code{''}}{~}
\lineiv{doc}{\code{string}}{\code{''}}{~}
! \lineiv{inverse}{\code{string}}{\code{''}}{~}
\end{longtableiv}
--- 1085,1091 ----
\lineiv{displayLabel}{\code{string}}{\code{''}}{~}
\lineiv{doc}{\code{string}}{\code{''}}{~}
! \lineiv{inverse}{\code{string}}{\code{''}}{a valid relationship's name in the
! destination entity --see~\ref{pymodel-relationship-props-inverse}, ''Inverse
! relationships'' for a full discussion.}
\end{longtableiv}
***************
*** 1208,1214 ****
inverse of each other.
! \subsubsection{Inverse relationship\label{pymodel-relationship-props-inverse}}
%%
--- 1230,1312 ----
inverse of each other.
! \subsubsection{Inverse relationships\label{pymodel-relationship-props-inverse}}
!
! Most of the times, a \class{RToOne} relationship is the inverse of a
! \class{RToMany}. That's why they both have a field \code{inverse}, which
! allows you to identify the inverse relationship.
!
! When you define both \class{RToOne} and \class{RToMany} with \emph{explicit}
! source- and destination attributes (using the fields, resp., \code{src} and
! \code{dst}), a PyModel does not need this information to know that the two
! relationships are inverse for each other: a simple inspection of the
! relationships makes it noticeable that their source/destination entity and
! attributes are the same, which allows it to deduce that they are inverse to
! each other.
+ However, when you use the automatic and \emph{implicit} declaration of source
+ and destination attributes, you must supply the \code{inverse} keyword,
+ otherwise you won't get what you expect. Suppose you declare something like
+ this:
+ \begin{verbatim}
+ self.model.entities = [
+ Entity('Employee',
+ properties=[ RToOne('toStore', 'Store'),
+ ] ),
+ Entity('Store',
+ properties=[RToMany('toEmployees','Employee'),
+ ] ),
+ ]
+ \end{verbatim}
+
+ Now see what happens (we suppose here that you have read how automatic binding
+ of source and destination attributes is done, as described
+ in~\ref{pymodel-relationship-props-toone}):
+
+ \begin{enumerate}
+
+ \item the PyModel examine the first \class{RToOne}; given that neither
+ \code{src} nor \code{dst} are supplied, its destination attribute is
+ automatically bound to the \code{Store}'s primary key, and a
+ \class{AForeignKey} is created, named \code{'fkStore'}, and assigned to
+ the source attribute.
+
+ \item Now the PyModel examine the other \class{RToMany} relationship. The
+ source attribute is automatically bound to \class{Store}'s primary
+ key. What about the destination attribute? As expected, a foreign key
+ should be created then bound; but since a attribute \code{'fkStore'}
+ already exists (created at the previous step), a foreign key named
+ \code{'fkStore1'} is created and bound to the destination attribute.
+
+ \end{enumerate}
+
+ So: two foreign keys were created in entity \code{Store}, one for each
+ relationship defined. As a consequence, and since the two relationships use
+ their own foreign key, they cannot be considered as inverse to each other.
+
+ This is why you must supply the \code{inverse} attribute when designing a
+ relationship and its inverse. When it is supplied, the automatic generation of
+ foreign key detects it and, rather than re-creating an other foreign key such
+ as above in step 2., re-uses the foreign key that was previously created in
+ step 1. Hence, the following declaration is correct:
+
+ \begin{verbatim}
+ self.model.entities = [
+ Entity('Employee',
+ properties=[ RToOne('toStore', 'Store', inverse='toEmployees'),
+ ] ),
+ Entity('Store',
+ properties=[RToMany('toEmployees','Employee',inverse='toStore'),
+ ] ),
+ ]
+ \end{verbatim}
+
+ \begin{notice}
+ It is not required that both relationships defines the \code{inverse}
+ attribute: it is sufficient to declare it in one of the two relationships
+ (either the \class{RToOne} or the \class{RToMany}). However and as a general
+ rule, we think that it makes a pymodel clearer if you define it in both
+ relationships, and we suggest that you do that.
+ \end{notice}
%%
***************
*** 1243,1246 ****
--- 1341,1349 ----
Before going into details, here is the skeleton of an xml-model:
+
+ %% this is ended before subsection Full Format
+ \makeatletter
+ \def\verbatim@font{\footnotesize\ttfamily}
+ \makeatother
\begin{verbatim}
<?xml version='1.0' encoding='iso-8859-1'?>
***************
*** 1268,1272 ****
\begin{notice}
! Please note that every value associated to a xml attribute should be a string.
\end{notice}
--- 1371,1376 ----
\begin{notice}
! every value associated to a xml attribute should be a string. It is
! automatically converted to the right type when the model is loaded.
\end{notice}
***************
*** 1396,1406 ****
All these attributes are described in section~\ref{relationships-props}.
! Possible values for delete rules are:
\begin{description}
! \item[for \code{DELETE_NULLIFY}:] (default) \code{'0'}
! \item[for \code{DELETE_DENY}:] \code{'1'}
! \item[for \code{DELETE_CASCADE}:] \code{'2'}
! \item[for \code{DELETE_NOACTION}:] \code{'3'}
! \end{description}
Note: in future it will be possible to enter the real names (such as
--- 1500,1512 ----
All these attributes are described in section~\ref{relationships-props}.
! Here are the possible values for these attributes, and their meaning:
\begin{description}
! \item[\code{isClassProperty}:]
! \begin{itemize}
! \item{} code{'0'}: \code{DELETE NULLIFY}
! \item{} \code{'1'}: \code{DELETE DENY}
! \item{} \code{'2'}: \code{DELETE CASCADE}
! \item{} \code{'3'}: \code{DELETE NOACTION}
! \end{itemize}
Note: in future it will be possible to enter the real names (such as
***************
*** 1408,1412 ****
module \module{ClassDescription}.
- \begin{description}
\item[\code{isClassProperty}:]
Default value: \code{'1'} ({\em Yes}). \code{'0'} stands for {\em No}.
--- 1514,1517 ----
***************
*** 1488,1491 ****
--- 1593,1600 ----
</relation>
\end{verbatim}
+ %% This ends the redefinition started at Xml Overview (beginning of section)
+ \makeatletter
+ \def\verbatim@font{\normalsize\ttfamily}
+ \makeatother
\subsection{Full format of an xml-model\label{full-xml-format}}
|
|
From: <sbi...@us...> - 2003-08-30 15:13:06
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv25909/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Misc. cleanup in PyModel doc.
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** DefiningaModel.tex 30 Aug 2003 15:03:25 -0000 1.31
--- DefiningaModel.tex 30 Aug 2003 15:13:00 -0000 1.32
***************
*** 1032,1036 ****
the object's field \code{destination}, see below).
! \item Instead of declaring two directional relationships, each being the
inverse of the other, you can also declare a object \class{Association}
which gives you the opportunity to declare a relationship and its inverse in
--- 1032,1036 ----
the object's field \code{destination}, see below).
! \item Or, instead of declaring two directional relationships, each being the
inverse of the other, you can also declare a object \class{Association}
which gives you the opportunity to declare a relationship and its inverse in
***************
*** 1043,1047 ****
other component defining relationships: \class{RToOne}
(cf.\ref{pymodel-relationship-props-toone}),
! \class{RToMany}((cf.\ref{pymodel-relationship-props-toone}) and
\class{Association} (cf.\ref{pymodel-association-props}).
--- 1043,1047 ----
other component defining relationships: \class{RToOne}
(cf.\ref{pymodel-relationship-props-toone}),
! \class{RToMany} (cf.\ref{pymodel-relationship-props-tomany}) and
\class{Association} (cf.\ref{pymodel-association-props}).
***************
*** 1079,1083 ****
own defaults (and override some of them).
! \paragraph{Join semantic\label{pymodel-relationship-props-join-semantic}}
The possible values for the attribute \code{joinSemantic}, and their respective
--- 1079,1083 ----
own defaults (and override some of them).
! \paragraph{\bf Join semantic\label{pymodel-relationship-props-join-semantic}}~\\
The possible values for the attribute \code{joinSemantic}, and their respective
***************
*** 1112,1116 ****
destination entity, \code{destination}.
! \paragraph{Source and destination attributes}
Attributes \code{src} and \code{dst}, identifying source and destination
--- 1112,1116 ----
destination entity, \code{destination}.
! \paragraph{\bf Source and destination attributes}~\\
Attributes \code{src} and \code{dst}, identifying source and destination
***************
*** 1178,1188 ****
destination entity, \code{destination}.
! \paragraph{Source and destination attributes}
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied. The rules
! are the same than the ones given in~\ref{pymodel-relationship-props-toone},
! you just need to swap name \code{'src'} and \code{'dst'} in the above
! explanation.
As an example, suppose you have a pymodel declaring such a \code{RToMany}:
--- 1178,1188 ----
destination entity, \code{destination}.
! \paragraph{\bf Source and destination attributes}~\\
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied. The rules
! are the same than the ones given above for \class{RToOne}, you just need to
! swap name \code{'src'}/''source'' and \code{'dst'}/''destination'' in the
! above explanation.
As an example, suppose you have a pymodel declaring such a \code{RToMany}:
***************
*** 1220,1225 ****
\lineiv{dst}{\code{string}}{\emph{no default}}{The destination entity's
name. This parameter is mandatory when creating a \class{Association}}
! \lineiv{multiplicity}{sequence of sequences}{\code{[ [0,1], [0,None] ]}}{}
! \lineiv{relations}{sequence of sequences}{~}{~}
\lineiv{keys}{\code{sequence}}{\code{[None, None]}}{~}
\lineiv{delete}{sequence}{\code{[ RToOne.defaults['delete'],
--- 1220,1225 ----
\lineiv{dst}{\code{string}}{\emph{no default}}{The destination entity's
name. This parameter is mandatory when creating a \class{Association}}
! \lineiv{multiplicity}{sequence}{\code{[ [0,1], [0,None] ]}}{}
! \lineiv{relations}{sequence}{~}{~}
\lineiv{keys}{\code{sequence}}{\code{[None, None]}}{~}
\lineiv{delete}{sequence}{\code{[ RToOne.defaults['delete'],
|
|
From: <sbi...@us...> - 2003-08-30 15:03:28
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv24042/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Reorganized PyModel / Relationships doc.
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** DefiningaModel.tex 30 Aug 2003 14:42:33 -0000 1.30
--- DefiningaModel.tex 30 Aug 2003 15:03:25 -0000 1.31
***************
*** 1020,1025 ****
%%
! \subsection{BaseRelationship\label{pymodel-relationship-props}}
A \class{BaseRelationship} describes how two entities relate to each other.
It has the following attributes:
--- 1020,1050 ----
%%
! \subsection{Relationship\label{pymodel-relationship-props}}
!
! Relationships can be declared in two different manners:
!
! \begin{itemize}
!
! \item you can declare \class{RToOne} and \class{RToMany}
! relationships, joining an entity to an other one. Each of these objects
! defines a directional relationship, from a source entity (this is the entity
! where the relationship is defined) to a destination entity (pointed to by
! the object's field \code{destination}, see below).
!
! \item Instead of declaring two directional relationships, each being the
! inverse of the other, you can also declare a object \class{Association}
! which gives you the opportunity to declare a relationship and its inverse in
! a signle python statement.
!
! \end{itemize}
!
! In the next section, we'll see the defaults of \class{BaseRelationship}; while
! it's not a pymodel component \emph{per se}, it defines the defaults for all
! other component defining relationships: \class{RToOne}
! (cf.\ref{pymodel-relationship-props-toone}),
! \class{RToMany}((cf.\ref{pymodel-relationship-props-toone}) and
! \class{Association} (cf.\ref{pymodel-association-props}).
+ \subsubsection{BaseRelationship\label{pymodel-relationship-props-base-relationship}}
A \class{BaseRelationship} describes how two entities relate to each other.
It has the following attributes:
***************
*** 1054,1057 ****
--- 1079,1092 ----
own defaults (and override some of them).
+ \paragraph{Join semantic\label{pymodel-relationship-props-join-semantic}}
+
+ The possible values for the attribute \code{joinSemantic}, and their respective
+ meaning are:
+ \begin{itemize}
+ \item{}\code{0}: Inner join
+ \item{}\code{1}: Full outer join
+ \item{}\code{2}: Left outer join
+ \item{}\code{3}: Right outer join
+ \end{itemize}
%%
***************
*** 1067,1075 ****
should not be changed}
\lineiv{multiplicity}{sequence}{\code{[0,1]}}{~}
! \lineiv{joinSemantic}{\code{~}}{~}{~}
\end{longtableiv}
(All other defaults are \class{BaseRelationship}'s ones,
! cf.\ref{pymodel-relationship-props})
Minimally, a \class{RToOne} needs a \code{name} and a the name of the
--- 1102,1111 ----
should not be changed}
\lineiv{multiplicity}{sequence}{\code{[0,1]}}{~}
! \lineiv{joinSemantic}{\code{int}}{\code{0}}{see
! \ref{pymodel-relationship-props-join-semantic} for possible values}
\end{longtableiv}
(All other defaults are \class{BaseRelationship}'s ones,
! cf.\ref{pymodel-relationship-props-base-relationship})
Minimally, a \class{RToOne} needs a \code{name} and a the name of the
***************
*** 1130,1139 ****
mandatory arguments when instanciating a \class{APrimaryKey}. Once set, it
should not be changed}
! \lineiv{multiplicity}{\code{}}{}{}
! \lineiv{joinSemantic}{\code{}}{}{}
\end{longtableiv}
(All other defaults are \class{BaseRelationship}'s ones,
! cf.\ref{pymodel-relationship-props})
Minimally, a \class{RToMany} needs a \code{name} and a the name of the
--- 1166,1177 ----
mandatory arguments when instanciating a \class{APrimaryKey}. Once set, it
should not be changed}
! \lineiv{multiplicity}{sequence}{\code{[0, None]}}{\code{None} means
! \emph{unconstrained}: no upper limit}
! \lineiv{joinSemantic}{\code{int}}{\code{0}}{see
! \ref{pymodel-relationship-props-join-semantic} for possible values}
\end{longtableiv}
(All other defaults are \class{BaseRelationship}'s ones,
! cf.\ref{pymodel-relationship-props-base-relationship})
Minimally, a \class{RToMany} needs a \code{name} and a the name of the
|
|
From: <sbi...@us...> - 2003-08-30 14:42:37
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv20492/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Documented PyModel RToOne / RToMany
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** DefiningaModel.tex 30 Aug 2003 14:07:11 -0000 1.29
--- DefiningaModel.tex 30 Aug 2003 14:42:33 -0000 1.30
***************
*** 1073,1089 ****
cf.\ref{pymodel-relationship-props})
! Minimally, a \class{RToOne]} needs a \code{name} and a the name of the
destination entity, \code{destination}.
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied:
\begin{itemize}
! \item \code{src}
! \item \code{dst}
\end{itemize}
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
--- 1073,1122 ----
cf.\ref{pymodel-relationship-props})
! Minimally, a \class{RToOne} needs a \code{name} and a the name of the
destination entity, \code{destination}.
+ \paragraph{Source and destination attributes}
+
Attributes \code{src} and \code{dst}, identifying source and destination
attributes, are automatically calculated if they are not supplied:
\begin{itemize}
! \item \code{dst} is the primary key of the destination entity identified by
! its name in attribute \code{destination}.
! \item \code{src} is calculated from the destination entity's name stored in
! the relationship's \code{destination } attribute. It is a string like:
! \code{'fk<sourceEntityName>'}, possibly followed by a integer (such as in
! \code{'fkEmployee1'}) if the name already exists in the destination entity. In
! fact, a PyModel does more than just computing a name: it also automatically
! creates the corresponding foreign key in the source entity.
!
! For example, a pymodel containing:
! \begin{verbatim}
! self.model.entities = [
! Entity('Employee',
! properties=[ RToOne('toStore', 'Store'),
! # ...
! ]
! \end{verbatim}
!
! automatically binds \code{dst} to the destination entity \code{'Store'}~'s
! primary key, and creates a \code{AForeignKey} named \code{'fkStore'} in the
! source entity \code{'Employee'} (unless such a property --either an attribute
! or a relationship-- already exists with this name, in which case it uses the
! first unused name among \code{'fkStore1'}, \code{'fkStore2'}, etc.
!
! Last, the \code{'inverse'} field of a \class{RToOne} (which designates the
! inverse relationship defined in the destination entity) has some effect in the
! automatic generation of \class{AForeignKey}: please refer to
! \ref{pymodel-relationship-props-inverse} for a full discussion on this topic.
\end{itemize}
+ Of course, you can specify your own source and destination attributes. In this
+ case, it is requires that both are supplied, and that they corrspond to
+ attributes (resp. \code{AForeignKey} and \code{APrimaryKey} attributes)
+ explicitly declared in the source/destination entities.
+
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
***************
*** 1103,1106 ****
--- 1136,1175 ----
(All other defaults are \class{BaseRelationship}'s ones,
cf.\ref{pymodel-relationship-props})
+
+ Minimally, a \class{RToMany} needs a \code{name} and a the name of the
+ destination entity, \code{destination}.
+
+ \paragraph{Source and destination attributes}
+
+ Attributes \code{src} and \code{dst}, identifying source and destination
+ attributes, are automatically calculated if they are not supplied. The rules
+ are the same than the ones given in~\ref{pymodel-relationship-props-toone},
+ you just need to swap name \code{'src'} and \code{'dst'} in the above
+ explanation.
+
+ As an example, suppose you have a pymodel declaring such a \code{RToMany}:
+ \begin{verbatim}
+ self.model.entities = [
+ Entity('Store',
+ properties=[RToMany('toEmployees','Employee')]
+ ),
+ # ...
+ ]
+ \end{verbatim}
+
+ \class{RToMany} then automatically binds \code{'src'} to the source entity
+ \code{'Store'}~'s primary key, and creates a \code{AForeignKey} named
+ \code{'fkStore'} in the destination entity \code{'Employee'} (unless such a
+ property --either an attribute or a relationship-- already exists with this
+ name, in which case it uses the first unused name among \code{'fkStore1'},
+ \code{'fkStore2'}, etc.
+
+ You'll also want to read the section \ref{pymodel-relationship-props-inverse}
+ for a complete explanation on how automatic binding/generation of
+ \class{APrimaryKey}/\class{AForeignKey} is handled when two relationships are
+ inverse of each other.
+
+ \subsubsection{Inverse relationship\label{pymodel-relationship-props-inverse}}
+
|
|
From: <sbi...@us...> - 2003-08-30 14:07:15
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv15053/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Documented defaults for BaseRelationship / PyModel
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** DefiningaModel.tex 30 Aug 2003 12:24:24 -0000 1.28
--- DefiningaModel.tex 30 Aug 2003 14:07:11 -0000 1.29
***************
*** 301,305 ****
\code{externalName} \code{BOOK}, and \code{RegularCustomer} becomes
\code{REGULAR_CUSTOMER}.
! (cf. \function{Modeling.Entity.externalNameForInternalName()})
\item[\code{parentEntity}:] you can choose a parent entity (a *super class*)
--- 301,308 ----
\code{externalName} \code{BOOK}, and \code{RegularCustomer} becomes
\code{REGULAR_CUSTOMER}.
! (cf. \function{Modeling.Entity.externalNameForInternalName()} and its
! \footnote{as defined in module \module{Entity}, see
! \ulink{documentation}
! {http://modeling.sf.net/API/Modeling-API/public/Modeling.Entity-module.html\#externalNameForInternalName}})
\item[\code{parentEntity}:] you can choose a parent entity (a *super class*)
***************
*** 848,852 ****
arguments when instanciating a \class{Attribute}. Once set, it should not be
changed}
! \lineiv{columnName}{\code{string}}{\code{externalNameForInternalName(name)}}{}
\lineiv{type}{\code{string}}{\code{'int'}}{}
\lineiv{externalType}{\code{string}}{\code{'INTEGER'}}{}
--- 851,856 ----
arguments when instanciating a \class{Attribute}. Once set, it should not be
changed}
! \lineiv{columnName}{\code{string}}{\code{externalNameForInternalName(name)}
! \footnote{as defined in module \module{Entity}, see \ulink{externalNameForInternalName}{http://modeling.sf.net/API/Modeling-API/public/Modeling.Entity-module.html\#externalNameForInternalName}}}{}
\lineiv{type}{\code{string}}{\code{'int'}}{}
\lineiv{externalType}{\code{string}}{\code{'INTEGER'}}{}
***************
*** 854,859 ****
\lineiv{isRequired}{\code{int}}{\code{0}}{}
\lineiv{precision}{\code{int}}{\code{0}}{}
- \lineiv{width}{\code{int}}{\code{0}}{}
\lineiv{scale}{\code{int}}{\code{0}}{}
\lineiv{defaultValue}{~}{\code{None}}{}
\lineiv{usedForLocking}{\code{int}}{\code{0}}{}
--- 858,863 ----
\lineiv{isRequired}{\code{int}}{\code{0}}{}
\lineiv{precision}{\code{int}}{\code{0}}{}
\lineiv{scale}{\code{int}}{\code{0}}{}
+ \lineiv{width}{\code{int}}{\code{0}}{}
\lineiv{defaultValue}{~}{\code{None}}{}
\lineiv{usedForLocking}{\code{int}}{\code{0}}{}
***************
*** 913,916 ****
--- 917,923 ----
\end{notice}
+ Of course, you can redefine the defaults for \class{AFloat} in your PyModel to
+ fit your needs.
+
%%
\subsubsection{AInteger\label{pymodel-attribute-props-integer}}
***************
*** 956,959 ****
--- 963,974 ----
to~\ref{attributes-props}.
\end{notice}
+ Of course, you can redefine the defaults for \class{AString} in your PyModel to
+ fit your needs. For example, if you prefer to use \code{TEXT}, you'll probably
+ add this to your PyModel:
+
+ \begin{verbatim}
+ AString.defaults['externalType'] = 'TEXT'
+ AString.defaults['width'] = 0
+ \end{verbatim}
%%
***************
*** 1001,1051 ****
\end{notice}
! %%
! \subsection{Association\label{pymodel-association-props}}
!
! \begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
! \lineiv{multiplicity}{\code{~}}{~}{~}
! \lineiv{relations}{\code{~}}{~}{~}
! \lineiv{keys}{\code{~}}{~}{~}
! \lineiv{delete}{\code{~}}{~}{~}
! \lineiv{isClassProperty}{\code{~}}{~}{~}
! \lineiv{joinSemantic}{\code{~}}{~}{~}
! \lineiv{displayLabel}{\code{~}}{~}{~}
! \lineiv{doc}{\code{~}}{~}{~}
! \end{longtableiv}
%%
! \subsection{Relationship\label{pymodel-relationship-props}}
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
! \lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the only
! mandatory arguments when instanciating a \class{APrimaryKey}. Once set, it
should not be changed}
! \lineiv{delete}{\code{~}}{~}{~}
! \lineiv{isClassProperty}{\code{~}}{~}{~}
! \lineiv{multiplicity}{\code{~}}{~}{~}
! \lineiv{joinSemantic}{\code{~}}{~}{~}
! \lineiv{src}{\code{~}}{~}{~}
! \lineiv{dst}{\code{~}}{~}{~}
! \lineiv{displayLabel}{\code{~}}{~}{~}
! \lineiv{doc}{\code{~}}{~}{~}
! \lineiv{inverse}{\code{~}}{~}{~}
\end{longtableiv}
%%
\subsubsection{RToOne\label{pymodel-relationship-props-toone}}
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
\lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the only
! mandatory arguments when instanciating a \class{APrimaryKey}. Once set, it
should not be changed}
! \lineiv{multiplicity}{\code{~}}{~}{~}
\lineiv{joinSemantic}{\code{~}}{~}{~}
\end{longtableiv}
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
\lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the only
--- 1016,1096 ----
\end{notice}
! If you want to make your foreign keys class properties, please be sure to read
! the dedicated ''FAQ'' entry (\ref{design-faq}).
%%
! \subsection{BaseRelationship\label{pymodel-relationship-props}}
!
! A \class{BaseRelationship} describes how two entities relate to each other.
! It has the following attributes:
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
! \lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the first
! mandatory argument when instanciating a \class{BaseRelationship}. Once set, it
should not be changed}
! \lineiv{destination}{\code{string}}{\emph{no default}}{The destination
! entity's \code{name} is the second mandatory argument when instanciating a
! \class{BaseRelationship}. Once set, it should not be changed}
! \lineiv{delete}{\code{string}}{\code{'nullify'}}{~}
! \lineiv{isClassProperty}{\code{int}}{1}{~}
! \lineiv{multiplicity}{sequence}{\code{[0,1]}}{~}
! \lineiv{joinSemantic}{\code{int}}{0}{see below}
! \lineiv{src}{\code{string}}{\code{''}}{source attr.'s name}
! \lineiv{dst}{\code{string}}{\code{''}}{destination attr.'s names}
! \lineiv{displayLabel}{\code{string}}{\code{''}}{~}
! \lineiv{doc}{\code{string}}{\code{''}}{~}
! \lineiv{inverse}{\code{string}}{\code{''}}{~}
\end{longtableiv}
+ You'll never need to use a \class{BaseRelationship}; in fact, it's not even
+ legal in a PyModel. Instead, you'll declare \class{RToOne}
+ (\ref{pymodel-relationship-props-toone}) and \class{RToMany}
+ (\ref{pymodel-relationship-props-tomany}) objects; or even better, you'll use
+ \class{Association} (\ref{pymodel-association-props}) objects to create both a
+ relationship and its inverse in a single declaration.
+
+ We presented it here because all three element \class{RToOne}, \class{RToMany}
+ and \class{Association} use the \class{BaseRelationship}'s defaults for their
+ own defaults (and override some of them).
+
%%
\subsubsection{RToOne\label{pymodel-relationship-props-toone}}
+ \class{RToOne} objects describe a to-one relationship from an \class{Entity}
+ to another. It derives from \class{Relationship} and overrides the following
+ defaults:
+
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
\lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the only
! mandatory arguments when instanciating a \class{RToOne}. Once set, it
should not be changed}
! \lineiv{multiplicity}{sequence}{\code{[0,1]}}{~}
\lineiv{joinSemantic}{\code{~}}{~}{~}
\end{longtableiv}
+ (All other defaults are \class{BaseRelationship}'s ones,
+ cf.\ref{pymodel-relationship-props})
+
+ Minimally, a \class{RToOne]} needs a \code{name} and a the name of the
+ destination entity, \code{destination}.
+
+ Attributes \code{src} and \code{dst}, identifying source and destination
+ attributes, are automatically calculated if they are not supplied:
+ \begin{itemize}
+
+ \item \code{src}
+
+ \item \code{dst}
+
+ \end{itemize}
+
%%
\subsubsection{RToMany\label{pymodel-relationship-props-tomany}}
+ \class{RToOne} objects describe a to-many relationship from an \class{Entity}
+ to another. It derives from \class{Relationship} and overrides the following
+ defaults:
+
\begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
\lineiv{name}{\code{string}}{\emph{no default}}{The \code{name} is the only
***************
*** 1054,1057 ****
--- 1099,1129 ----
\lineiv{multiplicity}{\code{}}{}{}
\lineiv{joinSemantic}{\code{}}{}{}
+ \end{longtableiv}
+
+ (All other defaults are \class{BaseRelationship}'s ones,
+ cf.\ref{pymodel-relationship-props})
+
+
+ %%
+ \subsection{Association\label{pymodel-association-props}}
+
+ \begin{longtableiv}{p{3cm}p{1.5cm}p{4cm}p{5.5cm}}{code}{Prop.}{Type}{Default}{Comment}
+ \lineiv{src}{\code{string}}{\emph{no default}}{The source entity's name. This
+ parameter is mandatory when creating a \class{Association}}
+ \lineiv{dst}{\code{string}}{\emph{no default}}{The destination entity's
+ name. This parameter is mandatory when creating a \class{Association}}
+ \lineiv{multiplicity}{sequence of sequences}{\code{[ [0,1], [0,None] ]}}{}
+ \lineiv{relations}{sequence of sequences}{~}{~}
+ \lineiv{keys}{\code{sequence}}{\code{[None, None]}}{~}
+ \lineiv{delete}{sequence}{\code{[ RToOne.defaults['delete'],
+ RToMany.defaults['delete'] ]}}{~}
+ \lineiv{isClassProperty}{sequence}{\code{[ RToOne.defaults['isClassProperty'],
+ RToMany.defaults['isClassProperty'] ]}}{~}
+ \lineiv{joinSemantic}{sequence}{\code{[ RToOne.defaults['joinSemantic'],
+ RToMany.defaults['joinSemantic'] ]}}{~}
+ \lineiv{displayLabel}{sequence}{\code{[ RToOne.defaults['displayLabel'],
+ RToMany.defaults['displayLabel'] ]}}{~}
+ \lineiv{doc}{sequence}{\code{[ RToOne.defaults['doc'],
+ RToMany.defaults['doc'] ]}}{~}
\end{longtableiv}
|
|
From: <sbi...@us...> - 2003-08-30 12:55:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling
In directory sc8-pr-cvs1:/tmp/cvs-serv4739/Modeling
Modified Files:
PyModel.py
Log Message:
Fixed bug #794185: Entity.__init__() ignores associations
Index: PyModel.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/PyModel.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PyModel.py 26 Aug 2003 19:40:24 -0000 1.5
--- PyModel.py 30 Aug 2003 12:55:05 -0000 1.6
***************
*** 130,134 ****
self.name=self.requiredField(name)
self.entities=list(kw.get('entities', []))
! self.entities=list(kw.get('associations', []))
from Model import Model as MModel
self.component=MModel(name)
--- 130,134 ----
self.name=self.requiredField(name)
self.entities=list(kw.get('entities', []))
! self.associations=list(kw.get('associations', []))
from Model import Model as MModel
self.component=MModel(name)
|
|
From: <sbi...@us...> - 2003-08-30 12:55:09
|
Update of /cvsroot/modeling/ProjectModeling
In directory sc8-pr-cvs1:/tmp/cvs-serv4739
Modified Files:
CHANGES
Log Message:
Fixed bug #794185: Entity.__init__() ignores associations
Index: CHANGES
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/CHANGES,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** CHANGES 26 Aug 2003 19:40:24 -0000 1.11
--- CHANGES 30 Aug 2003 12:55:05 -0000 1.12
***************
*** 12,15 ****
--- 12,17 ----
- Fixed bug #795561: __init__() did not recognize 'version' as a parameter
+ - Fixed bug #794185: Entity.__init__() ignores associations
+
- Now raises PyModel.IncompatibleVersionError when a model has an
incompatible version (was: ValueError)
|
|
From: <sbi...@us...> - 2003-08-30 12:24:29
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide
In directory sc8-pr-cvs1:/tmp/cvs-serv715/ProjectModeling/Modeling/doc/UserGuide
Modified Files:
DefiningaModel.tex
Log Message:
Updated doc. for XML model
Index: DefiningaModel.tex
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/doc/UserGuide/DefiningaModel.tex,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** DefiningaModel.tex 26 Aug 2003 20:25:45 -0000 1.27
--- DefiningaModel.tex 30 Aug 2003 12:24:24 -0000 1.28
***************
*** 1078,1081 ****
--- 1078,1082 ----
</entity>
</model>
+
\end{verbatim}
***************
*** 1083,1090 ****
section~\ref{full-xml-format}.
! Each of the xml elements \code{<model>}, \code{<entity>} etc. has its own set of
! attributes, as indicated by the ellipses found in the xml elements above. The
! following subsections describe each element in detail.
\subsection{Model \label{xml-model-props}}
--- 1084,1094 ----
section~\ref{full-xml-format}.
+ Each of the xml elements \code{<model>}, \code{<entity>} etc. has its own
+ set of attributes, as indicated by the ellipses found in the xml elements
+ above. The following subsections describe each element in detail.
! \begin{notice}
! Please note that every value associated to a xml attribute should be a string.
! \end{notice}
\subsection{Model \label{xml-model-props}}
***************
*** 1093,1098 ****
is, hence, the root element of the model.
! The \code{<model>} element may have the following attributes:
The connection dictionary should be a valid python expression for
--- 1097,1113 ----
is, hence, the root element of the model.
! The \code{<model>} element has the following attributes:
!
! \begin{verbatim}
! <model
! name = '' -- unique per model set
! packageName = '' -- generate classes into, and import from, this package
! adaptorName = ( MySQL | Oracle | Postgresql | SQLite ) : Postgresql -- a supported database adaptor
! comment = '' -- a comment
! connectionDictionary = "{}" -- string representation of a python dictionary
! >
! \end{verbatim}
+ All these attributes are described in section~\ref{model-props}.
The connection dictionary should be a valid python expression for
***************
*** 1134,1142 ****
--- 1149,1219 ----
\end{verbatim}
+ \subsubsection{Definition of an entity\label{xml-entity-props-entity}}
+
+ The \code{<entity>} element is a child of the \code{<model>} element. It has
+ the following attributes:
+
+ \begin{verbatim}
+ <entity
+ name = '' -- relates class to db table
+ className = '' -- python class name for this entity
+ moduleName = '' -- class is generated into, and accessed from, this module
+ externalName = '' -- db table name
+ parentEntity = '' -- name of entity to "inherit" from
+ typeName = '' -- not yet used
+ isAbstract = '0' -- not yet used
+ isReadOnly = '0' -- not yet used
+ comment = '' -- a comment
+ >
+ \end{verbatim}
+
+ All these attributes are described in section~\ref{entity-props}.
\subsection{Attribute\label{xml-attributes-props}}
+ The \code{<attribute>} element is a child of the \code{<entity>} element. It
+ may have the following attributes:
+
+ \begin{verbatim}
+ <attribute
+ name = '' -- class attribute name
+ type = ( string | int | float | DateTime ) : string -- python type
+ isClassProperty = '1' -- '0' or '1'; attribute is also a class property
+ isRequired = '1' -- '0' or '1'; cannot be null
+ columnName = '' -- database table column name
+ externalType = '' -- database type
+ width = '' -- qualifier for some values of externalType
+ precision = '' -- qualifier for some values of externalType
+ scale = '' -- qualifier for some values of externalType
+ defaultValue = '' -- class attribute default value
+ displayLabel = '' -- text label to use in applications
+ comment = '' -- a comment
+ />
+ \end{verbatim}
+ All these attributes are described in section~\ref{attributes-props}.
+
\subsection{Relationship\label{xml-relationships-props}}
+ The \code{<relationship>} element is a child of the \code{<entity>}
+ element. It has the following attributes:
+
+ \begin{verbatim}
+ <relation
+ name = '' -- relation name
+ deleteRule = ( 0,DELETE_NULLIFY | 1,DELETE_DENY | 2,DELETE_CASCADE |
+ 3,DELETE_NOACTION ) : 0 -- behaviour when object is deleted
+ isClassProperty = '1' -- '0' or '1'; relation is also a class property
+ multiplicityLowerBound = ( int > -1 ) : 0
+ multiplicityUpperBound = ( int > -1 | -1,* ) : 1
+ -- -1 or * indicate unconstrained upper bound
+ destinationEntity = '' -- name of destination entity
+ joinSemantic = ( 0,Inner | 1,FullOuter | 2,LeftOuter | 3,Right Outer ) : 0
+ displayLabel = '' -- text label to use in applications
+ comment = '' -- a comment
+ >
+ </relation>
+ \end{verbatim}
+
+ All these attributes are described in section~\ref{relationships-props}.
Possible values for delete rules are:
***************
*** 1217,1220 ****
--- 1294,1313 ----
\end{description}
+ It is formatted this way:
+
+ \begin{verbatim}
+ <relation
+ name = '' -- relation name
+ ...
+ destinationEntity = '' -- name of destination entity
+ >
+ <!-- unordered content: (join) -->
+ <join
+ sourceAttribute = '' -- name of source attribute, in enclosing entity
+ destinationAttribute = '' -- name of target attribute, in ../@destinationEntity
+ />
+ </relation>
+ \end{verbatim}
+
\subsection{Full format of an xml-model\label{full-xml-format}}
\makeatletter
***************
*** 1256,1262 ****
columnName = '' -- database table column name
externalType = '' -- database type
! width = '' -- qualifer for some values of externalType
! precision = '' -- qualifer for some values of externalType
! scale = '' -- qualifer for some values of externalType
defaultValue = '' -- class attribute default value
displayLabel = '' -- text label to use in applications
--- 1349,1355 ----
columnName = '' -- database table column name
externalType = '' -- database type
! width = '' -- qualifier for some values of externalType
! precision = '' -- qualifier for some values of externalType
! scale = '' -- qualifier for some values of externalType
defaultValue = '' -- class attribute default value
displayLabel = '' -- text label to use in applications
***************
*** 1264,1268 ****
/>
<relation
! name = '' -- class attribute name
deleteRule = ( 0,DELETE_NULLIFY | 1,DELETE_DENY | 2,DELETE_CASCADE |
3,DELETE_NOACTION ) : 0 -- behaviour when object is deleted
--- 1357,1361 ----
/>
<relation
! name = '' -- relation name
deleteRule = ( 0,DELETE_NULLIFY | 1,DELETE_DENY | 2,DELETE_CASCADE |
3,DELETE_NOACTION ) : 0 -- behaviour when object is deleted
|