[ckan-changes] commit/ckanext-csw: amercader: Add check to just output records coming from CSW servers.

Bitbucket commits-noreply at bitbucket.org
Fri May 13 09:48:33 UTC 2011


1 new changeset in ckanext-csw:

http://bitbucket.org/okfn/ckanext-csw/changeset/788661a6d93a/
changeset:   r31:788661a6d93a
user:        amercader
date:        2011-05-13 11:48:23
summary:     Add check to just output records coming from CSW servers.
affected #:  1 file (262 bytes)

--- a/ckanext/csw/controller.py	Fri May 13 10:25:40 2011 +0100
+++ b/ckanext/csw/controller.py	Fri May 13 10:48:23 2011 +0100
@@ -388,13 +388,14 @@
                                         ).filter(HarvestObject.package!=None
                                              ).order_by(HarvestObject.gathered.desc()
                                                         ).limit(1).first()
-
-                try:
-                    record = etree.parse(StringIO(doc.content.encode("utf-8")))
-                    results.append(record.getroot())
-                except:
-                    log.error("exception parsing document %s:\n%s", doc.id, traceback.format_exc())
-                    raise
+                #TODO: Use proper checking with source type
+                if 'MD_Metadata' in doc.content:
+                    try:
+                        record = etree.parse(StringIO(doc.content.encode("utf-8")))
+                        results.append(record.getroot())
+                    except:
+                        log.error("exception parsing document %s:\n%s", doc.id, traceback.format_exc())
+                        raise
             
         return self._render_xml(resp)
 
@@ -409,12 +410,15 @@
                                                     ).limit(1).first()
             if doc is None:
                 continue
-            try:
-                record = etree.parse(StringIO(doc.content.encode("utf-8")))
-                resp.append(record.getroot())
-            except:
-                log.error("exception parsing document %s:\n%s", doc.id, traceback.format_exc())
-                raise
+
+            #TODO: Use proper checking with source type
+            if 'MD_Metadata' in doc.content:    
+                try:
+                    record = etree.parse(StringIO(doc.content.encode("utf-8")))
+                    resp.append(record.getroot())
+                except:
+                    log.error("exception parsing document %s:\n%s", doc.id, traceback.format_exc())
+                    raise
 
         return self._render_xml(resp)

Repository URL: https://bitbucket.org/okfn/ckanext-csw/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list