Ticket #7385 (closed Bug: fixed)

Opened 4 years ago

Last modified 4 years ago

content rules fail when creating content types.

Reported by: regebro Owned by: optilude
Priority: minor Milestone: 3.1
Component: Content Rules Keywords:
Cc: regebro@…

Description

If you have a content type that filters on portal type, it will look for getTypeInfo on the object and call it to see what portal type is is.

However, when you add something under portal_types, it will find the getTypeInfo method of the TypesTool, which requires a parameter. The subsequent call to getTypeInfo will fail with a type error.

There are two possible solutions.

1: Replace line 68 in plone.app.contentrules.conditions.portaltype with

try:

return getTypeInfo().getId() in self.element.check_types

except TypeError:

# We added an object under portal_types. return False

2: Change line 65 from:

getTypeInfo = getattr(aq_inner(self.event.object), 'getTypeInfo', None)

to

getTypeInfo = getattr(aq_base(self.event.object), 'getTypeInfo', None)

to prevent acquisition of getTypeInfo. But that may have other side effects.

Change History

comment:1 Changed 4 years ago by optilude

Lennart,

Are you seeing invocation of content rules on an FTI object created in portal_types? That's a bit strange - they should only be enabled for contentish objects.

In any case, +1 for option 2 - I don't see a use case for acquiring getTypeInfo().

comment:2 Changed 4 years ago by optilude

  • Status changed from new to closed
  • Resolution set to fixed

(In [19729]) MAke sure we're getting the type info from the right object. Fixes #7385.

Note: See TracTickets for help on using tickets.