How do I get type methods?
Carsten Haese
carsten at uniqsys.com
Sat May 5 09:21:10 EDT 2007
On Sat, 2007-05-05 at 01:19 -0700, yavannadil at yahoo.com wrote:
> On May 4, 7:13 pm, Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
> > The OPs problem is, there is no access to the class or type because
> > there is no name.
>
> Exactly :-(
>
> > You can get just instances from a factory function.
>
> Worse, if I call
>
> localContext.ServiceManage
>
> I'll get something with different set of methods, but of the same type
> - 'pyuno' :-(
'pyuno' objects are proxy objects that represent UNO objects, services,
and interfaces. Since all attribute lookups are handled by the UNO
bridge, the proxy object doesn't actually know what attributes it has,
which is why it won't respond anything useful to the usual dir()
inspection.
To list the methods and properties that the UNO object behind a pyuno
proxy object has, you need to use UNO inspection capabilities. Something
like the following seems to work:
# unodir.py
def unodir(unoobj):
import uno
from com.sun.star.beans.MethodConcept import ALL as ALLMETHS
from com.sun.star.beans.PropertyConcept import ALL as ALLPROPS
ctx = uno.getComponentContext()
introspection = ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.beans.Introspection", ctx)
access = introspection.inspect(unoobj)
meths = access.getMethods(ALLMETHS)
props = access.getProperties(ALLPROPS)
return [ x.getName() for x in meths ] + [ x.Name for x in props ]
>>> import uno
>>> from unodir import unodir
>>> localContext = uno.getComponentContext()
>>> unodir(localContext)
[u'queryInterface', u'acquire', u'release', u'getValueByName',
u'getServiceManager', u'getElementType', u'hasElements', u'getByName',
u'getElementNames', u'hasByName', u'replaceByName', u'insertByName',
u'removeByName', u'getTypes', u'getImplementationId', u'queryAdapter',
u'dispose', u'addEventListener', u'removeEventListener',
u'ServiceManager', u'ElementType', u'ElementNames', u'Types',
u'ImplementationId']
Hope this helps,
Carsten
More information about the Python-list
mailing list