On Mon, 2010-04-26 at 11:24 -0400, Michael Bayer wrote:

> 2. I wonder if there's a way to make this happen more deeply than within
> setattr().   Like the collection internals would include an event to
> operate upon the target object that includes the other args from the
> collection decorator.

Sorry, I was unable to follow you here. You think there should be an
event generated to be handled by the collection internals? What
arguments of the decorator are you talking about?

> 3. corresponding delete() event.  Set the attribute on the replaced object
> to None ?   that seems potentially surprising ?

In my case it did not matter much since the object is owned by the
mapped collection. So after the delete, it is garbage collected anyway.
As the client code does not "know" about the key attribute, it would not
notice the change anyway even if it still has a pointer.

For me this is the same as some code still having a reference to a value
that was stored in a dict. If you remove it from the dictionary, you may
still keep a reference but it is not reachable anymore from the dict. To
make this match with the database, I am using cascade=delete-orphan.

> > item2 = Item()
> > item2.notes['color'] = item.notes['color']
> >
> > will not work contrary to what one might expect (it generated a conflict
> > on the id column). The solution is to have the target collection copy
> > the assigned object if it has a key already. But that might be too much
> > magic to be easy to understand.
> 
> the target can only be in one collection at a time so I would think
> item2's id wins.  its a primary key switch.

Can't it belong to two collections if there is a secondary join?
In plain Python code, both mappings would have a reference to the same
object.

Greetings, Torsten

-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:torsten.landsch...@dynamore.de
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to