def _add(self, handler, allow_dupe=False, send_event=True):
if not allow_dupe and handler in self.handlers:<EOL><INDENT>raise ValueError("<STR_LIT>" % handler)<EOL><DEDENT>self.handlers.append(handler)<EOL>self._attach_handler_events(handler)<EOL>if send_event:<EOL><INDENT>self.on_handler_add(handler)<EOL><DEDENT>
Add handler instance and attach any events to it.

:param object handler: handler instance
:param bool allow_dupe: If True, allow registering a handler more than once.
:return object: The handler you added is given back so this can be used as a decorator.