Re: [bdbxml] XmlManager.openContainer
George Feinberg <[email protected]>
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
Andrew,
It's odd that the open would succeed, but the query fail,
unless something else is going on.
Are you changing directories between the openContainer()
call and the query that uses collection('rssfeeds.dbxml') ?
One thing to try that eliminates paths in container names
in queries is the XmlContainer::addAlias() call. E.g.:
container = manager.openContainer("rssfeeds.dbxml")
container.addAlias("feeds")
Then you can do things like this:
...
results = manager.query("collection('feeds')/xml", qc)
George
> hi,
> I'm having trouble opening a container separately from creating
> it. I'm working in the python port of BDB XML on a UNIX
> machine...I'll just paste the code where the container is created
> originally:
>
> def StoreFeeds(feedDocs,feedNames):
>
> manager = XmlManager()
> updateContext = manager.createUpdateContext()
> container = manager.openContainer("rssfeeds.dbxml",DB_CREATE)
> for n in range(0,len(feedDocs)):
> feedString = feedDocs[n].toxml("utf-8")
> feedName = feedNames[n]
> clockTime = str(clock())
> feedID = feedName + " " + clockTime
> container.putDocument(feedID,feedString,updateContext)
> #End for
> #End StoreFeeds
>
> That works fine. The file is created as I expect. In another
> program I want to use to query the DB, I use this code:
>
> manager = XmlManager()
> uc = manager.createUpdateContext()
>
> container = manager.openContainer("rssfeeds.dbxml")
> qc = manager.createQueryContext()
> results = manager.query("collection('rssfeeds.dbxml')/xml",qc)
> results.reset()
>
> for value in results:
> document = value.asDocument()
> print document.getName(), "=", value.asString()
> #End while
>
> This code doesn't work. On running I get a Runtime Error as follows:
>
> -bash-3.00$ python RSSretrieve.py
> Traceback (most recent call last):
> File "RSSretrieve.py", line 27, in ?
> results = manager.query("collection('rssfeeds.dbxml')/link",qc)
> File "/home/afister/lib/python/dbxml.py", line 124, in query
> def query(*args): return _dbxml.XmlManager_query(*args)
> RuntimeError: Error: Cannot query in container
> dbxml:rssfeeds.dbxml. Container not open and auto-open is not enabled
>
> Any help would be appreciated :-)
>
> -Andrew
------------------------------------------
To remove yourself from this list, send an
email to [email protected]