Commits

Anonymous committed bb9c69c

added more example data

Comments (0)

Files changed (4)

             
     def update_record(self, oai_id, modified, deleted, sets, data):
         # adds a record, call flush to actually store in db
-        data['sets'] = sets.keys()
+        data['sets'] = sets
         data = json.dumps(data)
         self._cache['records'][oai_id] = (dict(modified=modified,
                                                deleted=deleted,

moai/example-2345.xml

+<publication xmlns="http://example.org/data">
+  <id>2345</id>
+  <title>A Secret Example Test Publication</title>
+  <abstract>
+    This is a piece of example data that is used to 
+    demonstrate how arbitrary data can be loaded into
+    the MOAI OAIPMH server.
+    Data is not limited to XML files, it could also come
+    from an SQL database, in which case a different data
+    provider should be used.
+  </abstract>
+  <subject>example</subject>
+  <subject>test</subject>
+  <author>
+    <givenName>Jane</givenName>
+    <familyName>Doe</familyName>
+    <author-id>41431324</author-id>
+  </author>
+  <author>
+    <givenName>John</givenName>
+    <familyName>Doe</familyName>
+  </author>
+  <access>public</access>
+  <issued>2011-10-10T15:53:00Z</issued>
+  <modified>2011-10-12T15:56:00Z</modified>
+  <asset>
+    <type>application/pdf</type>
+    <name>example.pdf</name>
+    <description>example pdf</description>
+    <access>private</access>
+  </asset>
+</publication>
         doc = etree.parse(path)
         self.root = doc.getroot()
 
-        self.id = self.xpath('ex:id/text()', 'id', unicode, required=True)
+        id = self.xpath('ex:id/text()', 'id', unicode, required=True)
+        self.id = 'oai:example-%s' % id
         self.modified = datetime(*time.gmtime(os.path.getmtime(path))[:6])
         self.deleted = False
         self.sets = {}
         self.sets[u'example'] = {'name':u'example',
                                  'description':u'An Example Set'}
         
-        self.data = {}
+        self.data = {'uri': 'http://example.org/data/%s' % id}
         for el in self.root:
             tagname = el.tag.split('}', 1)[-1]
             if tagname in ['author', 'asset']:
                     value[s_el.tag.split('}', 1)[-1]] = text
             else:
                 value = el.text.strip().decode('utf8')
-            self.data.setdefault(tagname,[]).append(value)
+            self.data.setdefault(
+                {'abstract': 'description',
+                 'issued': 'date',
+                 }.get(tagname, tagname),[]).append(value)
 
 
         if 'public' in self.data['access']:
     
     def _listQuery(self, set=None, from_=None, until=None, 
                    cursor=0, batch_size=10, identifier=None):
-
-        if identifier:
-            identifier = self.config.get_internal_id(identifier)
-        if set:
-            set = self.config.get_internal_set_id(set)
             
         now = datetime.now()
         if until != None and until > now:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.