summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebd <>2005-05-19 15:13:41 (GMT)
committersebd <>2005-05-19 15:13:41 (GMT)
commit9310c8306d36820b4f88051ce22a4a6a44cb7b00 (patch)
tree05dcf98ff86bb3c178e68a9ec50d1e9de7e20ed5
parentad72e09297a1964a9d78699fa902507eb05eceb0 (diff)
downloadexpression-9310c8306d36820b4f88051ce22a4a6a44cb7b00.zip
expression-9310c8306d36820b4f88051ce22a4a6a44cb7b00.tar.gz
expression-9310c8306d36820b4f88051ce22a4a6a44cb7b00.tar.bz2
Support for optional document "labels" (aka name in DBXML 1)
-rw-r--r--src/modules/dbxmlcontainers.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/modules/dbxmlcontainers.py b/src/modules/dbxmlcontainers.py
index 026a192..2e85534 100644
--- a/src/modules/dbxmlcontainers.py
+++ b/src/modules/dbxmlcontainers.py
@@ -224,6 +224,7 @@ class DbXmlContainerHolder(dataholders.DataHolder):
""" returns a tuple (id, name) list of all documents
id is the Uri of the document
+ name is the dbxml:label of the document (if so defined)
argument xpathExpression can be specified to restrict the list
"""
@@ -233,9 +234,13 @@ class DbXmlContainerHolder(dataholders.DataHolder):
for value in results:
document = value.asDocument()
uri = "%s/%s" % (uriBase, document.getName())
- name = document.getName()
+ labelValue = dbxml.XmlValue("")
+ if document.getMetaData("http://www.sleepycat.com/2002/dbxml", "label", labelValue):
+ label = labelValue.asString()
+ else:
+ label = document.getName()
documentList.append(
- (uri, name)
+ (uri, label)
)
return documentList
@@ -479,14 +484,15 @@ class DbXmlDocumentStation(stations.AbstractStation, documents.AbstractDocument)
def save(self):
self.dbxmlDocument.setContent(self.serialize())
container = self.getParent().getContainer()
+ element = self.getRootElement()
+ try:
+ label = element.getLabel()
+ except AttributeError:
+ pass
+ else:
+ self.dbxmlDocument.setMetaData("http://www.sleepycat.com/2002/dbxml", "label", dbxml.XmlValue(label))
if self.isTemporary:
name = self.getPublicName()
- if name is None:
- element = self.getRootElement()
- try:
- name = element.getLabel()
- except AttributeError:
- pass
if name is not None:
name = strings.simplify(name)
self.dbxmlDocument.setName(name)