refindlyllc / rets

A thin RETS client
MIT License
69 stars 26 forks source link

Allow STANDARD-XML searches #200

Closed cmdevpy closed 5 years ago

cmdevpy commented 5 years ago

Currently 'rets.session.search' has an option for 'response_format' 'STANDARD-XML' but as far as I can tell it's not implemented. Add a simple implementation using 'xmltodict'.

mcrowson commented 5 years ago

It gets added to the parameters dictionary, which in turns gets turned into parameters for the search request:

https://github.com/refindlyllc/rets/blob/master/rets/session.py#L323

cmdevpy commented 5 years ago

@mcrowson Thank you. I guess my question is regarding 'search_cursor.generator(response=response)'. In 'rets.parsers.search.generator' it parses only RETS xml. Would a general xml implementation be possible ? Just basically return 'xmltodict(response.text)'. This came up because "CREA" mls has a 'STANDARD-XML' option that is not fully RETS compliant. Here is an example: OrderedDict([(u'RETS', OrderedDict([(u'@ReplyCode', u'0'), (u'@ReplyText', u'Operation successful'), (u'COUNT', OrderedDict([(u'@Records', u'2')])), (u'RETS-RESPONSE', OrderedDict([(u'@xmlns', u'urn:CREA.Search.Property'), (u'Pagination', OrderedDict([(u'TotalRecords', u'2'), (u'Limit', u'100'), (u'Offset', u'1'), (u'TotalPages', u'1'), (u'RecordsReturned', u'2')])), (u'PropertyDetails', [OrderedDict([(u'@ID', u'20270723'), (u'@LastUpdated', u'Sun, 27 Jan 2019 20:42:05 GMT'),

mcrowson commented 5 years ago

I initially tried using xmltodict on the listings responses (we use it elsewhere in the library) but not knowing a consistent response format from the various RETS servers kept giving us inconsistent results. Which is why we end up using Python's native XML library to get the rows: https://github.com/refindlyllc/rets/blob/master/rets/parsers/search.py#L18

I'd love to see it work though if you want to try a new approach.

cmdevpy commented 5 years ago

@mcrowson here is an option to pass a custom parser: https://github.com/refindlyllc/rets/compare/master...cmdevpy:search-parser?expand=1 Is this okay ? If so I'll open a pr.

mcrowson commented 5 years ago

That looks awesome, PR welcome

mcrowson commented 5 years ago

OK, pushed 0.4.8 which includes this. I made a few stylistic changes but the core of it should still work. Give a shout if something is amiss.

Thanks for the contribution!

cmdevpy commented 5 years ago

Looks great. Thank you !

On Thu, May 2, 2019 at 12:49 PM MCrowson notifications@github.com wrote:

OK, pushed 0.4.8 which includes this. I made a few stylistic changes but the core of it should still work. Give a shout if something is amiss.

Thanks for the contribution!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/refindlyllc/rets/issues/200#issuecomment-488788160, or mute the thread https://github.com/notifications/unsubscribe-auth/AL63Z5ZKHMXKF3JQHI7EO33PTMZUTANCNFSM4HJXTGPA .