如何通过 Plone 中的完整路径检查文件夹是否存在?
我使用 xmlrpclib、wsapi4plone 连接到 plone:
client = xmlrpclib.ServerProxy('http://user:[email protected]/plone')
有没有一种方法可以通过 url 检查 plone 上的文件夹是否存在?类似于: client.exists('/sites/ng/path/to/folder')
我所做的有点作弊:
try:
client.get_types('/sites/ng/path/to/folder')
except:
#if there's an exception, that means there's no folder -> create it here
client.post_object(folder)
我没有管理员权限,所以我无法查看方法列表(我被告知它位于克隆站点上的某个位置,但我需要成为管理员)。我不想一直在这里问有关可用方法的问题,网络上是否有克隆人的方法列表?
I use xmlrpclib, wsapi4plone to connect to plone:
client = xmlrpclib.ServerProxy('http://user:[email protected]/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:
try:
client.get_types('/sites/ng/path/to/folder')
except:
#if there's an exception, that means there's no folder -> create it here
client.post_object(folder)
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个快速的解决方案是查询目录,如下所示:
另一种解决方案可能是遍历文件夹结构,如下所示:
编辑:
我必须修改我的答案。我尝试通过 xmlrpc 与 Portal_catalog 进行交互,但实际上并不那么容易。我的两个选项都不错,但不能通过 xmlrpc 使用。因此,以 transmogrify.ploneremote 为例,用于检查远程文件夹是否存在的一个简单选项(与您的实现没有太大不同)是这样的:
A fast solution is to query the catalog, like this:
Another solution could be to traverse the folders structure like this:
edit:
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: