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

Remove dependency on five.grok #634

Merged
merged 9 commits into from
Aug 17, 2016
Merged

Remove dependency on five.grok #634

merged 9 commits into from
Aug 17, 2016

Conversation

l34marr
Copy link
Contributor

@l34marr l34marr commented Jul 10, 2016

A new pull request based on the latest master branch, hopefully this will make things easier to move on.
I try this manually with a fresh Plone 4.3.10 instance and seems working. However, I run locally bin/test and see errors like:

  • AttributeError: 'IncrementalEncoder' object has no attribute '_push'
  • AttributeError: 'UpdateTile' object has no attribute 'response'
  • AssertionError: Parent suite setup failed: WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

I know little about debugging test errors. Advices are appreciated.

@hvelarde
Copy link
Member

hvelarde commented Jul 11, 2016

thanks for taking care of this, @l34marr! seems there are still a few fixes pending to make tests pass.

I have no idea on the first error, but the others seem easy to fix: tests for UpdateTile may need to use self.request.RESPONSE attribute instead of view.request; the other looks like an outdated version of Selenium; run bin/buildout again to update it.

from zope.annotation.interfaces import IAnnotations
from zope.component import getUtility
from zope.event import notify

import json


grok.templatedir('templates')
class View(BrowserView):
implements(IBlocksTransformEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

use the @implementer decorator instead

@hvelarde
Copy link
Member

@rodfersou can you help here?

@rodfersou
Copy link
Member

@hvelarde sure

@@ -114,11 +99,8 @@ def render(self):
return 'Widget does not exist'


class RemoveTileWidget(grok.View):
class RemoveTileWidget(DefaultView):
Copy link
Member

Choose a reason for hiding this comment

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

Why we use DefaultView instead of BrowserView ?

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering the same, but that's what we did in collective.nitf; please do some research about it.

Copy link
Contributor

@davilima6 davilima6 Jul 21, 2016

Choose a reason for hiding this comment

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

DefaultView brings in the "w" dictionary, containing Dex fields and widgets. If you don't need that in your template or class, it's best to save the overhead and use a simpler BrowserView. Refs:

Copy link
Member

Choose a reason for hiding this comment

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

thank you for the explanation

@rodfersou rodfersou force-pushed the remove-grok-dep branch 5 times, most recently from a511962 to d9cfd7e Compare July 22, 2016 14:59
class LayoutEdit(grok.View):
grok.context(ICover)
grok.require('collective.cover.CanEditLayout')
class LayoutEdit(BrowserView):

def update(self):
Copy link
Member

@hvelarde hvelarde Jul 22, 2016

Choose a reason for hiding this comment

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

this could be moved to __init__()

@hvelarde
Copy link
Member

hvelarde commented Aug 2, 2016

@l34marr @rodfersou the package is in an unusable state now we need to fix all view following the pattern explained in the documentation, not just the tests; for the record:

class MyView(BrowserView):

    def __init__(self, context, request):
        # used to initialize the view code, only add if need
        self.context = context
        self.request = request

    def render(self):
        # used to render the code (JSON, etc.) or just to call the template
        return self.index()

    def __call__(self):
        # use it to do things needed before rendering the code and after the initialization
        return self.render()

@rodfersou
Copy link
Member

@hvelarde the documentation is not talking about the __init__ method.. and if it is ommited, it does exactly the same https://github.com/zopefoundation/Zope/blob/master/src/Products/Five/browser/__init__.py#L27-L29

@hvelarde
Copy link
Member

hvelarde commented Aug 2, 2016

and that's exactly what I meant when I wrote: only add if need.

if IListTile.providedBy(tile):
tile.remove_item(uuid)
# reinstantiate the tile to update its content on AJAX calls
tile = self.context.restrictedTraverse('{0}/{1}'.format(tile_type, tile_id))
tile = self.context.restrictedTraverse(
'{0}/{1}'.format(tile_type, tile_id))
Copy link
Member

Choose a reason for hiding this comment

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

@rodfersou wouldn't be better to do '{0}/{1}'.format(tile_type, tile_id) only once?

@rodfersou rodfersou force-pushed the remove-grok-dep branch 6 times, most recently from de10620 to a5f9350 Compare August 17, 2016 16:35
@rodfersou
Copy link
Member

@hvelarde finally green \o/

@hvelarde
Copy link
Member

@l34marr @idgserpro we need help on testing nothing is broken now.

@idgserpro
Copy link
Member

I tested and everything was ok. Great work!

Remembering that this fix #510.

@hvelarde hvelarde changed the title Remove Grok Dependency for Cover Remove dependency on five.grok Aug 17, 2016
@hvelarde hvelarde merged commit 58844b8 into master Aug 17, 2016
@hvelarde hvelarde deleted the remove-grok-dep branch August 17, 2016 22:03
hvelarde added a commit that referenced this pull request Aug 18, 2016
This view is used by anonymous users also.

Refs. #634
@l34marr
Copy link
Contributor Author

l34marr commented Aug 18, 2016

@hvelarde I manually test it with a fresh Plone 4.3.9 installation and work well. The buildout message still shows the grok dependency but I believe that's because of plone.directives.form 2.0.2. Thank you all the Plone heroes for the great work.

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.

5 participants