XML data base objects support (in addition to the functionality provided
by the pdk.DomClasses.PyObjectDomTree base class):
concise DOM tree path specifications with "node definition tuples" for
retrieving existing (getNode or XmlReadOnlyDataBase) or building new
(buildNode of XmlReadWriteDataBase) of DOM tree nodes
dynamic insertion of sub-trees from XML sources (insert of
XmlReadWriteDataBase)
inserts (i.e., appends) the data in recordData in the table specified
by tableName and automatically increments the (numeric) primary key
primaryKey, if autoIncrement is set.
key can either be a string (if the column by which to perform the
join has the same name in both tables) or a 2-tuple of strings
(containing the names of the column by which to perform the join for
the left and the right table, respectively).
If not None, columns should be a list of column names specifying
a subset of columns to be used from the right table to construct the
joined table.
perform an inner join of leftTable with the table specified by
rightTableName using the key key. For further information on the
parameters, see the .join method.
perform a left join of leftTable with the table specified by
rightTableName using the key key. For further information on the
parameters, see the .join method.
perform a right join of leftTable with the table specified by
rightTableName using the key key. For further information on the
parameters, see the .join method.
returns the names of all tables in the data base. Note that this
includes tables which have been added (with the __setitem__ method),
but not committed yet.
select the single record in the table specified by tableName for
which the field keyName has the value keyValue. If the table has
an index "id", it is assumed that this is what we look for. If
keyName is a tuple, we do a more elaborate .selectByKey query and
check that the result has length 1 (if not, an IndexError is raised).
Finally, if keyName is None, the table structure is returned.
specializes ShelfDataBase to prefix all key accesses to an
underlying tree shelf with the tuple key that is provided
with the locator argument locator, which is a tuple of
the form (<shelf source>,<shelf key tuple>), where
<shelf source> is anything accepted by
pdk.DataClasses.ShelfClasses.shelf_factory and
<shelf key tuple> is a tuple of strings pointing into the
underlying tree shelf.
an XML data base connected to a (read-only) input stream
Detail:
extends PyObjectDomTree with a connection to an XML input
stream.
The .synchronizeWithSource method should be called whenever
the input stream is modified to update the DOM tree data.
i.e., it is really a tuple of node specifying tuples.
<nodename> matches the tag name of a DOM tree node
<nodevalue> matches the node value (not yet implemented!)
<attributedictionary> matches the node attributes.
Matching starts with the children of the node given in
contextNode (or the root node, if contextNode is None),
with the leftmost node specifying tuple, and descends recursively
into the DOM tree until the specified node is found or no node
matching the next node specifying tuple can be found among
the children of the currenly matched node. This case either
raises an error or returns the current matching node and the
left-over of the node specifying tuple, depending on the setting
of the findClosestMatchingNode option.
CODES = {'insert_duplicate_id': ('Trying to insert a node with an already existing node ID string.', ''), 'path_not_unique': ('Identical nodes were encountered while following the given DOM path.', '')}
an XML data base connected to an input and a storage stream
Detail:
augments the interface of XmlReadOnlyDataBase with the
capability to write changes made to the DOM tree (via
an instance of the DomBuilder class) to the stream-like object
xmlStorageStream. Note that changes are not commited until
the .close method is called.
build a new node according to the definitions in nodeTT as a child
of contextNode. Note that, if necessary, all intermediate nodes are
also created. Works by calling .getNode with the "buildRecursive"
flag set to True.
this extends the base class method with the capability to dynamically
create a node on the fly according to the node definitions in
nodeTT, if it does not exist. To enable this behavior, switch
on buildRecursive.
inserts the content (i.e., the child nodes of the document node) of the
database specified by source at the node parentNode into the DOM
tree. Only if persistent is true, the change to the data base will
be committed to the XML target stream connected to this instance upon
exit. For the insertBefore argument, see the buildChildFromNode
method of pdk.DomClasses.DomTree.
Notes
each call to .synchronizeWithSource will check not only for
modifications of the main tree`s XML source, but also for
modifications of any of the sources of these inserted data bases
for the insertion operation to work, all child nodes in the
inserted data base have to provide an "id" attribute
in addition to the base class method, this checks for
modifications in the sources of all inserted data bases, if any.
Returns True if the tree was updated in any way, False
otherwise.