#1637: To allow .cps_discussions in other types of folders not only in Sections or
Workspaces
--------------------------------------+-------------------------------------
Reporter: joseluis.rosa at iavante.es | Owner: trac
Type: enhancement | Status: new
Priority: P2 | Milestone: CPS 3.4.1
Component: CPSForum | Version: 3.4.1
Severity: normal | Keywords:
--------------------------------------+-------------------------------------
I've found this snippet in CommentTool.py inside CPSForum product:
{{{
def getParentFolder(proxy):
"""Returns 'Section' or 'Workspace' parent folder."""
parent = proxy.aq_inner.aq_parent
while parent:
if hasattr(parent, 'portal_type') and \
(parent.portal_type == 'Section' or
parent.portal_type == 'Workspace'):
return parent
parent = parent.aq_inner.aq_parent
return proxy.aq_inner.aq_parent
}}}
I had some problem with this as I have a new type of folder which type
information id is "WorkspaceCustomized".
In fact, the problem is that when a user tries to add a comment to a
document hosted in a WorkspaceCustomized (where the user has permissions
to write), the code above moves to the first instance of "Workspace"
(where by chance the user has no permissions to write).
What I propose to improve this code is to add a new attribute to the
class, let's say:
{{{
parentTypes = ['Section', 'Workspace',] ## This would be the initial value
for a CPSDefault Site
}}}
and modify the procedure as this:
{{{
def getParentFolder(proxy):
"""Returns parent folder."""
parent = proxy.aq_inner.aq_parent
while parent:
if hasattr(parent, 'portal_type') and
(parent.portal_type in parentTypes):
return parent
parent = parent.aq_inner.aq_parent
return proxy.aq_inner.aq_parent
}}}
I implemented this for my own site, and I thought it would be useful for
any site. Is this possible to apply it to the original code?
Even this type information identifiers could be managed from ZMI in
portal_discussions, what do you think?
Thanks.
--
Ticket URL: <http://svn.nuxeo.org/trac/pub/ticket/1637>
Nuxeo Repository <http://www.cps-project.org/>
Nuxeo Repository
Hosting: Nuxeo: Zope service provider