Akonadi.PreprocessorBase

KDE 4.9 PyKDE API Reference

- KDE's Python API

# PreprocessorBase Class Reference

`from PyKDE4.akonadi import *`

Inherits: Akonadi.AgentBase → QObject
Namespace: Akonadi

## Detailed Description

The base class for all Akonadi preprocessor agents.

This class should be used as a base class by all preprocessor agents since it encapsulates large parts of the protocol between preprocessor agent, agent manager and the Akonadi storage.

Preprocessor agents are special agents that are informed about newly added items before any other agents. This allows them to do filtering on the items or any other task that shall be done before the new item is visible in the Akonadi storage system.

The method all the preprocessors must implement is processItem().

Author:
  Szymon Stefanek <s.stefanek@gmail.com>

Since:
  4.4

## Enumerations
ProcessingResult | { ProcessingCompleted, ProcessingDelayed, ProcessingFailed, ProcessingRefused }
## Methods
| __init__ (self, QString id)
Akonadi.ItemFetchScope | fetchScope (self)
| finishProcessing (self, Akonadi.PreprocessorBase.ProcessingResult result)
Akonadi.PreprocessorBase.ProcessingResult | processItem (self, Akonadi.Item item)
| setFetchScope (self, Akonadi.ItemFetchScope fetchScope)

## Method Documentation

__init__ | ( | self, |
|  | QString | id
| ) |  |  |

Creates a new preprocessor base agent.

Parameters:

  | id | The instance id of the preprocessor base agent.

Akonadi.ItemFetchScope fetchScope | ( |  | self ) |

Returns the item fetch scope.

Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.

Returns:
  a reference to the current item fetch scope

See also:
  setFetchScope() for replacing the current item fetch scope

finishProcessing | ( | self, |
|  | Akonadi.PreprocessorBase.ProcessingResult | result
| ) |  |  |

This method must be called if processing is implemented asynchronously.

You should call it when you have completed the processing or if an abortRequest() signal arrives (and in this case you will probably use ProcessingFailed as result).

Valid values for result are ProcessingCompleted, PocessingRefused and ProcessingFailed. Passing any other value will lead to a runtime assertion.

Akonadi.PreprocessorBase.ProcessingResult processItem | ( | self, |
|  | Akonadi.Item | item
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

This method must be implemented by every preprocessor subclass.

It must realize the preprocessing of the given item.

The Akonadi server will push in for preprocessing any newly created item: it's your responsibility to decide if you want to process the item or not.

The method should return ProcessingCompleted on success, ProcessingDelayed if processing is implemented asynchronously and ProcessingRefused or ProcessingFailed if the processing didn't complete.

If your operation is asynchronous then you should also connect to the abortRequested() signal and handle it appropriately (as the server MAY abort your async job if it decides that it's taking too long).

setFetchScope | ( | self, |
|  | Akonadi.ItemFetchScope | fetchScope
| ) |  |  |

Sets the item fetch scope.

The ItemFetchScope controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.

Parameters:

  | fetchScope | The new scope for item fetch operations.

See also:
  fetchScope()

## Enumeration Documentation

ProcessingResult

Describes the possible return values of the processItem() method.

Enumerator:

  ProcessingCompleted |
  ProcessingDelayed |
  ProcessingFailed |
  ProcessingRefused |