Take the 2-minute tour ×

I use xmlrpclib, wsapi4plone to connect to plone:

client = xmlrpclib.ServerProxy('http://user:password@blah.com/plone')

is there a method to check if a folder on plone exists by its url? something like: client.exists('/sites/ng/path/to/folder')
What I did is a bit of cheating:

    #if there's an exception, that means there's no folder -> create it here

I dont have the admin rights so i can't look at the methods list (which I was told that it's somewhere on the plone site but I need to be the admin). I don't want to keep having to ask question on here about what method is available, is there a plone's methods list anywhere on the web?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

A fast solution is to query the catalog, like this:

completePath = '/'.join(client.getPhysicalPath()) + '/sites/ng/path/to/folder'
if len(client.portal_catalog.searchResults(path=completePath)):
    return True

Another solution could be to traverse the folders structure like this:

path = '/sites/ng/path/to/folder'
subdirs = path.split('/')[1:]
dir = client
for subdir in subdirs:
    if subdir in dir.objectIds():
        dir = dir[subdir]
        return False
return True


I have to ammend my answer. I tried to interact with the portal_catalog via xmlrpc and actually it's not so easy. My two options are good, but not for use via xmlrpc. So, taking as example transmogrify.ploneremote, a simple option (not very different from your implementation) for checking if a remote folder exists is this:

   path = 'http://user:password@blah.com/plone/sites/ng/path/to/folder'
   return True
except xmlrpclib.Fault, e:
   return False
share|improve this answer
i like the first solution. however when i tried it, i get this error: TypeError: __call__() got an unexpected keyword argument 'path' . Or if i remove the keyword, i get this error : xmlrpclib.Fault: <Fault -1: "Unexpected Zope exception: <type 'exceptions.TypeError'> - string indices must be integers, not str"> –  BPm Nov 10 '11 at 21:55
add comment

Your Answer


