In Python 2, dir(obj) on a PyUno object correctly finds its method names. In Python 3, it fails to find any names. This means that it isn't introspected, e.g. for tab completion. PyUno objects make their attributes visible via __members__, an older method for introspection that was removed for Python 3. The new standard is to define a __dir__() method returning the list of names. See documentation: http://docs.python.org/library/functions.html#dir . __dir__() works at least from Python 2.6.
This should be really easy. The code that handles the __members__ function is in pyuno/source/module/pyuno.cxx at line 456; it only needs to be adapted to handle __dir__ as well.
It's not completely trivial: obj.__members__ is a list itself, while obj.__dir__ should be a method that returns a list when called. The PyUno class doesn't yet have any regular methods defined, so it will need a bit of adaptation to declare a method to the Python C-API. The docs are here: http://docs.python.org/c-api/typeobj.html#PyTypeObject.tp_methods But all the code needed is already there, so I think it still qualifies as an Easy Hack. If I wanted to have a go at it, can pyuno be built by itself, or would I have to build the whole of LO to test it?
> But all the code needed is already there, so I think it still qualifies as an > Easy Hack. If I wanted to have a go at it, can pyuno be built by itself, or > would I have to build the whole of LO to test it? No, you have to build the whole thing.
I ran into this myself recently while doing some testing with LO 4.x, and have generated a patch. Tested against current master (should apply in general to any LO 4.x). Also built against 3.6.7 (to verify compatibility back to 2.6), though obviously it's not needed in the LO 3.x versions. https://gerrit.libreoffice.org/5375
David Bolen committed a patch related to this issue. It has been pushed to "libreoffice-4-1": http://cgit.freedesktop.org/libreoffice/core/commit/?id=125be9e41c2a6d40bf4646d4a8af96f5d97994d8&h=libreoffice-4-1 fdo#50470: Restore pyuno object method introspection in Python 3 It will be available in LibreOffice 4.1.2. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
David Bolen committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=1be8e912ba8a7d1acaf40d5a8597421c104ab39c fdo#50470: Restore pyuno object method introspection in Python 3 The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility. see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
this appears to be fixed, thanks Daniel! >>> import uno >>> x = uno.getComponentContext() >>> dir(x) ['/services/com.sun.star.security.AccessController/mode', ... 'ElementNames', 'ElementType', 'ImplementationId', 'ServiceManager', 'Types', 'addEventListener', 'dispose', 'getByName', 'getElementNames', 'getElementType', 'getImplementationId', 'getServiceManager', 'getTypes', 'getValueByName', 'hasByName', 'hasElements', 'insertByName', 'queryAdapter', 'queryInterface', 'removeByName', 'removeEventListener', 'replaceByName']
(In reply to comment #8) > this appears to be fixed, thanks Daniel! argh sorry, thanks *David* of course