[orm-devel] ORM's overhaul finally underway
Diedrich Vorberg
orm-devel@mailman.tux4web.de
Sat, 6 Sep 2003 22:26:00 +0200
Hello everybody!
Please do not cvs update your workdirs! This is going to fail due to
changes I made in the repository. I've started working on orm today
and the first thing I did was cleaning up a little.
- I've moved the examples back into their own examples/ directory
directly onder orm/. There will be one directory for each RDBMS
supported with its own set of sql and py files for testing. There
will be a lot of code doubling here, but I thought the old test
programs were a mess. Werner started this way for his Firebird
adapter and I thought this was the better thing to do.
- I've modified the one2one relationship.
The assumptions made for a one2one relationship will be followed
more strictly:
- If you assign a childobject to a one2one relationship the object
that has been there in its place before will be DELETEed from the
database.
- If you assign a childobject to a one2one relationship that is
already assigned to another object of the parent class that other
objects's reference to the childobject will be set to NULL
(The child will move from one parent to another)
- If you set a one2one relationship = None it will DELETEes from the
RDBMS
I'm not sure if it is wise to trigger destructive actions through
an assignment. On the other hand if you set an object's attribute to
some value it's just natural for the value that's been there before
to be garbage collected. And since a one2one relationship is for
exactly one parent object for exactly one child, this is what
happens.
Also actually maving a child from one parent to another is a bit
subtle: in regular Python you're used to create two references to
one object by doing that. Not so with a one2one relationship.
- The many2one relationship manages columns which represent its own
forign key much better now (see the example program).
I'll start looking into the many2* relationships tomorow.
Uh.. I've only tested this on mysql, because that's what the
application I'm going to write is supposed to work with. Sorry about
that...
Other things on the todo list:
- smarter debugging (a warning mechanism)
- testing things with constraints (in PostgreSQL and Werner will
want to do this in Firebird as well I guess)
- integrating Kevin Howe's operator module
- your add here!
As usual, any comment or addition welcome!
Diedrich
--
_..._ Diedrich Vorberg
.' '.
/ _ _ \ http://www.tux4web.de
| (o)_(o) | info@tux4web.de
\( ) / .---.
//'._.'\ \ / \ Internet Dienstleistungen
// . \ \ \.@-@./ und 'Consulting'.
|| . \ \ /`\_/`\
|\ : / | // _ \\ Linux Rules!
\ `) ' (` /_ | \ )|_
_)``".____,.'"` (_ /`\_`> <_/ \
) )'--'( ( \__/'---'\__/
'---` `---`