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

move repr_html to _ImageWrapper #429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jo-mueller
Copy link
Contributor

Fixes #428

Dear OME-Team,

this PR fixes the issue that some classes that derive from BlitzObjectWrapper do not possess the necessary attributes to display the repr_html method correctly. repr_html mthods should be introduced specifically for each derived object. In this PR I simply move the repr_html to the derived class.

Since this is my last day at work before a longer parental leave, I unfortunately don't have the time to test this in detail but I hope that it's enough to get you started on the fix.

Copy link
Member

@erindiel erindiel left a comment

Choose a reason for hiding this comment

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

Thank you @jo-mueller - I came across the same issue when working with XML Annotations, and how nice to have the issue not only already reported but a fix proposed as well.

When using conn.getObject('Annotation', annotation_id) (where conn is my BlitzGateway), my error was (same as yours):

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/venvs/roi.venv/lib/python3.10/site-packages/omero/gateway/__init__.py in ?(self)
    249         """
    250         Returns an HTML representation of the object. This is used by the
    251         IPython notebook to display the object in a cell.
    252         """
--> 253         return image_to_html(self)

~/venvs/roi.venv/lib/python3.10/site-packages/omero/gateway/utils.py in ?(image)
    267     <table>
    268         <tr><th></th><th>ID</th><th>Name</th></tr>
    269         {obj_html(image, 'Image')}
    270         {obj_html(image.getParent(), 'Dataset')}
--> 271         {obj_html(image.getProject(), 'Project')}
    272     </table>
    273     """
    274 

~/venvs/roi.venv/lib/python3.10/site-packages/omero/gateway/__init__.py in ?(self, attr)
   1307                             rv = rv.decode('utf8')
   1308                         except:
   1309                             pass
   1310             return rv
-> 1311         raise AttributeError(
   1312             "'%s' object has no attribute '%s'"
   1313             % (self._obj.__class__.__name__, attr))

AttributeError: 'XmlAnnotationI' object has no attribute 'getProject'

Including your changes resolved this issue and all downstream work with the resultant XmlAnnotationWrapper behaved as expected.

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.

_repr_html throws error for mapAnnotation object
2 participants