# OAI-PMH problem with more than one parameter

**URL:** <https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314>\
**Category:** Rails\
**Created:** [January 9, 2010, 1:48pm UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314 "2010-01-09T13:48:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 9, 2010, 1:48pm UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/1 "2010-01-09T13:48:19Z")

</div>

Hello.

I’m trying to make my site work with OAI-PMH (http://  
[oai.rubyforge.org/](http://oai.rubyforge.org/)). Whilst running the tests on [http://re.cs.uct.ac.za/](http://re.cs.uct.ac.za/)  
it seems that it can’t process more than two parameters. For example:

[http://mysite.com/oai?verb=Identify](http://mysite.com/oai?verb=Identify) works fine, but  
[http://mysite.com/oai?verb=Identify&test=tes](http://mysite.com/oai?verb=Identify&test=tes) end ups with an error  
with any second parameter

Processing OaiController#index (for 0.0.0.0:3030 at 2010-01-09  
00:47:21) [GET]  
Parameters: {“verb”=\>“Identify”, “test”=\>“tes”}

TypeError (can’t convert nil into Array):  
oai (0.0.12) lib/oai/provider/response.rb:67:in `-' oai (0.0.12) lib/oai/provider/response.rb:67:in `valid?’  
oai (0.0.12) lib/oai/provider/response.rb:31:in `initialize’  
…

Line 67 is: return false unless (@options.keys -  
self.class.valid\_options).empty?  
where, ofcourse, self.class.valid\_options is nil. But why?  
Any thoughts?

–  
szymszy

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 10, 2010, 9:37am UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/2 "2010-01-10T09:37:05Z")

</div>

Hi,

As you know the OAI-PMH standard is pretty specific about what are  
acceptable parameters to requests and “test” is definitely not one. I  
have a pretty customized version of the OAI lib running on the Kete  
project and though it answers properly formed requests correctly it  
gives a 500 error when passed “&test=test”, too.

You seem to indicate that you have tried other second parameters, but  
are they definitely valid. Here’s a valid URL query string, for  
example:

[http://yoursite.com/oai?verb=ListRecords&from=2010-01-01](http://yoursite.com/oai?verb=ListRecords&from=2010-01-01)

and here is one with a valid third parameter:

[http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01](http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01)

You may get “no records match” type message, but it should be a well  
formed XML response.

Hopefully it is just a matter of testing with valid parameters and  
things will come right. At the least it is good to narrow down your  
issue.

## Cheers, Walter

Walter McGinnis  
Kete Project Lead ([http://kete.net.nz](http://kete.net.nz))  
Katipo Communications, Ltd. ([http://katipo.co.nz](http://katipo.co.nz))  
[http://twitter.com/wtem](http://twitter.com/wtem)

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 10, 2010, 9:38am UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/3 "2010-01-10T09:38:51Z")

</div>

On Sun, Jan 10, 2010 at 9:35 PM, Walter McGinnis  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You seem to indicate that you have tried other second parameters, but  
> are they definitely valid.

Sheesh, wish I had used “valid” grammar. Oops.

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 20, 2010, 12:07am UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/4 "2010-01-20T00:07:37Z")

</div>

Yeah, wish I could be of more help, but I don’t use the ActiveRecord  
wrapper with the OAI gem. I use another one that ties directly into  
my search engine.

I recommend trying to contact Terry Reese (one of the gem’s  
contributors). Here’s his blog, he’s helped me in the past:

[http://people.oregonstate.edu/~reeset/blog/](http://people.oregonstate.edu/~reeset/blog/)

Cheers,  
Walter

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 19, 2010, 3:22pm UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/5 "2010-01-19T15:22:29Z")

</div>

Hi,

> You seem to indicate that you have tried other second parameters, but  
> are they definitely valid.

Pretty sure. I used the tests from [http://re.cs.uct.ac.za/](http://re.cs.uct.ac.za/)

> Here’s a valid URL query string, for example:
> 
> [http://yoursite.com/oai?verb=ListRecords&from=2010-01-01](http://yoursite.com/oai?verb=ListRecords&from=2010-01-01)
> 
> and here is one with a valid third parameter:
> 
> [http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01](http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01)

Unfortunatly your examples don’t work either. I get this error:

Processing OaiController#index (for 0.0.0.0 at 2010-01-19 14:15:44)  
[GET]  
Parameters: {“verb”=\>“ListRecords”, “from”=\>“2010-01-01”}

NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time): /usr/lib/ruby/1.8/date/format.rb:1061:in `\_parse’  
/usr/lib/ruby/1.8/time.rb:240:in `parse' oai (0.0.12) lib/oai/provider/model/activerecord_wrapper.rb:123:in `sql\_conditions’  
oai (0.0.12) lib/oai/provider/model/activerecord\_wrapper.rb:46:in  
`find' oai (0.0.12) lib/oai/provider/response/list_records.rb:6:in `to\_xml’  
oai (0.0.12) lib/oai/provider.rb:260:in `list_records' oai (0.0.12) lib/oai/provider.rb:286:in `send’  
oai (0.0.12) lib/oai/provider.rb:286:in `process_request' app/controllers/oai_controller.rb:6:in `index’  
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’  
…

Rendering /srv/mysite/rails/public/500.html (500 Internal Server Error)

Even funnier is that the same link in the dev mode gives:

Processing OaiController#index (for 127.0.0.1 at 2010-01-19 15:20:18)  
[GET]  
Parameters: {“verb”=\>“ListRecords”, “from”=\>“2010-01-01”}

TypeError (can’t dup NilClass):  
oai (0.0.12) lib/oai/provider/model/activerecord\_wrapper.rb:34:in  
`latest' oai (0.0.12) lib/oai/provider/response/record_response.rb:7:in `inherited’  
oai (0.0.12) lib/oai/provider/response.rb:73:in `call' oai (0.0.12) lib/oai/provider/response.rb:73:in `populate\_defaults’  
oai (0.0.12) lib/oai/provider/response.rb:72:in `each' oai (0.0.12) lib/oai/provider/response.rb:72:in `populate\_defaults’  
oai (0.0.12) lib/oai/provider/response.rb:68:in `valid?' oai (0.0.12) lib/oai/provider/response.rb:31:in `initialize’  
oai (0.0.12) lib/oai/provider.rb:260:in `new' oai (0.0.12) lib/oai/provider.rb:260:in `list\_records’  
oai (0.0.12) lib/oai/provider.rb:286:in `send' oai (0.0.12) lib/oai/provider.rb:286:in `process\_request’  
app/controllers/oai\_controller.rb:6:in `index' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’  
…

Really have no idea what’s going on here. ☹

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [January 20, 2010, 12:49am UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/6 "2010-01-20T00:49:13Z")

</div>

Walter McGinnis wrote:

> Yeah, wish I could be of more help, but I don’t use the ActiveRecord  
> wrapper with the OAI gem. I use another one that ties directly into  
> my search engine.

It is very strange to me. Seem that the problem is with parsing the  
date.

NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time): /usr/lib/ruby/1.8/date/format.rb:1061:in `\_parse’

> I recommend trying to contact Terry Reese (one of the gem’s  
> contributors). Here’s his blog, he’s helped me in the past:
> 
> [http://people.oregonstate.edu/~reeset/blog/](http://people.oregonstate.edu/~reeset/blog/)

Ok, thanks! Will do so straight away

best of all,  
Szymon

---

<div class="post-metadata">

**Author:** ![szymonides](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/43a26b/32.png) [@szymonides](https://www.ruby-forum.com/u/szymonides)\
**Post date:** [June 30, 2010, 5:29am UTC](https://www.ruby-forum.com/t/oai-pmh-problem-with-more-than-one-parameter/181314/7 "2010-06-30T05:29:15Z")

</div>

Szymon Maka wrote:

> Walter McGinnis wrote:
> 
> > Yeah, wish I could be of more help, but I don’t use the ActiveRecord  
> > wrapper with the OAI gem. I use another one that ties directly into  
> > my search engine.
> 
> It is very strange to me. Seem that the problem is with parsing the  
> date.
> 
> NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time): /usr/lib/ruby/1.8/date/format.rb:1061:in `\_parse’
> 
> > I recommend trying to contact Terry Reese (one of the gem’s  
> > contributors). Here’s his blog, he’s helped me in the past:
> > 
> > [http://people.oregonstate.edu/~reeset/blog/](http://people.oregonstate.edu/~reeset/blog/)
> 
> Ok, thanks! Will do so straight away
> 
> best of all,  
> Szymon

The problem here is that the parameter is not a string

Time.parse(“2010-06-27 13:44:11”) works  
Time.parse(myDateTimeObject) throws this error

TypeError ($\_ value need to be String (nil given)):  
/usr/lib/ruby/1.8/date/format.rb:1061:in `_parse' /usr/lib/ruby/1.8/time.rb:240:in `parse’

Make sure you do

Time.parse(myDateTimeObject.to\_s)
