-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
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 |
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) |
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.
use the @implementer
decorator instead
@rodfersou can you help here? |
@hvelarde sure |
@@ -114,11 +99,8 @@ def render(self): | |||
return 'Widget does not exist' | |||
|
|||
|
|||
class RemoveTileWidget(grok.View): | |||
class RemoveTileWidget(DefaultView): |
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.
Why we use DefaultView
instead of BrowserView
?
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.
I was wondering the same, but that's what we did in collective.nitf; please do some research about it.
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.
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:
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.
thank you for the explanation
a511962
to
d9cfd7e
Compare
class LayoutEdit(grok.View): | ||
grok.context(ICover) | ||
grok.require('collective.cover.CanEditLayout') | ||
class LayoutEdit(BrowserView): | ||
|
||
def update(self): |
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 could be moved to __init__()
2befd11
to
302f9a1
Compare
302f9a1
to
0c9ba94
Compare
@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() |
@hvelarde the documentation is not talking about the |
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)) |
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.
@rodfersou wouldn't be better to do '{0}/{1}'.format(tile_type, tile_id)
only once?
de10620
to
a5f9350
Compare
a5f9350
to
87d019c
Compare
87d019c
to
ed30b7c
Compare
@hvelarde finally green \o/ |
@l34marr @idgserpro we need help on testing nothing is broken now. |
I tested and everything was ok. Great work! Remembering that this fix #510. |
d38674f
to
f9c52e2
Compare
f9c52e2
to
4ffd3f4
Compare
This view is used by anonymous users also. Refs. #634
@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. |
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.