|
From: SVN c. m. f. t. SWORD-A. p. <swo...@li...> - 2012-03-17 18:40:37
|
Revision: 479
http://sword-app.svn.sourceforge.net/sword-app/?rev=479&view=rev
Author: richard-jones
Date: 2012-03-17 18:40:31 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
fix bug with aggregated resource uris being erroneously kept in memory between statements, and correct serialisation of state in atom formatted sword statement
Modified Paths:
--------------
sss/branches/sss-2/sss/core.py
sss/branches/sss-2/sss/spec.py
sss/branches/sss-2/sss/webpy.py
Modified: sss/branches/sss-2/sss/core.py
===================================================================
--- sss/branches/sss-2/sss/core.py 2012-03-17 10:23:41 UTC (rev 478)
+++ sss/branches/sss-2/sss/core.py 2012-03-17 18:40:31 UTC (rev 479)
@@ -729,7 +729,7 @@
"""
Class representing the Statement; a description of the object as it appears on the server
"""
- def __init__(self, rdf_file=None, aggregation_uri=None, rem_uri=None, original_deposits=[], aggregates=[], states=[]):
+ def __init__(self, rdf_file=None, aggregation_uri=None, rem_uri=None, original_deposits=None, aggregates=None, states=None):
"""
The statement has 4 important properties:
- aggregation_uri - The URI of the aggregation in ORE terms
@@ -740,9 +740,9 @@
"""
self.aggregation_uri = aggregation_uri
self.rem_uri = rem_uri
- self.original_deposits = original_deposits
- self.aggregates = aggregates
- self.states = states
+ self.original_deposits = original_deposits if original_deposits is not None else []
+ self.aggregates = aggregates if aggregates is not None else []
+ self.states = states if states is not None else []
# Namespace map for XML serialisation
self.ns = Namespaces()
@@ -855,13 +855,25 @@
# create the root atom feed element
feed = etree.Element(self.ns.ATOM + "feed", nsmap=self.fmap)
+ # NOTE: this bit is incorrect, just in for reference, see replacement
+ # implementation
# create the sword:state term in the root of the feed
+ """
for state_uri, state_description in self.states:
state = etree.SubElement(feed, self.ns.SWORD + "state")
state.set("href", state_uri)
meaning = etree.SubElement(state, self.ns.SWORD + "stateDescription")
meaning.text = state_description
-
+ """
+
+ # create the state categories
+ for state_uri, state_description in self.states:
+ state = etree.SubElement(feed, self.ns.ATOM + "category")
+ state.set("scheme", self.ns.SWORD_STATE)
+ state.set("term", state_uri)
+ state.set("label", "State")
+ state.text = state_description
+
# now do an entry for each original deposit
for (uri, datestamp, format_uri, by, obo) in self.original_deposits:
# FIXME: this is not an official atom entry yet
Modified: sss/branches/sss-2/sss/spec.py
===================================================================
--- sss/branches/sss-2/sss/spec.py 2012-03-17 10:23:41 UTC (rev 478)
+++ sss/branches/sss-2/sss/spec.py 2012-03-17 18:40:31 UTC (rev 479)
@@ -24,6 +24,9 @@
self.SWORD_NS = "http://purl.org/net/sword/terms/"
self.SWORD = "{%s}" % self.SWORD_NS
self.SWORD_PREFIX = "sword"
+
+ # SWORD State Scheme
+ self.SWORD_STATE = self.SWORD_NS + "state"
# Dublin Core namespace and lxml format
self.DC_NS = "http://purl.org/dc/terms/"
Modified: sss/branches/sss-2/sss/webpy.py
===================================================================
--- sss/branches/sss-2/sss/webpy.py 2012-03-17 10:23:41 UTC (rev 478)
+++ sss/branches/sss-2/sss/webpy.py 2012-03-17 18:40:31 UTC (rev 479)
@@ -136,11 +136,11 @@
def manage_error(self, sword_error):
status = STATUS_MAP.get(sword_error.status, "400 Bad Request")
ssslog.info("Returning error (" + str(sword_error.status) + ") - " + str(sword_error.error_uri))
- web.ctx.status = status
+ web.ctx.status = str(sword_error.status)
if not sword_error.empty:
web.header("Content-Type", "text/xml")
return sword_error.error_document
- return
+ return ""
def _map_webpy_headers(self, headers):
return dict([(c[0][5:].replace("_", "-") if c[0].startswith("HTTP_") else c[0].replace("_", "-"), c[1]) for c in headers.items()])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|