> I have two simple SQLObject classes, WebTag and WebTopic that are > related using a RelatedJoin: > > > class WebTag(SQLObject): > Name = StringCol( alternateID=True) > Topics = RelatedJoin('WebTopic') > > class WebTopic(SQLObject): > Name = StringCol( unique=True ) > Format = StringCol( default="rst" ) > Title = StringCol( ) > Subtitle = StringCol( default=None) > Description = StringCol(default=None) > Keywords = StringCol( default=None ) > Author = StringCol( default=None ) > DateTimePosted = DateTimeCol() > DateTimeLastModified = DateTimeCol() > UUID = StringCol() > Content = StringCol( default=None ) > Tags = RelatedJoin('WebTag') > > What is the appropriate way to delete an instance of a WebTopic or a > WebTag so that RelatedJoin won't be broken? > > Right now I have a simple: > > WebTopic.delete(id_to_delete) > > or a > > WebTag.delete(id_to_delete) > > But I just started getting this error, so I must have missed something > in the documentation: > > >>> for a in WebTag.selectBy(Name='python'): > ... print a.Name > ... print a.Topics > ... > python > Traceback (most recent call last): > File "<stdin>", line 3, in <module> > File "<string>", line 1, in <lambda> > File "/usr/lib/python2.5/site-packages/sqlobject/joins.py", line > 207, in performJoin > return self._applyOrderBy([self.otherClass.get(id, conn) for (id,) > in ids if id is not None], self.otherClass) > File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 913, in > get > val._init(id, connection, selectResults) > File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 958, in > _init > raise SQLObjectNotFound, "The object %s by the ID %s does not > exist" % (self.__class__.__name__, self.id) > sqlobject.main.SQLObjectNotFound: The object WebTopic by the ID 12 > does not exist > >>> > > Any help and suggestions would be appreciated. The db can be wiped and > started over, because this is a little test system. Should I have > dropped all references to the missing WebTopic instance from all > WebTag instances?
Yes, you need to delete everything manually that is referenced by anything that is to be deleted. A question to the experts: I usually do this by overloading destroySelf so that it loops over all references, is that a good idea? ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss