Skip to content

Is a custom QueryModifier wanted or possible? #145

@1letter

Description

@1letter

@thet @agitator
I would like manipulate the custom query in the Collectionish Collection Object. I implement, in a local branch of this package, a hook via adapter registration. The rest of the manipulation is in my own addon.

# interfaces.py
class ICustomQueryModifier(Interface):
    """adapter interface for modifying the custom query"""

    def transformQuery(self, custom_query):
        """transform the query
        @return: a new custom query
        """
@implementer(ICollectionish)
class CollectionishCollection(object):
    ....
    def results(self, custom_query, request_params):

        # Hook to customize the custom_query
        qm = queryMultiAdapter((self,), ICustomQueryModifier)
        if qm is not None:
            custom_query = qm.transformQuery(custom_query)
            
        return self.collection.results(
            batch=False, brains=True, custom_query=custom_query
        )

My Question, is such extension needed, wanted, possible, tolerate or permitted if i make a PR with this changes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions