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

Pymongo breaks displayhook _graphics_() #15066

Closed
vbraun opened this issue Aug 20, 2013 · 10 comments
Closed

Pymongo breaks displayhook _graphics_() #15066

vbraun opened this issue Aug 20, 2013 · 10 comments

Comments

@vbraun
Copy link
Member

vbraun commented Aug 20, 2013

Apparently pymongo uses a getattr hack that claims to have all and every method implemented, and then fails flat on its face when you actually try. This breaks the new displayhook.

Note that this error will just appear if you (implicitly) call the displayhook. Pymongo is working just fine, only the implicit printing is broken:

sage: import pymongo 
sage: c = pymongo.Connection()
sage: c.__repr__()
"Connection('localhost', 27017)"
sage: c
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-2cd6ee2c70b0> in <module>()
----> 1 c

/home/vbraun/opt/sage-5.12.beta0/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
    236             self.start_displayhook()
    237             self.write_output_prompt()
--> 238             format_dict = self.compute_format_data(result)
    239             self.write_format_data(format_dict)
    240             self.update_user_ns(result)

/home/vbraun/opt/sage-5.12.beta0/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
    148             MIME type representation of the object.
    149         """
--> 150         return self.shell.display_formatter.format(result)
    151 
    152     def write_format_data(self, format_dict):

/home/vbraun/opt/sage-5.12.beta0/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in format(self, obj, include, exclude)
    124                     continue
    125             try:
--> 126                 data = formatter(obj)
    127             except:
    128                 # FIXME: log the exception

/home/vbraun/opt/sage-5.12.beta0/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in __call__(self, obj)
    310         """
    311         if hasattr(obj, '_graphics_') and not isinstance(obj, type):
--> 312             if obj._graphics_():
    313                 return ''
    314         s = self._format_obj(obj)

/home/vbraun/opt/sage-5.12.beta0/local/lib/python2.7/site-packages/pymongo-2.6-py2.7-linux-x86_64.egg/pymongo/database.pyc in __call__(self, *args, **kwargs)
    811                         "call the '%s' method on a '%s' object it is "
    812                         "failing because no such method exists." % (
--> 813                             self.__name, self.__connection.__class__.__name__))
    814 
    815 

TypeError: 'Database' object is not callable. If you meant to call the '_graphics_' method on a 'Connection' object it is failing because no such method exists.

Depends on #14469

CC: @JohnCremona

Component: graphics

Author: Volker Braun

Reviewer: John Cremona

Merged: sage-5.12.beta4

Issue created by migration from https://trac.sagemath.org/ticket/15066

@vbraun vbraun added this to the sage-5.12 milestone Aug 20, 2013
@ppurka
Copy link
Member

ppurka commented Aug 20, 2013

comment:1

Where do you get pymongo from? It is not in standard packages and it is not even in optional packages.

@JohnCremona
Copy link
Member

comment:2

Replying to @ppurka:

Where do you get pymongo from? It is not in standard packages and it is not even in optional packages.

You get it like this:

sage -sh
<different prompt> easy_install -U pymongo
(exit)

I am using it for a project which uses Sage as a backend to a big number theory database, see http://www.lmfdb.org/ and the readme at https://github.com/LMFDB/lmfdb/wiki/GettingGoing .

@JohnCremona
Copy link
Member

comment:3

Sorry, the initial patch does not work for me (but I know that you have not marked the ticket as needs_review).

@vbraun
Copy link
Member Author

vbraun commented Aug 20, 2013

Attachment: trac_15066_pymongo_displayhook.patch.gz

Updated patch

@vbraun
Copy link
Member Author

vbraun commented Aug 20, 2013

comment:4

I had only changed the doctest but not the interactive displayhook... my bad. I will set this to "needs review" once tests pass ;-)

@JohnCremona
Copy link
Member

comment:5

With the new patch all tests pass for me: both my manual test with pymongo, and a full test of the whole library.

Note to Release Manager: it is OK not to have a doctest showing that the problem is fixed since the original problem only arises when pymongo has been installed and the machine has a running mongo daemon. I was the original reporter, and "it works for me".

As soon as Volker sets the tciket to "needs review" I'll give it a positive review.

@vbraun
Copy link
Member Author

vbraun commented Aug 20, 2013

comment:6

Tests pass for me, too

@vbraun
Copy link
Member Author

vbraun commented Aug 20, 2013

Reviewer: John Cremona

@vbraun
Copy link
Member Author

vbraun commented Aug 20, 2013

Author: Volker Braun

@jdemeyer
Copy link

Merged: sage-5.12.beta4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants