List Info

Thread: python question




python question
user name
2006-06-20 16:47:56
Hi.

I think Tom ment to ask something else? I think he tryed
oppening the
container using

container = manager.openContainer(database)

and then

manager.openContainer(database)

and wondered why the latest resulted in an error.

If that was indeed the question, I would guess that the
answer is that
the latest creates a container object that is imediatly
collected by
the python's Garbage Collector (thus destroyed) because
there are no
refferences to it. And that, because of specific
dbxml-python API
implementation details, this reflects in the container not
being open
anymore in underlaying dbxml library either. This is a wild
guess,
anyway.

-Mihai

On 6/20/06, Mihai Ilinca <muqkermuqker.com> wrote:
> Hi.
>
> I think Tom ment to ask something else? I think he
tryed oppening the
> container using
>
> container = manager.openContainer(database)
>
> and then
>
> manager.openContainer(database)
>
> and wondered why the latest resulted in an error.
>
> If that was indeed the question, I would guess that the
answer is that
> the latest creates a container object that is imediatly
collected by
> the python's Garbage Collector (thus destroyed)
because there are no
> refferences to it. And that, because of specific
dbxml-python API
> implementation details, this reflects in the container
not being open
> anymore in underlaying dbxml library either. This is a
wild guess,
> anyway.
>
> -Mihai
>
> > Tom,
> >
> > > why should the code below, when
"container =" is removed (there is
> > > no use of container in this script), cause
the following error?
> >
> > Containers need to be open in order to be queried,
and that is the
> > best way to do it.
> > However, there is a flag you can pass to the
XmlManager constructor
> > that allows auto-opening (and subsequent closing)
of containers --
> > DBXML_ALLOW_AUTO_OPEN.
> >
> > Note that if you use this for your primary access
to containers, your
> > performance will be quite poor.   The same is true
 you are creating,
> > and
> > closing XmlManager() objects on each call.
> >
> > Regards,
> >
> > George
> >
> > >
> > > Traceback (most recent call last):
> > >   File
"/home/tvaughan/current/install/bin/missiondump.py&qu
ot;, line
> > > 11, in ?
> > >     expression = manager.prepare(query,
context)
> > >   File
"/home/tvaughan/current/install/lib/python/dbxml.py&q
uot;, line
> > > 133, in prepare
> > >     def prepare(*args): return
_dbxml.XmlManager_prepare(*args)
> > > RuntimeError: Error: Cannot query in
container dbxml:/home/tvaughan/
> > > current/install/var/dbxml/mission.dbxml. 
Container not open and
> > > auto-open is not enabled
> > >
> > > #!/usr/bin/env python
> > >
> > > import os, dbxml
> > >
> > > database =
os.environ["XMLDB_HOME"] + "/" +
"mission.dbxml"
> > > manager = dbxml.XmlManager()
> > > container = manager.openContainer(database) #
???
> > >
> > > query = "collection('" +
database + "')"
> > > context = manager.createQueryContext()
> > > expression = manager.prepare(query, context)
> > > results = expression.execute(context, 0)
>


------------------------------------------
To remove yourself from this list, send an
email to xml-unsubscribesleepycat.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )