# Filtering

Filtering is handy when more control over your plugins is needed.

After registering a callback function, it'll run on all registered plugins during discovery. This is useful to overwrite the settings of registered plugins.

For example, here's how we can overwrite a hardcoded export path so as to reuse a plugin for another project, without having to write and register a new plugin.

```python
import pyblish.api

# The original plug-in
class MyExportPlugin(pyblish.api.ContextPlugin):
  export_path = "C:/project_alpha/models"
  def process(self, context):
    print("Exported to: '%s'" % self.export_path)

pyblish.api.register_plugin(MyExportPlugin)

# Our custom "filter"
def export_path_filter(plugins):
  for plugin in plugins:
    if hasattr(plugin, 'export_path'):
      plugin.export_path = 'D:/project_beta/models'

pyblish.api.register_discovery_filter(export_path_filter)

import pyblish.util
pyblish.util.publish()
# Exported to 'to:D:/project_beta/models'
```

You can register a filter using `api.register_discovery_filter.`

Note that functions stay registered and won't update when you re-register them with the same name. You have to either deregister the original one, or use `pyblish.api.deregister_all_discovery_filters()` to unregister all filters.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pyblish.com/24-filtering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
