Let's say I've got classes like this (cut for question purposes):

class Artykul(SQLObject):
        tytul = StringCol()
        klucze = RelatedJoin('klucz')

class Klucz(SQLObject):
        wartosc = StringCol(alternateID=True)
        artykuly = RelatedJoin('Artykul')

class Autor(SQLObject):
        nazwa = StringCol()

...and in database there are Artykul with id 1 and Klucz's objects with
id 1,2,..,10 and Autor with id 1

let's execute some code:
>>> artykul = Artykul.get(1)
>>> artykul.addKlucz(11)

and it gives no exception, and attach non existing Klucz(11) to Artykul(1)..

>>> artykul.klucze

it raise SQLObjectNotFound exception.(**)

I know I could avoid such situations with:

>>> klucz = Klucz.get(id)

... that let's me catch exception when needed and if OK (***)

>>> artykul.addKlucz(klucz)

... but code like this (****)

>>> klucz = Autor.get(1)
>>> artykul.addKlucz(klucz)

attaches the Klucz object with id 1 (if exist) to Artykul...

I know I can write additional adding method that check out if the
attached object exist, and if it's the desired class and than when
everything is OK call generic "addName".

Why (*) is like this - any special purposes or just cause SQLObject is
still 0.7dev..? Quite chilling for consistency, and presence when (**) -
I'm not able to get to others real proper objects if attached. And about
(****) too, even more wondering. Why couldn't it rise some exception
like (***)? I'm just curious, why or I've expected too much "magic" ;-)











-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to