Skip to content
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

Fix handling of broken objects in ZMI #336

Merged
merged 5 commits into from Oct 3, 2018
Merged

Conversation

viktordick
Copy link
Contributor

@viktordick viktordick commented Oct 2, 2018

Instead of obtaining the list of objects from objectValues and assuming that these provide all necessary attributes (like getId()), a list of dictionaries is created on the basis of objectItems, which has access to the object's ID as it is known to the parent. This is used for sorting as well as interaction with the specific items, so it allows to show broken objects and also delete them.

fixes #311
fixes #213

rkey python:request.get('rkey','asc');
rkey_alt python:request.get('rkey','asc')=='asc' and 'desc' or 'asc';
sort_func python:['nocase','cmp'][skey not in ['getId','meta_type','id','title']];
obs python:sequence.sort(obs, ((skey,sort_func,rkey),) )"
sort_func python:['strcoll','cmp'][skey not in ['meta_type','id','title']];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'cmp' if skey in ['meta_type', 'id', 'title'] else 'strcoll' would be a bit easier to read in my mind.

(key, getattr(item[1],key))
for key in ['title', 'meta_type']
if hasattr(item[1],key)
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be easier to read when using if ... else None and filtering out None afterwards.

for item in here.objectItems()
];
obs python: [dict(item) for item in obs];
obs python: sequence.sort(obs, ((skey,sort_func,rkey),), mapping=1 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP-8, please.

Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM I have only some minor comments.

self.assertTrue(one_before_two == one_before_two_found)

self.browser.open(base_url % ('id', 'asc'))
do_assert(one_before_two = True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP-8 does not allow spaces around = in function calls.

one_before_two_found = (
self.browser.contents.find('File2') > self.browser.contents.find('File1')
)
self.assertTrue(one_before_two == one_before_two_found)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about assertEqual?

@icemac icemac added the bug label Oct 3, 2018
@icemac icemac added this to In progress in Zope 4 final release via automation Oct 3, 2018
@icemac icemac added this to the 4.0 final milestone Oct 3, 2018
@icemac icemac moved this from In progress to Reviewer approved in Zope 4 final release Oct 3, 2018
@viktordick viktordick merged commit 6fba729 into master Oct 3, 2018
Zope 4 final release automation moved this from Reviewer approved to Done Oct 3, 2018
@viktordick viktordick deleted the zmi-fix-broken-objects branch October 3, 2018 09:52
@icemac icemac modified the milestones: 4.0 final, 4.0b6 Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

broken objects are rendered with the ID broken in ZMI Broken objects are rendered as Folders in ZMI
2 participants