Menu

LogicCommand

Adam Tauno Williams

[Development]

Logic Commands

Logic commands are always executed using the "run_command" method of a [Context] instance.

ctx = AdminsitrativeContext()
result = ctx.run_command( 'project::get', number='Wiki Project' )

For scripting and interactive use the [Contact] method "r_c" exists as a short-cut for "run_command". But formal code committed to the repository should always use the long form.

Sequence Of Operations

  1. ctor
  2. prepare( **params )
    1. parse_parameters( **params )
    2. check_run_permissions( ) - Should raise an exception if the current [Context] does not have the privileges or roles required to perform the specified action.
  3. run( )
  4. epilogue( )
    1. audit_action( )
  5. Return value of get_result( ) is the result of the run_command method.

Methods

Method Description
command_name() Returns the string name of the command, as in domain::action
get_result() Returns the assigned command result, only useful to the [Context] after the Command has been executed.
generate_object_id() For use by the Command's run() method, generates a new unique objectId for any new entities created.
set_result( value ) Set the value to be returned by the Command to the [Context]. Every call overwrites the previous value.
set_return_value( date, right='r' ) Set the return value of the Command to an entity or list of entities - reducing that list to only those for which the Context has the specified privilege.

Related

Wiki: Context
Wiki: Development
Wiki: Document
Wiki: Project

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.