10.6.9. Class cerebro.events.BeforeEventChangingOfAttachments¶
The class for attachment properties change - for a single attachment or several attachments at once. It grants access to the data of the modified attachment before writing it into the database.
this class is used to handle the changes of most part of the properties, but not all of them. In order to handle, for example, tag modifying, some other classes should be used.
See the complete list of event classes.
def before_event(event): if event.event_type() == event.EVENT_CHANGING_OF_ATTACHMENT_HASHTAGS: ...
Returns: a new value of the property undergoing changing.
The type of the returning value depends on the Property being changed. Check the methods on getting the values of similar properties of the
cerebro.aclasses.Messageclass to define the type.
def before_event(event): if event.event_type() == event.EVENT_CHANGING_OF_MESSAGE_HASHTAGS: # activity type is being changed tasks = event.messages() for message in messages: print('Message name', message.name()) print('<Previous activity type', message.activity()) print('New activity type', event.new_value())
Parameters: val – parameter value.
Sets a new value of the property being changed.
The type of the new value depends on the property being changed. Check the methods of setting up similar properties of the
cerebro.aclasses.Attachmentclass to define the type.
if event.type() == event.EVENT_CHANGING_OF_ATTACHMENT_HASHTAGS: attachment_name = event.new_value() if attachment_name.isupper() == False: new_name = attachment_name.upper() # changing the symbols to the upper register event.set_new_value(new_name) # substituting the value entered by user for the new one