Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Jon R. Fox
Excellent.

I tried changing syntax first, which didn't work, and then realized
that the version of sqlobject installed on this machine was stale. I'm
glad they are equivalent, because I enjoy terseness.

Filing an upgrade bugrequest for the ubuntu people is now on my todo
list. With the popularity of  turbogears, a lot of folks are going to
try a related join and then reach this problem.

-- Jon

On 7/9/07, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 09, 2007 at 08:28:51AM -0400, Jon R. Fox wrote:
> > I switched to
> >
> >  WebTag.get(tag_id_to_delete).destroySelf()
>
>This is equivalent to
>
> WebTag.delete(tag_id_to_delete)
>
> Oleg.
> --
>  Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
>Programmers don't die, they just GOSUB without RETURN.
>
> -
> 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
>


-- 
Dr. Jon R. Fox
Applied Physicist and Technologist
[EMAIL PROTECTED]
http://www.drfox.com
1-973-494-0370

-
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


Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Oleg Broytmann
On Mon, Jul 09, 2007 at 08:28:51AM -0400, Jon R. Fox wrote:
> I switched to
> 
>  WebTag.get(tag_id_to_delete).destroySelf()

   This is equivalent to

WebTag.delete(tag_id_to_delete)

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Jon R. Fox
On 7/9/07, Oleg Broytmann <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 09, 2007 at 12:09:25PM +0200, Daniel Nogradi wrote:
> > Yes, you need to delete everything manually that is referenced by
> > anything that is to be deleted.
>
>No, you don't. .destroySelf() in SQLObject 0.7.2 was extended to
> automatically remove rows from the intermediate table. Does it work?

I switched to

 WebTag.get(tag_id_to_delete).destroySelf()

and that works great in SQLObject-0.10dev_r2730 that the python
easy_install upgrade leads to. Unfortunately Ubuntu Feisty Fawn is
still stuck on 0.7.1 on their distro.

Best Regards,
Jon

-
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


Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Oleg Broytmann
On Mon, Jul 09, 2007 at 12:09:25PM +0200, Daniel Nogradi wrote:
> Yes, you need to delete everything manually that is referenced by
> anything that is to be deleted.

   No, you don't. .destroySelf() in SQLObject 0.7.2 was extended to
automatically remove rows from the intermediate table. Does it work?

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Oleg Broytmann
On Sat, Jul 07, 2007 at 02:34:11PM -0400, Jon R. Fox wrote:
> What is the appropriate way to delete an instance of a WebTopic or a
> WebTag so that RelatedJoin won't be broken?

   .destroySelf() in SQLObject 0.7.2 was extended to automatical remove
rows from the intermediate table. Does it work?

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] Types not interpreted correctly with fromDatabase=True

2007-07-09 Thread Oleg Broytmann
On Fri, Jul 06, 2007 at 01:55:19PM -0600, Brian Cole wrote:
> Little confusing, which patch tracker to use?

   Whatever you prefer. If you have already registered at SF - you are
probably accustomed to the SF tracker; if you have used Trac before - use
Trac.

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.

-
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


Re: [SQLObject] The proper way to delete an instance of an SQLObject that is linked as a RelatedJoin

2007-07-09 Thread Daniel Nogradi
> 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 "", line 3, in 
>   File "", line 1, in 
>   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