Package Camelot :: Package camelot :: Package admin :: Package form_action :: Class FormActionFromModelFunction |
[frames] | no frames]

# Class FormActionFromModelFunction

source code

Convert a function that is supposed to run in the model thread to a FormAction.

Instance Methods
__init__(self, name, model_function, icon=None, flush=False, enabled=<function <lambda> at 0xb62ddbc>) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
enabled(*args, **kwargs) Overwrite this method to have the action only enabled for certain states of the entity displayed :param entity: the entity currently in the form view :return: True or False, returns True by default | source code
run(*args, **kwargs) Overwrite this method to create an action that does something | source code
Inherited from `FormAction`: `get_icon`, `get_name`, `render` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, name, model_function, icon=None, flush=False, enabled=<function <lambda> at 0xb62ddbc>) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Parameters: `name` - the name of the action `model_function` - a function that has 1 arguments : the object on which to apply the action `icon` - an Icon `flush` - flush the object to the db and refresh it in the views `enabled` - a function that has 1 argument : the object on which the action would be applied Overrides: object.__init__

### enabled(*args, **kwargs) | source code
Overwrite this method to have the action only enabled for certain states of the entity displayed :param entity: the entity currently in the form view :return: True or False, returns True by default Decorators: `@model_function` Overrides: FormAction.enabled (inherited documentation)

### run(*args, **kwargs) | source code
Overwrite this method to create an action that does something Decorators: `@gui_function` Overrides: FormAction.run (inherited documentation)