Skip to main content

Query a daterange on objects with a daterange.

Example: You want all events within a date range of next two weeks, neither if the event has started one week ago nor ends one week later - or both.

Consider objects with a daterange start and end. Use this addon to query all objects inside a query-start and query-end range, where either or both of objects start and end match the query range.

This index is possibly the fastest way to solve the problem, it solves it as an zope index and works direct with the catalogs fast IISets (or IFSets). Its much faster than formerly used classical catalog-query post-processing.

There are two types of indexes available:

  • Products.ZCatalog (Zope 2) compatible

  • zope.catalog (Zope (3) framework) compatible

The index acts as an proxy for a more complex query on two indexes (DateIndex on ZCatalog or FieldIndex on zope.catalog). It utilize the other indexes and does not store any index-data itself.

To illustrate this a query example on ZCatalog):

>>> result = zcatalog.search({'myindex': {'start':'2000-10-01 00:00',
...                                       'end':'2010-10-31 23:59'} })

or a query example on zope.catalog:

>>> query = catalog.apply({'myindex': (datetime(2000, 10, 01, 00, 00'),
...                                    datetime(2010, 10, 31, 23, 59'))})

This will find objects (consider start is always before end date):

  1. where start date is before 2000-10-01 and end date is after 2010-10-31.

  2. where start date is between 2000-10-01 and 2010-10-31.

  3. where end date is between 2000-10-01 and 2010-10-31.

  4. where both are between 2000-10-01 and 2010-10-31.

ASCII-Art of the above (q=query, e=event):

Q)    q_start|--------------------|q_end

1) e_start|---------------------------|e_end

2) e_start|---------------|e_end

3)           e_start|-----------------|e_end

4)           e_start|-----|e_end

It’s also possible to configure this indexer through XML. Add a catalog.xml to your profile with the following settings:

    <?xml version="1.0"?>
    <object name="portal_catalog" meta_type="Plone Catalog Tool">

<index name="start_end_range" meta_type="DateRangeInRangeIndex">
    <startindex value="your_custom_start_field_index" />
    <endindex value="your_custom_end_field_index" />
</index>

    </object>

The startindex and endindex nodes define the indexes for the start and end fields of this DateRangeInRangeIndex.

Source Code

The sources are in a GIT DVCS with its main branches at github.

We’d be happy to see many commits, forks and pull-requests to make DateRangeInRangeIndex even better.

Contributors

History

2.0.2 (2025-02-28)

  • Fix Exception when calling catalog.getIndexDataForRID(rid) by implementing missing getEntryForObject method [petschki]

2.0.1 (2019-03-21)

  • Fix exportimport.py (GenericSetup) for Python 3 and add Python 3.7 to test matrix [MrTango]

2.0 (2018-07-12)

  • Add support for Products.ZCatalog >= 4 while dropping support for older versions. [icemac, 2018-07-11]

  • Add support for Python 3.5 and Python 3.6 on Zope 4. While dropping support for older Zope versions. [icemac, 2018-07-11]

  • Remove dependency from Globals for Zope 4 compat. [sallner, 2017-08-21]

  • some code cleanup [jensens, 2016-06-14]

1.3

  • added support for generic setup [SyZn, 2014-01-16]

1.2

  • added zope.catalog compatible index. [jensens, 2012-04-12]

1.1

  • eggification and release at pypi [jensens, 2011-03-08]

1.0

  • final release as Zope Product [jensens, 2007-08-29]

License

Copyright (c) 2007-2016, BlueDynamics Alliance, Austria All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the BlueDynamics Alliance nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Release files for Products.DateRangeInRangeIndex 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Products.DateRangeInRangeIndex 2.0.2
File Size Uploaded
products_daterangeinrangeindex-2.0.2.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Products.DateRangeInRangeIndex 2.0.2
File Interpreter ABI Platform
Products.DateRangeInRangeIndex-2.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 31.4 kB

Release files / products_daterangeinrangeindex-2.0.2.tar.gz

Download URL products_daterangeinrangeindex-2.0.2.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
24f1e0808e57c5c89d04bab1cef9db9fe5d7a9ffef3ad801e30cabade44e1deb
BLAKE2b-256 checksum
How to use checksums
0827fccb67f7f8101b1b6f3a82ff4799446c1bb1316624528f346de80bf09d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / Products.DateRangeInRangeIndex-2.0.2-py2.py3-none-any.whl

Download URL Products.DateRangeInRangeIndex-2.0.2-py2.py3-none-any.whl
Size 16.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6255a2312d597c6b31335e97a1d8a8d7c1bac12c6d6daa0a8c75c551f8ba80bd
BLAKE2b-256 checksum
How to use checksums
72c7e8e90acd7406d1220f1c6d5f05b4135b556851ef5aca3212d0781d05df5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0

2 release files

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page