Class Handler
source code
object --+
|
Handler
Base handler class.
Workflow of handler processing is follow:
- Call C{filter(event="start", ("action", None), None)}.
- If returned C{True} enter handler loop (for each registered handler):
- Call C{filter("pre", ("call", None), handler, *args, **kwds)} for "call",
C{filter("pre", ("get", name), handler)} for "get",
C{filter("pre", ("set", name), handler, value)} for set.
- If returned C{True}:
- Call C{handler.action(*args, **kwds)} for "call" or getattr and
setattr for "get" and "set".
- Call C{filter("post", ("action", None), handler, result)}.
- Call C{filter("stop", ("action", None), None)}.
Pre processing filter functon must return C{True} for processing current handler and
C{False} for skip. Post processing filter must return C{True} for
continue processing remain handlers or C{False} for stop processing.
@ivar __handler_hl: Registered handlers list.
@type __handler_hl: list of handler instances
@ivar handler_filter: Filter function for handlers.
Called each time befor work with each handler.
Function must return C{True} for enable handler execution, or C{False} for
disable. Function I{B{C{ fun (event, action, handler, *args, **kwds) }}} where:
- B{event} - event type:
- "I{start}" - Initialization, befor start handlers loop.
- "I{pre}" - Pre handlers loop.
- "I{post}" - Post handlers loop.
- "I{stop}" - Deinitialization after handlers loop.
- B{action} - Tuple of (function, name) of method requested from handler.
- I{function} - "call", "get", "set" for calling, getattr and setattr.
- I{name} - name for attribute for "get" and "set", and None for "call".
- B{handler} - Handler instance.
- B{args} - Arguments passed to handler.
- B{kwds} - Keywords passed to handler.
Additional arguments:
- For "pre" + "call" - is function arguments.
- For "pre" + "set" arg[0] - is value to setup.
- For "post" arg[0] is result from handler.
@type handler_filter: function or None
|
__init__(self,
filter=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature |
source code
|
|
int
|
|
int
|
|
|
|
handler-object
|
|
int
|
|
Handler-object instance
|
|
int
|
|
|
__call__(self,
*args,
**kwds)
Execute call for each handler-object ho(*args, **kwds). |
source code
|
|
Handler
|
|
list
|
|
|
|
|
|
Inherited from object :
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__
|
Inherited from object :
__class__
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
- Overrides:
object.__init__
|
Add handler-object.
- Parameters:
handlers (handler-objects instance) - Handler-objects for append. Add only new handlers (unique for
this list). For not unique do nothing.
- Returns: int
- Index of last added handler-object.
|
Insert handler-object.
- Parameters:
handlers (handler-objects instance) - Handler-objects for inserting. Insert only new handlers
(unique for this list). For not unique do nothing.
- Returns: int
- Index of handler that point index befor insertion.
|
Remove handler-objects.
- Parameters:
handlers (handler-object instance) - Handler-objects for removing.
|
Remove and return handler-objects by index.
- Parameters:
handlers (handler-object instance.) - Handler-objects for removing.
- Returns: handler-object
- Poped handler.
|
Test handler-objects for exists.
- Parameters:
handlers (handler-object instance) - Handler-objects for test.
- Returns: int
- List of handler-object's index if exist or -1 if not
find.
|
Get handler-object by index.
- Parameters:
index (int) - Handler's object index.
- Returns: Handler-object instance
- Handler-bject.
|
Count handler-objects.
- Returns: int
- Handler-objects count.
|
__call__(self,
*args,
**kwds)
(Call operator)
| source code
|
Execute call for each handler-object ho(*args, **kwds).
- Returns:
- List returned values from handler-objects. For error
handler-objects return HandlerError instance instead object's rezult.
Filtered handlers is skiped from results. Error in filters is
skiped and equivalent True.
|
__getattr__(self,
name)
(Qualification operator)
| source code
|
Get new handler of attribute's values from handler-objects.
- Returns: Handler
- New of attribute's values from handler-objects.
|
Set attrebute for all handler-objects.
- Returns: list
- List of rezults for handler-objects: None if no error, or
Exception instance if error occur.
- Overrides:
object.__setattr__
Warning:
For self may set only "__handler_hl" attribute. All
other attributes try set to handler-objects.
|
Delete attrebute for all handler-objects.
- Overrides:
object.__delattr__
|
__str__(self)
(Informal representation operator)
| source code
|
Return informal string.
- Overrides:
object.__str__
|