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 for #53 #56

Merged
merged 9 commits into from
Jul 10, 2018
Merged

fix for #53 #56

merged 9 commits into from
Jul 10, 2018

Conversation

petschki
Copy link
Member

@petschki petschki commented Jul 9, 2018

and some features:

  • uninstall profile
  • CSRF warning when editing taxonomy data the first time (write on read)
  • update/fix german translations

and some features:

- uninstall profile
- CSRF warning when editing taxonomy data the first time (write on read)
- update/fix german translations
@petschki petschki requested a review from tomgross July 9, 2018 10:34
@petschki petschki requested a review from malthe July 9, 2018 10:59
@petschki
Copy link
Member Author

petschki commented Jul 9, 2018

what's the reason why travis doesn't start?

@@ -24,7 +29,7 @@ def __init__(self, context, request):
utility_name = request.get('taxonomy', '')
taxonomy = queryUtility(ITaxonomy, name=utility_name)
if not taxonomy:
raise ValueError('Taxonomy `%s` could not be found.' % utility_name)
raise ValueError('Taxonomy `%s` could not be found.' % utility_name) # noqa
Copy link
Member

Choose a reason for hiding this comment

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

please don't use generic noqa comments; it's better to explicitly specify what are you trying to ignore.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

make code-analysis happy
except ConfigParser.NoOptionError:
pass

for name in ['is_single_select', 'is_required']:
try:
result[name] = config.get('taxonomy', name) == 'true' and True
result[name] = config.get('taxonomy', name) == 'true' and True # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

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

The and True here seems to be reminiscent of a time when there wasn't an explicit comparison involved – as far as I can tell it's unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

you're right ... I'll change that

@@ -47,6 +52,7 @@ def generate_json(self, root):

def get_data(self):
"""Get json data."""
alsoProvides(self.request, IDisableCSRFProtection)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary here? No ZODB object seems to be modified in this code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have do dig here further, but if you have a clean Plone-5.1 installation, create a taxonomy and want to edit data for the first time, you get a CSRF warning from plone.protect ...

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it happens in the _fixup method.

You could argue that there shouldn't be any fixing upping on a GET request.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the pointer ... the _fixup was indeed the problem ... I've refactored this to get rid of CSRF warnings ...

Copy link
Member

@malthe malthe Jul 10, 2018

Choose a reason for hiding this comment

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

The dilemma is this:

There's an old version of the data format and there is an upgrade step which migrates this to the new format by calling _fixup().

But what if people try to use their site without – yet – having gone through the upgrade step.

I think that was the reasoning behind these fixing upper calls. And there used to be no upgrade step!

But now, perhaps the right move is simply to throw and error and log a warning "Data not upgraded" – ?

That is:

  1. I think revert that last commit;
  2. In _fixup(): if said data attributes are None, add the CSRF interface to the request and just go ahead and migrate the data.

# for old Taxonomy instances.
# XXX: remove this in version 2.0 to prevent write on read
if self.order is None:
safeWrite(self, getRequest())
Copy link
Member

Choose a reason for hiding this comment

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

Great. Poor old self.REQUEST – acquisition has fallen out of favor...

Copy link
Member Author

Choose a reason for hiding this comment

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

strange .. I got an AttributeError when doing self.REQUEST in _fixup ?

Copy link
Member

Choose a reason for hiding this comment

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

I guess the utility is not acquisition-wrapped. Makes sense I guess.

Plone is really split brain in terms of acquisition and components.

@malthe
Copy link
Member

malthe commented Jul 10, 2018

I guess we're ready to merge this then?

@petschki
Copy link
Member Author

yes ... and I also think we should release 1.5.0 ... changelog gets longer and longer 😉

@petschki
Copy link
Member Author

@malthe but before I'd like to run the tests ... somehow my branch doesn't start automatically on travis-ci .... do you have an idea why?

@malthe
Copy link
Member

malthe commented Jul 10, 2018

I think the buildout is outdated.

While:
  Installing.
  Getting section download.
  Initializing section download.
  Installing recipe hexagonit.recipe.download.
  Getting distribution for 'hexagonit.recipe.download'.
Error: Wheels are not supported
The command "bin/buildout -N -q versions:setuptools= versions:zc.buildout=" failed and exited with 1 during .

@petschki
Copy link
Member Author

I thought there would be some errors with this travis configuration, but this branch never ever gets started on travis-ci ... https://travis-ci.org/collective/collective.taxonomy says "This is not an active repository" .... I do not have privileges to activate it. Do you have @malthe ?

@malthe
Copy link
Member

malthe commented Jul 10, 2018

I don't really understand if I'm an admin or not. I can use "Settings" on that repo, but I also get the same error message.

@petschki
Copy link
Member Author

just found this entry from june 29th stating some issues with de/activating repositories on https://www.traviscistatus.com/ ... I'll get in touch with travis support

@petschki
Copy link
Member Author

ping @jensens are you able to activate this repository on travis-ci, or do you have an idea what's going wrong here? https://travis-ci.org/collective/collective.taxonomy
thx

@jensens
Copy link
Member

jensens commented Jul 10, 2018

I activated it on TravisCI (.org) - no idea why it was deactivated there.

@petschki
Copy link
Member Author

@malthe finally

@malthe malthe merged commit 923b6ca into master Jul 10, 2018
@malthe malthe deleted the petschki-fix_53 branch July 10, 2018 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants