Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
 
← Back to post

Revisions 2

How to create a generic Audit callback?
How to create a generic Audit callback?
I'm writing an extension that will listen to several AuditActions (possibly the 141 Audit Actions that are marked as `IsRiskAction=true` in the `Q2_AuditAction` table). All actions will invoke the same generic code. From the tutorial, it seems I need to create 141 individual methods, one per AuditAction, but instead of doing that, I was thinking to override the method `__getattr__` to return a reference to the generic method for any of the 141 audit actions I have registered in the `AUDIT_ACTIONS` list. This seems to be compatible with the implementation I see in `Q2AuditActionRequestHandler`. And it's working ok: ``` async def generic_audit_handler(self): self.logger.info('Auditing action %s:', self.audit_details.audit_action) def __getattr__(self, item): if item in self.AUDIT_ACTIONS: return self.generic_audit_handler return super().__getattr__(item) ``` Another way I thought of doing this was to invoke `setattr(cls, audit_name, method_ref)` for each of the 141 AuditActions (in a loop on `AUDIT_ACTIONS`), this would actually create the methods in the class, although the `__getattr__` approach seems simpler. Is there another, more proper, way to achieve this in Q2? Like a default action handler? Thanks.
I'm writing an extension that will listen to several AuditActions (possibly the 141 Audit Actions that are marked as `IsRiskAction=true` in the `Q2_AuditAction` table). All actions will invoke the same generic code. From the tutorial, it seems I need to create 141 individual methods, one per AuditAction, but instead of doing that, I was thinking to override the method `__getattr__` to return a reference to the generic method for any of the 141 audit actions I have registered in the `AUDIT_ACTIONS` list. This seems to be compatible with the implementation I see in `Q2AuditActionRequestHandler`. And seems to work ok: ``` async def generic_audit_handler(self): self.logger.info('Auditing action %s:', self.audit_details.audit_action) def __getattr__(self, item): if item in self.AUDIT_ACTIONS: return self.generic_audit_handler return super().__getattr__(item) ``` Another way I thought of doing this was to invoke `setattr(cls, audit_name, method_ref)` for each of the 141 AuditActions (in a loop on `AUDIT_ACTIONS`), this would actually create the methods in the class, although the `__getattr__` approach seems simpler. Is there another, more proper, way to achieve this in Q2? Like a default action handler? Thanks.
#
#
How to create a generic Audit callback?

I'm writing an extension that will listen to several AuditActions (possibly the 141 Audit Actions that are marked as `IsRiskAction=true` in the `Q2_AuditAction` table). All actions will invoke the same generic code. From the tutorial, it seems I need to create 141 individual methods, one per AuditAction, but instead of doing that, I was thinking to override the method `__getattr__` to return a reference to the generic method for any of the 141 audit actions I have registered in the `AUDIT_ACTIONS` list. This seems to be compatible with the implementation I see in `Q2AuditActionRequestHandler`. And seems to work ok: ``` async def generic_audit_handler(self): self.logger.info('Auditing action %s:', self.audit_details.audit_action) def __getattr__(self, item): if item in self.AUDIT_ACTIONS: return self.generic_audit_handler return super().__getattr__(item) ``` Another way I thought of doing this was to invoke `setattr(cls, audit_name, method_ref)` for each of the 141 AuditActions (in a loop on `AUDIT_ACTIONS`), this would actually create the methods in the class, although the `__getattr__` approach seems simpler. Is there another, more proper, way to achieve this in Q2? Like a default action handler? Thanks.
#