eea / eea.facetednavigation

Faceted Navigation for Plone Classic
http://eea.github.com/docs/eea.facetednavigation
20 stars 56 forks source link

Count breaks when using a text widget and collective.solr #191

Closed pbauer closed 4 years ago

pbauer commented 4 years ago

When using a text widget to do a fulltext-search, you use collective.solr and enable count on some widgets the parameter brains in eea.facetednavigation.widgets.widget.CountableWidget.count will be a SolrResponse. If you did not configure faceted fields in your solr schema (as I did) it will be handled exactly like a normal result from ZCatalog.

In that case the line IISet(brain.getRID() for brain in brains) fails:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 155, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 337, in publish_module
  Module ZPublisher.WSGIPublisher, line 255, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module Products.PDBDebugMode.wsgi_runcall, line 60, in pdb_runcall
  Module eea.facetednavigation.caching.nocache, line 12, in replacement
  Module eea.facetednavigation.browser.app.counter, line 77, in __call__
  Module eea.facetednavigation.browser.app.counter, line 58, in query
  Module eea.facetednavigation.widgets.widget, line 378, in count
TypeError: integer out of range

The reason is that getRID() for PloneFlare is calculated from the UUID and usually returns a integer that is larger than what a IISet can handle (see https://github.com/zopefoundation/BTrees/issues/100). We could use LLSet instead of IISet but I'd rather simply use frozenset since I doubt a real performance-benefit of using a BTree for this operation.