Ticket #1638 (closed enhancement: invalid)

Opened 3 years ago

Last modified 3 years ago

To allow .cps_discussions in other types of folders not only in Sections or Workspaces

Reported by: joseluis.rosa@iavante.es Assigned to: trac
Priority: P2 Milestone: CPS 3.4.1
Component: CPSForum Version: 3.4.0
Severity: normal Keywords: cps_discussion comments forum
Cc:

Description

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.

Change History

05/06/06 18:24:30 changed by fguillaume

  • status changed from new to closed.
  • resolution set to invalid.

Dupe of #1636.