[orm-devel] one2one relationship's behavior when
reassigning (was: Bug or feature in relationships.py)
Mike Watkins
orm-devel@mailman.tux4web.de
Mon, 17 Feb 2003 15:05:21 -0800
Diedrich, Ross -
Good comments from both. I agree the n:1 relationship should be in there -
its a very common pattern.
In the short term I've called my new relationship class "lookup" and have
lazily just duplicated the one2one code without the delete. I have not done
much (yet) in the way of review of one2one to see if I've inherited other
undesirable behaviour.
Ah, I see Diedrich volunteering to add a new class to the package !
Mike
At 11:44 PM 2/17/2003 +0100, you wrote:
>Hi Mike!
>
> >Line 172 of relationships.py in the set method of one2oneColumn contains:
> > if self._data: self._data.delete()
>
>Mike's
> > is a slightly different use case than what (I think) one2one
> >envisions. The example Diedrich uses is a photograph to a person. I guess I
> >can see deleting a photograph row if the persons photo is being replaced
> >with another, so the delete that happens in lock step with the status_id
> >attribute reassignment could make sense.
>
>Orm thinks in objects. So a one2one relationship is a relationship
>between objects. Deleting the parent also deletes the child as
>
> >>> del obj
>
>also deletes obj's attributes... if obj is the only reference to
>them.
>
> >When a document has its status changed, the relationship between Document
> >and a row in Status should change, but no rows in Status should be deleted.
>
>I can see that...
>
> >one2one functionally delivers all that is needed with the important
> >exception of that delete happening on line 172. I guess I could just
> >subclass it and modify its behaviour for myself but I imagine I'm not the
> >only person with this need so here I am raising this.
>
>and I too think subclassing is a good idea. It is a new kind of for orm
>relation and should get a good name. From your eMail I guess 'lookup'
>suggests itself. At the company I used to work for these were
>referred to as 'domain tables", so perhaps 'domain' or 'domain_table'
>would be a good idea. What do you think?
>
>Diedrich
>
>--
> _..._ Diedrich Vorberg
> .' '.
> / _ _ \ http://www.tux4web.de
> | (o)_(o) | info@tux4web.de
> \( ) / .---.
> //'._.'\ \ / \ Internet Dienstleistungen
> // . \ \ \.@-@./ und 'Consulting'.
> || . \ \ /`\_/`\
> |\ : / | // _ \\ Linux Rules!
> \ `) ' (` /_ | \ )|_
> _)``".____,.'"` (_ /`\_`> <_/ \
> ) )'--'( ( \__/'---'\__/
> '---` `---`
>_______________________________________________
>orm-devel mailing list
>orm-devel@mailman.tux4web.de
>http://mailman.tux4web.de/mailman/listinfo/orm-devel