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

Issue-383: Click on some analyses pops up a new page instead of object log #454

Merged
merged 5 commits into from
Dec 7, 2017

Conversation

ramonski
Copy link
Contributor

@ramonski ramonski commented Dec 7, 2017

Description of the issue/feature this PR addresses

Linked issue: #383

Current behavior before PR

Clicking on an Analysis where the method has an attached document raises an Unauthorized Error

Desired behavior after PR is merged

Analysis Info is displayed properly

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@ramonski
Copy link
Contributor Author

ramonski commented Dec 7, 2017

@xispa: Please only look at the third commit, the rest is only formatting and PEP8'ing

@@ -87,7 +87,7 @@
tal:condition="filename"
tal:define="file method/MethodDocument;
filename python:getattr(file, 'filename', '');
filesize python:file.getObjSize();
filesize python:file.get_size() or 0;
Copy link
Member

Choose a reason for hiding this comment

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

I've checked getObjSize() from Products.CMFPlone.CatalogTooland the function already delegates the action to get_size:

def getObjSize(obj):
    """ Helper method for catalog based folder contents.
    """
    smaller = SIZE_ORDER[-1]

    if base_hasattr(obj, 'get_size'):
        size = obj.get_size()
    else:
        size = 0
    ...

Also, as per the following log that appears in the traceback, I am not sure this change would be enough:

Unauthorized: The object is marked as private.  Access to 'get_size' of (plone.app.blob.field.BlobWrapper object at 0x10ce0f938) denied.

I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

plone.app.blob.field.BlobWrapper defines this:

    @security.private
    def get_size(self):
        """ return the size of the blob """
        blob = openBlob(self.blob)
        size = fstat(blob.fileno()).st_size
        blob.close()
        return size

Afaik this means that it is not accessible from a template or script context.

So if you analyze this part of the traceback, it makes sense:

 Module script, line 17, in getObjSize
   - <FSPythonScript at /bikalims/methods/method-5/getObjSize>
   - Line 17

@xispa xispa merged commit 83c7b46 into master Dec 7, 2017
@xispa xispa deleted the bugfix/issue-383-analyses-popup-fixture branch December 9, 2017 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants