metaodi / sruthi

SRU (Search/Retrieve via URL) client library for Python
MIT License
9 stars 3 forks source link

Session parameter #44

Closed metaodi closed 1 year ago

metaodi commented 1 year ago

@tijmenbaarda I propose to use custom session objects to achive the same thing as you in #42 , e.g.

import sruthi
import requests

# customize session
session = requests.Session()
session.params = {"x-collection": "GGC"}

# create client
sru_client = sruthi.Client("https://jsru.kb.nl/sru", session=session)

# use client
records = sru_client.searchretrieve(query="gruninger")
print(records[0])

This would always add x-collection=GGC to all requests. With this approach, you'll get more control over the session and could add custom headers, authentication etc. as well.

What do you think?

tijmenbaarda commented 1 year ago

Thanks for the very quick reply! Yes, I think this is an excellent, much better solution and clearly it works very well in my case.

metaodi commented 1 year ago

@tijmenbaarda: I just released sruthi 2.0.0 with the new session parameter. Enjoy!

tijmenbaarda commented 1 year ago

That is great!! Thanks a lot!