Ticket #13356 (confirmed Bug)

Opened 3 years ago

Last modified 3 years ago

use getSite() instead of context in plone.app.vocabularies and add test

Reported by: khink Owned by:
Priority: minor Milestone: 4.x
Component: General Version: 4.2
Keywords: Cc:

Description

(Taken from  https://github.com/plone/plone.app.vocabularies/pull/1)

We still have vocabularies using "context" in these files:  https://github.com/plone/plone.app.vocabularies/blob/master/plone/app/vocabularies/groups.py  https://github.com/plone/plone.app.vocabularies/blob/master/plone/app/vocabularies/users.py

This might break if "context" is a RecordsProxy object. I'm posting some code from the pull request submitter:

ipdb> getToolByName(site, 'portal_catalog')
<CatalogTool at /Plone/portal_catalog>
ipdb> getToolByName(context, 'portal_catalog')
*** AttributeError: portal_catalog
ipdb> context
<RecordsProxy for my.product.interfaces.IMyProductRegistrySettings>

He has a plone.app.registry record entry which is defined in the interface like this:

tags = schema.Tuple(
    required=False,
    title=_(
        u"label_tags",
        default=u"Keywords",
    ),
    value_type=schema.Choice(
        vocabulary="plone.app.vocabularies.Keywords",
    ),
)

It would be nice to have this in a test.

Change History

comment:1 Changed 3 years ago by khink

  • Component changed from Unknown to General

comment:2 Changed 3 years ago by kleist

  • Status changed from new to confirmed
Note: See TracTickets for help on using tickets.