Commit 50b26f2b authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added support for retrieval of my content through webdav.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13440 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 42b9e4ae
...@@ -337,6 +337,13 @@ class ContributionTool(BaseTool): ...@@ -337,6 +337,13 @@ class ContributionTool(BaseTool):
if document_url is not None: if document_url is not None:
return self.getPortalObject().unrestrictedTraverse(document_url) return self.getPortalObject().unrestrictedTraverse(document_url)
# Try first to return an object listed bv listDAVObjects
uid = str(id).split('-')[-1]
object = self.getPortalObject().portal_catalog.unrestrictedGetResultValue(uid=uid)
if object is not None:
return object.getObject()
# Fallback to default method
if default is _marker: if default is _marker:
return BaseTool._getOb(self, id) return BaseTool._getOb(self, id)
else: else:
...@@ -358,19 +365,30 @@ class ContributionTool(BaseTool): ...@@ -358,19 +365,30 @@ class ContributionTool(BaseTool):
return BaseTool._delOb(self, id) return BaseTool._delOb(self, id)
def listDAVObjects(self): def listDAVObjects(self):
""" """
Get all docs contributed by the current user Get all contents contributed by the current user. This is
XXX you can only list them this way, but they're not accessible delegated to a script in order to help customisation.
to make it fully usable we should set their id's with module name """
and possibly something nicer to display method = getattr(self, 'ContributionTool_getMyContentList', None)
""" if method is not None:
sm = getSecurityManager() object_list = method()
u = sm.getUser() else:
kw = {} sm = getSecurityManager()
res = self.portal_catalog(portal_type=self.getPortalDocumentTypeList()) user = sm.getUser()
res = [r.getObject() for r in res] object_list = self.portal_catalog(portal_type=self.getPortalMyDocumentTypeList(),
res = [o for o in res if u.allowed(o, ('Owner',))] # XXX terrible - needs to use portal_catalog owner=str(user))
return res
def wrapper(o_list):
for o in o_list:
o = o.getObject()
reference = o.getReference()
if reference:
id = '%s-%s' % (reference, o.getUid())
else:
id = '%s' % o.getUid()
yield o.getObject().asContext(id=id)
return wrapper(object_list)
InitializeClass(ContributionTool) InitializeClass(ContributionTool)
......
...@@ -535,7 +535,20 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -535,7 +535,20 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
return result[0].getObject() return result[0].getObject()
except IndexError: except IndexError:
return None return None
security.declarePrivate('unrestrictedGetResultValue')
def unrestrictedGetResultValue(self, query=None, **kw):
"""
A method to factor common code used to search a single
object in the database. Same as getResultValue but without
taking into account security.
"""
result = self.unrestrictedSearchResults(query=query, **kw)
try:
return result[0].getObject()
except IndexError:
return None
def countResults(self, query=None, **kw): def countResults(self, query=None, **kw):
""" """
Calls ZCatalog.countResults with extra arguments that Calls ZCatalog.countResults with extra arguments that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment