libsolace.Decorators module

Some decorators which are used within the Plugins in order to control / limit execution.

libsolace.Decorators.backup()[source]

Sets the backupOnly kwarg before calling the method. Use this to add a specific router to the appliances to call list. Note, this does not unset primaryOnly kwarg, so you can actualy double target.

Returns:method
libsolace.Decorators.before(method_name, skip_before=False)[source]

Call a named method before. This is typically used to tell a object to shutdown so some modification can be made. This decorator passes all kwargs and args on to the “before” method so keep your params and keywords in sync!

Example:

>>> def shutdown(self, **kwargs):
>>>    # shutdown some object
>>> @before("shutdown")
>>> def delete(self, **kwargs):
>>>    # delete object since its shutdown
Parameters:
  • method_name (str) – the method name to call
  • skip_before (bool) – skips the before hook
Returns:

the decorated object

Return type:

obj

libsolace.Decorators.deprecation_warning(warning_msg)[source]

Log a deprecation warning and carry on.

Parameters:warning_msg (str) – the warning text
Return type:object
Returns:the decorated object
libsolace.Decorators.only_if_exists(entity, data_path, primaryOnly=False, backupOnly=False, **kwargs)[source]

The inverse of only_if_not_exists()

libsolace.Decorators.only_if_not_exists(entity, data_path, primaryOnly=False, backupOnly=False)[source]

Call the method only if the Solace object does NOT exist in the Solace appliance.

  • if the object’s exists caching bit is False, return the method
  • If the object does not exist, return the method and set the exists bit to False
  • If the object exists in the appliance, set the exists bit to True

Example:

>>> @only_if_not_exists('get', 'rpc-reply.rpc.show.client-username.client-usernames.client-username')
>>> def create_user(**kwargs):
>>>    return True
>>> create_user()
Parameters:
Return type:

object

Returns:

the object to call

libsolace.Decorators.only_on_shutdown(entity)[source]

Only calls the method if the shutdown_on_apply rules apply to the entity type. The entity can be either queue or user.

Methods decorated with this can optionally be decorated with the @shutdown decorator to actually call whatever method is capable of shutting down the object. If the object is not shutdown correcty, the appliance can not change the property and will raise an exception.

Example:

>>> @only_on_shutdown('user')
>>> def delete_user(**kwargs):
>>>    return True
>>> delete_user(shutdown_on_apply='u')
True
>>> delete_user(shutdown_on_apply='q')
None
Parameters:
  • entity (str) –

    the type of entity were expecting for the following comparisons:

    “user”: If shutdown_on_apply is True | b | u for a “user” entity, then allow the method to run.

    “queue”: If shutdown_on_apply is True | b | q for a “queue” entity, then allow the method to run.

  • force (bool) – libsolace.Kwargs.force
  • shutdown_on_applylibsolace.Kwargs.shutdown_on_apply
Return type:

object

Returns:

the object to call

libsolace.Decorators.primary()[source]

Sets the primaryOnly kwarg before calling the method. Use this to add a specific router to the appliances to call list. Note, this does not unset backupOnly kwarg, so you can actualy double target.

Returns:method