10.6.10. Class cerebro.events.BeforeEventChangingOfAttachmentsHashtags

class cerebro.events.BeforeEventChangingOfAttachmentsHashtags(event_type, event_id)[source]

Bases: cerebro.events.BeforeEventChangingOfAttachments

The class for the attachment hashtags changing event. It grants access to the attachment hashtags being changed before writing them into the database.

Methods

The class object is input into the functions before_event and error_event (in case of error) of the module event.

def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_ATTACHMENT_HASHTAGS:
                ...
is_added()[source]
Returns:True, if hashtags are being added to attachment. False, is being removed.
Return type:bool
def before_event(event):        
        if event.event_type() == event.EVENT_CHANGING_OF_ATTACHMENT_HASHTAGS: # hashtags is being changed
        
                if event.is_added() == False: # hashtags are being dismissed                                    
                        # asking the user if he/she is sure to do it
                        q = 'Are you sure you want to remove hashtags from the attachment?'
                        if cerebro.gui.question_box('User list change',  q) == False: # if the user is not sure
                                raise Exception('') 
                        # Hashtags will remain added to the attachment