Re: loadComponentFromURL & AttributeError

Sandro <[email protected]>
Newsgroups gmane.comp.openoffice.devel.general
Message-ID <[email protected]>
Hi Stephan,

Stephan Bergmann <stephan.bergmann <at> oracle.com> writes:

> 
> On 01/20/11 11:25, Sandro wrote:
> > Hi I'm using uno from python. The script I use is working under Ubuntu 10.04
> > (OO 3.2) and Windows 2003 +OOo3 but in XP with OOo 3.2 (italian) is failing
> > with an attribute error on loadComponentFromURL.
> 
> Is the "OOo3" you use with Windows 2003 the same version as the OOo 3.2 
> you use with XP?

No, working setup:
   Ubuntu 3.2.1
   Windows 2003  3.2.0

Not working:
   XP 3.2.1

> 
> > Googling around it seems an error that was present in OOo 3.0.0 due to
> > URE_BOOTSTRAP, so I tryed it anyhow with no luck (I tried setting
> > os.environ['URE_BOOTSTRAP'] =
> > 'vnd.sun.star.pathname:c:\\Programmi\\OpenOffice.Org
> > 3\\program\fundamental.ini' both before and after 'import uno') I do see
> > that even in OOo3.2 URE_BOOTSTRAP is not set when I import uno,
> > nevertheless, the setting I reported abive does not work.
> 
> If there were any problems with URE_BOOTSTRAP and Python on Windows in 
> OOo 3.2 (sorry, can't remember), I doubt the effect would have been a 
> specific failure of loadComponentFromURL.  Rather, it would probably 
> have caused Python UNO to not work at all.

'import uno' works in the sense it does not raise any errors, but fails to set 
URE_BOOTSTRAP. The Desktop object 

The simple demo that raises an error is:

import os
import uno
from com.sun.star.beans import PropertyValue

OutOfBoundsException = 
uno.getClass("com.sun.star.lang.IndexOutOfBoundsException")


local = uno.getComponentContext()
resolver = 
local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolv
er", local)
context = 
resolver.resolve("uno:socket,host=192.168.5.1,port=8100;urp;StarOffice.Component
Context")
desktop = 
context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", 
context)
filename = r"%s/template-debug.odt" % os.getcwd()
print filename, os.path.exists(filename)  # filename exists!!!
document = desktop.loadComponentFromURL(u"file://" +filename ,"_blank", 0, ())



the object 'desktop' does not have attribute loadComponentFromURL

Any hint is appreciated

sandro
*:-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.