Smart inference for the arguments wanted by procedures, hooks and crons #400

Closed
opened 2024-05-07 16:12:23 +02:00 by blacklight · 1 comment
Owner

As of now, procedures, hooks and crons have to be define like this:

from platypush import procedure

@procedure
def some_procedure(**context):
  ...

That's because there's a bunch of stuff that we passed on the context (response of the previous request, environment variables, results of previous key-value parsing operations etc.)

We should also allow more compact definitions:

from platypush import procedure, when

@procedure
def some_procedure():
  ...

@when(SomeEvent)
def on_some_event(event):
  ...

@when(SomeOtherEvent)
def on_some_other_event():
  ...

The caller should inspect the signature of the function and pass the arguments according to what it needs.

As of now, procedures, hooks and crons have to be define like this: ```python from platypush import procedure @procedure def some_procedure(**context): ... ``` That's because there's a bunch of stuff that we passed on the context (response of the previous request, environment variables, results of previous key-value parsing operations etc.) We should also allow more compact definitions: ```python from platypush import procedure, when @procedure def some_procedure(): ... @when(SomeEvent) def on_some_event(event): ... @when(SomeOtherEvent) def on_some_other_event(): ... ``` The caller should inspect the signature of the function and pass the arguments according to what it needs.
blacklight added this to the v0.60.0 milestone 2024-05-07 16:12:23 +02:00
blacklight added the
enhancement
label 2024-05-07 16:12:23 +02:00
blacklight self-assigned this 2024-05-07 16:12:23 +02:00
blacklight added this to the core project 2024-05-07 16:12:23 +02:00
Author
Owner

Closed by 32b8296244

Closed by https://git.platypush.tech/platypush/platypush/commit/32b8296244c9766156bd4a07908a9a86e339e1d8
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: platypush/platypush#400
No description provided.