Differences

This shows you the differences between two versions of the page.

tinyoai [2010/07/29 10:20]
yamamoto
tinyoai [2010/10/04 11:37] (current)
yamamoto
Line 23: Line 23:
# easy tag # easy tag
def tagged(t, v): def tagged(t, v):
 +  #vv = str(v).replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
  return "<%s>%s</%s>" % (t, v, t)   return "<%s>%s</%s>" % (t, v, t)
Line 141: Line 142:
        else:         else:
          (r['metadataPrefix'], r['offset'], r['from'], r['until'], r['set'], dummy) = (r['resumptionToken']+"!!!!!").split("!", 5)           (r['metadataPrefix'], r['offset'], r['from'], r['until'], r['set'], dummy) = (r['resumptionToken']+"!!!!!").split("!", 5)
-          r['offset'] = int(r['offset'])+          try: 
 +            r['offset'] = int(r['offset']
 +          except: 
 +            raise BadParams('badResumptionToken', 'malformed resumptionToken')
          if not r.has_key('offset'):           if not r.has_key('offset'):
            raise BadParams('badResumptionToken', 'malformed resumptionToken')             raise BadParams('badResumptionToken', 'malformed resumptionToken')
-          r['resumptionToken'] = None+          #r['resumptionToken'] = None
      else:       else:
        if not r.has_key('metadataPrefix'):         if not r.has_key('metadataPrefix'):
Line 203: Line 207:
  def listrecords(self, mode="r"):   def listrecords(self, mode="r"):
    r = self.req     r = self.req
 +    if r['from']:
 +      param_from = r['from']
 +    else:
 +      param_from = self.EARLIEST_DATE
    try:     try:
      recs = self.fw_getrecords(       recs = self.fw_getrecords(
-        r['metadataPrefix'], r['from'], r['until'],+        r['metadataPrefix'], param_from, r['until'],
        r['set'], r['offset'], self.LIST_MAX + 1)         r['set'], r['offset'], self.LIST_MAX + 1)
    except OAIException, e:     except OAIException, e:
Line 236: Line 244:
  def listidentifiers(self):   def listidentifiers(self):
-    self.do_listrecords(mode="i")+    self.listrecords(mode="i")
  def mainroutine(self):   def mainroutine(self):
Line 265: Line 273:
    _w = self.writer.write     _w = self.writer.write
    _w("""<?xml version="1.0" encoding="utf-8"?>     _w("""<?xml version="1.0" encoding="utf-8"?>
-<OAI-PMH +<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">""")
- xmlns="http://www.openarchives.org/OAI/2.0/" +
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +
- xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ +
- http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">""")+
    _w(tagged("responseDate", time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())))     _w(tagged("responseDate", time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())))
Line 275: Line 279:
      _w('<request verb="%s"' % r['verb'])       _w('<request verb="%s"' % r['verb'])
      if not err:       if not err:
-        for i in ('set', 'identifier', 'from', 'until', 'metadataPrefix', 'resumptionToken'): +        if r.get('resumptionToken', ''): 
-          if r.has_key(i)+          _w(' resumptionToken="%s" ' % cgi.escape(r['resumptionToken'])) 
-            if r[i]:+        else: 
 +          for i in ('set', 'identifier', 'from', 'until', 'metadataPrefix'): 
 +            if r.get(i, ''):
              _w(' %s="%s" ' % (i, cgi.escape(r[i])))               _w(' %s="%s" ' % (i, cgi.escape(r[i])))
      _w(">%s</request>" % self.BASEURL)       _w(">%s</request>" % self.BASEURL)
Line 293: Line 299:
  o = OAIPMHHandler({'verb':'Identify'})   o = OAIPMHHandler({'verb':'Identify'})
  o.mainroutine()   o.mainroutine()
- 
</code> </code>
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki