-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add static catalog vocabulary to support various widgets with relationsfields or uuid-fields #66
Conversation
@pbauer thanks for creating this Pull Request and help improve Plone! To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass. Whenever you feel that the pull request is ready to be tested, either start all jenkins jobs pull requests by yourself, or simply add a comment in this pull request stating:
With this simple comment all the jobs will be started automatically. Happy hacking! |
It's using |
@jenkins-plone-org please run jobs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the code that is no longer needed. Or did I miss something?
@jenkins-plone-org please run jobs |
plone/app/vocabularies/catalog.py
Outdated
@@ -1,4 +1,5 @@ | |||
# -*- coding: utf-8 -*- | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import should go after import itertools
.
Not a big deal, but imports are already sorted and would be nice to keep them sorted
plone/app/vocabularies/catalog.py
Outdated
def createTerm(self, brain, context=None): | ||
return SimpleTerm( | ||
value=brain.UID, token=brain.UID, | ||
title=self.title_template.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not wrong this might break in Python 2, where title is expected to be text. Please consider this before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, we probably need some special handling here for Python 2 where brain.Title
is always an encoded string, but Term.title
is always unicode. I think that can be fixed with a simple call to safe_unicode
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the last blocker here before we can merge, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, wrapping this with safe_unicode
seem to be the right thing to do
@ale-rt @alecpm The change to use Here is the relevant excerpt from my schema: basisvariante = RelationChoice(
title='Basisvariante',
description=_('Leer lassen, wenn dies eine Basisvariante ist!'),
vocabulary=StaticCatalogVocabulary(
{
'portal_type': ['product'],
'base_variant': True,
'path': '/Plone/produkte',
'sort_on': 'id',
},
title_template='{brain.getId} - {brain.Title}',
),
required=False,
)
directives.widget(
'basisvariante',
SelectFieldWidget,
)
sonderausstattung = RelationList(
title='Sonderausstattung',
default=[],
value_type=RelationChoice(
vocabulary=StaticCatalogVocabulary(
{
'portal_type': 'accessory',
'path': '/Plone/accessories',
'sort_on': 'id',
},
title_template='{brain.getId} - {brain.Title}',
)
),
required=False,
missing_value=[],
)
directives.widget(
'sonderausstattung',
AjaxSelectFieldWidget,
vocabulary=StaticCatalogVocabulary(
{
'portal_type': 'accessory',
'path': '/Plone/accessories',
'sort_on': 'id',
},
title_template='{brain.getId} - {brain.Title}',
),
pattern_options={
'closeOnSelect': False,
'minimumInputLength': 2,
'ajax': {'quietMillis': 500},
},
)
|
@pbauer, indeed, view.memoize does take context physical path and function arguments into the cache key, both are the same in one request for |
The original implementation using request.memoize used the |
Sorry for the delay all. I've reverted the cache changes, added a call to |
@jenkins-plone-org please run jobs |
Seems tests in Python 2.7 are still failing because of some unicode confusion. I would say, after fixing this just go and merge: https://jenkins.plone.org/job/pull-request-5.2/1959/testReport/junit/plone.app.vocabularies/catalog/StaticCatalogVocabulary/ |
Sorry for giving you a wrong hint about using plone.memoize! |
738fc9d
to
b3c12f6
Compare
@jenkins-plone-org please run jobs |
@jenkins-plone-org please run jobs |
No description provided.