On Sat, 2007-05-05 at 01:19 -0700, [EMAIL PROTECTED] wrote:
> On May 4, 7:13 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> 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


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to