Table of Contents

Class: ReXistDA trunk/ReXistDA.py

An Remote eXist connector object.

The class which represents an remote eXist "proxy" or database adapter.

Base Classes   
eXistDA.eXistDA
Methods   
__init__
_getConnection
createColl
delColl
delDoc
findXMLRPCAddress
getDictFromDoc
getDoc
getFilesFromQuery
isCollection
isDocument
isOnline
listColl
listDoc
query
saveDoc
xupdate
  __init__ 
__init__ (
        self,
        id,
        title,
        server='',
        port=utils.DEFAULT_PORT,
        username='',
        password='',
        encoding=utils.DEFAULT_ENCODING,
        xmlrpc_path=utils.DEFAULT_ZOPE_XMLRPC_PATH,
        )

Class constructor.

  • Returns a new object !!

  • id : string containing the id of the Zope object created

  • title : string containing the title property of the Zope object

  • server : remote zope server name which owns the eXistDA object.

  • port : port number used by Zope HTTP server. Default is 8080. Ex : 8080

  • username : login of the user on Zope, with access to target eXistDA. Leave empty for guest (for python2.1). Ex: my_user

  • password : password of the selected user. Leave empty if none. Ex : '******' ;-)

  • encoding : encoding of the string which are passed and will be returned by eXistDA object. Default is ISO-8859-1, if an empty string is passed. Ex : UTF-8

  • xmlrpc_path : address of eXistDA object on remote Zope. Ex : /my/path/existda

  _getConnection 
_getConnection ( self,  xmlrpc_path=None )

Opens a connection to the remote Zope server if there's no one available.

  • Returns the object which is the proxy to the XMLRPC server

  createColl 
createColl ( self,  coll_name )

Creates a new collection in the coll_name collection.

  • Returns 1 if no problem. Returns 0 if collection has not been created

  • coll_name : string containing the name of the collection to create, with the FULL path

  delColl 
delColl ( self,  coll_name )

Deletes a collection and ALL what it contains.

  • Returns 1 if no problem. Returns 0 if collection has not been deleted

  • coll_name : string containing the name of the collection to delete, with the FULL path

  delDoc 
delDoc ( self,  doc_name )

Deletes a document of the DB.

  • Returns 1 if no problem. Returns 0 if document has not been deleted

  • doc_name : string containing the name of the document to delete, with the FULL path

  findXMLRPCAddress 
findXMLRPCAddress ( self )

Dummy method to provide compatibility to eXistDA. Always return "" for ReXistDA.

  getDictFromDoc 
getDictFromDoc ( self,  doc_name )

Returns a dictionary which keys are XML tags and values are XML values from the doc.

WARNING : for the moment, attributes are ignored and forgotten.

  • Returns a python dictionary

  • doc_name : a string containing the full path and name of an existing document in the DB

  getDoc 
getDoc (
        self,
        doc_name,
        xsl='',
        pretty_print=utils.DEFAULT_PP,
        **kws,
        )

Retrieve a document in the database.

  • Returns a string containing the (XSL transformed if suited) XML document.

  • doc_name : a string containing the full path and name of an existing document in the DB

  • xsl : a string containing the full path and name of an existing XSL document in the DB. If an empty string is passed, no XSLT is done

  • if pretty_print == 1, then the returned string is "pretty printed", ie indented. Else, the string is returned as it is saved in the DB

  • kws : dict for any other parameters. See README.txt for recognized parameters

  getFilesFromQuery 
getFilesFromQuery (
        self,
        query,
        **kws,
        )

BROKEN SINCE JUNE 2004 SNAPSHOTS -> modify eXist src to make it work

Executes an XPATH query or an XQuery on the DB.

  • Returns a list of string containing the name and full path of files in the DB which matches the query

  • query : a object/URI/string containing an XPATH query or an XQuery

  • kws : dict for any other parameters. See README.txt and query for recognized parameters

  isCollection 
isCollection ( self,  resource_name )

Determines if resource_name is a collection in the DB or not.

  • Returns 1 if resource_name is a collection, 0 otherwise

  • resource_name : a string containing the full path and name of the resource to test

  isDocument 
isDocument ( self,  resource_name )

Determines if resource_name is a document in the DB or not.

  • Returns 1 if resource_name is a document, 0 otherwise

  • resource_name : a string containing the full path and name of the resource to test

  isOnline 
isOnline ( self )

  listColl 
listColl (
        self,
        coll_name=utils.EXIST_ROOT_COLL,
        recursive=0,
        full_path=1,
        )

Lists the collections contained in collection coll_name.

  • Returns a list containing strings which are sub-collections of coll_name

  • coll_name : a string containing the base collection, containing the others. If the parameter is not passed, defaults to EXIST_ROOT_COLL (ie /db)

  • if recursive == 0, returned values will be the direct children collections of coll_name. Otherwise, all sub-collections will be recursively returned (even the children of the children)

  • if full_path == 1, the full path to the collections is returned (including /db/...). Otherwise, the path returned is relative to coll_name

  listDoc 
listDoc (
        self,
        coll_name='',
        full_path=0,
        )

Returns the list of all documents contained in collection coll_name.

  • coll_name : the name (with complete path) of the collection you want to list the child collections

  • full_path : if != 0 returns the full path of the document, otherwise, only the document name

  query 
query (
        self,
        query,
        **kws,
        )

Execute an XPATH query or an XQuery on the DB.

  • Returns a eXistDAresultsSet object containing all the results returned by the query.

  • query : an object/URI/string containing an XPATH query or an XQuery

  • kws : dict for any other parameters. See README.txt for recognized parameters

    • object_only : cf. README.txt

    • variables : key to a dict containing variables to pass to the xquery

  saveDoc 
saveDoc (
        self,
        my_doc,
        doc_uri,
        overwrite=1,
        **kws,
        )

Save a document in the database.

  • Returns 1 if saved, 0 otherwise

  • my_doc : an object/URI/string containing the doc

  • doc_uri : a string containing the complete URI (server, path and name) of the doc in the DB

  • if overwrite == 1 then if there's an existing doc with the same name, it will be overwritten

  • kws : dict for any other parameters. See README.txt for recognized parameters

  xupdate 
xupdate (
        self,
        res_name,
        xupdate_doc,
        **kws,
        )

Issues an XUpdate command to update a document or a whole collection in the database.

  • Returns a number > 0 (nb of updates done ?) if AOK or raise an exception if pb

  • res_name : the name (with complete path) of a collection or a document

  • xupdate_doc : an object/URI/string containing an XUpdate string

  • kws : dict for any other parameters. See README.txt for recognized parameters


Table of Contents

This document was automatically generated on Wed Apr 4 20:49:08 2007 by HappyDoc version 2.1