Page 1 of 1

Deleting an Object

PostPosted: Tue Apr 24, 2012 1:21 pm
by icaoberg
So far I have deleted objects through scripts. Mainly, I create a delete service using the connection and then I use the client object on the callback methods to monitor object deletion. Very straightforward.

Now I want to implement a method within pyslid. The main issue I have is that I create the connection in the following fashion

Code: Select all
def connect( server, port, username, password ):
    '''
    Helper method that connects to an OMERO.searcher server.
    @param server
    @param port
    @param username
    @param password
    @returns connection
    '''

    try:
        conn = BlitzGateway( username, password, host=server, port=int(port))
        conn.connect()
        return conn
    except:
        return None


meaning I don't create a client. So I have two questions. Either I think will provide me with a solution
1) is it possible to delete an object without a client object? is the callback strictly neccesary?
2) is it possible to get the client from the connection?

thanks
ivan

Re: Deleting an Object

PostPosted: Tue Apr 24, 2012 1:30 pm
by wmoore
You can get the client with

Code: Select all
conn.c


Are you using

Code: Select all
conn.deleteObjects()   
# E.g. deleteObjects("Dataset", [dsId ], deleteChildren=True, deleteAnns=True)


You can just use this method without monitoring the delete process and it should work just fine.

Re: Deleting an Object

PostPosted: Tue Apr 24, 2012 8:23 pm
by icaoberg
pardon my ignorance. i can see an scenario where i want to delete a project/dataset and not its children. but why would i want to delete an image and not its children?

children for an image are pixels and annotations, right? sorry for the lame question.

ivan

Re: Deleting an Object

PostPosted: Tue Apr 24, 2012 8:44 pm
by wmoore
The deleteChildren flag is meaningless for Images. It will have no effect either way you set it.

deleteAnns is the same for Images as Projects, Datasets etc. It only refers to 'standalone' annotations like Tags and if False, then the Tag will not be deleted even if it becomes an "orphan" (not used).

Comments are always deleted and Tags, File-Annotations etc will not be deleted if they are used to annotate other objects.